Class StrictConneg

  • Direct Known Subclasses:
    FlexibleConneg

    public class StrictConneg
    extends Conneg
    Content negotiation algorithm that strictly interprets the content negotiation preferences.
    • Constructor Detail

      • StrictConneg

        public StrictConneg​(Request request,
                            MetadataService metadataService)
        Constructor.
        Parameters:
        request - The request including client preferences.
        metadataService - The metadata service used to get default metadata values.
    • Method Detail

      • getCharacterSetPrefs

        protected java.util.List<Preference<CharacterSet>> getCharacterSetPrefs()
        Returns the enriched list of character set preferences.
        Returns:
        The enriched list of character set preferences.
      • getEncodingPrefs

        protected java.util.List<Preference<Encoding>> getEncodingPrefs()
        Returns the enriched list of encoding preferences.
        Returns:
        The enriched list of encoding preferences.
      • getLanguagePrefs

        protected java.util.List<Preference<Language>> getLanguagePrefs()
        Returns the enriched list of language preferences.
        Returns:
        The enriched list of language preferences.
      • getMediaTypePrefs

        protected java.util.List<Preference<MediaType>> getMediaTypePrefs()
        Returns the enriched list of media type preferences.
        Returns:
        The enriched list of media type preferences.
      • scoreAnnotation

        protected float scoreAnnotation​(MethodAnnotationInfo annotation)
        Scores the annotation descriptor. By default, it assess the quality of the query parameters with the URI query constraint defined in the annotation value if any.
        Parameters:
        annotation - The annotation descriptor to score.
        Returns:
        The annotation descriptor score.
      • scoreCharacterSet

        public float scoreCharacterSet​(CharacterSet characterSet)
        Scores a character set relatively to enriched client preferences.
        Parameters:
        characterSet - The character set to score.
        Returns:
        The score.
      • scoreEncodings

        public float scoreEncodings​(java.util.List<Encoding> encodings)
        Scores encodings relatively to enriched client preferences.
        Parameters:
        encodings - The encodings to score.
        Returns:
        The score.
      • scoreLanguages

        public float scoreLanguages​(java.util.List<Language> languages)
        Scores languages relatively to enriched client preferences.
        Parameters:
        languages - The languages to score.
        Returns:
        The score.
      • scoreMediaType

        public float scoreMediaType​(MediaType mediaType)
        Scores a media type relatively to enriched client preferences.
        Parameters:
        mediaType - The media type to score.
        Returns:
        The score.
      • scoreMetadata

        protected <T extends Metadata> float scoreMetadata​(java.util.List<T> metadataList,
                                                           java.util.List<Preference<T>> prefs)
        Scores a list of metadata relatively to enriched client preferences.
        Parameters:
        metadataList - The list of metadata to score.
        Returns:
        The score.
      • scoreMetadata

        protected <T extends Metadata> float scoreMetadata​(T metadata,
                                                           java.util.List<Preference<T>> prefs)
        Scores a metadata relatively to enriched client preferences.
        Parameters:
        metadata - The metadata to score.
        Returns:
        The score.
      • scoreVariant

        public float scoreVariant​(Variant variant)
        Scores a variant relatively to enriched client preferences. The language has a weight of 4, the media type 3, the character set 2 and the encoding 1.
        Specified by:
        scoreVariant in class Conneg
        Parameters:
        variant - The variant to score.
        Returns:
        The enriched client preferences.