com.filenet.wcm.toolkit.server.util

Class UserAgent

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

  1. public class UserAgent
  2. 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

Modifier and Type Field and Description
  1. protected static
  2. java.util.Map
activeXBrowserMap
  1. protected static
  2. java.util.Map
activeXOSMap
  1. protected
  2. boolean
addsExtraLinefeeds
  1. protected static
  2. java.util.Map
addsExtraLinefeedsMap
  1. protected static
  2. java.util.Map
agentCache
  1. protected
  2. boolean
calendarWorkaroundIE
  1. protected static
  2. java.util.Map
calendarWorkaroundMap
  1. protected static
  2. java.util.Map
encodedFilenameMap
  1. protected static
  2. java.util.Map
inputTypeFileMap
  1. protected
  2. java.lang.String
name
  1. protected
  2. java.lang.String
osName
  1. protected
  2. java.lang.String
osVersion
  1. protected static
  2. java.util.Set
recognizedBrowsers
  1. protected static
  2. java.util.Map
rfc2231Map
  1. protected
  2. java.lang.String
rName
  1. protected
  2. java.lang.String
rVersion
  1. protected
  2. boolean
supportsActiveX
  1. protected
  2. boolean
supportsEncodedFilename
  1. protected
  2. boolean
supportsInputTypeFile
  1. protected
  2. boolean
supportsRFC2231
  1. protected
  2. java.util.List
tokens
  1. protected
  2. boolean
useAttachmentHeader
  1. protected static
  2. java.util.Map
useAttachmentMap
  1. static
  2. java.lang.String
USER_AGENT
  1. protected
  2. java.lang.String
version

Method Summary

Modifier and Type Method and Description
  1. boolean
addsExtraLinefeeds()
  1. protected
  2. int
compareVersions(java.lang.String version1,java.lang.String version2)
Compare version strings.
  1. java.lang.String
getName()
Returns the identified browser's name.
  1. static
  2. UserAgent
getUserAgent(javax.servlet.http.HttpServletRequest request)
Static factory convenience signature that thakes the request object as input.
  1. static
  2. UserAgent
getUserAgent(java.lang.String userAgentHeader)
Static factory method.
  1. java.lang.String
getVersion()
Returns the identified browser's version String.
  1. 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
  1. 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.
  1. boolean
hasInputTypeFileSupport()
  1. boolean
hasRFC2231Support()
Returns true if the browser supports rfc2231 Content-Disposition headers.
  1. protected
  2. void
initialize(java.lang.String userAgent)
Initializes the UserAgent object.
  1. boolean
needsCalendarTabWorkaround()
  1. protected
  2. void
setFlags()
Configure all of the boolean flags in this object.
  1. boolean
useAttachmentHeader()
Tells whether or not to ALWAYS use the "attachment" keyword in the Content-Disposition header at all times.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

USER_AGENT

  1. public static final java.lang.String USER_AGENT
See Also:

agentCache

  1. protected static java.util.Map agentCache

recognizedBrowsers

  1. protected static java.util.Set recognizedBrowsers

rfc2231Map

  1. protected static java.util.Map rfc2231Map

encodedFilenameMap

  1. protected static java.util.Map encodedFilenameMap

addsExtraLinefeedsMap

  1. protected static java.util.Map addsExtraLinefeedsMap

inputTypeFileMap

  1. protected static java.util.Map inputTypeFileMap

calendarWorkaroundMap

  1. protected static java.util.Map calendarWorkaroundMap

useAttachmentMap

  1. protected static java.util.Map useAttachmentMap

activeXBrowserMap

  1. protected static java.util.Map activeXBrowserMap

activeXOSMap

  1. protected static java.util.Map activeXOSMap

tokens

  1. protected java.util.List tokens

name

  1. protected java.lang.String name

version

  1. protected java.lang.String version

rName

  1. protected java.lang.String rName

rVersion

  1. protected java.lang.String rVersion

osName

  1. protected java.lang.String osName

osVersion

  1. protected java.lang.String osVersion

supportsRFC2231

  1. protected boolean supportsRFC2231

supportsEncodedFilename

  1. protected boolean supportsEncodedFilename

addsExtraLinefeeds

  1. protected boolean addsExtraLinefeeds

supportsInputTypeFile

  1. protected boolean supportsInputTypeFile

calendarWorkaroundIE

  1. protected boolean calendarWorkaroundIE

supportsActiveX

  1. protected boolean supportsActiveX

useAttachmentHeader

  1. protected boolean useAttachmentHeader

Method Detail

getUserAgent

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

getUserAgent

  1. public static UserAgent getUserAgent( java.lang.String userAgentHeader)
Static factory method.
Parameters:
userAgentHeader -
Returns:

getName

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

getVersion

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

hasRFC2231Support

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

hasEncodedFilenameSupport

  1. 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

  1. public boolean hasInputTypeFileSupport( )

needsCalendarTabWorkaround

  1. public boolean needsCalendarTabWorkaround( )

addsExtraLinefeeds

  1. public boolean addsExtraLinefeeds( )

hasActiveXSupport

  1. 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:

useAttachmentHeader

  1. public boolean useAttachmentHeader( )
Tells whether or not to ALWAYS use the "attachment" keyword in the Content-Disposition header at all times. Reference defect ecmdb00854172
Returns:

initialize

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

setFlags

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

compareVersions

  1. protected int compareVersions(java.lang.String version1,
  2. 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.