Package org.restlet.representation
Class Variant
java.lang.Object
org.restlet.representation.Variant
- Direct Known Subclasses:
RepresentationInfo,VariantInfo
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
For this, you need to use on of the
Representation subclasses.- Author:
- Jerome Louvel
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates aClientInfoinstance with preferences matching exactly the current variant.booleanIndicates if the current variant is equal to the given variant.Returns the character set or null if not applicable.Returns the modifiable list of encodings applied to the entity-body.Returns the modifiable list of languages.Returns an optional location reference.Returns the media type.
Note that when used with HTTP connectors, this property maps to the "Content-Type" header.inthashCode()booleanIndicates if the current variant includes the given variant.booleanisCompatible(Variant other) Indicates if the current variant is compatible with the given variant.voidsetCharacterSet(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.voidsetEncodings(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.voidsetLanguages(List<Language> languages) Sets the list of languages.
Note that when used with HTTP connectors, this property maps to the "Content-Language" header.voidsetLocationRef(String locationUri) Sets the identifier from a URI string.
Note that when used with HTTP connectors, this property maps to the "Content-Location" header.voidsetLocationRef(Reference location) Sets the optional identifier.voidsetMediaType(MediaType mediaType) Sets the media type.
Note that when used with HTTP connectors, this property maps to the "Content-Type" header.toString()
-
Constructor Details
-
Variant
public Variant()Default constructor. -
Variant
Constructor.- Parameters:
mediaType- The media type.
-
Variant
Constructor.- Parameters:
mediaType- The media type.language- The language.
-
-
Method Details
-
createClientInfo
Creates aClientInfoinstance with preferences matching exactly the current variant.- Returns:
- The new
ClientInfoinstance.
-
equals
Indicates if the current variant is equal to the given variant. -
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
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
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
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
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() -
includes
Indicates if the current variant includes the given variant.- Parameters:
other- The other variant.- Returns:
- True if the current variant includes the other.
-
isCompatible
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
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
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
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
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
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
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
-