|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.cargo.util.Dom4JUtil
public class Dom4JUtil
This class offers utility methods not exposed in the current dom4j api.
Constructor Summary | |
---|---|
Dom4JUtil()
default constructor will assign no namespaces and use a default file handler. |
|
Dom4JUtil(FileHandler fileHandler)
constructor will assign no namespaces. |
Method Summary | |
---|---|
FileHandler |
getFileHandler()
|
Map |
getNamespaces()
|
org.dom4j.Document |
loadXmlFromFile(String sourceFile)
read the specified file into a Document. |
org.dom4j.Element |
parseIntoElement(String elementToParse)
parse the passed string into an Element object. |
void |
saveXml(org.dom4j.Document document,
String filename)
write the xml document to disk, rethrowing checked exceptions as runtime. |
org.dom4j.Element |
selectElementMatchingXPath(String xpath,
org.dom4j.Element toSearch)
The following will search the given element for the specified xpath and return any node that matches. |
List |
selectElementsMatchingXPath(String xpath,
org.dom4j.Element toSearch)
The following will search the given element for the specified xpath and return a list of nodes that match. |
void |
setFileHandler(FileHandler fileHandler)
|
void |
setNamespaces(Map namespaces)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Dom4JUtil()
public Dom4JUtil(FileHandler fileHandler)
fileHandler
- used to read and write xml files.Method Detail |
---|
public List selectElementsMatchingXPath(String xpath, org.dom4j.Element toSearch)
xpath
- - selection criteriatoSearch
- - element to start the search at
public org.dom4j.Element selectElementMatchingXPath(String xpath, org.dom4j.Element toSearch)
xpath
- - selection criteriatoSearch
- - element to start the search at
public org.dom4j.Document loadXmlFromFile(String sourceFile)
sourceFile
- file to read
public void saveXml(org.dom4j.Document document, String filename)
document
- document to write to diskfilename
- where to write the documentpublic FileHandler getFileHandler()
public void setFileHandler(FileHandler fileHandler)
fileHandler
- the Cargo file utility class to use. This method is useful for unit
testing with Mock objects as it can be passed a test file handler that doesn't
perform any real file action.public void setNamespaces(Map namespaces)
namespaces
- the namespaces to setpublic Map getNamespaces()
public org.dom4j.Element parseIntoElement(String elementToParse)
Element
object.
elementToParse
- string to parse
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |