com.endeca.soleng.urlformatter.seo
Class SeoUrlFormatter

java.lang.Object
  extended by com.endeca.soleng.urlformatter.basic.BasicUrlFormatter
      extended by com.endeca.soleng.urlformatter.seo.SeoUrlFormatter
All Implemented Interfaces:
UrlFormatter

public class SeoUrlFormatter
extends BasicUrlFormatter

An UrlFormatter that parses and formats optimized URLs.

Property Summary
Property Type Default Value
pathSeparatorToken String _ (underscore)
pathKeyValueSeparator char - (hyphen)
navStateFormatter NavStateFormatter null
ERecFormatter ERecFormatter null
aggrERecFormatter AggrERecFormatter null
pathParamKeys String[] null
urlParamEncoders UrlParamEncoder[] null
navStateCanonicalizer NavStateCanonicalizer null
See properties inherited from BasicUrlFormatter


Field Summary
static char PATH_SEPARATOR
           
 
Constructor Summary
SeoUrlFormatter()
           
 
Method Summary
 AggrERecUrlParam createAggrERecUrlParam(UrlState pUrlState, com.endeca.navigation.AggrERec pAggrERec)
          Creates an URL parameter containing an AggrERec.
 ERecUrlParam createERecUrlParam(UrlState pUrlState, com.endeca.navigation.ERec pERec)
          Creates an URL parameter containing an ERec.
 NavStateUrlParam createNavStateUrlParam(UrlState pUrlState)
          Creates an URL parameter containing an empty NavState.
 UrlParam createUrlParam(UrlState pUrlState, String pKey, String pValue)
          Creates an URL parameter for the specified UrlState.
protected  String formatAggrERec(UrlState pUrlState)
           
 String formatCanonicalUrl(UrlState pUrlState)
          Formats a canonical url.
protected  String formatERec(UrlState pUrlState)
           
protected  String formatNavState(UrlState pUrlState)
           
protected  String formatPathKeywords(UrlState pUrlState)
           
protected  String formatPathParams(UrlState pUrlState)
           
protected  String formatQueryString(UrlState pUrlState)
           
 String formatUrl(UrlState pUrlState)
          Formats the specified UrlState into an URL string.
 AggrERecFormatter getAggrERecFormatter()
          The AggrERecFormatter used to render aggregate record attributes to the URL path keywords.
 ERecFormatter getERecFormatter()
          The ERecFormatter used to render endeca record attributes to the URL path keywords.
 NavStateCanonicalizer getNavStateCanonicalizer()
          Returns the canonicalizer used to sort the navigation state before rendering an UrlState.
 NavStateFormatter getNavStateFormatter()
          The NavStateFormatter property used to render navigation state information to the URL path keywords.
 char getPathKeyValueSeparator()
          The character used to separate key/value pairs in the path parameter section of the URL.
 String[] getPathParamKeys()
          The parameter keys that will be appended to the path.
 String getPathSeparatorToken()
          The separator token that is used to separate the misc-path section of the URL from the path parameter section.
 UrlParamEncoder[] mUrlParamEncoders()
          The UrlParamEncoder objects used by this SeoUrlFormatter.
protected  void parsePathInfo(UrlState pUrlState, String pPathInfo)
           
