org.norther.tammi.spray.terminal
Interface TerminalFilter

All Superinterfaces:
Filter, KeyFilter
All Known Implementing Classes:
DefaultTerminalFilter

public interface TerminalFilter
extends KeyFilter

An interface to filters determining the properties of the terminal. The main properties include the preferred MIME type for the terminal and the identification of the terminal.

Version:
$Id: TerminalFilter.java,v 1.28 2010-04-09 15:46:23 cvsimp Exp $
Author:
Ilkka Priha

Method Summary
 void addDefaultContentTypes(String[] types)
          Adds more default content type for requests.
 void addHostPatterns(String name, String[] patterns)
          Adds more host patterns for a named profile.
 void addProfileContentTypes(String name, String[] types)
          Adds more profile specific content types.
 boolean addProfileName(String name)
          Adds a named profile if absent.
 void addProfileNames(String[] names)
          Adds named profiles if absent.
 void addTerminalIdCookies(String[] names)
          Adds more potential terminal id cookies.
 void addTerminalIdHeaders(String[] names)
          Adds more potential terminal id headers.
 void addTerminalIdParameters(String[] names)
          Adds more potential terminal id parameters.
 void addUserAgentPatterns(String name, String[] patterns)
          Adds more user agent patterns for a named profile.
 void clearDefaultContentTypes()
          Clears all default content types for requests.
 void clearHostPatterns(String name)
          Clears all host patterns.
 void clearProfileContentTypes(String name)
          Clears all profile specific content types.
 void clearProfiles()
          Clears all profiles.
 void clearTerminalIdCookies()
          Clears all potential terminal id cookies.
 void clearTerminalIdHeaders()
          Clears all potential terminal id headers.
 void clearTerminalIdParameters()
          Clears all potential terminal id parameters.
 void clearUserAgentPatterns(String name)
          Clears all user agent patterns.
 boolean containsProfile(String name)
          Checks the named profile.
 String[] getDefaultContentTypes()
          Gets the default content types for requests.
 int getDefaultHeight()
          Gets the default height in pixels.
 String getDefaultProfileName()
          Gets the name of the default profile.
 int getDefaultWidth()
          Gets the default width in pixels.
 String[] getHostPatterns(String name)
          Gets host patterns for a named profile.
 Profile getProfile(String name)
          Gets the named profile.
 String[] getProfileContentTypes(String name)
          Gets profile specific content types.
 String getProfileDefaultName(String name)
          Gets the default profile name of the specified skin.
 int getProfileHeight(String name)
          Gets the height of the named profile in pixels.
 int getProfileWidth(String name)
          Gets the width of the named profile in pixels.
 MimeType getTerminalContentType(MimeType favorite, Profile profile, ServletRequest request, ServletResponse response, FilterChain chain)
          Gets the terminal specific MIME type best matching the accepted content types of the current user agent.
 String[] getTerminalIdCookies()
          Gets potential terminal id cookies.
 String[] getTerminalIdHeaders()
          Gets potential terminal id headers.
 String[] getTerminalIdParameters()
          Gets potential terminal id parameters.
 String[] getUserAgentPatterns(String name)
          Gets user agent patterns for a named profile.
 boolean isProfileScriptable(String name)
          Checks whether the named profile is scriptable.
 boolean isScriptableProfiles()
          Checks whether profiles are scriptable by default.
 Profile matchHost(String host)
          Matches the given host against profiles in definition order.
 Profile matchUserAgent(String agent)
          Matches the given user agent against profiles in definition order.
 Set<String> profileNameSet()
          Returns a read-only set of profile names.
 void removeDefaultContentType(String csv)
          Removes one or more default content types for requests.
 void removeHostPattern(String name, String pattern)
          Removes a host pattern from a named profile.
 void removeProfile(String name)
          Removes the named profile.
 void removeProfileContentType(String name, String type)
          Removes a profile specific content type.
 void removeTerminalIdCookie(String name)
          Removes a potential terminal id cookie.
 void removeTerminalIdHeader(String name)
          Removes a potential terminal id header.
 void removeTerminalIdParameter(String name)
          Removes a potential terminal id header.
 void removeUserAgentPattern(String name, String pattern)
          Removes a user agent pattern from a named profile.
 Profile resolveCurrentProfile(String agent, String... host)
          Resolves the current profile for the given user agent and host.
 void setDefaultContentTypes(String[] types)
          Sets the default content types for requests.
 void setDefaultHeight(int h)
          Sets the default height in pixels.
 void setDefaultProfileName(String name)
          Sets the name of the default profile.
 void setDefaultWidth(int w)
          Sets the default width.in pixels
 void setHostPatterns(String name, String[] patterns)
          Sets host patterns for a named profile.
 void setProfileContentTypes(String name, String[] types)
          Sets profile specific content types.
 void setProfileDefaultName(String name, String dname)
          Sets the default profile name of the specified profile.
 void setProfileHeight(String name, int h)
          Sets the height of the named profile in pixels.
 void setProfileName(String name)
          Sets or replaces a named profile.
 void setProfileNames(String[] names)
          Sets or replaces named profiles.
 void setProfileScriptable(String name, boolean flag)
          Sets whether the named profile is scriptable.
 void setProfileWidth(String name, int w)
          Sets the width of the named profile in pixels.
 void setScriptableProfiles(boolean flag)
          Sets whether profiles are scriptable by default.
 void setTerminalIdCookies(String[] names)
          Sets potential terminal id cookies.
 void setTerminalIdHeaders(String[] names)
          Sets potential terminal id headers.
 void setTerminalIdParameters(String[] names)
          Sets potential terminal id parameters.
 void setUserAgentPatterns(String name, String[] patterns)
          Sets user agent patterns for a named profile.
 Set<String> terminalIdCookieSet()
          Returns a set of terminal id cookies.
 Set<String> terminalIdHeaderSet()
          Returns a set of terminal id headers.
 Set<String> terminalIdParameterSet()
          Returns a set of terminal id parameters.
 
