Class AlgorithmUtil


  • @Deprecated
    public class AlgorithmUtil
    extends java.lang.Object
    Deprecated.
    Will be removed in next minor release.
    This class contains helper methods for the algorithm in JaxRsRestlet.
    • Field Detail

      • COMP

        private static java.util.Comparator<ResourceMethod> COMP
        Deprecated.
        Sorts the ResourceMethods by it's number of non default regular expressions
    • Constructor Detail

      • AlgorithmUtil

        public AlgorithmUtil()
        Deprecated.
    • Method Detail

      • addPathVarsToMap

        public static void addPathVarsToMap​(MatchingResult matchResult,
                                            CallContext callContext)
        Deprecated.
        Adds the matched template parameters to the CallContext.
        Parameters:
        matchResult -
        callContext - Contains the encoded template Parameters, that are read from the called URI, the Restlet Request and the Restlet Response.
      • 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 mediaType
        givenMediaType - The MediaType of the given entity.
        accMediaTypes - The accepted MediaTypes
        requHttpMethod - The HTTP method of the request.
        Returns:
        Returns the method who best matches the given and accepted media type in the request, or null
      • 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
        1. the number of literal characters in each member as the primary key (descending order),
        2. the number of capturing groups as a secondary key (descending order),
        3. the number of capturing groups with non-default regular expressions (i.e. not "([^/]+?)") as the tertiary key (descending order), and
        4. 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 the ResourceMethods from the collection, that do not support the given HTTP method.
        Parameters:
        resourceMethods - the collection of ResourceMethods.
        httpMethod - the HTTP Method
        alsoGet - if true, also methods suporting GET are included, also if another HTTP method is required. It is intended to be used for HEAD requests.