atg.repository.seo
Class UrlParameterLookup

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

public class UrlParameterLookup
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  int mGroupIndex
           
protected  java.lang.String mItemDescriptorName
           
protected  ApplicationLogging mLogger
           
protected  java.lang.String mName
           
protected  Repository mRepository
           
protected  RepositoryItem mRepositoryItem
           
protected  java.lang.String mRepositoryItemID
           
protected  java.lang.String mRepositoryName
           
protected  java.lang.String mType
           
 
Constructor Summary
UrlParameterLookup(ApplicationLogging pLogger, int pGroupIndex, java.lang.String[] pParts)
          Constructor.
UrlParameterLookup(ApplicationLogging pLogger, java.lang.String pName, java.lang.String pType)
          Constructor.
 
Method Summary
 java.lang.Object clone()
          Clones this object for use in a request
 int getGroupIndex()
          Getter method for the group index.
 java.lang.String getItemDescriptorName()
          Getter method of the item descriptor name.
 java.lang.String getName()
          Getter method for the name of this lookup object.
 Repository getRepository()
          Gets the Repositoryinstance to use for looking up the item.
 Repository getRepository(DynamoHttpServletRequest pRequest)
          Gets the Repository for the item doing a lookup if needed.
 RepositoryItem getRepositoryItem()
          Getter method for the repository item.
 RepositoryItem getRepositoryItem(DynamoHttpServletRequest pRequest)
          Method to get the repository item doing a lookup if needed.
 java.lang.String getRepositoryItemID()
          Getter method for the repository item ID.
 java.lang.String getRepositoryName()
          Getter method of the repository name to lookup the item.
 java.lang.String getType()
          Getter method of the type of this lookup object.
 java.lang.String getValue(java.lang.String pPropertyName, DynamoHttpServletRequest pRequest, java.lang.Object pElementValue)
          Gets the value of a property of the item represented by this lookup object.
 Repository lookupRepository(DynamoHttpServletRequest pRequest)
          Method to resolve a Repository using the request context.
 RepositoryItem lookupRepositoryItem(DynamoHttpServletRequest pRequest)
          Looks up the repository item from the repository.
protected  void setGroupIndex(int pGroupIndex)
          Setter method for group index.
 void setItemDescriptorName(java.lang.String pItemDescriptorName)
          Setter method of the item descriptor name.
 void setName(java.lang.String pName)
          Setter method for the lookup object name.
 void setRepository(Repository pRepository)
          Sets the Repository>code> to use when looking up the item
 void setRepositoryItem(RepositoryItem pRepositoryItem)
          Setter method for the repository item.
 void setRepositoryItemID(java.lang.String pRepositoryItemID)
          Setter method for the repository item ID.
 void setRepositoryName(java.lang.String pRepositoryName)
          Setter method of the repository name to lookup the item.
 void setType(java.lang.String pType)
          Setter method for the type of this lookup object.
 java.lang.String toString()
          Overrides toString() to provide meaningful logging.
 
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


mLogger

protected ApplicationLogging mLogger

mGroupIndex

protected int mGroupIndex

mName

protected java.lang.String mName

mType

protected java.lang.String mType

mRepositoryName

protected java.lang.String mRepositoryName

mItemDescriptorName

protected java.lang.String mItemDescriptorName

mRepository

protected Repository mRepository

mRepositoryItem

protected RepositoryItem mRepositoryItem

mRepositoryItemID

protected java.lang.String mRepositoryItemID
Constructor Detail

UrlParameterLookup

public UrlParameterLookup(ApplicationLogging pLogger,
                          int pGroupIndex,
                          java.lang.String[] pParts)
Constructor. Populates member variables by parsing an array of Strings -

element name | element type [| [:]]

Parameters:
pLogger - ApplicationLogging object to do logging with
pGroupIndex - int index of the regex group
pParts - String array of element parts.

UrlParameterLookup

public UrlParameterLookup(ApplicationLogging pLogger,
                          java.lang.String pName,
                          java.lang.String pType)
Constructor. Sets name and type only.

Parameters:
pLogger - ApplicationLogging object to do logging with
pName - String name of this element
pType - String type of this element
Method Detail

clone

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

Overrides:
clone in class java.lang.Object

getGroupIndex

public int getGroupIndex()
Getter method for the group index.

The group index is an index into the regex Matcher for this lookup object. i.e. given a Matcher object the value is obtained by:

