Package edu.msu.cme.rdp.classifier.io

# Class TreeFileParser

java.lang.Object
org.xml.sax.helpers.DefaultHandler
edu.msu.cme.rdp.classifier.io.TreeFileParser

All Implemented Interfaces:
  `ContentHandler`, `DTDHandler`, `EntityResolver`, `ErrorHandler`

public class TreeFileParser extends DefaultHandler
A parser to parse a reader containing taxonomic training information. Note: The first TreeNode is the root TreeNode.

## Constructor Summary

Constructors
Constructor
Description
`TreeFileParser()`
Creates a new instance of TreeFileParser.

## Method Summary

Modifier and Type
Method
Description
`HierarchyTree`
`createTree(Reader in, HierarchyVersion version)`
Reads from a reader that contains the information for each treenode.
`void`
`endElement(String str, String str1, String str2)`
`void`
`error(SAXParseException e)`
`String`
`getTrainRank()`
`void`
`startElement(String namespaceURI, String lName, String qName, Attributes attrs)`

### Methods inherited from class org.xml.sax.helpers.DefaultHandler

`characters, endDocument, endPrefixMapping, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.xml.sax.ContentHandler

`declaration`

## Constructor Details

### TreeFileParser

public TreeFileParser()
Creates a new instance of TreeFileParser.

## Method Details

### getTrainRank

public String getTrainRank()

### createTree

public HierarchyTree createTree(Reader in, HierarchyVersion version) throws IOException, TrainingDataException
Reads from a reader that contains the information for each treenode. Creates all the HierarchyTrees and returns the root of the trees. Note: The first TreeNode is the root TreeNode. The version information should be obtained from the other files first.

Throws:
  `IOException`
  `TrainingDataException`

### startElement

public void startElement(String namespaceURI, String lName, String qName, Attributes attrs) throws SAXException

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

### endElement

public void endElement(String str, String str1, String str2) throws SAXException

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

### error

public void error(SAXParseException e) throws SAXException

Specified by:
  `error` in interface `ErrorHandler`
Overrides:
  `error` in class `DefaultHandler`
Throws:
  `SAXException`