Package org.restlet.representation
Class Variant
- java.lang.Object
-
- org.restlet.representation.Variant
-
- Direct Known Subclasses:
RepresentationInfo
public class Variant extends java.lang.ObjectDescriptor 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 theRepresentationsubclasses.- Author:
- Jerome Louvel
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClientInfocreateClientInfo()Creates aClientInfoinstance with preferences matching exactly the current variant.booleanequals(java.lang.Object other)Indicates if the current variant is equal to the given variant.CharacterSetgetCharacterSet()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.ReferencegetLocationRef()Returns an optional location reference.MediaTypegetMediaType()Returns the media type.
Note that when used with HTTP connectors, this property maps to the "Content-Type" header.inthashCode()booleanincludes(Variant other)Indicates 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(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.voidsetLanguages(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.voidsetLocationRef(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.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.java.lang.StringtoString()
-
-
-
Constructor Detail
-
Variant
public Variant()
Default constructor.
-
Variant
public Variant(MediaType mediaType)
Constructor.- Parameters:
mediaType- The media type.
-
-
Method Detail
-
createClientInfo
public ClientInfo createClientInfo()
Creates aClientInfoinstance with preferences matching exactly the current variant.- Returns:
- The new
ClientInfoinstance.
-
equals
public boolean equals(java.lang.Object other)
Indicates if the current variant is equal to the given variant.- Overrides:
equalsin classjava.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:
hashCodein classjava.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:
toStringin classjava.lang.Object
-
-