|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.sun.faban.harness.util.XMLReader
public class XMLReader
Provides all XML accesses to the parameter repository and other XML files.
| Constructor Summary | |
|---|---|
XMLReader(String file)
Constructs the XML reader. |
|
XMLReader(String file,
boolean useFabanNS,
boolean warnDeprecated)
Constructs the XML reader. |
|
| Method Summary | |
|---|---|
Element |
addNode(Element parent,
String namespaceURI,
String prefix,
String nodeName)
Adds a node. |
Element |
addNode(String baseXPath,
String namespaceURI,
String prefix,
String nodeName)
Adds a node. |
void |
deleteNode(Node deleteNode,
Node parent)
Deletes a node. |
List<String> |
getAttributeValues(String xpath,
String attribute)
Returns the list of attribute values for a given xpath and attribute. |
List<String> |
getAttributeValues(String xpath,
String attribute,
Node base)
Returns the list of attribute values for a given xpath and attribute based on base node. |
List<NameValuePair<Integer>> |
getHostPorts(Element roleNode)
Obtains the host:port pairs based on a role. |
List<NameValuePair<Integer>> |
getHostPorts(String xPathExpr)
Obtains the host:port name value pair list from the element matching this XPath. |
Node |
getNode(String xpath)
Returns node for the given xpath. |
Node |
getNode(String xpath,
Node base)
Returns node for the given xpath based on the base node. |
NodeList |
getNodeList(String xPathExpr)
Returns NodeList for a given xpath string. |
NodeList |
getNodeListForTagName(String tagName)
Returns nodelist for the given tag. |
NodeList |
getNodes(String xpath)
Returns the nodelist for a given xpath. |
NodeList |
getNodes(String xpath,
Node base)
Returns the nodelist for a given xpath based on a base node. |
Element |
getRootNode()
Returns the root element. |
NodeList |
getTopLevelElements()
Returns nodelist for top level elements(Children of root element). |
String |
getValue(String xpath)
Returns the value for the given xpath. |
String |
getValue(String xpath,
Node base)
Returns the value for the given xpath based on the base node. |
List<String> |
getValues(String xpath)
Returns the list of values for a given xpath. |
List<String> |
getValues(String xpath,
Node base)
Returns the list of values for a given xpath based on base node. |
static void |
main(String[] args)
Runs some testing of the XML reader. |
void |
processHostPorts()
Scans the XML for specific entries matching "//fa:hostConfig/fa:hostPorts" and processes them for later retrieval. |
void |
replaceValue(Element element,
String value)
Replaces the new value for the element text. |
boolean |
save(String backupFileName)
This method saves the XML file if it was modified and if a back up file name is specified the original file is backed up. |
void |
setValue(Element element,
String value)
Sets the new value for the element. |
void |
setValue(String xpath,
String newValue)
Sets the new value for a given xpath. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public XMLReader(String file)
file - The XML file
public XMLReader(String file,
boolean useFabanNS,
boolean warnDeprecated)
file - The XML fileuseFabanNS - Whether to apply Faban namespaces in this filewarnDeprecated - Whether to warn for deprecated Faban elements| Method Detail |
|---|
public NodeList getNodeListForTagName(String tagName)
tagName -
public NodeList getTopLevelElements()
public Element getRootNode()
public Node getNode(String xpath)
xpath -
public Node getNode(String xpath,
Node base)
xpath - base -
public NodeList getNodes(String xpath)
xpath -
public NodeList getNodes(String xpath,
Node base)
xpath - base -
public String getValue(String xpath)
xpath -
public String getValue(String xpath,
Node base)
xpath - base -
public List<String> getValues(String xpath)
xpath -
public List<String> getValues(String xpath,
Node base)
xpath - base -
public List<String> getAttributeValues(String xpath,
String attribute)
xpath - attribute -
public List<String> getAttributeValues(String xpath,
String attribute,
Node base)
xpath - attribute - base -
public void setValue(String xpath,
String newValue)
xpath - The XPath to the element to set the valuenewValue - The new value
public void setValue(Element element,
String value)
element - The DOM elementvalue - The new value
public void replaceValue(Element element,
String value)
element - value -
public void deleteNode(Node deleteNode,
Node parent)
deleteNode - parent -
public Element addNode(Element parent,
String namespaceURI,
String prefix,
String nodeName)
parent - namespaceURI - prefix - nodeName -
public Element addNode(String baseXPath,
String namespaceURI,
String prefix,
String nodeName)
baseXPath - namespaceURI - prefix - nodeName -
public boolean save(String backupFileName)
throws Exception
backupFileName - - the name of the backup file
Exception - Error saving the filepublic void processHostPorts()
public List<NameValuePair<Integer>> getHostPorts(String xPathExpr)
xPathExpr -
public List<NameValuePair<Integer>> getHostPorts(Element roleNode)
roleNode - The node representing the role
public NodeList getNodeList(String xPathExpr)
xPathExpr -
public static void main(String[] args)
throws Exception
args - The command line arguments
Exception - If there are errors with the test
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||