org.jtheque.core.utils.file
Class XMLWriter

java.lang.Object
  extended by org.jtheque.core.utils.file.XMLWriter

public final class XMLWriter
extends java.lang.Object

An XML writer.

Author:
Baptiste Wicht

Constructor Summary
XMLWriter()
          Construct a new XMLWriter.
XMLWriter(java.lang.String root)
          Construct a new XML writer.
 
Method Summary
 void add(java.lang.String element)
          Add the element to the document and set the new element as the current element.
 void add(java.lang.String element, java.lang.String text)
          Add an element to the document and set the new element as the current element.
 void addAttribute(java.lang.String key, java.lang.String value)
          Add an attribute to the current element.
 void addOnly(java.lang.String element, java.lang.String text)
          Add the element.
 org.jdom.Element getRoot()
          Return the root element of the document.
 void setCurrent(org.jdom.Element element)
          Set the current element.
 void switchToParent()
          Switch to parent.
 void write(java.lang.String filepath)
          Write the XML document to the file path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLWriter

public XMLWriter()
Construct a new XMLWriter.


XMLWriter

public XMLWriter(java.lang.String root)
Construct a new XML writer.

Parameters:
root - The name of the root element.
Method Detail

add

public void add(java.lang.String element)
Add the element to the document and set the new element as the current element.

Parameters:
element - The element to add.

add

public void add(java.lang.String element,
                java.lang.String text)
Add an element to the document and set the new element as the current element.

Parameters:
element - The name of the element to add.
text - The text of the element.

addOnly

public void addOnly(java.lang.String element,
                    java.lang.String text)
Add the element.

Parameters:
element - The name of the element.
text - The text of the element.

addAttribute

public void addAttribute(java.lang.String key,
                         java.lang.String value)
Add an attribute to the current element.

Parameters:
key - The key of the attribute.
value - The value of the attribute.

getRoot

public org.jdom.Element getRoot()
Return the root element of the document.

Returns:
The root element of the document.

setCurrent

public void setCurrent(org.jdom.Element element)
Set the current element.

Parameters:
element - The current element.

write

public void write(java.lang.String filepath)
Write the XML document to the file path.

Parameters:
filepath - The file path.

switchToParent

public void switchToParent()
Switch to parent.



Copyright © 2009 JTheque. All Rights Reserved.