it.unimo.dbgroup.momis.tools
Class BaseParserXml

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended byit.unimo.dbgroup.momis.tools.BaseParserXml
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler
Direct Known Subclasses:
SchemaParserXml, TypeParserXml

public class BaseParserXml
extends org.xml.sax.helpers.DefaultHandler

Generic parser for XML files. This handles the levelTexts that collects the between the tags and provides the method endElement_getElementText


Field Summary
private  boolean _debug
          if true enables some verbose output
private  int _level
          current level (deepth in elementa)
private  java.util.Vector _levelTexts
          Vector of StringBuffers where
_text = _levelTexts.get(_level);
protected  java.io.PrintStream _logPrintStream
           
protected  java.lang.StringBuffer _text
          Collect text during the parsing
 
Constructor Summary
BaseParserXml()
          Constructor
BaseParserXml(java.io.PrintStream logPrintStream)
          Constructor
 
Method Summary
 void characters(char[] ch, int start, int length)
          Receive notification of character data inside an element.
 java.lang.String endElement_getElementText()
          To be used in endElement: Retrieve the text for the ended element
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String rawName)
          manages the text between elements
 void error(org.xml.sax.SAXParseException spe)
          Error callback.
 void fatalError(org.xml.sax.SAXParseException spe)
          Fatal error callback.
 boolean getDebug()
           
 void setDebug(boolean debug)
           
 void setLogPrintStream(java.io.PrintStream logPrintStream)
           
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String rawName, org.xml.sax.Attributes atts)
          manages the text between elements
 void warning(org.xml.sax.SAXParseException spe)
          Warning callback.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_logPrintStream

protected java.io.PrintStream _logPrintStream

_level

private int _level
current level (deepth in elementa)


_text

protected java.lang.StringBuffer _text
Collect text during the parsing


_levelTexts

private java.util.Vector _levelTexts
Vector of StringBuffers where
_text = _levelTexts.get(_level);


_debug

private boolean _debug
if true enables some verbose output

Constructor Detail

BaseParserXml

public BaseParserXml()
Constructor


BaseParserXml

public BaseParserXml(java.io.PrintStream logPrintStream)
Constructor

Parameters:
logPrintStream - where write the output
Method Detail

setLogPrintStream

public void setLogPrintStream(java.io.PrintStream logPrintStream)

setDebug

public void setDebug(boolean debug)

getDebug

public boolean getDebug()

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Receive notification of character data inside an element.

Throws:
org.xml.sax.SAXException

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String rawName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
manages the text between elements

Throws:
org.xml.sax.SAXException

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String rawName)
                throws org.xml.sax.SAXException
manages the text between elements

Throws:
org.xml.sax.SAXException

endElement_getElementText

public java.lang.String endElement_getElementText()
To be used in endElement: Retrieve the text for the ended element


warning

public void warning(org.xml.sax.SAXParseException spe)
Warning callback.

Throws:
spe - The parse exception that caused the callback to be invoked.

error

public void error(org.xml.sax.SAXParseException spe)
Error callback.

Throws:
spe - The parse exception that caused the callback to be invoked.

fatalError

public void fatalError(org.xml.sax.SAXParseException spe)
Fatal error callback.

Throws:
spe - The parse exception that caused the callback to be invoked.


Universita' di Modena e Reggio Emilia