public final class ClientInfo
extends java.lang.Object
#Firefox for Windows Mozilla/{mozillaVersion} (Windows; U; {agentOs}; {osData}; rv:{releaseVersion}) Gecko/{geckoReleaseDate} {agentName}/{agentVersion}This template matches the "user-agent" string of the Firefox client for windows:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20060918 Firefox/2.0At this time, six predefined variables are used:
Name | Description |
---|---|
agentName | Name of the user agent (i.e.: Firefox) |
agentVersion | Version of the user agent |
agentOs | Operating system of the user agent |
agentComment | Comment string, that is to say a sequence of characters enclosed "(", or ")" |
commentAttribute | A sequence of characters enclosed by ";", "(", or ")" |
facultativeData | A sequence of characters that can be empty |
Product
instance with the main
data (name, version, comment). This instance is accessible via the
ClientInfo#getMainAgentProduct()
method. All other variables used in
the template aims at catching a sequence of characters and are accessible via
the ClientInfo#getAgentAttributes()
method.Constructor and Description |
---|
ClientInfo()
Constructor.
|
ClientInfo(MediaType mediaType)
Constructor from a media type.
|
Modifier and Type | Method and Description |
---|---|
void |
accept(Metadata... metadata)
Updates the client preferences to accept the given metadata (media types,
character sets, etc.) with a 1.0 quality in addition to existing ones.
|
void |
accept(Metadata metadata,
float quality)
Updates the client preferences to accept the given metadata (media types,
character sets, etc.) with a given quality in addition to existing ones.
|
java.util.List<Preference<CharacterSet>> |
getAcceptedCharacterSets()
Returns the modifiable list of character set preferences.
|
java.util.List<Preference<Encoding>> |
getAcceptedEncodings()
Returns the modifiable list of encoding preferences.
|
java.util.List<Preference<Language>> |
getAcceptedLanguages()
Returns the modifiable list of language preferences.
|
java.util.List<Preference<MediaType>> |
getAcceptedMediaTypes()
Returns the modifiable list of media type preferences.
|
java.util.List<Preference<MediaType>> |
getAcceptedPatches()
Returns the modifiable list of patch preferences.
|
java.lang.String |
getAddress()
Returns the immediate client's IP address.
|
java.lang.String |
getAgent()
Returns the agent name (ex: "Restlet-Framework/2.0").
|
java.util.List<java.lang.String> |
getForwardedAddresses()
Returns the list of forwarded IP addresses.
|
java.lang.String |
getFrom()
Returns the email address of the human user controlling the user agent.
|
int |
getPort()
Returns the port number which sent the call.
|
void |
setAcceptedCharacterSets(java.util.List<Preference<CharacterSet>> acceptedCharacterSets)
Sets the character set preferences.
|
void |
setAcceptedEncodings(java.util.List<Preference<Encoding>> acceptedEncodings)
Sets the encoding preferences.
|
void |
setAcceptedLanguages(java.util.List<Preference<Language>> acceptedLanguages)
Sets the language preferences.
|
void |
setAcceptedMediaTypes(java.util.List<Preference<MediaType>> acceptedMediaTypes)
Sets the media type preferences.
|
void |
setAcceptedPatches(java.util.List<Preference<MediaType>> acceptedPatches)
Sets the patch preferences.
|
void |
setAddress(java.lang.String address)
Sets the client's IP address.
|
void |
setAgent(java.lang.String agent)
Sets the agent name (ex: "Restlet-Framework/2.0").
|
void |
setForwardedAddresses(java.util.List<java.lang.String> forwardedAddresses)
Sets the list of forwarded IP addresses.
|
void |
setFrom(java.lang.String from)
Sets the email address of the human user controlling the user agent.
|
void |
setPort(int port)
Sets the port number which sent the call.
|
public ClientInfo()
public ClientInfo(MediaType mediaType)
mediaType
- The preferred media type.public void accept(Metadata... metadata)
metadata
- The metadata to accept.public void accept(Metadata metadata, float quality)
metadata
- The metadata to accept.quality
- The quality to set.public java.util.List<Preference<CharacterSet>> getAcceptedCharacterSets()
public java.util.List<Preference<Encoding>> getAcceptedEncodings()
public java.util.List<Preference<Language>> getAcceptedLanguages()
public java.util.List<Preference<MediaType>> getAcceptedMediaTypes()
public java.util.List<Preference<MediaType>> getAcceptedPatches()
public java.lang.String getAddress()
#getUpstreamAddress()
,
getForwardedAddresses()
public java.lang.String getAgent()
public java.util.List<java.lang.String> getForwardedAddresses()
#getUpstreamAddress()
,
Wikipedia
page for the "X-Forwarded-For" HTTP headerpublic java.lang.String getFrom()
public int getPort()
public void setAcceptedCharacterSets(java.util.List<Preference<CharacterSet>> acceptedCharacterSets)
acceptedCharacterSets
- The character set preferences.public void setAcceptedEncodings(java.util.List<Preference<Encoding>> acceptedEncodings)
acceptedEncodings
- The encoding preferences.public void setAcceptedLanguages(java.util.List<Preference<Language>> acceptedLanguages)
acceptedLanguages
- The language preferences.public void setAcceptedMediaTypes(java.util.List<Preference<MediaType>> acceptedMediaTypes)
acceptedMediaTypes
- The media type preferences.public void setAcceptedPatches(java.util.List<Preference<MediaType>> acceptedPatches)
acceptedPatches
- The media type preferences.public void setAddress(java.lang.String address)
address
- The client's IP address.public void setAgent(java.lang.String agent)
agent
- The agent name.public void setForwardedAddresses(java.util.List<java.lang.String> forwardedAddresses)
forwardedAddresses
- The list of forwarded IP addresses.getForwardedAddresses()
public void setFrom(java.lang.String from)
from
- The email address of the human user controlling the user
agent.public void setPort(int port)
port
- The port number which sent the call.Copyright © 2005-2024 Restlet.