com.plumtree.portaluiinfrastructure.tags.helper
Class TagHelper

java.lang.Object
  extended by com.plumtree.portaluiinfrastructure.tags.helper.TagHelper

public class TagHelper
extends java.lang.Object

This helper class contains the framework code that tags use and helps to keep the ATag class simple.


Field Summary
static char ATTRIBUTE_I18N_MARKER
          The marker used for attribute i18n string replacement ($#n.file).
static char ATTRIBUTE_VARIABLE_MARKER
          The marker for the beginning of a $var or $data.var attribute value replacement.
static char ATTRIBUTE_VARIABLE_SEPARATOR
          The separator between data collection name and value key in $data.var attribute value replacement.
protected  java.lang.Object[][] m_attributeObjXML
           
protected  boolean m_bPTAttributesProcessed
           
protected  boolean m_bXMLAttributesProcessed
           
protected  XPHashtable m_processedPTAttributes
           
protected  XPHashtable m_processedXMLAttributes
           
protected  java.lang.String m_strUniqueID
           
protected  java.lang.String m_strXMLAttributeDisplaystring
           
protected  ATag m_tag
           
protected  IDisplayElement m_tagBody
           
protected  TagVisitor m_tagVisitor
           
static java.lang.String UNIQUE_ID_COUNTER_KEY
          This key is used to store the unique ID counter in the HTTP request data.
static java.lang.String UNIQUE_ID_KEY
          This key is used to store the unique ID for each tag in Tag Scope.
 
Constructor Summary
TagHelper(java.lang.Object[][] _attributeObjXML, IDisplayElement _tagBody, ATag _Tag)
          Constructor for the TagHelper.
 
Method Summary
 void AddJavascript(HTMLScriptCollection _script)
           
protected  void CheckAttribute(ATagAttribute _attribute, AttributeType _type)
          Check the type safety of the requested attribute.
 HTMLElement DisplayTag()
          The Tag Container uses this method to display this tag.
 java.lang.String GetAttribute(java.lang.String _strAttribute)
           
 boolean GetAttributeAsBoolean(ATagAttribute _attribute)
           
 char GetAttributeAsChar(ATagAttribute _attribute)
           
 double GetAttributeAsDouble(ATagAttribute _attribute)
           
 int GetAttributeAsInt(ATagAttribute _attribute)
           
 long GetAttributeAsLong(ATagAttribute _attribute)
           
 java.lang.String GetAttributeAsString(ATagAttribute _attribute)
           
 IXPEnumerator GetAttributeNames()
           
protected  java.lang.String GetCollectionVariable(java.lang.String _strDataCollection, java.lang.String _strKey)
          Looks up the data collection in memory, accesses the specified key, and converts the value to a string.
 IEnvironment GetEnvironment()
           
protected  XPHashtable GetProcessedPTAttributes()
          Helper access method to allow lazy initialization of the processed PT attribute hashtable.
protected  XPHashtable GetProcessedXMLAttributes()
          Helper access method to allow lazy initialization of the processed XML attribute hashtable.
 TagState GetState()
           
 java.lang.String GetUniqueID()
           
protected  java.lang.String GetVariable(java.lang.String _strKey)
          Looks up the variable in memory and converts the value to a string.
protected  java.lang.Object GetVariableObject(java.lang.String _strKey)
          Looks up the variable in memory and converts the value to a string.
 java.lang.String GetXMLAttribute(java.lang.String _strAttribute)
           
 IXPEnumerator GetXMLAttributeNames()
           
 java.lang.String GetXMLTagAttributesAsString()
           
 boolean HasAttribute(ATagAttribute _attribute)
           
 int HasChildTag(ITagMetaData _childTag)
          Check whether or not a particular Transformer Tag is nested inside the current Tag.
 int HasParentTag(ITagMetaData _parentTag)
          Check whether or not the current Tag is nested inside a given parent Tag.
 boolean HasXMLAttribute(java.lang.String _strAttribute)
           
protected  java.lang.String InternalGetAttribute(ATagAttribute _attribute)
          This helper method gets an attribute as a string.
protected  java.lang.String InternalGetAttributeFromName(java.lang.String _strAttribute, int _nXMLAttributeType)
          This helper method gets an attribute from a String object rather than an attribute object.
protected  java.lang.String InternalGetAttributeFromName(java.lang.String _strAttribute, int _nXMLAttributeType, boolean _bIgnoreProcessingErrors)
          This helper method gets an attribute from a String object rather than an attribute object.
protected  boolean IsProcessedXMLAttributesEmpty()
          Helper method to check if the hashtable is empty.
protected  void ProcessAllAttributes()
          This helper method process all the PT attributes and stores them in the hashtable.
protected  void ProcessAllXMLAttributes()
          This helper method process all the XML attributes and stores them in the hashtable.
protected  java.lang.String ProcessAttribute(java.lang.String _strAttribute)
          Performs attribute value replacement on the attribute.
protected  java.lang.String ProcessI18NStringAttribute(java.lang.String _strAttribute)
          Performs attribute value replacement on the attribute.
 HTMLElement ProcessTagBody()
           
 void ReleaseTagVisitor()
          This method releases the tag visitor to make sure it is not leaked (retained).
 void SetTagVisitor(TagVisitor _tagVisitor)
          This method sets the tag visitor so we can process the tag.
 java.lang.String ValidateContext()
          The Tag Container uses this method to check whether or not this tag is being displayed in the correct context.
 java.lang.String ValidateRequiredAttributes()
          This helper method processes all the required PT attributes, validates them, and stores them in the hashtable.
 java.lang.String ValidateRequiredChildTags()
          This helper method processes the tag display tree for required child tags.
 java.lang.String ValidateRequiredParentTags()
          This helper method processes the tag display tree for required parent tags (at least one must be present).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTRIBUTE_VARIABLE_MARKER

public static final char ATTRIBUTE_VARIABLE_MARKER
The marker for the beginning of a $var or $data.var attribute value replacement.

See Also:
Constant Field Values

ATTRIBUTE_VARIABLE_SEPARATOR

public static final char ATTRIBUTE_VARIABLE_SEPARATOR
The separator between data collection name and value key in $data.var attribute value replacement.

See Also:
Constant Field Values

ATTRIBUTE_I18N_MARKER

public static final char ATTRIBUTE_I18N_MARKER
The marker used for attribute i18n string replacement ($#n.file).

See Also:
Constant Field Values

UNIQUE_ID_COUNTER_KEY

public static final java.lang.String UNIQUE_ID_COUNTER_KEY
This key is used to store the unique ID counter in the HTTP request data.

See Also:
Constant Field Values

UNIQUE_ID_KEY

public static final java.lang.String UNIQUE_ID_KEY
This key is used to store the unique ID for each tag in Tag Scope.

See Also:
Constant Field Values

m_tagVisitor

protected TagVisitor m_tagVisitor

m_attributeObjXML

protected java.lang.Object[][] m_attributeObjXML

m_bPTAttributesProcessed

protected boolean m_bPTAttributesProcessed

m_strXMLAttributeDisplaystring

protected java.lang.String m_strXMLAttributeDisplaystring

m_bXMLAttributesProcessed

protected boolean m_bXMLAttributesProcessed

m_processedPTAttributes

protected XPHashtable m_processedPTAttributes

m_processedXMLAttributes

protected XPHashtable m_processedXMLAttributes

m_tagBody

protected IDisplayElement m_tagBody

m_tag

protected ATag m_tag

m_strUniqueID

protected java.lang.String m_strUniqueID
Constructor Detail

TagHelper

public TagHelper(java.lang.Object[][] _attributeObjXML,
                 IDisplayElement _tagBody,
                 ATag _Tag)
Constructor for the TagHelper. This object should only be created by the tag framework.

Parameters:
_attributeObjXML - The XML data that describes this tag and its attributes.
_tagBody - The child display element of this tag in the display tree. May be null.
_Tag - The current tag.
Method Detail

GetEnvironment

public IEnvironment GetEnvironment()
See Also:
ATag.GetEnvironment()

GetState

public TagState GetState()
See Also:
ATag.GetState()

ProcessTagBody

public HTMLElement ProcessTagBody()
See Also:
ATag.ProcessTagBody()

AddJavascript

public void AddJavascript(HTMLScriptCollection _script)
See Also:
ATag.AddJavascript(HTMLScriptCollection)

HasParentTag

public int HasParentTag(ITagMetaData _parentTag)
Check whether or not the current Tag is nested inside a given parent Tag. The parent tag must be in the same library as the current tag. E.G. would return 1 for "parenttag". Tag Utility Method

Parameters:
ITagMetaData - _parentTag The Tag Meta Data of the requested parent tag
Returns:
int 0 implies the parent tag was not found and a positive integer implies that the parent tag was found n levels above the current tag (only counting PT Transformer Tags, not normal HTML tags).

HasChildTag

public int HasChildTag(ITagMetaData _childTag)
Check whether or not a particular Transformer Tag is nested inside the current Tag. The child tag must be in the same library as the current tag. E.G. would return a positive integer for "firstchildtag", "secondchildtag", and "subsubchildtag", but not "span", since it is an HTML Tag, not a Transformer Tag. Tag Utility Method

Parameters:
ITagMetaData - _childTag A Tag Meta Data objects of the requested child tag
Returns:
int 0 implies the child tag was not found and a positive integer implies that the child tag was found n levels below the current tag (only counting PT Transformer Tags, not normal HTML tags).

GetAttributeAsString

public java.lang.String GetAttributeAsString(ATagAttribute _attribute)
See Also:
com.plumtree.portaluiinfrastructure.tags.ATag#GetAttributeAsString(ATagAttribute)

GetAttributeAsInt

public int GetAttributeAsInt(ATagAttribute _attribute)
See Also:
com.plumtree.portaluiinfrastructure.tags.ATag#GetAttributeAsInt(ATagAttribute)

GetAttributeAsBoolean

public boolean GetAttributeAsBoolean(ATagAttribute _attribute)
See Also:
com.plumtree.portaluiinfrastructure.tags.ATag#GetAttributeAsBoolean(ATagAttribute)

GetAttributeAsChar

public char GetAttributeAsChar(ATagAttribute _attribute)
See Also:
com.plumtree.portaluiinfrastructure.tags.ATag#GetAttributeAsChar(ATagAttribute)

GetAttributeAsDouble

public double GetAttributeAsDouble(ATagAttribute _attribute)
See Also:
com.plumtree.portaluiinfrastructure.tags.ATag#GetAttributeAsDouble(ATagAttribute)

GetAttributeAsLong

public long GetAttributeAsLong(ATagAttribute _attribute)
See Also:
com.plumtree.portaluiinfrastructure.tags.ATag#GetAttributeAsLong(ATagAttribute)

HasAttribute

public boolean HasAttribute(ATagAttribute _attribute)
See Also:
com.plumtree.portaluiinfrastructure.tags.ATag#HasAttribute(ATagAttribute)

GetAttribute

public java.lang.String GetAttribute(java.lang.String _strAttribute)
See Also:
ATag.GetTagAttribute(String)

GetAttributeNames

public IXPEnumerator GetAttributeNames()
See Also:
com.plumtree.portaluiinfrastructure.tags.ATag#GetAttributeNames()

GetXMLAttribute

public java.lang.String GetXMLAttribute(java.lang.String _strAttribute)
See Also:
com.plumtree.portaluiinfrastructure.tags.ATag#GetXMLAttribute(String)

HasXMLAttribute

public boolean HasXMLAttribute(java.lang.String _strAttribute)
See Also:
com.plumtree.portaluiinfrastructure.tags.ATag#HasXMLAttribute(String)

InternalGetAttribute

protected java.lang.String InternalGetAttribute(ATagAttribute _attribute)
This helper method gets an attribute as a string.

Parameters:
_attribute - The requested Attribute.
Returns:
The attribute as a string.

InternalGetAttributeFromName

protected java.lang.String InternalGetAttributeFromName(java.lang.String _strAttribute,
                                                        int _nXMLAttributeType)
This helper method gets an attribute from a String object rather than an attribute object.

Parameters:
_strAttribute - The name of the attribute to retrieve.
_nXMLAttributeType - The attribute type.
Returns:
The value of the attribute.

InternalGetAttributeFromName

protected java.lang.String InternalGetAttributeFromName(java.lang.String _strAttribute,
                                                        int _nXMLAttributeType,
                                                        boolean _bIgnoreProcessingErrors)
This helper method gets an attribute from a String object rather than an attribute object. It also allows you to set the error handling behavior of this method.

Parameters:
_strAttribute - The name of the attribute to retrieve.
_nXMLAttributeType - The attribute type.
_bIgnoreProcessingErrors - False implies that exceptions should be generated when processing attributes for value replacement. This is not the default behavior.
Returns:
The value of the attribute.
Throws:
XPIllegalArgumentException - if the attribute specifies an invalid variable for variable replacement and _bIgnoreProcessingErrors is false.

CheckAttribute

protected void CheckAttribute(ATagAttribute _attribute,
                              AttributeType _type)
Check the type safety of the requested attribute.

Parameters:
ATagAttribute - _attribute The requested attribute.
AttributeType - _type The requested data type.
Throws:
XPIllegalArgumentException - if the requested data type does not match the attribute.

GetXMLAttributeNames

public IXPEnumerator GetXMLAttributeNames()
See Also:
com.plumtree.portaluiinfrastructure.tags.ATag#GetXMLAttributeNames()

GetXMLTagAttributesAsString

public java.lang.String GetXMLTagAttributesAsString()
See Also:
ATag.GetXMLTagAttributesAsString()

ProcessAllAttributes

protected void ProcessAllAttributes()
This helper method process all the PT attributes and stores them in the hashtable. This is only used if we are looping through the PT attributes instead of accessing them using their associated ATagAttribute objects.


ProcessAllXMLAttributes

protected void ProcessAllXMLAttributes()
This helper method process all the XML attributes and stores them in the hashtable.


ProcessAttribute

protected java.lang.String ProcessAttribute(java.lang.String _strAttribute)
Performs attribute value replacement on the attribute. I.E. Replaces $var with the value of the tag variable var and $data.var with the value of the key var in the tag variable data collection data. Replaces $#n.file with the internationalized string with ID n in file file.

Parameters:
_strAttribute - The pre-processed attribute.
Returns:
String The processed attribute. Empty string if there was an error.

ProcessI18NStringAttribute

protected java.lang.String ProcessI18NStringAttribute(java.lang.String _strAttribute)
Performs attribute value replacement on the attribute. I.E. Replaces $var with the value of the tag variable var and $data.var with the value of the key var in the tag variable data collection data. Replaces $#n.file with the internationalized string with ID n in file file.

Parameters:
_strAttribute - The pre-processed attribute.
Returns:
String The processed attribute. Empty string if there was an error.

GetVariable

protected java.lang.String GetVariable(java.lang.String _strKey)
Looks up the variable in memory and converts the value to a string.

Parameters:
String - _strKey The name of the variable.
Returns:
String The value stored in the variable. Null if there was an error.

GetCollectionVariable

protected java.lang.String GetCollectionVariable(java.lang.String _strDataCollection,
                                                 java.lang.String _strKey)
Looks up the data collection in memory, accesses the specified key, and converts the value to a string.

Parameters:
String - _strDataCollection The name of the data collection.
String - _strKey The key into the data collection.
Returns:
String The value stored in the data collection under the specified key. Null if there was an error.

GetVariableObject

protected java.lang.Object GetVariableObject(java.lang.String _strKey)
Looks up the variable in memory and converts the value to a string.

Parameters:
String - _strKey The name of the variable.
Returns:
Object The value stored in the variable. Null if it could not be found.

GetUniqueID

public java.lang.String GetUniqueID()
See Also:
ATag.GetUniqueID()

DisplayTag

public HTMLElement DisplayTag()
The Tag Container uses this method to display this tag. This method calls the DisplayTag() method. The TagVisitor must be set before this method can be called. Framework Helper Method

Returns:
HTMLElement The result of displaying this tag

SetTagVisitor

public void SetTagVisitor(TagVisitor _tagVisitor)
This method sets the tag visitor so we can process the tag. This needs to be called before we can validate or process the tag. The tag visitor needs to be released after the tag has been validated and processed.

Parameters:
_tagVisitor - The tag visitor.

ReleaseTagVisitor

public void ReleaseTagVisitor()
This method releases the tag visitor to make sure it is not leaked (retained). This should be called after the tag has been validated and processed.


ValidateContext

public java.lang.String ValidateContext()
The Tag Container uses this method to check whether or not this tag is being displayed in the correct context. This method checks for required parent and child tags, as well as for proper formatting and presence of required attributes. If the tag is not being used in a valid way, the Tag Container will log an error and not display this tag. Framework Helper Method

Returns:
String The error message if this tag is not being used correctly and should not be displayed. Null implies the tag is being used correctly and should be displayed.

ValidateRequiredParentTags

public java.lang.String ValidateRequiredParentTags()
This helper method processes the tag display tree for required parent tags (at least one must be present). This method is public for testing purposes and should not be called otherwise.

Returns:
String The error message if a required parent tag is missing. Null implies that at least one required parent tag was present.

ValidateRequiredChildTags

public java.lang.String ValidateRequiredChildTags()
This helper method processes the tag display tree for required child tags. This method is public for testing purposes and should not be called otherwise.

Returns:
String The error message if a required child tag is missing. Null implies that all required child tags were present.

ValidateRequiredAttributes

public java.lang.String ValidateRequiredAttributes()
This helper method processes all the required PT attributes, validates them, and stores them in the hashtable. This method is public for testing purposes and should not be called otherwise.

Parameters:
_attributes - The array of required attributes for this tag.
Returns:
String The error message if an attribute was invalid. Null implies that all attributes were valid.

GetProcessedPTAttributes

protected XPHashtable GetProcessedPTAttributes()
Helper access method to allow lazy initialization of the processed PT attribute hashtable. This method will create the hashtable when the method is called.

Returns:
The processed PT attributes.

GetProcessedXMLAttributes

protected XPHashtable GetProcessedXMLAttributes()
Helper access method to allow lazy initialization of the processed XML attribute hashtable. This method will create the hashtable when the method is called.

Returns:
The processed XML attributes.

IsProcessedXMLAttributesEmpty

protected boolean IsProcessedXMLAttributesEmpty()
Helper method to check if the hashtable is empty. This method will not create the hashtable if it does not exist.

Returns:
Whether there are any processed XML attributes or not.



Copyright © 2002,2003,2004,2005 Plumtree Software, Inc., All Rights Reserved.