gate.util
Class Lax

java.lang.Object
  |
  +--org.xml.sax.helpers.DefaultHandler
        |
        +--gate.util.Lax
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

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

LAX (LazyProgrammer Api for XML) layer for a SAX parser, based on Sun's JAXP layer...so it works with any JAXP compliant parser


Field Summary
private static Class[] _caAttrList
           
private static Class[] _caNoArgs
           
private static Class[] _caString
           
private  boolean _namespaceAwareParser
           
private  LaxErrorHandler _seh
           
private  boolean _validatingParser
           
private  Vector _vecHandlers
           
private  Vector _vecTags
           
private static boolean DEBUG
          Debug flag
 
Constructor Summary
Lax(LaxErrorHandler leh)
          Lax default constructor
Lax(Object handler_, LaxErrorHandler leh)
          Lax ctor with a single handler
 
Method Summary
(package private) static void ()
           
 void addHandler(Object objHandler_)
          Add a handler to the list of handler objects.
 void characters(char[] caChars, int iStart, int iEnd)
          Handle an incoming block of text by calling the textOf method for the current tag.
 void endDocument()
          endDocument method comment.
 void endElement(String uri, String qName, String sTag)
          Call all end tag methods in the handler list
 void error(org.xml.sax.SAXParseException ex)
          error method comment.
 void fatalError(org.xml.sax.SAXParseException ex)
          fatalError method comment.
 LaxErrorHandler getErrorHandler()
          Get the CustomErrorHandler
 boolean getNamespacesAware()
          Get the namespacesAware property
 boolean getValidating()
          Get the validating property
private  Method mFindMethod(Object oHandler, String sMethodName, Class[] caArgs)
          Return a method of object oHandler with the given name and argument list, or null if not found
 void parseXmlDocument(File xmlFile)
           
 void parseXmlDocument(org.xml.sax.InputSource xmlInputSource)
           
 void parseXmlDocument(InputStream xmlInputStream)
           
 void parseXmlDocument(String xmlURI)
           
private  void popTag()
          Pop tag off of tag stack.
private  void pushTag(String sTag)
          Push tag onto tag stack.
private  String sCurrentTag()
          Return tag at top of tag stack.
 void setErrorHandler(LaxErrorHandler leh)
          Sets the CustomErrorHandler
 void setNamespacesAware(boolean namespacesAware)
          Sets the parser to be a namespaces aware one implicit parameter is false (so the parser is not a namespaces aware one)
 void setValidating(boolean validating)
          Sets the parser to be a validating one implicit parameter is false (so the parser is not a validating one)
 void startDocument()
          startDocument method comment.
 void startElement(String uri, String qName, String sTag, org.xml.sax.Attributes alAttrs)
          Call all start methods for this tag.
 void warning(org.xml.sax.SAXParseException ex)
          warning method comment.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG
Debug flag

_vecHandlers

private Vector _vecHandlers

_vecTags

private Vector _vecTags

_caNoArgs

private static Class[] _caNoArgs

_caAttrList

private static Class[] _caAttrList

_caString

private static Class[] _caString

_seh

private LaxErrorHandler _seh

_validatingParser

private boolean _validatingParser

_namespaceAwareParser

private boolean _namespaceAwareParser
Constructor Detail

Lax

public Lax(LaxErrorHandler leh)
Lax default constructor

Lax

public Lax(Object handler_,
           LaxErrorHandler leh)
Lax ctor with a single handler
Method Detail

static void ()

setErrorHandler

public void setErrorHandler(LaxErrorHandler leh)
Sets the CustomErrorHandler
Parameters:
leh - gate.util.LaxErrorHandler

getErrorHandler

public LaxErrorHandler getErrorHandler()
Get the CustomErrorHandler
Returns:
gate.util.LaxErrorHandler

setValidating

public void setValidating(boolean validating)
Sets the parser to be a validating one implicit parameter is false (so the parser is not a validating one)
Parameters:
validating - boolean

getValidating

public boolean getValidating()
Get the validating property
Returns:
boolean

setNamespacesAware

public void setNamespacesAware(boolean namespacesAware)
Sets the parser to be a namespaces aware one implicit parameter is false (so the parser is not a namespaces aware one)
Parameters:
namespacesAware - boolean

getNamespacesAware

public boolean getNamespacesAware()
Get the namespacesAware property
Returns:
boolean

addHandler

public void addHandler(Object objHandler_)
Add a handler to the list of handler objects.
Parameters:
objHandler_ - java.lang.Object

characters

public void characters(char[] caChars,
                       int iStart,
                       int iEnd)
                throws org.xml.sax.SAXException
Handle an incoming block of text by calling the textOf method for the current tag.
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
endDocument method comment.
Overrides:
endDocument in class org.xml.sax.helpers.DefaultHandler

endElement

public void endElement(String uri,
                       String qName,
                       String sTag)
                throws org.xml.sax.SAXException
Call all end tag methods in the handler list
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler

error

public void error(org.xml.sax.SAXParseException ex)
           throws org.xml.sax.SAXException
error method comment.
Overrides:
error in class org.xml.sax.helpers.DefaultHandler

fatalError

public void fatalError(org.xml.sax.SAXParseException ex)
                throws org.xml.sax.SAXException
fatalError method comment.
Overrides:
fatalError in class org.xml.sax.helpers.DefaultHandler

mFindMethod

private Method mFindMethod(Object oHandler,
                           String sMethodName,
                           Class[] caArgs)
Return a method of object oHandler with the given name and argument list, or null if not found
Parameters:
oHandler - java.lang.Object - The handler object to search for a method.
sTag - java.lang.String - The tag to find.
Returns:
java.lang.reflect.Method

parseXmlDocument

public void parseXmlDocument(File xmlFile)

parseXmlDocument

public void parseXmlDocument(org.xml.sax.InputSource xmlInputSource)

parseXmlDocument

public void parseXmlDocument(InputStream xmlInputStream)

parseXmlDocument

public void parseXmlDocument(String xmlURI)

popTag

private void popTag()
Pop tag off of tag stack.

pushTag

private void pushTag(String sTag)
Push tag onto tag stack.
Parameters:
sTag - java.lang.String

sCurrentTag

private String sCurrentTag()
Return tag at top of tag stack. At any particular point in the parse, this string represents the tag being processed.
Returns:
java.lang.String

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
startDocument method comment.
Overrides:
startDocument in class org.xml.sax.helpers.DefaultHandler

startElement

public void startElement(String uri,
                         String qName,
                         String sTag,
                         org.xml.sax.Attributes alAttrs)
Call all start methods for this tag.
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler

warning

public void warning(org.xml.sax.SAXParseException ex)
             throws org.xml.sax.SAXException
warning method comment.
Overrides:
warning in class org.xml.sax.helpers.DefaultHandler