org.opennms.web.parsers
Class XMLWriter

java.lang.Object
  extended by org.opennms.web.parsers.XMLWriter
Direct Known Subclasses:
GroupsWriter, NotificationsWriter, UsersWriter, ViewsWriter

public abstract class XMLWriter
extends Object

This class is used to parse data from and save data to the users.xml file.

Version:
1.1.1.1
Author:
Jason Johns , OpenNMS

Field Summary
protected static String DTD_EXTENSION
           
protected  String m_baseName
           
protected  DocumentBuilder m_docBuilder
           
protected  Document m_document
           
protected  String m_dtd
           
protected  String m_dtdPath
           
protected  String m_fileName
           
protected static XMLHeader m_headerInfo
          The header information parsed from the file
protected  String m_xmlPath
           
protected static String XML_EXTENSION
           
 
Constructor Summary
XMLWriter(String fileName)
          Default constructor, intializes the member variables
 
Method Summary
 Element addCDataElement(Element parent, String elementName, String data)
           
 Element addDataElement(Element parent, String elementName, String data)
           
 Element addEmptyElement(Element parent, String elementName)
           
 void backup()
          This method attempts to make a backup of the xml file.
 String getDTD(String dtdFileName)
           
 String getVersion()
           
protected  void loadDTD(String dtdFileName)
           
 void save(Collection list)
           
protected abstract  void saveDocument(Collection list)
           
protected  void serializeToFile()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_headerInfo

protected static XMLHeader m_headerInfo
The header information parsed from the file


m_document

protected Document m_document

m_docBuilder

protected DocumentBuilder m_docBuilder

m_fileName

protected String m_fileName

m_baseName

protected String m_baseName

m_xmlPath

protected String m_xmlPath

m_dtdPath

protected String m_dtdPath

m_dtd

protected String m_dtd

XML_EXTENSION

protected static final String XML_EXTENSION
See Also:
Constant Field Values

DTD_EXTENSION

protected static final String DTD_EXTENSION
See Also:
Constant Field Values
Constructor Detail

XMLWriter

public XMLWriter(String fileName)
          throws XMLWriteException
Default constructor, intializes the member variables

Throws:
XMLWriteException
Method Detail

loadDTD

protected void loadDTD(String dtdFileName)
                throws FileNotFoundException,
                       IOException
Throws:
FileNotFoundException
IOException

getDTD

public String getDTD(String dtdFileName)
              throws FileNotFoundException,
                     IOException
Throws:
FileNotFoundException
IOException

getVersion

public String getVersion()

backup

public void backup()
            throws XMLWriteException
This method attempts to make a backup of the xml file. It is recommended that this method is called prior to making the call to save(), so that the original config file will be recoverable if the writting of the new config file fails.

Throws:
XMLWriteException

serializeToFile

protected void serializeToFile()
                        throws XMLWriteException
Throws:
XMLWriteException

addEmptyElement

public Element addEmptyElement(Element parent,
                               String elementName)

addDataElement

public Element addDataElement(Element parent,
                              String elementName,
                              String data)

addCDataElement

public Element addCDataElement(Element parent,
                               String elementName,
                               String data)
                        throws XMLWriteException
Throws:
XMLWriteException

save

public void save(Collection list)
          throws XMLWriteException
Throws:
XMLWriteException

saveDocument

protected abstract void saveDocument(Collection list)
                              throws XMLWriteException
Throws:
XMLWriteException


Copyright ? 2007. All Rights Reserved.