atg.repository.seo
Class UrlParameter

java.lang.Object
  extended by atg.repository.seo.UrlParameter
All Implemented Interfaces:
java.lang.Cloneable

public class UrlParameter
extends java.lang.Object
implements java.lang.Cloneable

Class that represents a parameter in a UrlTemplate.

This object holds the following details about a parameter:

When the UrlParameter is first created the value will be null. This class provides a method to lookup the value for a given request.

The item name and the property name are obtained by splitting the parameter name up by the first '.'.

If a parameter name is wrapped by curly brackets then the parameter value will be escaped. Otherwise if the parameter name is wrapped by square brackets then the value will not be escaped.

e.g. For "[item.template.url]":

Lookup items are objects of class UrlParameterLookup. They are created during initialization of indirect templates from the properties file and also by the ItemLink droplet from the request parameters.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
protected  boolean mIsEscaped
           
protected  java.lang.String mItemName
           
protected  ApplicationLogging mLogger
           
protected  UrlParameterLookup mLookup
           
protected  java.lang.String mName
           
protected  java.lang.String mPropertyName
           
protected static java.lang.String mSpaceMapping
          Class version
protected  java.lang.String mValue
           
 
Constructor Summary
protected UrlParameter(ApplicationLogging pLogger, java.lang.String pName)
          Constructor.
 
Method Summary
 java.lang.Object clone()
          Clones this object for use by a request
 java.lang.String getItemName()
          Getter method for the item name
 UrlParameterLookup getLookup()
          Getter method for the lookup object.
 java.lang.String getName()
          Getter method for the parameter name
 java.lang.String getPropertyName()
          Getter method for the property name
static java.lang.String getSpaceMapping()
          Getter for String to escape space characters.
 java.lang.String getValue()
          Getter method for the value of this parameter in the current request.
 boolean isEscaped()
          Getter method to flag whether the value of this parameter will be escaped.
 java.lang.String lookupValue(DynamoHttpServletRequest pRequest, java.lang.Object pElementValue)
          This method will set the value of this parameter.
 void setEscaped(boolean pIsEscaped)
          Setter method to flag whether the value of this parameter will be escaped.
 void setItemName(java.lang.String pItemName)
          Setter method for the item name
 void setLookup(UrlParameterLookup pLookup)
          Setter method for the lookup object.
 void setName(java.lang.String pName)
          Setter mthod for the parameter name.
 void setPropertyName(java.lang.String pPropertyName)
          Setter method for the property name
static void setSpaceMapping(java.lang.String pSpaceMapping)
          Setter for String to escape space characters.
 void setValue(java.lang.String pValue)
          Setter method for the value of this parameter.
 java.lang.String toString()
          Override toString() to return the value.
protected static java.lang.String urlEncodeParameter(java.lang.String pText)
          URL encodes the given text so that it can be added to a URL
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string


mSpaceMapping

protected static java.lang.String mSpaceMapping
Class version


mLogger

protected ApplicationLogging mLogger

mName

protected java.lang.String mName

mValue

protected java.lang.String mValue

mLookup

protected UrlParameterLookup mLookup

mIsEscaped

protected boolean mIsEscaped

mItemName

protected java.lang.String mItemName

mPropertyName

protected java.lang.String mPropertyName
Constructor Detail

UrlParameter

protected UrlParameter(ApplicationLogging pLogger,
                       java.lang.String pName)
Constructor. Sets the name of this parameter.

Parameters:
pLogger - ApplicationLogging object to do logging with
pName - String name to set, e.g. "item.template.url"
Method Detail

getName

public java.lang.String getName()
Getter method for the parameter name

Returns:
String name for this parameter, e.g. "item.template.url"

setName

public void setName(java.lang.String pName)
Setter mthod for the parameter name.

This method also splits up the parameter name to set the item name and the property name.

The property name will be null if there is only an item name.

For example,"item.template.url" will be split into item name "item" and property name "template.url" However, "navCount" will set item name to "navCount" and property name to null.

Parameters:
pName - String parameter name e.g. "item.template.url"

getItemName

public java.lang.String getItemName()
Getter method for the item name

Returns:
String item name for this parameter, e.g. "item"

getPropertyName

public java.lang.String getPropertyName()
Getter method for the property name

Returns:
String property name for this parameter, e.g. "template.url". May be null.

setItemName

public void setItemName(java.lang.String pItemName)
Setter method for the item name

Parameters:
pItemName - String item name for this parameter, e.g. "item"

setPropertyName

public void setPropertyName(java.lang.String pPropertyName)
Setter method for the property name

Parameters:
pPropertyName - String property name for this parameter, e.g. "template.url". May be null.

getValue

public java.lang.String getValue()
Getter method for the value of this parameter in the current request.

This value may have been escaped depending on the mIsEscaped property of this parameter.

Returns:
String value of this parameter

setValue

public void setValue(java.lang.String pValue)
Setter method for the value of this parameter.

If this parameter is set to be escaped then the passed in value should already be escaped.

Parameters:
pValue - String value to set

getLookup

public UrlParameterLookup getLookup()
Getter method for the lookup object.

Returns:
UrlParameterLookup object. May be null.

setLookup

public void setLookup(UrlParameterLookup pLookup)
Setter method for the lookup object. If the lookup type isn't string then this method will derive the property name from this parameters name relative to the lookup name. e.g. if the lookup name is "item.parent.parent" and this parameter name is "item.parent.parent.displayName" then the property name is set to "displayName"

Parameters:
pLookup - UrlParameterLookup object. May be null.

isEscaped

public boolean isEscaped()
Getter method to flag whether the value of this parameter will be escaped.

Returns:
true if the value will be escaped, otherwise false.

setEscaped

public void setEscaped(boolean pIsEscaped)
Setter method to flag whether the value of this parameter will be escaped.

Parameters:
pIsEscaped - true if the value of this parameter should be escaped, otherwise false.

getSpaceMapping

public static java.lang.String getSpaceMapping()
Getter for String to escape space characters. Default is null which will cause space character to map to '-' (dash)

Returns:
String to map spaces

setSpaceMapping

public static void setSpaceMapping(java.lang.String pSpaceMapping)
Setter for String to escape space characters. Default is null which will cause space character to map to '-' (dash)

Parameters:
pSpaceMapping - String to map spaces

lookupValue

public java.lang.String lookupValue(DynamoHttpServletRequest pRequest,
                                    java.lang.Object pElementValue)
This method will set the value of this parameter.

If this parameter has a lookup object then this is used first to get a value. If there is no lookup object set or the lookup object fails to get a value then the method will check the request to get a value.

If a value is obtained then it is escaped if this parameter is set to escape the value.

Parameters:
pRequest - DynamoHttpServletRequest object
pElementValue - Value for the lookup object if available, otherwise null.
Returns:
String value of this parameter if found otherwise null.

urlEncodeParameter

protected static java.lang.String urlEncodeParameter(java.lang.String pText)
URL encodes the given text so that it can be added to a URL

Parameters:
pText - The String object containing the text to be encoded
Returns:
A String object

toString

public java.lang.String toString()
Override toString() to return the value.

Used by the MessageFormat object in the UrlPattern class.

Overrides:
toString in class java.lang.Object

clone

public java.lang.Object clone()
Clones this object for use by a request

Overrides:
clone in class java.lang.Object