- java.lang.Object
-
- ilusr.core.datamanager.xml.XmlGenerator
-
public class XmlGenerator extends Object
- Author:
- Jeff Riggle This class provides a simple wrapper around the xml document class. This allows the user to write data to a xml document and save it later.
-
-
Constructor Summary
Constructors Constructor Description XmlGenerator()
Minimal constructor, using this constructor will cause the xml document to be created for you.XmlGenerator(Document document)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAttributeToElement(Element parent, String name, String value)
void
addChildToElement(Element parent, Element child)
void
addElementToRoot(Element value)
Node
addNodeToElement(Element parent, String data)
Element
createElement(String id)
Document
document()
void
document(Document document)
void
removeAttributeFromElement(Element parent, String name)
void
removeChildFromElement(Element parent, Element child)
void
removeElementFromRoot(Element value)
void
removeNodeFromElement(Element parent, Node value)
void
saveToFile(String fileLocation)
-
-
-
Constructor Detail
-
XmlGenerator
public XmlGenerator() throws ParserConfigurationException, TransformerConfigurationException
Minimal constructor, using this constructor will cause the xml document to be created for you.- Throws:
ParserConfigurationException
- When the generated xml cannot be parsed.TransformerConfigurationException
- When the generated xml cannot be transformed.
-
XmlGenerator
public XmlGenerator(Document document) throws TransformerConfigurationException
- Parameters:
document
- The document to modify and save.- Throws:
TransformerConfigurationException
- When the generated xml cannot be transformed.
-
-
Method Detail
-
document
public void document(Document document)
- Parameters:
document
- The new document to generate on.
-
document
public Document document()
- Returns:
- The document associated with this generator.
-
addElementToRoot
public void addElementToRoot(Element value)
- Parameters:
value
- The element to add to the root of this document.
-
removeElementFromRoot
public void removeElementFromRoot(Element value)
- Parameters:
value
- The element to remove from the root of this document.
-
addChildToElement
public void addChildToElement(Element parent, Element child)
- Parameters:
parent
- The parent element.child
- The element you would like to add to this parent.
-
removeChildFromElement
public void removeChildFromElement(Element parent, Element child)
- Parameters:
parent
- The parent element.child
- The elment you would like to remove from this parent.
-
addAttributeToElement
public void addAttributeToElement(Element parent, String name, String value)
- Parameters:
parent
- The element you would like to add an attribute to.name
- The name of the attributevalue
- The value of the attribute.
-
removeAttributeFromElement
public void removeAttributeFromElement(Element parent, String name)
- Parameters:
parent
- The element you would like to remove an attribute from.name
- The name of the attribute you would like to remove.
-
addNodeToElement
public Node addNodeToElement(Element parent, String data)
- Parameters:
parent
- The element you would like to add this node data to.data
- The data to insert into the node.- Returns:
- The node that has been created.
-
removeNodeFromElement
public void removeNodeFromElement(Element parent, Node value)
- Parameters:
parent
- The element you would like to remove a node from.value
- The node to remove.
-
createElement
public Element createElement(String id)
- Parameters:
id
- The String identifier for this element.- Returns:
- The element that has been created.
-
saveToFile
public void saveToFile(String fileLocation) throws TransformerException
- Parameters:
fileLocation
- The file location to save this xml, should include file name.- Throws:
TransformerException
- When the generated xml cannot be transformed.
-
-