|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.faban.harness.ParamRepository
public class ParamRepository
The ParamRepository is the programmatic representation of the configuration file. It allows access to the xml file via xpath. In addition, the ParamRepository also allows updating the configuration file. Such updates should be made during the validation stage.
Nested Class Summary | |
---|---|
static class |
ParamRepository.HostConfig
HostConfig structure holding a hostConfig element from the config file. |
Constructor Summary | |
---|---|
ParamRepository(String file,
boolean warnDeprecated)
Constructor: Open specified repository. |
Method Summary | |
---|---|
Element |
addParameter(Element parent,
String paramName)
Adds a new XPath to the param repository, based on a previously added parameter. |
Element |
addParameter(Element parent,
String namespace,
String prefix,
String paramName)
Adds a new XPath to the param repository, based on a previously added parameter. |
Element |
addParameter(String baseXPath,
String paramName)
Adds a new XPath to the param repository. |
Element |
addParameter(String baseXPath,
String namespace,
String prefix,
String paramName)
Adds a new XPath to the param repository. |
List<String> |
getAttributeValues(String elementPath,
String attributeName)
Gets the attribute values for the specified attribute of a certain XPath. |
boolean |
getBooleanValue(String xpath)
This method reads a value using the XPath and converts it to a boolean. |
boolean |
getBooleanValue(String xpath,
boolean defaultValue)
Obtains the boolean value at the given xpath, providing a default value if it does not exist or is not a boolean. |
boolean |
getBooleanValue(String xpath,
Element base)
This method reads a value using the XPath and converts it to a boolean. |
boolean |
getBooleanValue(String xpath,
Element base,
boolean defaultValue)
This method reads a value using the XPath and converts it to a boolean. |
List<NameValuePair<Integer>> |
getEnabledHostPorts(Element base)
Obtains the list of enabled hostports. |
String[] |
getEnabledHosts(Element base)
Obtains the list of enabled hosts. |
List<ParamRepository.HostConfig> |
getHostConfigs()
Obtains the list of enabled host configurations. |
List<NameValuePair<Integer>> |
getHostPorts(Element base)
Obtains the host:port pairs at this element. |
List<NameValuePair<Integer>> |
getHostPorts(String xPathExpr)
Obtains the host:port name value pair list from the element matching this XPath. |
List<NameValuePair<String>> |
getHostRoles()
Obtains the host/role mappings. |
Node |
getNode(String xPath)
Generic method to get a Node for a given xpath. |
Node |
getNode(String xPath,
Element top)
Generic method to get a Node for a given xpath with respect to base node. |
NodeList |
getNodeListForTagName(String tagName)
Generic method to get NodeList for a given tagName. |
NodeList |
getNodes(String xPath)
Generic method to get NodeList for a given xpath. |
NodeList |
getNodes(String xPath,
Element top)
Generic method to get NodeList for a given xpath with respect to base node. |
String |
getParameter(String xpath)
Generic parameter access method. |
String |
getParameter(String xpath,
Element top)
Generic parameter access method. |
List<String> |
getParameters(String xpath)
Generic parameter access method. |
List<String[]> |
getTokenizedList(String xpath)
Obtains xpath values matching an xpath, broken into tokens. |
List<String[]> |
getTokenizedParameters(String xpath)
This returns tokenized values of parameters in a list. |
String[] |
getTokenizedValue(String xpath)
Obtains the value at an XPath, tokenized into an array. |
String[] |
getTokenizedValue(String xpath,
Element base)
Obtains the value at an XPath, tokenized into an array, from a specific base node in the document. |
NodeList |
getTopLevelElements()
Generic method to get a list of top level nodes. |
void |
save()
Saves the parameter repository back to file if it has been modified. |
void |
setParameter(Element element,
String value)
Sets the parameter for a newly added DOM element. |
void |
setParameter(String xpath,
String newValue)
Sets or replaces the parameter referenced by the XPath. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ParamRepository(String file, boolean warnDeprecated)
file
- Name of repositorywarnDeprecated
- Log warning when config file is deprecatedMethod Detail |
---|
public String getParameter(String xpath)
xpath
-
public String getParameter(String xpath, Element top)
xpath
- stringtop
- element
public NodeList getNodeListForTagName(String tagName)
tagName
- of type string
public NodeList getTopLevelElements()
public NodeList getNodes(String xPath)
xPath
- string
public NodeList getNodes(String xPath, Element top)
xPath
- stringtop
- element
public Node getNode(String xPath)
xPath
- string
public Node getNode(String xPath, Element top)
xPath
- stringtop
- element
public Element addParameter(String baseXPath, String paramName)
baseXPath
- The base XPath to add this nodeparamName
- The element name
public Element addParameter(String baseXPath, String namespace, String prefix, String paramName)
baseXPath
- The base XPath to add this nodenamespace
- The namespace for this new element, if anyprefix
- The namespace prefix for this new element, if anyparamName
- The element name
public Element addParameter(Element parent, String paramName)
parent
- The parent element to add this node toparamName
- The element name
public Element addParameter(Element parent, String namespace, String prefix, String paramName)
parent
- The parent element to add this node tonamespace
- The namespace for this new element, if anyprefix
- The namespace prefix for this new element, if anyparamName
- The element name
public void setParameter(String xpath, String newValue)
xpath
- The xpath referencing the parameternewValue
- The new value to setpublic void setParameter(Element element, String value)
element
- The newly added elementvalue
- The value to assign to the elementpublic void save() throws Exception
Exception
- If there is an exception saving the repository.public List<String> getParameters(String xpath)
xpath
-
public List<String> getAttributeValues(String elementPath, String attributeName)
elementPath
- The XPath of the elementattributeName
- The name of the attribute
public List<ParamRepository.HostConfig> getHostConfigs() throws ConfigurationException
ConfigurationException
- Error reading the configurationpublic String[] getEnabledHosts(Element base) throws ConfigurationException
base
- element
ConfigurationException
public List<NameValuePair<Integer>> getEnabledHostPorts(Element base) throws ConfigurationException
base
- element
ConfigurationException
public List<String[]> getTokenizedParameters(String xpath)
xpath
- The xpath to the parameters
public String[] getTokenizedValue(String xpath)
xpath
- XPath expression to get SPACE seperated values from a single
parameter. For Example sutConfig/host The values are seperated by SPACE
public String[] getTokenizedValue(String xpath, Element base)
xpath
- XPath expression to get SPACE seperated values from a single
parameter. For Example sutConfig/host The values are seperated by SPACEbase
- The base element.
public List<String[]> getTokenizedList(String xpath)
xpath
- XPath expression to get ',' and SPACE seperated
values from a single parameter. For Example sutConfig/instances
The values are seperated by ',' and then by SPACE
public List<NameValuePair<Integer>> getHostPorts(String xPathExpr)
xPathExpr
-
public List<NameValuePair<Integer>> getHostPorts(Element base)
base
- The base element
public List<NameValuePair<String>> getHostRoles() throws ConfigurationException
ConfigurationException
- Invalid host/role mappingpublic boolean getBooleanValue(String xpath)
xpath
- XPath expression to the value which is true or false
public boolean getBooleanValue(String xpath, boolean defaultValue)
xpath
- The given xpathdefaultValue
- The default value
public boolean getBooleanValue(String xpath, Element base)
xpath
- XPath expression to the value which is true or falsebase
- element
public boolean getBooleanValue(String xpath, Element base, boolean defaultValue)
xpath
- XPath expression to the value which is true or falsebase
- elementdefaultValue
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |