com.endeca.soleng.urlformatter.basic
Class BasicUrlFormatter

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

public class BasicUrlFormatter
extends Object
implements UrlFormatter

An UrlFormatter that formats traditional Endeca URLs.

Property Summary
Property Type Default Value
defaultEncoding String UTF-8
prependQuestionMark boolean true
navStateParamKey String N
ERecParamKey String R
aggrERecParamKey String A


Constructor Summary
BasicUrlFormatter()
           
 
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.
 String formatCanonicalUrl(UrlState pUrlState)
          Formats a canonical url.
 String formatUrl(UrlState pUrlState)
          Formats the specified UrlState into an URL string.
 String getAggrERecParamKey()
          The parameter key used for aggregate record detail links - typically "A".
 String getDefaultEncoding()
          Returns the default encoding for this URL formatter.
 String getERecParamKey()
          The parameter key used for record detail links - typically "R".
 String getNavStateParamKey()
          The parameter key used for navigation state - typically "N".
 boolean getPrependQuestionMark()
           
 UrlState parseRequest(javax.servlet.http.HttpServletRequest pRequest)
          Parses the specified request into an UrlState.
 UrlState parseRequest(String pQueryString, String pCharacterEncoding)
           
 UrlState parseRequest(String pQueryString, String pPathInfo, String pCharacterEncoding)
           
 void setAggrERecParamKey(String pAggrERecParamKey)
          Sets the AggrERecParamKey.
 void setDefaultEncoding(String pDefaultEncoding)
          Sets the default encoding for this URL formatter.
 void setERecParamKey(String pERecParamKey)
          Sets the ERecParamKey.
 void setNavStateParamKey(String pNavStateParamKey)
          Sets the NavStateParamKey.
 void setPrependQuestionMark(boolean pPrependQuestionMark)
          Determines whether or not question marks will be appended to the Url.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicUrlFormatter

public BasicUrlFormatter()
Method Detail

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
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
Throws:
UrlFormatException

parseRequest

public UrlState parseRequest(String pQueryString,
                             String pCharacterEncoding)
                      throws UrlFormatException
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
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
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
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
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
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
Parameters:
pUrlState - the UrlState that will contain the parameter.
Returns:
the newly created URL parameter.
See Also:
UrlFormatter.getNavStateParamKey()

getDefaultEncoding

public String getDefaultEncoding()
Returns the default encoding for this URL formatter.

Specified by:
getDefaultEncoding in interface UrlFormatter
Returns:
the default encoding.
See Also:
UrlState.UrlState(UrlFormatter,String)

setDefaultEncoding

public void setDefaultEncoding(String pDefaultEncoding)
Sets the default encoding for this URL formatter.

Parameters:
pDefaultEncoding - Encoding to set. Cannot be null.
Throws:
IllegalArgumentException - if pDefaultEncoding is null. The encoding is set to "UTF", for example.

getPrependQuestionMark

public boolean getPrependQuestionMark()

setPrependQuestionMark

public void setPrependQuestionMark(boolean pPrependQuestionMark)
Determines whether or not question marks will be appended to the Url.

Parameters:
pPrependQuestionMark - flag to set.

If this is set to true:

    String url = urlFormatter.formatUrl(urlState);
    // url = "?N=0";
 

If this is set to false:

    String url = urlFormatter.formatUrl(urlState);
    // url = "N=0";
 

getNavStateParamKey

public String getNavStateParamKey()
Description copied from interface: UrlFormatter
The parameter key used for navigation state - typically "N".

Specified by:
getNavStateParamKey in interface UrlFormatter
See Also:
UrlFormatter.createNavStateUrlParam(UrlState)

setNavStateParamKey

public void setNavStateParamKey(String pNavStateParamKey)
Sets the NavStateParamKey.

Parameters:
pNavStateParamKey - to set. Cannot be null.
Throws:
IllegalArgumentException - if pNavStateParamKey is null.

getERecParamKey

public String getERecParamKey()
Description copied from interface: UrlFormatter
The parameter key used for record detail links - typically "R".

Specified by:
getERecParamKey in interface UrlFormatter
See Also:
UrlFormatter.createERecUrlParam(UrlState,com.endeca.navigation.ERec)

setERecParamKey

public void setERecParamKey(String pERecParamKey)
Sets the ERecParamKey.

Parameters:
pERecParamKey - to set. Cannot be null.
Throws:
IllegalArgumentException - if pERecParamKey is null.

getAggrERecParamKey

public String getAggrERecParamKey()
Description copied from interface: UrlFormatter
The parameter key used for aggregate record detail links - typically "A".

Specified by:
getAggrERecParamKey in interface UrlFormatter
See Also:
UrlFormatter.createAggrERecUrlParam(UrlState,com.endeca.navigation.AggrERec)

setAggrERecParamKey

public void setAggrERecParamKey(String pAggrERecParamKey)
Sets the AggrERecParamKey.

Parameters:
pAggrERecParamKey - to set. Cannot be null.
Throws:
IllegalArgumentException - if pAggrERecParamKey is null.


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