uk.ac.ed.inf.ogsaconfig.garm.persistence
Class XMLNode

java.lang.Object
  |
  +--uk.ac.ed.inf.ogsaconfig.garm.persistence.XMLNode
All Implemented Interfaces:
org.xml.sax.ContentHandler
Direct Known Subclasses:
DependenceNode, GeneratedNode, HistoryNode, LayoutNode

public abstract class XMLNode
extends java.lang.Object
implements org.xml.sax.ContentHandler

XMLNode forms the base for all the nodes which persist collections to XML files as part of the XML persistence mechanism


Constructor Summary
protected XMLNode(java.io.File xmlFile, java.lang.String ref)
           
 
Method Summary
 void characters(char[] txt, int start, int len)
           
 void endDocument()
           
 void endElement(java.lang.String ns, java.lang.String name, java.lang.String qname)
           
 void endPrefixMapping(java.lang.String prefix)
           
protected  java.io.PrintStream getOutputStream()
          Returns a stream to the xmlFile that subclasses can use to persist their data
 void ignorableWhitespace(char[] txt, int start, int len)
           
 VFile[] load()
          loads all the VFiles associated with the given file using SAX.
abstract  VFile[] loadedContent()
          subclasses should override this method to return the array of VFile objects they created from the SAX event stream
protected  void printVFile(VFile vf, java.io.PrintStream p)
          Provides a standard way to create an xml node with the correct attributes from a vfile
protected  void printVFile(VFile vf, java.io.PrintStream p, java.lang.String tag)
          Provides a standard way to create an xml node with the correct attributes from a vfile.
 void processingInstruction(java.lang.String target, java.lang.String data)
           
abstract  void save(VFile[] files)
          subclasses should override this method to write the VFile array given to the xmlFile
 void setDocumentLocator(org.xml.sax.Locator locator)
           
 void skippedEntity(java.lang.String name)
           
 void startDocument()
           
 void startElement(java.lang.String ns, java.lang.String name, java.lang.String qname, org.xml.sax.Attributes atts)
           
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
           
protected  VFile vFileFromAttributes(org.xml.sax.Attributes atts)
          Provides a standard way to turn an XML element into a vfile, using only the attributes of the node
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLNode

protected XMLNode(java.io.File xmlFile,
                  java.lang.String ref)
Parameters:
xmlFile - is the file that should be written to
ref - is a reference to the chain containing the collection
Method Detail

getOutputStream

protected java.io.PrintStream getOutputStream()
Returns a stream to the xmlFile that subclasses can use to persist their data


load

public VFile[] load()
loads all the VFiles associated with the given file using SAX. To create a new xml node, the relevant content handler routines should be overridden, together with loadedContent(). Do not override this routine directly


vFileFromAttributes

protected VFile vFileFromAttributes(org.xml.sax.Attributes atts)
Provides a standard way to turn an XML element into a vfile, using only the attributes of the node


printVFile

protected void printVFile(VFile vf,
                          java.io.PrintStream p)
Provides a standard way to create an xml node with the correct attributes from a vfile


printVFile

protected void printVFile(VFile vf,
                          java.io.PrintStream p,
                          java.lang.String tag)
Provides a standard way to create an xml node with the correct attributes from a vfile. This is the inverse of vFileFromAttributes()


loadedContent

public abstract VFile[] loadedContent()
subclasses should override this method to return the array of VFile objects they created from the SAX event stream


save

public abstract void save(VFile[] files)
subclasses should override this method to write the VFile array given to the xmlFile


setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
Specified by:
setDocumentLocator in interface org.xml.sax.ContentHandler

startDocument

public void startDocument()
Specified by:
startDocument in interface org.xml.sax.ContentHandler

endDocument

public void endDocument()
Specified by:
endDocument in interface org.xml.sax.ContentHandler

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
Specified by:
startPrefixMapping in interface org.xml.sax.ContentHandler

endPrefixMapping

public void endPrefixMapping(java.lang.String prefix)
Specified by:
endPrefixMapping in interface org.xml.sax.ContentHandler

startElement

public void startElement(java.lang.String ns,
                         java.lang.String name,
                         java.lang.String qname,
                         org.xml.sax.Attributes atts)
Specified by:
startElement in interface org.xml.sax.ContentHandler

endElement

public void endElement(java.lang.String ns,
                       java.lang.String name,
                       java.lang.String qname)
Specified by:
endElement in interface org.xml.sax.ContentHandler

characters

public void characters(char[] txt,
                       int start,
                       int len)
Specified by:
characters in interface org.xml.sax.ContentHandler

ignorableWhitespace

public void ignorableWhitespace(char[] txt,
                                int start,
                                int len)
Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
Specified by:
processingInstruction in interface org.xml.sax.ContentHandler

skippedEntity

public void skippedEntity(java.lang.String name)
Specified by:
skippedEntity in interface org.xml.sax.ContentHandler