Class AlgorithmUtil
- java.lang.Object
-
- org.restlet.ext.jaxrs.internal.util.AlgorithmUtil
-
@Deprecated public class AlgorithmUtil extends java.lang.ObjectDeprecated.Will be removed in next minor release.This class contains helper methods for the algorithm inJaxRsRestlet.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classAlgorithmUtil.ConsOrProdMimeDeprecated.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Comparator<ResourceMethod>COMPDeprecated.Sorts the ResourceMethods by it's number of non default regular expressions
-
Constructor Summary
Constructors Constructor Description AlgorithmUtil()Deprecated.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidaddPathVarsToMap(MatchingResult matchResult, CallContext callContext)Deprecated.Adds the matched template parameters to theCallContext.private static OrderedMap<ResourceMethod,java.util.List<MediaType>>findMethodsSupportAllTypes(java.util.Collection<ResourceMethod> resourceMethods, AlgorithmUtil.ConsOrProdMime inOut)Deprecated.private static OrderedMap<ResourceMethod,java.util.List<MediaType>>findMethodsSupportType(java.util.Collection<ResourceMethod> resourceMethods, AlgorithmUtil.ConsOrProdMime inOut, SortedMetadata<MediaType> mediaTypes)Deprecated.private static OrderedMap<ResourceMethod,java.util.List<MediaType>>findMethodsSupportTypeAndSubType(java.util.Collection<ResourceMethod> resourceMethods, AlgorithmUtil.ConsOrProdMime inOut, SortedMetadata<MediaType> mediaTypes)Deprecated.private static OrderedMap<ResourceMethod,java.util.List<MediaType>>findMethodSupportsMime(java.util.Collection<ResourceMethod> resourceMethods, AlgorithmUtil.ConsOrProdMime inOut, SortedMetadata<MediaType> mediaTypes)Deprecated.static ResourceMethodgetBestMethod(java.util.Collection<ResourceMethod> unsortedResourceMethods, MediaType givenMediaType, SortedMetadata<MediaType> accMediaTypes, Method requHttpMethod)Deprecated.Sort by using the media type of input data as the primary key and the media type of output data as the secondary key.
Sorting of media types follows the general rule: x/y < x/* < */*, i.e.private static java.util.List<MediaType>getConsOrProdMimes(ResourceMethod resourceMethod, AlgorithmUtil.ConsOrProdMime inOut)Deprecated.static <R extends RrcOrRml>
RgetFirstByNoOfLiteralCharsNoOfCapturingGroups(java.util.Collection<R> rrcOrRmls)Deprecated.Implementation of algorithm in JSR-311-Spec, Revision 151, Version 2008-08-27, Section 3.7.2, Part 1.e and nearly the same part 2f+2g.
Sort E using the number of literal characters in each member as the primary key (descending order), the number of capturing groups as a secondary key (descending order), the number of capturing groups with non-default regular expressions (i.e.static voidremoveNotSupportedHttpMethod(java.util.Collection<ResourceMethod> resourceMethods, Method httpMethod, boolean alsoGet)Deprecated.Removes theResourceMethods from the collection, that do not support the given HTTP method.
-
-
-
Field Detail
-
COMP
private static java.util.Comparator<ResourceMethod> COMP
Deprecated.Sorts the ResourceMethods by it's number of non default regular expressions
-
-
Method Detail
-
addPathVarsToMap
public static void addPathVarsToMap(MatchingResult matchResult, CallContext callContext)
Deprecated.Adds the matched template parameters to theCallContext.
-
findMethodsSupportAllTypes
private static OrderedMap<ResourceMethod,java.util.List<MediaType>> findMethodsSupportAllTypes(java.util.Collection<ResourceMethod> resourceMethods, AlgorithmUtil.ConsOrProdMime inOut)
Deprecated.
-
findMethodsSupportType
private static OrderedMap<ResourceMethod,java.util.List<MediaType>> findMethodsSupportType(java.util.Collection<ResourceMethod> resourceMethods, AlgorithmUtil.ConsOrProdMime inOut, SortedMetadata<MediaType> mediaTypes)
Deprecated.
-
findMethodsSupportTypeAndSubType
private static OrderedMap<ResourceMethod,java.util.List<MediaType>> findMethodsSupportTypeAndSubType(java.util.Collection<ResourceMethod> resourceMethods, AlgorithmUtil.ConsOrProdMime inOut, SortedMetadata<MediaType> mediaTypes)
Deprecated.- Parameters:
resourceMethods-inOut-mediaType-- Returns:
- Never returns null.
-
findMethodSupportsMime
private static OrderedMap<ResourceMethod,java.util.List<MediaType>> findMethodSupportsMime(java.util.Collection<ResourceMethod> resourceMethods, AlgorithmUtil.ConsOrProdMime inOut, SortedMetadata<MediaType> mediaTypes)
Deprecated.- Parameters:
resourceMethods-inOut-mediaType-- Returns:
-
getBestMethod
public static ResourceMethod getBestMethod(java.util.Collection<ResourceMethod> unsortedResourceMethods, MediaType givenMediaType, SortedMetadata<MediaType> accMediaTypes, Method requHttpMethod)
Deprecated.Sort by using the media type of input data as the primary key and the media type of output data as the secondary key.
Sorting of media types follows the general rule: x/y < x/* < */*, i.e. a method that explicitly lists one of the requested media types is sorted before a method that lists */*. Quality parameter values are also used such that x/y;q=1.0 < x/y;q=0.7.
See JSR-311 Spec, section 2.6, Part 3b+c.
Never returns null.- Parameters:
unsortedResourceMethods- the resourceMethods that provide the required mediaTypegivenMediaType- The MediaType of the given entity.accMediaTypes- The accepted MediaTypesrequHttpMethod- The HTTP method of the request.- Returns:
- Returns the method who best matches the given and accepted media type in the request, or null
-
getConsOrProdMimes
private static java.util.List<MediaType> getConsOrProdMimes(ResourceMethod resourceMethod, AlgorithmUtil.ConsOrProdMime inOut)
Deprecated.- Parameters:
resourceMethod-inOut-- Returns:
-
getFirstByNoOfLiteralCharsNoOfCapturingGroups
public static <R extends RrcOrRml> R getFirstByNoOfLiteralCharsNoOfCapturingGroups(java.util.Collection<R> rrcOrRmls)
Deprecated.Implementation of algorithm in JSR-311-Spec, Revision 151, Version 2008-08-27, Section 3.7.2, Part 1.e and nearly the same part 2f+2g.
Sort E using- the number of literal characters in each member as the primary key (descending order),
- the number of capturing groups as a secondary key (descending order),
- the number of capturing groups with non-default regular expressions (i.e. not "([^/]+?)") as the tertiary key (descending order), and
- the source of each member as quaternary key sorting those derived from Tmethod ahead of those derived from Tlocator.
- Type Parameters:
R-- Parameters:
rrcOrRmls- Collection of Sub-ResourceMethods and SubResourceLocators or root resource class wrappers.- Returns:
- the resource method or sub resource locator or root resource class, or null, if the Map is null or empty.
-
removeNotSupportedHttpMethod
public static void removeNotSupportedHttpMethod(java.util.Collection<ResourceMethod> resourceMethods, Method httpMethod, boolean alsoGet)
Deprecated.Removes theResourceMethods from the collection, that do not support the given HTTP method.- Parameters:
resourceMethods- the collection ofResourceMethods.httpMethod- the HTTPMethodalsoGet- if true, also methods suporting GET are included, also if another HTTP method is required. It is intended to be used for HEAD requests.
-
-