com.filenet.wcm.toolkit.server.util
Class UserAgent

java.lang.Object
  extended bycom.filenet.wcm.toolkit.server.util.UserAgent

public class UserAgent
extends java.lang.Object

UserAgent is a class representing the User-Agent header found on an incoming HTTP request object. An object of this class, therefore, requires a User-Agent string for construction. This string is parsed down, and provides accessors for browser name, browser version and boolean flags indicating certain things that the browser supports. UserAgents are created via a static factory method that caches UserAgent objects based on the user agent string that was used to construct them. This way, parsing of a given user agent string only needs to be done once per JVM process invocation. In the static initializer block, one or more Maps can be defined representing different browser capabilities. Entries can then be added with key==browser name and value==browser version. boolean flags are then set for each corresponding map, depending on whether or not there is a browser name hit in the map, and the version is greater than or equal to the browser version value found in the map.


Field Summary
protected static java.util.Map activeXBrowserMap
           
protected static java.util.Map activeXOSMap
           
protected  boolean addsExtraLinefeeds
           
protected static java.util.Map addsExtraLinefeedsMap
           
protected static java.util.Map agentCache
           
protected static java.util.Map encodedFilenameMap
           
protected static java.util.Map inputTypeFileMap
           
protected  java.lang.String name
           
protected  java.lang.String osName
           
protected  java.lang.String osVersion
           
protected static java.util.Set recognizedBrowsers
           
protected static java.util.Map rfc2231Map
           
protected  java.lang.String rName
           
protected  java.lang.String rVersion
           
protected  boolean supportsActiveX
           
protected  boolean supportsEncodedFilename
           
protected  boolean supportsInputTypeFile
           
protected  boolean supportsRFC2231
           
protected  java.util.List tokens
           
static java.lang.String USER_AGENT
           
protected  java.lang.String version
           
 
Method Summary
 boolean addsExtraLinefeeds()
           
protected  int compareVersions(java.lang.String version1, java.lang.String version2)
          Compare version strings.
 java.lang.String getName()
          Returns the identified browser's name.
static UserAgent getUserAgent(javax.servlet.http.HttpServletRequest request)
          Static factory convenience signature that thakes the request object as input.
static UserAgent getUserAgent(java.lang.String userAgentHeader)
          Static factory method.
 java.lang.String getVersion()
          Returns the identified browser's version String.
 boolean hasActiveXSupport()
          Returns true if the client machine's operating system and browser type/version are the proper type to support File Tracking through the Workplace FileTracker Active-X control
 boolean hasEncodedFilenameSupport()
          Returns true if the browser can accept a URL/UTF-8 encoded filename interchangeably with a clear text filename in the Content-Disposition header.
 boolean hasInputTypeFileSupport()
           
 boolean hasRFC2231Support()
          Returns true if the browser supports rfc2231 Content-Disposition headers.
protected  void initialize(java.lang.String userAgent)
          Initializes the UserAgent object.
protected  void setFlags()
          Configure all of the boolean flags in this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USER_AGENT

public static final java.lang.String USER_AGENT
See Also:
Constant Field Values

agentCache

protected static java.util.Map agentCache

recognizedBrowsers

protected static java.util.Set recognizedBrowsers

rfc2231Map

protected static java.util.Map rfc2231Map

encodedFilenameMap

protected static java.util.Map encodedFilenameMap

addsExtraLinefeedsMap

protected static java.util.Map addsExtraLinefeedsMap

inputTypeFileMap

protected static java.util.Map inputTypeFileMap

activeXBrowserMap

protected static java.util.Map activeXBrowserMap

activeXOSMap

protected static java.util.Map activeXOSMap

tokens

protected java.util.List tokens

name

protected java.lang.String name

version

protected java.lang.String version

rName

protected java.lang.String rName

rVersion

protected java.lang.String rVersion

osName

protected java.lang.String osName

osVersion

protected java.lang.String osVersion

supportsRFC2231

protected boolean supportsRFC2231

supportsEncodedFilename

protected boolean supportsEncodedFilename

addsExtraLinefeeds

protected boolean addsExtraLinefeeds

supportsInputTypeFile

protected boolean supportsInputTypeFile

supportsActiveX

protected boolean supportsActiveX
Method Detail

getUserAgent

public static UserAgent getUserAgent(javax.servlet.http.HttpServletRequest request)
Static factory convenience signature that thakes the request object as input.

Parameters:
request -
Returns:

getUserAgent

public static UserAgent getUserAgent(java.lang.String userAgentHeader)
Static factory method.

Parameters:
userAgentHeader -
Returns:

getName

public java.lang.String getName()
Returns the identified browser's name.

Returns:

getVersion

public java.lang.String getVersion()
Returns the identified browser's version String.

Returns:

hasRFC2231Support

public boolean hasRFC2231Support()
Returns true if the browser supports rfc2231 Content-Disposition headers. This is a standard for encoding extended characters.

Returns:

hasEncodedFilenameSupport

public boolean hasEncodedFilenameSupport()
Returns true if the browser can accept a URL/UTF-8 encoded filename interchangeably with a clear text filename in the Content-Disposition header. There is no RFC standard associated with this behavior.

Returns:

hasInputTypeFileSupport

public boolean hasInputTypeFileSupport()

addsExtraLinefeeds

public boolean addsExtraLinefeeds()

hasActiveXSupport

public boolean hasActiveXSupport()
Returns true if the client machine's operating system and browser type/version are the proper type to support File Tracking through the Workplace FileTracker Active-X control

Returns:

initialize

protected void initialize(java.lang.String userAgent)
Initializes the UserAgent object. This is the workhorse for the constructors.

Parameters:
userAgent -

setFlags

protected void setFlags()
Configure all of the boolean flags in this object.


compareVersions

protected int compareVersions(java.lang.String version1,
                              java.lang.String version2)
Compare version strings. This method assumes version strings consisting of one or more numeric parts separated by periods (dots). If for some reason a particular part cannot be interpreted as an integer value, then the parts are compared as strings.

Parameters:
version1 -
version2 -
Returns:
Returns 0 if version1 and version2 are equal, 1 if version1 is greater and -1 if version1 is less.


© Copyright IBM Corp. 2002, 2007. All Rights Reserved.