Methods inherited from interface org.norther.tammi.spray.filter.KeyFilter
getKey, getKeyValue, getKeyValues, isLinkedKey, setKey, setLinkedKey
 
Methods inherited from interface javax.servlet.Filter
destroy, doFilter, init
 

Method Detail

getDefaultProfileName

String getDefaultProfileName()
Gets the name of the default profile.

Returns:
the name of the profile or null.

setDefaultProfileName

void setDefaultProfileName(String name)
Sets the name of the default profile.

Parameters:
name - the name of the profile.

isScriptableProfiles

boolean isScriptableProfiles()
Checks whether profiles are scriptable by default.

Returns:
true if scriptable, false otherwise.

setScriptableProfiles

void setScriptableProfiles(boolean flag)
Sets whether profiles are scriptable by default.

Parameters:
flag - true if scriptable, false otherwise.

getDefaultWidth

int getDefaultWidth()
Gets the default width in pixels.

Returns:
the width.

setDefaultWidth

void setDefaultWidth(int w)
Sets the default width.in pixels

Parameters:
w - the width.

getDefaultHeight

int getDefaultHeight()
Gets the default height in pixels.

Returns:
the height.

setDefaultHeight

void setDefaultHeight(int h)
Sets the default height in pixels.

Parameters:
h - the height.

getDefaultContentTypes

String[] getDefaultContentTypes()
Gets the default content types for requests.

Returns:
an array of content types.

setDefaultContentTypes

void setDefaultContentTypes(String[] types)
Sets the default content types for requests. The type list is matched against the accepted MIME types provided by the user agent in the accept header of the request and the best match will be applied.

The format of the type is similar to that in the accept header except of an additional 'x' parameter, which specifies the content type variant corresponding to the file name extension of that content. The Q-value defines the priority between 0-1. E.g.

'MIME type'[; x='extension'][; q='value']

For more information about Internet media types, please check RFCs 2045-2049 and their updates.

Parameters:
types - an array of comma separated values of content types.

addDefaultContentTypes

void addDefaultContentTypes(String[] types)
Adds more default content type for requests.

Parameters:
types - an array of comma separated values of content types.

removeDefaultContentType

void removeDefaultContentType(String csv)
Removes one or more default content types for requests.

Parameters:
csv - comma separated values of content types or extensions.

clearDefaultContentTypes

void clearDefaultContentTypes()
Clears all default content types for requests.


setProfileName

void setProfileName(String name)
Sets or replaces a named profile.

Parameters:
name - the name of the profile.

addProfileName

boolean addProfileName(String name)
Adds a named profile if absent.

Parameters:
name - the name of the profile.
Returns:
true id added, false otherwise.

setProfileNames

void setProfileNames(String[] names)
Sets or replaces named profiles.

Parameters:
names - the names of the profiles.

addProfileNames

void addProfileNames(String[] names)
Adds named profiles if absent.

Parameters:
names - the names of the profiles.

profileNameSet

Set<String> profileNameSet()
Returns a read-only set of profile names.

Returns:
a set of profile names.

removeProfile

void removeProfile(String name)
Removes the named profile.

Parameters:
name - the name of the profile.

clearProfiles

