org.concord.biologica.engine
Class ElementContext

java.lang.Object
  |
  +--org.xml.sax.HandlerBase
        |
        +--org.concord.biologica.engine.ElementContext
All Implemented Interfaces:
org.xml.sax.DocumentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public final class ElementContext
extends org.xml.sax.HandlerBase

This class represents a context for an XML element during the process of reading that element in from a BioLogica XML file.

Version:
$Revision: 1.1.1.1 $ $Date: 2001/04/28 00:39:12 $
Author:
$Author: ed $

Constructor Summary
ElementContext(org.xml.sax.DocumentHandler aParentDocumentHandler, com.sun.xml.parser.Parser anXMLParser, ImportContext anImportContext)
          Creates a new ElementContext.
 
Method Summary
 void characters(char[] ch, int start, int length)
          Receive notification of character data.
 void endElement(java.lang.String anElementName)
          Handle notification that the parsing of the given element has ended.
 int getElementID()
          Return the element id
 java.lang.String getElementName()
          Return the element name
 ImportContext getImportContext()
          Return the import context.
 java.lang.String getValueString()
          Return a String that contains the contents of the text buffer
 com.sun.xml.parser.Parser getXMLParser()
          Return the parser
 void ignorableWhitespace(char[] ch, int start, int length)
          Receive notification of ignorable white space character data.
 void newElement(java.lang.String anElementName, int anElementID)
          New element is starting in an existing element context.
 
Methods inherited from class org.xml.sax.HandlerBase
endDocument, error, fatalError, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, startDocument, startElement, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ElementContext

public ElementContext(org.xml.sax.DocumentHandler aParentDocumentHandler,
                      com.sun.xml.parser.Parser anXMLParser,
                      ImportContext anImportContext)
Creates a new ElementContext. This version of the constructor should be used in the main document element, when we already know what the first element will be and we haven't started parsing yet. Hence we do NOT claim the document handler here.

Note that the import context may not be changed once set.

Parameters:
aParentDocumentHandler - DocumentHandler - the parent document handler
anXMLParser - com.sun.xml.parser.Parser - the element parser
anImportContext - ImportContext - the import context
Throws:
java.lang.IllegalArgumentException - - illegal argument input
Method Detail

newElement

public void newElement(java.lang.String anElementName,
                       int anElementID)
New element is starting in an existing element context. This method is called by the parent of this element (e.g. World). This element context should make itself the document handler and handle character and white space notifications until the new element is ended.
Parameters:
anElementName - String - the element name
anElementID - int - the element id
Throws:
java.lang.IllegalArgumentException - - illegal argument input

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Receive notification of character data.
Overrides:
characters in class org.xml.sax.HandlerBase
Parameters:
ch - char[] - characters
start - int - start of string
length - int - length of string

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws org.xml.sax.SAXException
Receive notification of ignorable white space character data.
Overrides:
ignorableWhitespace in class org.xml.sax.HandlerBase
Parameters:
ch - char[] - characters
start - int - start of string
length - int - length of string

endElement

public void endElement(java.lang.String anElementName)
                throws org.xml.sax.SAXException
Handle notification that the parsing of the given element has ended. This results in this object notifying the parent document handler, who then reclaims the parsing notifications and processes the element that this object just received string data for.

Overrides:
endElement in class org.xml.sax.HandlerBase
Parameters:
anElementName - String - the element name

getElementName

public java.lang.String getElementName()
Return the element name
Returns:
String - the element name

getElementID

public int getElementID()
Return the element id
Returns:
int - the element id

getXMLParser

public com.sun.xml.parser.Parser getXMLParser()
Return the parser
Returns:
com.sun.xml.parser.Parser - the parser

getImportContext

public ImportContext getImportContext()
Return the import context.
Returns:
ImportContext - the import context

getValueString

public java.lang.String getValueString()
Return a String that contains the contents of the text buffer
Returns:
String - the contents of this element context text buffer