org.codehaus.cargo.util
Class Dom4JXmlFileBuilder

java.lang.Object
  extended by org.codehaus.cargo.util.Dom4JXmlFileBuilder
All Implemented Interfaces:
XmlFileBuilder

public class Dom4JXmlFileBuilder
extends java.lang.Object
implements XmlFileBuilder

This implementation uses @{link Dom4JUtil Dom4JUtil} to manipulate xml files.

Version:
$Id$

Constructor Summary
Dom4JXmlFileBuilder(FileHandler fileHandler)
          creates the instance, which will use the specified @{link FileHandler fileHandler} to read or write the xml file.
 
Method Summary
 void insertElementsUnderXPath(java.lang.String elementsToParse, java.lang.String xpath)
          this will parse one or more elements from elementToParse and insert them under the xpath.
 void loadFile()
          load the current xml file into a Document.
 void setFile(java.lang.String path)
          sets the name of the file we will read and write.
 void setNamespaces(java.util.Map namespaces)
          assign prefix to namespace mappings used for xpath and other xml operations.
 void writeFile()
          write the current xml to disk.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Dom4JXmlFileBuilder

public Dom4JXmlFileBuilder(FileHandler fileHandler)
creates the instance, which will use the specified @{link FileHandler fileHandler} to read or write the xml file.

Parameters:
fileHandler - used for file i/o.
Method Detail

setFile

public void setFile(java.lang.String path)
sets the name of the file we will read and write.

Specified by:
setFile in interface XmlFileBuilder
Parameters:
path - - where the xml file will be read from or written to.

insertElementsUnderXPath

public void insertElementsUnderXPath(java.lang.String elementsToParse,
                                     java.lang.String xpath)
this will parse one or more elements from elementToParse and insert them under the xpath. note: elementsToParse may not be well formed, but only in one way. The elements may be missing a parent. Example: the following is acceptable by this method elementsToParse = xpath = //parent In this case, both elements child1 and child2 would be placed under the first match for parent. s

Specified by:
insertElementsUnderXPath in interface XmlFileBuilder
Parameters:
elementsToParse - String containing one or more elements in textual format
xpath - where to place the above elements.

loadFile

public void loadFile()
load the current xml file into a Document.

Specified by:
loadFile in interface XmlFileBuilder

writeFile

public void writeFile()
write the current xml to disk.

Specified by:
writeFile in interface XmlFileBuilder

setNamespaces

public void setNamespaces(java.util.Map namespaces)
assign prefix to namespace mappings used for xpath and other xml operations. Leave alone, or set to null, if you have no namespaces.

Specified by:
setNamespaces in interface XmlFileBuilder
Parameters:
namespaces - - key is prefix value is url


Copyright © 2004-2011 Codehaus. All Rights Reserved.