Class Variant

  • Direct Known Subclasses:
    RepresentationInfo

    public class Variant
    extends java.lang.Object
    Descriptor for available representations of a resource. It contains all the important metadata about a representation but is not able to actually serve the representation's content itself.

    For this, you need to use on of the Representation subclasses.
    Author:
    Jerome Louvel
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ClientInfo createClientInfo()
      Creates a ClientInfo instance with preferences matching exactly the current variant.
      boolean equals​(java.lang.Object other)
      Indicates if the current variant is equal to the given variant.
      CharacterSet getCharacterSet()
      Returns the character set or null if not applicable.
      java.util.List<Encoding> getEncodings()
      Returns the modifiable list of encodings applied to the entity-body.
      java.util.List<Language> getLanguages()
      Returns the modifiable list of languages.
      Reference getLocationRef()
      Returns an optional location reference.
      MediaType getMediaType()
      Returns the media type.

      Note that when used with HTTP connectors, this property maps to the "Content-Type" header.
      int hashCode()  
      boolean includes​(Variant other)
      Indicates if the current variant includes the given variant.
      boolean isCompatible​(Variant other)
      Indicates if the current variant is compatible with the given variant.
      void setCharacterSet​(CharacterSet characterSet)
      Sets the character set or null if not applicable.

      Note that when used with HTTP connectors, this property maps to the "Content-Type" header.
      void setEncodings​(java.util.List<Encoding> encodings)
      Sets the list of encodings applied to the entity-body.

      Note that when used with HTTP connectors, this property maps to the "Content-Encoding" header.
      void setLanguages​(java.util.List<Language> languages)
      Sets the list of languages.

      Note that when used with HTTP connectors, this property maps to the "Content-Language" header.
      void setLocationRef​(java.lang.String locationUri)
      Sets the identifier from a URI string.

      Note that when used with HTTP connectors, this property maps to the "Content-Location" header.
      void setLocationRef​(Reference location)
      Sets the optional identifier.
      void setMediaType​(MediaType mediaType)
      Sets the media type.

      Note that when used with HTTP connectors, this property maps to the "Content-Type" header.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Variant

        public Variant()
        Default constructor.
      • Variant

        public Variant​(MediaType mediaType)
        Constructor.
        Parameters:
        mediaType - The media type.
      • Variant

        public Variant​(MediaType mediaType,
                       Language language)
        Constructor.
        Parameters:
        mediaType - The media type.
        language - The language.
    • Method Detail

      • createClientInfo

        public ClientInfo createClientInfo()
        Creates a ClientInfo instance with preferences matching exactly the current variant.
        Returns:
        The new ClientInfo instance.
      • equals

        public boolean equals​(java.lang.Object other)
        Indicates if the current variant is equal to the given variant.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        other - The other variant.
        Returns:
        True if the current variant includes the other.
      • getCharacterSet

        public CharacterSet getCharacterSet()
        Returns the character set or null if not applicable. Note that when used with HTTP connectors, this property maps to the "Content-Type" header.
        Returns:
        The character set or null if not applicable.
      • getEncodings

        public java.util.List<Encoding> getEncodings()
        Returns the modifiable list of encodings applied to the entity-body. Creates a new instance if no one has been set. An "IllegalArgumentException" exception is thrown when adding a null encoding to this list.

        Note that when used with HTTP connectors, this property maps to the "Content-Encoding" header.
        Returns:
        The list of encodings applied to the entity-body.
      • getLanguages

        public java.util.List<Language> getLanguages()
        Returns the modifiable list of languages. Creates a new instance if no one has been set. An "IllegalArgumentException" exception is thrown when adding a null language to this list.

        Note that when used with HTTP connectors, this property maps to the "Content-Language" header.
        Returns:
        The list of languages.
      • getLocationRef

        public Reference getLocationRef()
        Returns an optional location reference. This is useful when the representation is accessible from a location separate from the representation's resource URI, for example when content negotiation occurs.

        Note that when used with HTTP connectors, this property maps to the "Content-Location" header.
        Returns:
        The identifier.
      • getMediaType

        public MediaType getMediaType()
        Returns the media type.

        Note that when used with HTTP connectors, this property maps to the "Content-Type" header.
        Returns:
        The media type.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • includes

        public boolean includes​(Variant other)
        Indicates if the current variant includes the given variant.
        Parameters:
        other - The other variant.
        Returns:
        True if the current variant includes the other.
      • isCompatible

        public boolean isCompatible​(Variant other)
        Indicates if the current variant is compatible with the given variant.
        Parameters:
        other - The other variant.
        Returns:
        True if the current variant is compatible with the other.
      • setCharacterSet

        public void setCharacterSet​(CharacterSet characterSet)
        Sets the character set or null if not applicable.

        Note that when used with HTTP connectors, this property maps to the "Content-Type" header.
        Parameters:
        characterSet - The character set or null if not applicable.
      • setEncodings

        public void setEncodings​(java.util.List<Encoding> encodings)
        Sets the list of encodings applied to the entity-body.

        Note that when used with HTTP connectors, this property maps to the "Content-Encoding" header.
        Parameters:
        encodings - The list of encodings applied to the entity-body.
      • setLanguages

        public void setLanguages​(java.util.List<Language> languages)
        Sets the list of languages.

        Note that when used with HTTP connectors, this property maps to the "Content-Language" header.
        Parameters:
        languages - The list of languages.
      • setLocationRef

        public void setLocationRef​(Reference location)
        Sets the optional identifier. This is useful when the representation is accessible from a location separate from the representation's resource URI, for example when content negotiation occurs.

        Note that when used with HTTP connectors, this property maps to the "Content-Location" header.
        Parameters:
        location - The location reference.
      • setLocationRef

        public void setLocationRef​(java.lang.String locationUri)
        Sets the identifier from a URI string.

        Note that when used with HTTP connectors, this property maps to the "Content-Location" header.
        Parameters:
        locationUri - The location URI to parse.
      • setMediaType

        public void setMediaType​(MediaType mediaType)
        Sets the media type.

        Note that when used with HTTP connectors, this property maps to the "Content-Type" header.
        Parameters:
        mediaType - The media type.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object