value = matcher.group(getGroupIndex());

Returns:
int group index into regex Matcher

setGroupIndex

protected void setGroupIndex(int pGroupIndex)
Setter method for group index.

Parameters:
pGroupIndex - The group index to set

getName

public java.lang.String getName()
Getter method for the name of this lookup object. This should match the item name of any parameters that are related to it. e.g. parameter name "item.template.url" may be related to lookup object "item"

Returns:
String name of this lookup object

setName

public void setName(java.lang.String pName)
Setter method for the lookup object name.

Parameters:
pName - String name of the lookup object.

getType

public java.lang.String getType()
Getter method of the type of this lookup object. One of "item", "id" or "string"

Returns:
String type

setType

public void setType(java.lang.String pType)
Setter method for the type of this lookup object. One of "item", "id", or "string"

Parameters:
pType - String type

getRepositoryName

public java.lang.String getRepositoryName()
Getter method of the repository name to lookup the item.

Returns:
String name of the repository

setRepositoryName

public void setRepositoryName(java.lang.String pRepositoryName)
Setter method of the repository name to lookup the item.

Parameters:
pRepositoryName - String repository name

getItemDescriptorName

public java.lang.String getItemDescriptorName()
Getter method of the item descriptor name.

Returns:
String item descriptor name

setItemDescriptorName

public void setItemDescriptorName(java.lang.String pItemDescriptorName)
Setter method of the item descriptor name.

Parameters:
pItemDescriptorName - String item descriptor name

getRepositoryItemID

public java.lang.String getRepositoryItemID()
Getter method for the repository item ID.

Returns:
String repository item ID

setRepositoryItemID

public void setRepositoryItemID(java.lang.String pRepositoryItemID)
Setter method for the repository item ID.

Parameters:
pRepositoryItemID - String ID of the repository item

getRepository

public Repository getRepository()
Gets the Repositoryinstance to use for looking up the item.

Returns:
Repository for this item

setRepository

public void setRepository(Repository pRepository)
Sets the Repository>code> to use when looking up the item

Parameters:
pRepository - The Repository object to set

getRepositoryItem

public RepositoryItem getRepositoryItem()
Getter method for the repository item.

Returns:
The RepositoryItem object

setRepositoryItem

public void setRepositoryItem(RepositoryItem pRepositoryItem)
Setter method for the repository item. Also sets the item descriptor and repository based on the item.

Parameters:
pRepositoryItem - The RepositoryItem to set

getRepository

public Repository getRepository(DynamoHttpServletRequest pRequest)
Gets the Repository for the item doing a lookup if needed.

Parameters:
DynamoHttpServletRequest - object
Returns:
Repository for the item

getRepositoryItem

public RepositoryItem getRepositoryItem(DynamoHttpServletRequest pRequest)
Method to get the repository item doing a lookup if needed.

Parameters:
pRequest - DynamoHttpServletRequest object
Returns:
The RepositoryItem object

lookupRepository

public Repository lookupRepository(DynamoHttpServletRequest pRequest)
Method to resolve a Repository using the request context.

Parameters:
pRequest - DynamoHttpServletRequest object
Returns:
The Repository object

lookupRepositoryItem

public RepositoryItem lookupRepositoryItem(DynamoHttpServletRequest pRequest)
                                    throws RepositoryException
Looks up the repository item from the repository.

Parameters:
pRequest - DynamoHttpServletRequest object
Returns:
The RepositoryItem object
Throws:
RepositoryException

getValue

public java.lang.String getValue(java.lang.String pPropertyName,
                                 DynamoHttpServletRequest pRequest,
                                 java.lang.Object pElementValue)
                          throws RepositoryException
Gets the value of a property of the item represented by this lookup object.

If the lookup object type is "string" then the pElementValue is returned as a String.

If the type is "id" then the passed in pElementValue is used as the repository item id and the item is looked up and the property value retrieved.

If the type is "item" then the property of the item is looked up from the already set item.

Parameters:
pPropertyName - String property name to lookup
pRequest - DynamoHttpServletRequest object
pElementValue - Used to perform the lookup
Returns:
String value of the property or null if not found
Throws:
RepositoryException

toString

public java.lang.String toString()
Overrides toString() to provide meaningful logging.

Overrides:
toString in class java.lang.Object
Returns:
String " | [| [repository name:][descriptor name]]"