JCas
v0.3.1

cas.xml
Class AbstractCasSaxTagHandler

java.lang.Object
  extended bycas.xml.AbstractCasSaxTagHandler
All Implemented Interfaces:
CasSaxTagHandler
Direct Known Subclasses:
JCasAdminRequest, JCasAdminTag, JCasAllowFromTag, JCasBindTag, JCasConfiguration, JCasCookiesTag, JCasCustomAuthorizationTag, JCasExtendedAuthorizationTag, JCasFunctionTag, JCasInstancesTag, JCasInstanceTag, JCasQueryTag, JCasRequest, JCasResponseTag, JCasSchemeTag, JCasServerTag, JCasSystemAuthorizationTag

public abstract class AbstractCasSaxTagHandler
extends Object
implements CasSaxTagHandler

Implements the basic functionality of CasSaxRagHandler.

Version:
1.0
Author:
Ralph Schuster

Constructor Summary
AbstractCasSaxTagHandler()
          Creates a new instance of AbstractCasSaxTagHandler
 
Method Summary
 void characters(char[] ch, int start, int length)
          Receive notification of character data inside an element.
 void clear()
          Initializes the handler.
protected abstract  AbstractCasSaxTagHandler createHandler(String tagName, Attributes attributes)
          Returns a new instance of the handler for the specified sub tag.
 void endElement(String uri, String localName, String qName)
          Receive notification of the end of an element.
 CasSaxTagHandler getHandler(String tagName, Attributes attributes)
          Returns the handler responsible for the sub tag.
abstract  String[] getParentTagNames()
          Returns the tag names of all possible parents.
 CasSaxTagHandler getSubHandler(int n)
          Returns the n-thr sub handler as it appeared in the XML parsing.
 int getSubHandlerCount()
          Returns the number of sub handlers.
 CasSaxTagHandler[] getSubHandlers()
          Returns all sub handlers.
 String[] getSubTag(int n)
          Returns the n-th sub tag as it appeared in the XML parsing.
 String getSubTag(String name)
          Returns the first sub tag value with the specified name.
 int getSubTagCount()
          Returns the number of sub tags.
protected  String[] getSubTagNames()
          Returns the tag names that can appear within this handler but actually do not contain other tags.
 String[][] getSubTags()
          Returns all sub tags.
 boolean ignoresUnknownTags()
          Returns true if unknown tags are ignored.
 void setAttributes(Attributes attr)
          Sets the attributes of the tag.
 void setIgnoreUnknownTags(boolean b)
          Sets the ignoreUnknownTags flag.
 void startElement(String uri, String localName, String qName, Attributes attributes)
          Receive notification of the start of an element.
 void tagCompleted()
          Validates the configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface cas.xml.CasSaxTagHandler
getTagName
 

Constructor Detail

AbstractCasSaxTagHandler

public AbstractCasSaxTagHandler()
Creates a new instance of AbstractCasSaxTagHandler

Method Detail

clear

public void clear()
Initializes the handler.


setIgnoreUnknownTags

public void setIgnoreUnknownTags(boolean b)
Sets the ignoreUnknownTags flag. Default is false.


ignoresUnknownTags

public boolean ignoresUnknownTags()
Returns true if unknown tags are ignored.


setAttributes

public void setAttributes(Attributes attr)
Sets the attributes of the tag.

Specified by:
setAttributes in interface CasSaxTagHandler
Parameters:
attr - - attributes of tag

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes attributes)
                  throws SAXException
Receive notification of the start of an element.

Specified by:
startElement in interface CasSaxTagHandler
Parameters:
attributes - - The specified or defaulted attributes.
localName - - The local name (without prefix), or the empty string if Namespace processing is not being performed.
qName - - The qualified name (with prefix), or the empty string if qualified names are not available.
Throws:
SAXException - - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

endElement

public void endElement(String uri,
                       String localName,
                       String qName)
                throws SAXException
Receive notification of the end of an element.

Specified by:
endElement in interface CasSaxTagHandler
Parameters:
localName - - The local name (without prefix), or the empty string if Namespace processing is not being performed.
qName - - The qualified name (with prefix), or the empty string if qualified names are not available.
Throws:
SAXException - - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)

characters

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

Specified by:
characters in interface CasSaxTagHandler
Parameters:
ch - - The characters.
start - - The start position in the character array.
length - - The number of characters to use from the character array.
Throws:
SAXException - - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.characters(char[], int, int)

getParentTagNames

public abstract String[] getParentTagNames()
Returns the tag names of all possible parents.

Returns:
- the tag names of possible parents

createHandler

protected abstract AbstractCasSaxTagHandler createHandler(String tagName,
                                                          Attributes attributes)
Returns a new instance of the handler for the specified sub tag.

Parameters:
tagName - - name of the sub tag
Returns:
new instance of sub tag handler or null

getSubTagNames

protected String[] getSubTagNames()
Returns the tag names that can appear within this handler but actually do not contain other tags.

Returns:
- all tag names that represent simple tags.

getHandler

public CasSaxTagHandler getHandler(String tagName,
                                   Attributes attributes)
Returns the handler responsible for the sub tag. The method first calls createHandler(String,Attributes) to get an instance of a handler and then checks with the defined parents if it can pass the handler to the caller of the method.

Specified by:
getHandler in interface CasSaxTagHandler
Parameters:
tagName - - the parent of the handler
Returns:
- a handler for the tag.

getSubHandlers

public CasSaxTagHandler[] getSubHandlers()
Returns all sub handlers.

Returns:
- all handlers in order of appearance

getSubHandlerCount

public int getSubHandlerCount()
Returns the number of sub handlers.

Returns:
- number of sub handlers found

getSubHandler

public CasSaxTagHandler getSubHandler(int n)
Returns the n-thr sub handler as it appeared in the XML parsing.

Parameters:
n - - index of sub handler
Returns:
- n-th sub handler.

getSubTags

public String[][] getSubTags()
Returns all sub tags.

Returns:
- all sub tags in order of appearance

getSubTagCount

public int getSubTagCount()
Returns the number of sub tags.

Returns:
- number of sub tags found

getSubTag

public String[] getSubTag(int n)
Returns the n-th sub tag as it appeared in the XML parsing.

Parameters:
n - - index of sub tag
Returns:
- n-th sub tag.

tagCompleted

public void tagCompleted()
                  throws SAXException
Validates the configuration. By default this method does nothing but handlers should override to check the values.

Specified by:
tagCompleted in interface CasSaxTagHandler
Throws:
SAXException - if a configuration error occured.

getSubTag

public String getSubTag(String name)
Returns the first sub tag value with the specified name.


JCas
v0.3.1