void clearProfiles()
Clears all profiles.


getProfileDefaultName

String getProfileDefaultName(String name)
Gets the default profile name of the specified skin.

Parameters:
name - the name of the profile.
Returns:
the default profile name.

setProfileDefaultName

void setProfileDefaultName(String name,
                           String dname)
Sets the default profile name of the specified profile.

Parameters:
name - the name of the profile.
dname - the default profile name.
Throws:
NullPointerException - if the profile is not found.

isProfileScriptable

boolean isProfileScriptable(String name)
Checks whether the named profile is scriptable.

Parameters:
name - the name of the profile.
Returns:
true if scriptable, false otherwise.

setProfileScriptable

void setProfileScriptable(String name,
                          boolean flag)
Sets whether the named profile is scriptable.

Parameters:
name - the name of the profile.
flag - true if scriptable, false otherwise.
Throws:
NullPointerException - if the profile is not found.

getProfileWidth

int getProfileWidth(String name)
Gets the width of the named profile in pixels.

Parameters:
name - the name of the profile.
Returns:
the width.

setProfileWidth

void setProfileWidth(String name,
                     int w)
Sets the width of the named profile in pixels.

Parameters:
name - the name of the profile.
w - the width.
Throws:
NullPointerException - if the profile is not found.

getProfileHeight

int getProfileHeight(String name)
Gets the height of the named profile in pixels.

Parameters:
name - the name of the profile.
Returns:
the height.

setProfileHeight

void setProfileHeight(String name,
                      int h)
Sets the height of the named profile in pixels.

Parameters:
name - the name of the profile.
h - the height.
Throws:
NullPointerException - if the profile is not found.

getProfileContentTypes

String[] getProfileContentTypes(String name)
Gets profile specific content types.

Parameters:
name - the name of the profile.
Returns:
an array of content types or null.

setProfileContentTypes

void setProfileContentTypes(String name,
                            String[] types)
Sets profile specific content types. Profile content types can be used in an exceptional case to specify the preferred content type for a particular user agent. The user agent of the profile is specified with a user agent variant configured separately as a pattern matched against the 'user-agent' request header.

An additional 'nocharset' parameter defines that charset definition is not appended to the content type if it is not accepted by the user agent. E.g.

'VARIANT' = 'MIME type'[; x='extension'][; q='value'] [; nocharset=on]

Parameters:
name - the name of the profile.
types - an array of comma separated values of content types.
Throws:
NullPointerException - if the profile is not found.

addProfileContentTypes

void addProfileContentTypes(String name,
                            String[] types)
Adds more profile specific content types.

Parameters:
name - the name of the profile.
types - an array of comma separated values of content types.
Throws:
NullPointerException - if the profile is not found.

removeProfileContentType

void removeProfileContentType(String name,
                              String type)
Removes a profile specific content type.

Parameters:
name - the name of the profile.
type - the content type.

clearProfileContentTypes

void clearProfileContentTypes(String name)
Clears all profile specific content types.

Parameters:
name - the name of the profile.

getUserAgentPatterns

String[] getUserAgentPatterns(String name)
Gets user agent patterns for a named profile.

Parameters:
name - the name of the profile.
Returns:
an array of patterns.

setUserAgentPatterns

void setUserAgentPatterns(String name,
                          String[] patterns)
Sets user agent patterns for a named profile. User agent pattern is defined by giving a regular expression to be matched against the product tokens in the 'user-agent' header information.

Parameters:
name - the name of the profile.
patterns - an array of patterns.
Throws:
NullPointerException - if the profile is not found.

addUserAgentPatterns

void addUserAgentPatterns(String name,
                          String[] patterns)
Adds more user agent patterns for a named profile.

Parameters:
name - the name of the profile.
patterns - an array of patterns.

removeUserAgentPattern

void removeUserAgentPattern(String name,
                            String pattern)
Removes a user agent pattern from a named profile.

Parameters:
name - the name of the profile.
pattern - the pattern to remove.

clearUserAgentPatterns

void clearUserAgentPatterns(String name)
Clears all user agent patterns.

Parameters:
name - the name of the profile.

matchUserAgent

Profile matchUserAgent(String agent)
Matches the given user agent against profiles in definition order.

Parameters:
agent - the request specific user agent.
Returns:
the matching profile or null.

getHostPatterns

String[] getHostPatterns(String name)
Gets host patterns for a named profile.

Parameters:
name - the name of the profile.
Returns:
an array of patterns.

setHostPatterns

void setHostPatterns(String name,
                     String[] patterns)
Sets host patterns for a named profile. Host pattern is defined by giving a regular expression to be matched against the 'host' header.

