org.restlet.resource
Class Variant

java.lang.Object
  extended by org.restlet.resource.Variant
Direct Known Subclasses:
Representation

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 the Representation subclass.

Author:
Jerome Louvel (contact@noelios.com)

Field Summary
static long UNKNOWN_SIZE
          Indicates that the size of the representation can't be known in advance.
 
Constructor Summary
Variant()
          Default constructor.
Variant(MediaType mediaType)
          Constructor.
 
Method Summary
 CharacterSet getCharacterSet()
          Returns the character set or null if not applicable.
 List<Encoding> getEncodings()
          Returns the list of encodings applied to the entity-body.
 Date getExpirationDate()
          Returns the future date when this representation expire.
 Reference getIdentifier()
          Returns an optional identifier.
 List<Language> getLanguages()
          Returns the list of languages.
 MediaType getMediaType()
          Returns the media type.
 Date getModificationDate()
          Returns the last date when this representation was modified.
 long getSize()
          Returns the size in bytes if known, UNKNOWN_SIZE (-1) otherwise.
 Tag getTag()
          Returns the tag.
 void setCharacterSet(CharacterSet characterSet)
          Sets the character set or null if not applicable.
 void setExpirationDate(Date expirationDate)
          Sets the future date when this representation expire.
 void setIdentifier(Reference identifier)
          Sets the optional identifier.
 void setIdentifier(String identifierUri)
          Sets the identifier from a URI string.
 void setMediaType(MediaType mediaType)
          Sets the media type.
 void setModificationDate(Date modificationDate)
          Sets the last date when this representation was modified.
 void setSize(long expectedSize)
          Sets the expected size in bytes if known, -1 otherwise.
 void setTag(Tag tag)
          Sets the tag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNKNOWN_SIZE

public static final long UNKNOWN_SIZE
Indicates that the size of the representation can't be known in advance.

See Also:
Constant Field Values
Constructor Detail

Variant

public Variant()
Default constructor.


Variant

public Variant(MediaType mediaType)
Constructor.

Parameters:
mediaType - The media type.
Method Detail

getCharacterSet

public CharacterSet getCharacterSet()
Returns the character set or null if not applicable.

Returns:
The character set or null if not applicable.

getEncodings

public List<Encoding> getEncodings()
Returns the list of encodings applied to the entity-body. An "IllegalArgumentException" exception is thrown when adding a null encoding to this list.

Returns:
The list of encodings applied to the entity-body.

getExpirationDate

public Date getExpirationDate()
Returns the future date when this representation expire. If this information is not known, returns null.

Returns:
The expiration date.

getLanguages

public List<Language> getLanguages()
Returns the list of languages. An "IllegalArgumentException" exception is thrown when adding a null language to this list.

Returns:
The list of languages.

getMediaType

public MediaType getMediaType()
Returns the media type.

Returns:
The media type.

getModificationDate

public Date getModificationDate()
Returns the last date when this representation was modified. If this information is not known, returns null.

Returns:
The modification date.

getSize

public long getSize()
Returns the size in bytes if known, UNKNOWN_SIZE (-1) otherwise.

Returns:
The size in bytes if known, UNKNOWN_SIZE (-1) otherwise.

getTag

public Tag getTag()
Returns the tag.

Returns:
The tag.

setCharacterSet

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

Parameters:
characterSet - The character set or null if not applicable.

setExpirationDate

public void setExpirationDate(Date expirationDate)
Sets the future date when this representation expire. If this information is not known, pass null.

Parameters:
expirationDate - The expiration date.

setMediaType

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

Parameters:
mediaType - The media type.

setModificationDate

public void setModificationDate(Date modificationDate)
Sets the last date when this representation was modified. If this information is not known, pass null.

Parameters:
modificationDate - The modification date.

setSize

public void setSize(long expectedSize)
Sets the expected size in bytes if known, -1 otherwise.

Parameters:
expectedSize - The expected size in bytes if known, -1 otherwise.

setTag

public void setTag(Tag tag)
Sets the tag.

Parameters:
tag - The tag.

getIdentifier

public Reference getIdentifier()
Returns an 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.

Returns:
The identifier.

setIdentifier

public void setIdentifier(Reference identifier)
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.

Parameters:
identifier - The identifier.

setIdentifier

public void setIdentifier(String identifierUri)
Sets the identifier from a URI string.

Parameters:
identifierUri - The identifier to parse.


Copyright © 2005-2007 Noelios Consulting.