com.plumtree.uiinfrastructure.application.varpacks
Class XMLBaseVarPack

java.lang.Object
  extended by com.plumtree.uiinfrastructure.web.BaseVarPack
      extended by com.plumtree.uiinfrastructure.application.varpacks.XMLBaseVarPack
All Implemented Interfaces:
IVarPack

public abstract class XMLBaseVarPack
extends BaseVarPack

This class is designed to read in Name/Value pairs for an xml file and store them in a hashtable for easy lookup. The XML file is assumed to have a single root node with multiple section nodes underneath it. The section nodes contain multiple Name/Value pair nodes where the name of the node is the name and the value attribute is the value (i.e. ). These will be read into an internal hashtable and will be accessible by calling VarPack.GetValue("SectionNameNodeName"). For example, if there is a section called "Timeouts" and a Node in that section that looks like this: that value should be retrieved by calling VarPack.GetValueAsInt("Timeout", "DocumentTimeout"), which returns an int. You can also use VarPack.GetValue("TimeoutDocumentTimeout") which will return an Object, but that is not the preferred method.


Field Summary
protected static java.lang.String STR_COMMENT_PREFIX
          The marker for XML comments
protected static java.lang.String VALUE_ATTRIBUTE
          The value attribute
 
Constructor Summary
XMLBaseVarPack()
           
 
Method Summary
protected  void ExpireContent()
          You cannot expire the XML content.
protected  java.lang.Object GetValue(java.lang.String strSectionAndName)
          This method will return the String value for a named node in a section under the root XML node.
 boolean GetValueAsBoolean(java.lang.String strSection, java.lang.String strName)
          This method will return the boolean value for a named node in a section under the root XML node.
 int GetValueAsInt(java.lang.String strSection, java.lang.String strName)
          This method will return the int value for a named node in a section under the root XML node.
 java.lang.String GetValueAsString(java.lang.String strSection, java.lang.String strName)
          This method will return the String value for a named node in a section under the root XML node.
abstract  java.lang.String GetVarPackID()
          This method returns the name that the VarPack should be stored under on the application.
 IXPEnumerator GetVarPackKeys()
          This method will return an enumeration of the top level nodes in the XML tree that was loaded by this VarPack.
abstract  java.lang.String GetVarPackXMLFileName()
          This method returns the name of the XML file that this VarPack should load.
protected  void Load()
          This method loads the XML file into the hashtable in memory.
protected  void LoadSettingsIntoXPHashtable(XPDocument xmlDoc)
          Helper method to load the settings from the XML file and put them in a XPHashtable.
protected  void Reload()
          This method reloads the XML file into memory.
 
Methods inherited from class com.plumtree.uiinfrastructure.web.BaseVarPack
CanReloadVarPackFromUI, ExpireVarPackContent, GetConfigPath, GetExpireTimeout, GetLastAccessedTimeStamp, GetReloadInterval, GetVarPackValue, IsLoaded, LoadVarPack, ReloadVarPack, SetExpireTimeout, SetReloadInterval
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STR_COMMENT_PREFIX

protected static final java.lang.String STR_COMMENT_PREFIX
The marker for XML comments

See Also:
Constant Field Values

VALUE_ATTRIBUTE

protected static final java.lang.String VALUE_ATTRIBUTE
The value attribute

See Also:
Constant Field Values
Constructor Detail

XMLBaseVarPack

public XMLBaseVarPack()
Method Detail

GetVarPackID

public abstract java.lang.String GetVarPackID()
This method returns the name that the VarPack should be stored under on the application.

Specified by:
GetVarPackID in interface IVarPack
Specified by:
GetVarPackID in class BaseVarPack
Returns:
A unique key to store the var pack in the varpackmanager.
See Also:
IVarPack.GetVarPackID()

GetVarPackXMLFileName

public abstract java.lang.String GetVarPackXMLFileName()
This method returns the name of the XML file that this VarPack should load. This should be the full name including the ".xml" suffix. The file will be loaded from the the portal config directory (ptportal\5.0\settings\config) and should be placed there.

Returns:
String the full name of the xml file to load, without directory path.

GetValueAsString

public java.lang.String GetValueAsString(java.lang.String strSection,
                                         java.lang.String strName)
This method will return the String value for a named node in a section under the root XML node.

Parameters:
String - strSection the name of the section that the Name/Value pair is located in.
String - strName the name of the Name/Value pair.
Returns:
String the String value of the Name/Value pair.
Throws:
XPException - if the Value cannot be converted to a String.

GetValueAsInt

public int GetValueAsInt(java.lang.String strSection,
                         java.lang.String strName)
This method will return the int value for a named node in a section under the root XML node.

Parameters:
String - strSection the name of the section that the Name/Value pair is located in.
String - strName the name of the Name/Value pair.
Returns:
int the int value of the Name/Value pair.
Throws:
XPException - if the Value cannot be converted to an int.

GetValueAsBoolean

public boolean GetValueAsBoolean(java.lang.String strSection,
                                 java.lang.String strName)
This method will return the boolean value for a named node in a section under the root XML node.

Parameters:
String - strSection the name of the section that the Name/Value pair is located in.
String - strName the name of the Name/Value pair.
Returns:
boolean the boolean value of the Name/Value pair.
Throws:
XPException - if the Value cannot be converted to a boolean.

GetValue

protected java.lang.Object GetValue(java.lang.String strSectionAndName)
This method will return the String value for a named node in a section under the root XML node. GetValueAsString, GetValueAsInt, and GetValueAsBoolean are the preferred methods of accessing the data in this VarPack, and should be used instead of this method.

Specified by:
GetValue in class BaseVarPack
Parameters:
String - Concatenation of the Section name and the Name/Value pair name.
Returns:
the value from the lookup (null if not found)
See Also:
BaseVarPack.GetValue(String)

GetVarPackKeys

public IXPEnumerator GetVarPackKeys()
This method will return an enumeration of the top level nodes in the XML tree that was loaded by this VarPack. This is used by the Memory Debug page to query for the contents of the VarPack.

Specified by:
GetVarPackKeys in interface IVarPack
Specified by:
GetVarPackKeys in class BaseVarPack
Returns:
IXPEnumerator of keys in the var pack.
See Also:
IVarPack.GetVarPackKeys()

ExpireContent

protected void ExpireContent()
You cannot expire the XML content. You can only reload it. This method does nothing.

Specified by:
ExpireContent in class BaseVarPack
See Also:
BaseVarPack.ExpireContent()

Load

protected void Load()
This method loads the XML file into the hashtable in memory.

Specified by:
Load in class BaseVarPack
See Also:
BaseVarPack.Load()

LoadSettingsIntoXPHashtable

protected void LoadSettingsIntoXPHashtable(XPDocument xmlDoc)
Helper method to load the settings from the XML file and put them in a XPHashtable. This Hashtable will be used for the Memory Debug page where we need to be able to iterate through the keys and display all the name/value pairs. This can be overridden if the XML file has a different format.


Reload

protected void Reload()
This method reloads the XML file into memory. It delegates to Load(). This may not be entirely threadsafe.

Specified by:
Reload in class BaseVarPack
See Also:
BaseVarPack.Reload()



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