org.restlet.representation
Class Variant

java.lang.Object
  extended by org.restlet.representation.Variant
Direct Known Subclasses:
RepresentationInfo

public class Variant
extends 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

Constructor Summary
Variant()
          Default constructor.
Variant(MediaType mediaType)
          Constructor.
Variant(MediaType mediaType, Language language)
          Constructor.
 
Method Summary
 ClientInfo createClientInfo()
          Creates a ClientInfo instance with preferences matching exactly the current variant.
 boolean equals(Object other)
          Indicates if the current variant is equal to the given variant.
 CharacterSet getCharacterSet()
          Returns the character set or null if not applicable.
 List<Encoding> getEncodings()
          Returns the modifiable list of encodings applied to the entity-body.
 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.
 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(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(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(Reference location)
          Sets the optional identifier.
 void setLocationRef(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 setMediaType(MediaType mediaType)
          Sets the media type.

Note that when used with HTTP connectors, this property maps to the "Content-Type" header.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, 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(Object other)
Indicates if the current variant is equal to the given variant.

Overrides:
equals in class 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 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 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.

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(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(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(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 String toString()
Overrides:
toString in class Object


Copyright © 2005-2013 Restlet.