Parameters:
name - the name of the profile.
patterns - an array of patterns.
Throws:
NullPointerException - if the profile is not found.

addHostPatterns

void addHostPatterns(String name,
                     String[] patterns)
Adds more host patterns for a named profile.

Parameters:
name - the name of the profile.
patterns - an array of patterns.
Throws:
NullPointerException - if the profile is not found.

removeHostPattern

void removeHostPattern(String name,
                       String pattern)
Removes a host pattern from a named profile.

Parameters:
name - the name of the profile.
pattern - the pattern to remove.

clearHostPatterns

void clearHostPatterns(String name)
Clears all host patterns.

Parameters:
name - the name of the profile.

matchHost

Profile matchHost(String host)
Matches the given host against profiles in definition order.

Parameters:
host - the request specific host.
Returns:
the matching profile or null.

getProfile

Profile getProfile(String name)
Gets the named profile.

Parameters:
name - the name of the profile.
Returns:
the read-only profile or null.

containsProfile

boolean containsProfile(String name)
Checks the named profile.

Parameters:
name - the name of the profile.
Returns:
true if the profile exists, false otherwise.

resolveCurrentProfile

Profile resolveCurrentProfile(String agent,
                              String... host)
Resolves the current profile for the given user agent and host.

Parameters:
agent - the user agent.
host - the host name.
Returns:
the current profile.

getTerminalIdParameters

String[] getTerminalIdParameters()
Gets potential terminal id parameters.

Returns:
an array of parameter names.

setTerminalIdParameters

void setTerminalIdParameters(String[] names)
Sets potential terminal id parameters. Terminal id may be given as a parameter, or passed in header information or in a cookie.

Parameters:
names - an array of parameter names.

addTerminalIdParameters

void addTerminalIdParameters(String[] names)
Adds more potential terminal id parameters.

Parameters:
names - an array of parameter names.

removeTerminalIdParameter

void removeTerminalIdParameter(String name)
Removes a potential terminal id header.

Parameters:
name - a parameter name.

clearTerminalIdParameters

void clearTerminalIdParameters()
Clears all potential terminal id parameters.


terminalIdParameterSet

Set<String> terminalIdParameterSet()
Returns a set of terminal id parameters.

Returns:
a read-only set of terminal id parameter names.

getTerminalIdCookies

String[] getTerminalIdCookies()
Gets potential terminal id cookies.

Returns:
an array of cookie names.

setTerminalIdCookies

void setTerminalIdCookies(String[] names)
Sets potential terminal id cookies. Terminal id may be given as a parameter, or passed in header information or in a cookie.

Parameters:
names - an array of cookie names.

addTerminalIdCookies

void addTerminalIdCookies(String[] names)
Adds more potential terminal id cookies.

Parameters:
names - an array of cookie names.

removeTerminalIdCookie

void removeTerminalIdCookie(String name)
Removes a potential terminal id cookie.

Parameters:
name - a cookie name.

clearTerminalIdCookies

void clearTerminalIdCookies()
Clears all potential terminal id cookies.


terminalIdCookieSet

Set<String> terminalIdCookieSet()
Returns a set of terminal id cookies.

Returns:
a read-only set of id cookie names.

getTerminalIdHeaders

String[] getTerminalIdHeaders()
Gets potential terminal id headers.

Returns:
an array of header names.

setTerminalIdHeaders

void setTerminalIdHeaders(String[] names)
Sets potential terminal id headers. Terminal id may be given as a parameter, or passed in header information or in a cookie.

Parameters:
names - an array of header names.

addTerminalIdHeaders

void addTerminalIdHeaders(String[] names)
Adds more potential terminal id headers.

Parameters:
names - an array of header names.

removeTerminalIdHeader

void removeTerminalIdHeader(String name)
Removes a potential terminal id header.

Parameters:
name - a header name.

clearTerminalIdHeaders

void clearTerminalIdHeaders()
Clears all potential terminal id headers.


terminalIdHeaderSet

Set<String> terminalIdHeaderSet()
Returns a set of terminal id headers.

Returns:
a read-only set of id header names.

getTerminalContentType

MimeType getTerminalContentType(MimeType favorite,
                                Profile profile,
                                ServletRequest request,
                                ServletResponse response,
                                FilterChain chain)
Gets the terminal specific MIME type best matching the accepted content types of the current user agent.

Parameters:
favorite - the favorite type.
profile - the profile to apply.
request - the request.
response - the response.
chain - the filter chain.
Returns:
the terminal MIME type.


Copyright © 2004 The Norther Organization. All rights reserved.