info.aduna.clustermap
Class ClassificationTreeReader

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by info.aduna.clustermap.ClassificationTreeReader
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class ClassificationTreeReader
extends DefaultHandler

ClassificationTreeReader is a ContentHandler capable of reconstructing a series of SAX 2.0 events (such as generated by a ClassificationTreeWriter or an XML parser reading an XML SAX file) back into a Classification tree.

ClassificationTreeReader is rather flexible concerning the content it expects. When for example no Classification is specified in the entire stream, a new, empty Classification is constructed that contains all the Objects. When unknown elements or attributes are encountered, they are simply ignored (but be careful not to use existing tag names in different contexts!).

The getTree method, which returns the deserialized Classification tree, has as a side-effect that this ClassificationTreeReader loses its reference to the tree. By that time it has also cleared its internal datastructures. Therefore, after returning the deserialized Classification tree the ClassificationTreeReader is immediately capable of deserializing the next XML stream. A ClassificationTreeReader is also capable of deserializing legacy MapModel serializations. Only the Classification tree of this MapModel will be returned.


Constructor Summary
ClassificationTreeReader()
           
 
Method Summary
 void characters(char[] chars, int offset, int length)
          Appends the specified characters to the local StringBuilder.
 void endDocument()
          Cleans up the intermediate data structures generated in the startDocument method, leaving only a reference to the created Classification tree behind.
 void endElement(String uri, String localName, String qualifiedName)
          Reconstructs the information contained in the element that has just been closed.
 Classification getClassificationTree()
          Returns the Classification tree generated by this ClassificationTreeReader and sets any internal references to it to 'null'.
 void setDocumentLocator(Locator locator)
          Locally registers the specified Locator.
 void startDocument()
          Prepares the ClassificationTreeReader for creating a new Classification tree, based on upcoming SAX events.
 void startElement(String uri, String localName, String qualifiedName, Attributes attributes)
          startElement implementation, dispatches the call to one of the other "startXXX" methods based on the tag name.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassificationTreeReader

public ClassificationTreeReader()
Method Detail

getClassificationTree

public Classification getClassificationTree()
Returns the Classification tree generated by this ClassificationTreeReader and sets any internal references to it to 'null'.


startDocument

public void startDocument()
Prepares the ClassificationTreeReader for creating a new Classification tree, based on upcoming SAX events.

Specified by:
startDocument in interface ContentHandler
Overrides:
startDocument in class DefaultHandler

endDocument

public void endDocument()
                 throws SAXException
Cleans up the intermediate data structures generated in the startDocument method, leaving only a reference to the created Classification tree behind.

Specified by:
endDocument in interface ContentHandler
Overrides:
endDocument in class DefaultHandler
Throws:
SAXException

setDocumentLocator

public void setDocumentLocator(Locator locator)
Locally registers the specified Locator.

Specified by:
setDocumentLocator in interface ContentHandler
Overrides:
setDocumentLocator in class DefaultHandler

characters

public void characters(char[] chars,
                       int offset,
                       int length)
Appends the specified characters to the local StringBuilder.

Specified by:
characters in interface ContentHandler
Overrides:
characters in class DefaultHandler

startElement

public void startElement(String uri,
                         String localName,
                         String qualifiedName,
                         Attributes attributes)
                  throws SAXException
startElement implementation, dispatches the call to one of the other "startXXX" methods based on the tag name.

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class DefaultHandler
Throws:
SAXException

endElement

public void endElement(String uri,
                       String localName,
                       String qualifiedName)
                throws SAXException
Reconstructs the information contained in the element that has just been closed.

Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class DefaultHandler
Throws:
SAXException


Copyright © 1997-2008 Aduna. All Rights Reserved.