public class ParamRepository extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ParamRepository.HostConfig
HostConfig structure holding a hostConfig element from the config file.
|
Constructor and Description |
---|
ParamRepository(String file,
boolean warnDeprecated)
Constructor: Open specified repository.
|
Modifier and Type | Method and Description |
---|---|
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.
|
public ParamRepository(String file, boolean warnDeprecated)
file
- Name of repositorywarnDeprecated
- Log warning when config file is deprecatedpublic String getParameter(String xpath)
xpath
- public String getParameter(String xpath, Element top)
xpath
- stringtop
- elementpublic NodeList getNodeListForTagName(String tagName)
tagName
- of type stringpublic NodeList getTopLevelElements()
public NodeList getNodes(String xPath)
xPath
- stringpublic NodeList getNodes(String xPath, Element top)
xPath
- stringtop
- elementpublic Node getNode(String xPath)
xPath
- stringpublic Node getNode(String xPath, Element top)
xPath
- stringtop
- elementpublic Element addParameter(String baseXPath, String paramName)
baseXPath
- The base XPath to add this nodeparamName
- The element namepublic 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 namepublic Element addParameter(Element parent, String paramName)
parent
- The parent element to add this node toparamName
- The element namepublic 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 namepublic 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 attributepublic List<ParamRepository.HostConfig> getHostConfigs() throws ConfigurationException
ConfigurationException
- Error reading the configurationpublic String[] getEnabledHosts(Element base) throws ConfigurationException
base
- elementConfigurationException
public List<NameValuePair<Integer>> getEnabledHostPorts(Element base) throws ConfigurationException
base
- elementConfigurationException
public List<String[]> getTokenizedParameters(String xpath)
xpath
- The xpath to the parameterspublic 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 SPACEpublic 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 SPACEpublic List<NameValuePair<Integer>> getHostPorts(String xPathExpr)
xPathExpr
- public List<NameValuePair<Integer>> getHostPorts(Element base)
base
- The base elementpublic 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 falsepublic boolean getBooleanValue(String xpath, boolean defaultValue)
xpath
- The given xpathdefaultValue
- The default valuepublic boolean getBooleanValue(String xpath, Element base)
xpath
- XPath expression to the value which is true or falsebase
- element