protected  void parseQueryString(UrlState pUrlState, String pQueryString)
           
 UrlState parseRequest(javax.servlet.http.HttpServletRequest pRequest)
          Parses the specified request into an UrlState.
 UrlState parseRequest(String pQueryString, String pPathInfo, String pCharacterEncoding)
           
 void setAggrERecFormatter(AggrERecFormatter pAggrERecFormatter)
          Sets the aggrERecFormatter property, which is used to render directory-style (path-encoded) keywords for UrlState objects containing an Endeca aggregate record.
 void setERecFormatter(ERecFormatter pERecFormatter)
          Sets the ERecFormatter property, which is used to render directory-style (path-encoded) keywords for UrlState objects containing an Endeca record.
 void setNavStateCanonicalizer(NavStateCanonicalizer pNavStateCanonicalizer)
          Specifies the canonicalizer used to sort the navigation state before rendering an UrlState.
 void setNavStateFormatter(NavStateFormatter pNavStateFormatter)
          Sets the navStateFormatter property, which is used to render directory-style (path-encoded) keywords for UrlState objects containing dimensional navigation state.
 void setPathKeyValueSeparator(char pPathKeyValueSeparator)
          Specifies the character used to separate key/value pairs in the path parameter section of the URL.
 void setPathParamKeys(String[] pPathParamKeys)
          Specifies the parameter keys that will be appended to the path, rather than the query string, which is the default setting for any given key.
 void setPathSeparatorToken(String pPathSeparatorToken)
          Specifies the separator token that is used to separate the misc-path section of the URL from the path parameter section.
 void setUrlParamEncoders(UrlParamEncoder[] pUrlParamEncoders)
          Specifies the UrlParamEncoder objects used by this SeoUrlFormatter.
 void setUseNavStateCanonicalizer(boolean useNavStateCanonicalizer)
          Determines whether or not to use canonicalizers when formatting the URL.
 boolean useNavStateCanonicalizer()
          The useNavStateCanonicalizer property used determine whether to use any canonicalizers associated with this formatter.
 
Methods inherited from class com.endeca.soleng.urlformatter.basic.BasicUrlFormatter
getAggrERecParamKey, getDefaultEncoding, getERecParamKey, getNavStateParamKey, getPrependQuestionMark, parseRequest, setAggrERecParamKey, setDefaultEncoding, setERecParamKey, setNavStateParamKey, setPrependQuestionMark
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATH_SEPARATOR

public static final char PATH_SEPARATOR
See Also:
Constant Field Values
Constructor Detail

SeoUrlFormatter

public SeoUrlFormatter()
Method Detail

getPathSeparatorToken

public String getPathSeparatorToken()
The separator token that is used to separate the misc-path section of the URL from the path parameter section.


setPathSeparatorToken

public void setPathSeparatorToken(String pPathSeparatorToken)
Specifies the separator token that is used to separate the misc-path section of the URL from the path parameter section.

In the following URL, "XX" is the pathSeparatorToken:

 http://www.mysite.com/controller/Wine+Type/Sparkling/Blanc+de+Blancs/XX/N-6202
 

Parameters:
pPathSeparatorToken - Path separator token to set. Cannot be null.
Throws:
IllegalArgumentException - if pPathSeparatorToken is null.

getPathKeyValueSeparator

public char getPathKeyValueSeparator()
The character used to separate key/value pairs in the path parameter section of the URL.


setPathKeyValueSeparator

public void setPathKeyValueSeparator(char pPathKeyValueSeparator)
Specifies the character used to separate key/value pairs in the path parameter section of the URL.

In the following URL, '*' is the keyValueSeparator:

 http://www.mysite.com/controller/Wine+Type/Sparkling/Blanc+de+Blancs/_/N*6202
 

Parameters:
pPathKeyValueSeparator - key value separator. Cannot be null.

useNavStateCanonicalizer

public boolean useNavStateCanonicalizer()
The useNavStateCanonicalizer property used determine whether to use any canonicalizers associated with this formatter.

Returns:
TRUE if the canonicalizer will be used.

setUseNavStateCanonicalizer

public void setUseNavStateCanonicalizer(boolean useNavStateCanonicalizer)
Determines whether or not to use canonicalizers when formatting the URL.

Parameters:
useNavStateCanonicalizer - If set to TRUE, the canonicalizer will be used.

getNavStateFormatter

public NavStateFormatter getNavStateFormatter()
The NavStateFormatter property used to render navigation state information to the URL path keywords.


setNavStateFormatter

public void setNavStateFormatter(NavStateFormatter pNavStateFormatter)
Sets the navStateFormatter property, which is used to render directory-style (path-encoded) keywords for UrlState objects containing dimensional navigation state.

Parameters:
pNavStateFormatter - object that is used to format the UrlState.
See Also:
SeoNavStateFormatter

getERecFormatter

public ERecFormatter getERecFormatter()
The ERecFormatter used to render endeca record attributes to the URL path keywords.


setERecFormatter

public void setERecFormatter(ERecFormatter pERecFormatter)
Sets the ERecFormatter property, which is used to render directory-style (path-encoded) keywords for UrlState objects containing an Endeca record.

Parameters:
pERecFormatter - object that is used to format the UrlState.
See Also:
SeoERecFormatter

getAggrERecFormatter

public AggrERecFormatter getAggrERecFormatter()
The AggrERecFormatter used to render aggregate record attributes to the URL path keywords.


setAggrERecFormatter

public void setAggrERecFormatter(AggrERecFormatter pAggrERecFormatter)
Sets the aggrERecFormatter property, which is used to render directory-style (path-encoded) keywords for UrlState objects containing an Endeca aggregate record.

Parameters:
pAggrERecFormatter - object that is used to format the UrlState.
See Also:
SeoAggrERecFormatter

getPathParamKeys

public String[] getPathParamKeys()
The parameter keys that will be appended to the path.


setPathParamKeys

public void setPathParamKeys(String[] pPathParamKeys)
Specifies the parameter keys that will be appended to the path, rather than the query string, which is the default setting for any given key. In the following Url, N has been added to the pathParamKeys:
 http://www.mysite.com/controller/Wine-Sparkling-Blanc-de-Blancs/Other-US/_/N-6202+4294963118
 

If N had not been added to the pathParamKeys, the URL would be output as follows:

 http://www.mysite.com/controller/Wine-Sparkling-Blanc-de-Blancs/Other-US?N=6202+4294963118
 

Parameters:
pPathParamKeys - Array of keys that will be added to the path, rather than the query string.

mUrlParamEncoders

public UrlParamEncoder[] mUrlParamEncoders()
The UrlParamEncoder objects used by this SeoUrlFormatter.


setUrlParamEncoders

public void setUrlParamEncoders(UrlParamEncoder[] pUrlParamEncoders)
Specifies the UrlParamEncoder objects used by this SeoUrlFormatter.

Parameters:
pUrlParamEncoders - array of encoders that are used to encode various URL parameters.

getNavStateCanonicalizer

public NavStateCanonicalizer getNavStateCanonicalizer()
Returns the canonicalizer used to sort the navigation state before rendering an UrlState.


setNavStateCanonicalizer

public void setNavStateCanonicalizer(NavStateCanonicalizer pNavStateCanonicalizer)
Specifies the canonicalizer used to sort the navigation state before rendering an UrlState.

Parameters:
pNavStateCanonicalizer - the NavStateCanonicalizer class to use.

parseRequest

public UrlState parseRequest(javax.servlet.http.HttpServletRequest pRequest)
                      throws UrlFormatException
Description copied from interface: UrlFormatter
Parses the specified request into an UrlState.

Specified by:
parseRequest in interface UrlFormatter
Overrides:
parseRequest in class BasicUrlFormatter
Parameters:
pRequest - the request to parse.
Throws:
UrlFormatException - if the request cannot be parsed.

parseRequest

public UrlState parseRequest(String pQueryString,
                             String pPathInfo,
                             String pCharacterEncoding)
                      throws UrlFormatException
Specified by:
parseRequest in interface UrlFormatter
Overrides:
parseRequest in class BasicUrlFormatter
Throws:
UrlFormatException

formatUrl

public String formatUrl(UrlState pUrlState)
                 throws UrlFormatException
Description copied from interface: UrlFormatter
Formats the specified UrlState into an URL string.

Specified by:
formatUrl in interface UrlFormatter
Overrides:
formatUrl in class BasicUrlFormatter
Parameters:
pUrlState - the UrlState to format.
Throws:
UrlFormatException - if the UrlState cannot be formatted.

formatCanonicalUrl

public String formatCanonicalUrl(UrlState pUrlState)
                          throws UrlFormatException
Description copied from interface: UrlFormatter
Formats a canonical url. Same functionality as the UrlFormatter#formatUrl method, but ensures canonicalizers associated with the formatter are not disabled, to ensure the url given is consistent.

