org.restlet.data
Class ClientInfo

java.lang.Object
  extended by org.restlet.data.ClientInfo

public final class ClientInfo
extends Object

Client specific data related to a call.

Author:
Jerome Louvel (contact@noelios.com)

Constructor Summary
ClientInfo()
          Constructor.
 
Method Summary
 List<Preference<CharacterSet>> getAcceptedCharacterSets()
          Returns the character set preferences.
 List<Preference<Encoding>> getAcceptedEncodings()
          Returns the encoding preferences.
 List<Preference<Language>> getAcceptedLanguages()
          Returns the language preferences.
 List<Preference<MediaType>> getAcceptedMediaTypes()
          Returns the media type preferences.
 String getAddress()
          Returns the client's IP address.
 List<String> getAddresses()
          Returns the list of client IP addresses.
The first address is the one of the immediate client component as returned by the getClientAdress() method and the last address should correspond to the origin client (frequently a user agent).
 String getAgent()
          Returns the agent name (ex: "Noelios Restlet Engine/1.0").
 int getPort()
          Returns the port number which sent the call.
 Variant getPreferredVariant(List<Variant> variants, Language defaultLanguage)
          Returns the best variant for a given resource according the the client preferences: accepted languages, accepted character sets, accepted media types and accepted encodings.
A default language is provided in case the variants don't match the client preferences.
 Variant getPreferredVariant(Resource resource, Language defaultLanguage)
          Returns the best variant for a given resource according the the client preferences.
A default language is provided in case the resource's variants don't match the client preferences.
 void setAddress(String address)
          Sets the client's IP address.
 void setAgent(String agent)
          Sets the agent name (ex: "Noelios Restlet Engine/1.0").
 void setPort(int port)
          Sets the port number which sent the call.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientInfo

public ClientInfo()
Constructor.

Method Detail

getAcceptedCharacterSets

public List<Preference<CharacterSet>> getAcceptedCharacterSets()
Returns the character set preferences.

Returns:
The character set preferences.

getAcceptedEncodings

public List<Preference<Encoding>> getAcceptedEncodings()
Returns the encoding preferences.

Returns:
The encoding preferences.

getAcceptedLanguages

public List<Preference<Language>> getAcceptedLanguages()
Returns the language preferences.

Returns:
The language preferences.

getAcceptedMediaTypes

public List<Preference<MediaType>> getAcceptedMediaTypes()
Returns the media type preferences.

Returns:
The media type preferences.

getAddress

public String getAddress()
Returns the client's IP address.

Returns:
The client's IP address.

getAddresses

public List<String> getAddresses()
Returns the list of client IP addresses.
The first address is the one of the immediate client component as returned by the getClientAdress() method and the last address should correspond to the origin client (frequently a user agent). This is useful when the user agent is separated from the origin server by a chain of intermediary components.

Returns:
The client IP addresses.

getAgent

public String getAgent()
Returns the agent name (ex: "Noelios Restlet Engine/1.0").

Returns:
The agent name.

getPort

public int getPort()
Returns the port number which sent the call. If no port is specified, -1 is returned.

Returns:
The port number which sent the call.

getPreferredVariant

public Variant getPreferredVariant(List<Variant> variants,
                                   Language defaultLanguage)
Returns the best variant for a given resource according the the client preferences: accepted languages, accepted character sets, accepted media types and accepted encodings.
A default language is provided in case the variants don't match the client preferences.

Parameters:
variants - The list of variants to compare.
defaultLanguage - The default language.
Returns:
The best variant.
See Also:
Apache content negotiation algorithm

getPreferredVariant

public Variant getPreferredVariant(Resource resource,
                                   Language defaultLanguage)
Returns the best variant for a given resource according the the client preferences.
A default language is provided in case the resource's variants don't match the client preferences.

Parameters:
resource - The resource for which the best representation needs to be set.
defaultLanguage - The default language.
Returns:
The best variant.
See Also:
Apache content negotiation algorithm

setAddress

public void setAddress(String address)
Sets the client's IP address.

Parameters:
address - The client's IP address.

setAgent

public void setAgent(String agent)
Sets the agent name (ex: "Noelios Restlet Engine/1.0").

Parameters:
agent - The agent name.

setPort

public void setPort(int port)
Sets the port number which sent the call.

Parameters:
port - The port number which sent the call.


Copyright © 2005-2007 Noelios Technologies.