net.livesite.xml
Class XMLDocument

java.lang.Object
  extended by net.livesite.xml.XMLDocument

public class XMLDocument
extends Object

An XML Document which can be loaded and saved to disk.

Author:
Ryan Gies

Field Summary
protected  Document dom
           
protected  File persistent
           
 
Constructor Summary
XMLDocument()
          Default constructor.
XMLDocument(File file)
          Construct a new instance from a file.
 
Method Summary
 Document getDocument()
          Return the member document.
 File getFile()
          Set the perisistent file.
 void open(File file)
          Open and represent a file.
 void save()
          Save the document to the file from which it was opened.
 void saveAs(File file, boolean overwrite)
          Save the document as an XML file.
 void setDocument(Document doc)
          Set the member document.
 void setFile(File file)
          Set the perisistent file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dom

protected Document dom

persistent

protected File persistent
Constructor Detail

XMLDocument

public XMLDocument()
            throws Exception
Default constructor.

Throws:
Exception

XMLDocument

public XMLDocument(File file)
            throws Exception
Construct a new instance from a file.

Parameters:
file - to open
Throws:
Exception
Method Detail

open

public void open(File file)
          throws Exception
Open and represent a file.

Parameters:
file - to open
Throws:
Exception - when an error occurs

getDocument

public Document getDocument()
Return the member document.

Returns:
the member document.

setDocument

public void setDocument(Document doc)
Set the member document.

Parameters:
doc - to be assigned

setFile

public void setFile(File file)
Set the perisistent file.


getFile

public File getFile()
Set the perisistent file.

Returns:
the file

save

public void save()
          throws Exception
Save the document to the file from which it was opened.

Throws:
Exception - if the file does not exist

saveAs

public void saveAs(File file,
                   boolean overwrite)
            throws IOException,
                   Exception
Save the document as an XML file.

Parameters:
file - to write to
overwrite - if the file exists
Throws:
IOException - while writing to file
Exception - if the file exists and overwrite is false