Specified by:
formatCanonicalUrl in interface UrlFormatter
Overrides:
formatCanonicalUrl in class BasicUrlFormatter
Parameters:
pUrlState - The URL State to use to format the URL.
Returns:
The String representation of the URL State, formatted.
Throws:
UrlFormatException - Throws formatting exception.

createUrlParam

public UrlParam createUrlParam(UrlState pUrlState,
                               String pKey,
                               String pValue)
Description copied from interface: UrlFormatter
Creates an URL parameter for the specified UrlState. This is an internal method used by an UrlState. You shouldn't need to use this method unless you are implementing a custom UrlFormatter.

Specified by:
createUrlParam in interface UrlFormatter
Overrides:
createUrlParam in class BasicUrlFormatter
Parameters:
pUrlState - the UrlState that will contain the parameter.
pKey - the parameter key.
pValue - the parameter string value (fully decoded).
Returns:
the newly created URL parameter.

createERecUrlParam

public ERecUrlParam createERecUrlParam(UrlState pUrlState,
                                       com.endeca.navigation.ERec pERec)
Description copied from interface: UrlFormatter
Creates an URL parameter containing an ERec. This is an internal method used by an UrlState. You shouldn't need to use this method unless you are implementing a custom UrlFormatter.

Specified by:
createERecUrlParam in interface UrlFormatter
Overrides:
createERecUrlParam in class BasicUrlFormatter
Parameters:
pUrlState - the UrlState that will contain the parameter.
pERec - the ERec to be contained in the UrlState.
Returns:
the newly created URL parameter.
See Also:
UrlFormatter.getERecParamKey()

createAggrERecUrlParam

public AggrERecUrlParam createAggrERecUrlParam(UrlState pUrlState,
                                               com.endeca.navigation.AggrERec pAggrERec)
Description copied from interface: UrlFormatter
Creates an URL parameter containing an AggrERec. This is an internal method used by an UrlState. You shouldn't need to use this method unless you are implementing a custom UrlFormatter.

Specified by:
createAggrERecUrlParam in interface UrlFormatter
Overrides:
createAggrERecUrlParam in class BasicUrlFormatter
Parameters:
pUrlState - the UrlState that will contain the parameter.
pAggrERec - the AggrERec to be contained in the UrlState.
Returns:
the newly created URL parameter.
See Also:
UrlFormatter.getAggrERecParamKey()

createNavStateUrlParam

public NavStateUrlParam createNavStateUrlParam(UrlState pUrlState)
Description copied from interface: UrlFormatter
Creates an URL parameter containing an empty NavState. This is an internal method used by an UrlState. You shouldn't need to use this method unless you are implementing a custom UrlFormatter.

Specified by:
createNavStateUrlParam in interface UrlFormatter
Overrides:
createNavStateUrlParam in class BasicUrlFormatter
Parameters:
pUrlState - the UrlState that will contain the parameter.
Returns:
the newly created URL parameter.
See Also:
UrlFormatter.getNavStateParamKey()

formatPathKeywords

protected String formatPathKeywords(UrlState pUrlState)
                             throws UrlFormatException
Throws:
UrlFormatException

formatNavState

protected String formatNavState(UrlState pUrlState)
                         throws UrlFormatException
Throws:
UrlFormatException

formatERec

protected String formatERec(UrlState pUrlState)
                     throws UrlFormatException
Throws:
UrlFormatException

formatAggrERec

protected String formatAggrERec(UrlState pUrlState)
                         throws UrlFormatException
Throws:
UrlFormatException

formatPathParams

protected String formatPathParams(UrlState pUrlState)
                           throws UrlFormatException
Throws:
UrlFormatException

formatQueryString

protected String formatQueryString(UrlState pUrlState)
                            throws UrlFormatException
Throws:
UrlFormatException

parsePathInfo

protected void parsePathInfo(UrlState pUrlState,
                             String pPathInfo)
                      throws UrlFormatException
Throws:
UrlFormatException

parseQueryString

protected void parseQueryString(UrlState pUrlState,
                                String pQueryString)
                         throws UrlFormatException
Throws:
UrlFormatException


Copyright © 2012, Oracle and/or its affiliates. All rights reserved.