com.aliasi.xml
Class SimpleElementHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by com.aliasi.xml.SimpleElementHandler
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler
Direct Known Subclasses:
DelegateHandler, DelegatingHandler, SAXFilterHandler, SAXWriter

public class SimpleElementHandler
extends DefaultHandler

A SimpleElementHandler is a default handler that supplies utilities for simple elements and attributes.

Since:
LingPipe1.0
Version:
2.3
Author:
Bob Carpenter

Field Summary
protected static String CDATA_ATTS_TYPE
          The type of character data attributes.
static Attributes EMPTY_ATTS
          An implementation of Attributes with no attributes.
static DefaultHandler NO_OP_DEFAULT_HANDLER
          A default handler which performs no operation for any method calls.
 
Constructor Summary
SimpleElementHandler()
           
 
Method Summary
static void addSimpleAttribute(AttributesImpl atts, String localName, String value)
          Add a local name and value to an attributes implementation as type "CDATA".
 void characters(char[] cs)
          Handls the specified character array by delegation to DefaultHandler.characters(char[],int,int).
static void characters(DefaultHandler handler, char[] cs)
          Handls the specified character array by delegation to DefaultHandler.characters(char[],int,int).
static void characters(DefaultHandler handler, String s)
          Converts the string to a character array in order to call DefaultHandler.characters(char[],int,int) to handle the characters.
 void characters(String s)
          Converts the string to a character array in order to call DefaultHandler.characters(char[],int,int) to handle the characters.
static Attributes createAttributes(String attribute, String value)
          Create an attributes list with the specified attribute and value.
static Attributes createAttributes(String attribute1, String value1, String attribute2, String value2)
          Create an attributes list with the specified pair of attributes.
static Attributes createAttributes(String attribute1, String value1, String attribute2, String value2, String attribute3, String value3)
          Create an attributes list with the specified tripe of attributes and values.
static Attributes createAttributes(String attribute1, String value1, String attribute2, String value2, String attribute3, String value3, String attribute4, String value4)
          Create an attributes list with the specified four attributes and values.
static Attributes createAttributes(String attribute1, String value1, String attribute2, String value2, String attribute3, String value3, String attribute4, String value4, String attribute5, String value5)
          Create an attributes list with the specified five attributes and values.
static Attributes createAttributes(String attribute1, String value1, String attribute2, String value2, String attribute3, String value3, String attribute4, String value4, String attribute5, String value5, String attribute6, String value6)
          Create an attributes list with the specified six attributes and values.
static void endSimpleElement(DefaultHandler handler, String localName)
          End an element for the specified handler with a null namespace, using the local name for both local and qualified names.
 void endSimpleElement(String localName)
          End an element with a null namespace, using the local name for both local and qualified names.
 void startEndSimpleElement(String localName)
          Starts and then ends a simple element of the specified local name.
 void startEndSimpleElement(String localName, Attributes atts)
          Starts and then ends a simple element of the specified local name with the specified attributes.
static void startSimpleElement(DefaultHandler handler, String name)
          Starts an element with a null namespace and no attributes.
static void startSimpleElement(DefaultHandler handler, String localName, Attributes atts)
          Starts an element with a null namespace and the specified local name, which is also provided as the qualified name.
static void startSimpleElement(DefaultHandler handler, String name, String att, String value)
          Starts an element with a null namespace and a single attribute and value.
 void startSimpleElement(String name)
          Starts an element with a null namespace and no attributes.
 void startSimpleElement(String localName, Attributes atts)
          Starts an element with a null namespace and the specified local name, which is also provided as the qualified name.
 void startSimpleElement(String name, String att, String value)
          Starts an element with a null namespace and a single attribute and value.
 void startSimpleElement(String name, String att1, String val1, String att2, String val2)
          Starts an element with a null namespace and a pair of attributes and values.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ATTS

public static final Attributes EMPTY_ATTS
An implementation of Attributes with no attributes.


NO_OP_DEFAULT_HANDLER

public static final DefaultHandler NO_OP_DEFAULT_HANDLER
A default handler which performs no operation for any method calls.


CDATA_ATTS_TYPE

protected static final String CDATA_ATTS_TYPE
The type of character data attributes.

See Also:
Constant Field Values
Constructor Detail

SimpleElementHandler

public SimpleElementHandler()
Method Detail

characters

public void characters(String s)
                throws SAXException
Converts the string to a character array in order to call DefaultHandler.characters(char[],int,int) to handle the characters.

Parameters:
s - String whose characters are to be handled.
Throws:
SAXException - if the handler throws a SAX exception.

characters

public void characters(char[] cs)
                throws SAXException
Handls the specified character array by delegation to DefaultHandler.characters(char[],int,int).

Parameters:
cs - Character array to be handled.
Throws:
SAXException - if the handler throws a SAX exception.

startSimpleElement

public void startSimpleElement(String name)
                        throws SAXException
Starts an element with a null namespace and no attributes.

Parameters:
name - Name of element to start.
Throws:
SAXException - if the contained hanlder throws a SAX exception.
See Also:
startSimpleElement(String,Attributes)

startSimpleElement

public void startSimpleElement(String name,
                               String att,
                               String value)
                        throws SAXException
Starts an element with a null namespace and a single attribute and value.

Parameters:
name - Name of element to start.
att - Name of single attribute.
value - The attribute's value.
Throws:
SAXException - if the contained hanlder throws a SAX exception.
See Also:
startSimpleElement(String,Attributes)

startSimpleElement

public void startSimpleElement(String name,
                               String att1,
                               String val1,
                               String att2,
                               String val2)
                        throws SAXException
Starts an element with a null namespace and a pair of attributes and values.

Parameters:
name - Name of element to start.
att1 - Name of the first attribute.
val1 - Value of the first attribute.
att2 - Name of the second attribute.
val2 - Value of the second attribute.
Throws:
SAXException - if the contained hanlder throws a SAX exception.

startSimpleElement

public void startSimpleElement(String localName,
                               Attributes atts)
                        throws SAXException
Starts an element with a null namespace and the specified local name, which is also provided as the qualified name.

Parameters:
localName - Local name of element to start.
atts - Attributes for this element.
Throws:
SAXException - if the contained hanlder throws a SAX exception.

endSimpleElement

public void endSimpleElement(String localName)
                      throws SAXException
End an element with a null namespace, using the local name for both local and qualified names.

Parameters:
localName - Local name of element to end.
Throws:
SAXException - if the contained hanlder throws a SAX exception.

startEndSimpleElement

public void startEndSimpleElement(String localName)
                           throws SAXException
Starts and then ends a simple element of the specified local name.

Parameters:
localName - Name of element.
Throws:
SAXException - If the contained handler throws a SAX exception.

startEndSimpleElement

public void startEndSimpleElement(String localName,
                                  Attributes atts)
                           throws SAXException
Starts and then ends a simple element of the specified local name with the specified attributes.

Parameters:
localName - Name of element.
atts - Attributes for the element.
Throws:
SAXException - If the contained handler throws a SAX exception.

addSimpleAttribute

public static void addSimpleAttribute(AttributesImpl atts,
                                      String localName,
                                      String value)
Add a local name and value to an attributes implementation as type "CDATA". Sets both local and qualified name on attribute.

Parameters:
atts - Attributes to which the specified attribute and value are added.
localName - Local name of attribute to add.
value - Value of attribute to add.

createAttributes

public static final Attributes createAttributes(String attribute,
                                                String value)
Create an attributes list with the specified attribute and value.

Parameters:
attribute - Name of attribute.
value - Value of attribute.
Returns:
Resulting attribute-value list.

createAttributes

public static final Attributes createAttributes(String attribute1,
                                                String value1,
                                                String attribute2,
                                                String value2)
Create an attributes list with the specified pair of attributes.

Parameters:
attribute1 - Name of first attribute.
value1 - Value of first attribute.
attribute2 - Name of second attribute.
value2 - Value of second attribute.
Returns:
Resulting attribute-value list.

createAttributes

public static final Attributes createAttributes(String attribute1,
                                                String value1,
                                                String attribute2,
                                                String value2,
                                                String attribute3,
                                                String value3)
Create an attributes list with the specified tripe of attributes and values.

Parameters:
attribute1 - Name of first attribute.
value1 - Value of first attribute.
attribute2 - Name of second attribute.
value2 - Value of second attribute.
attribute3 - Name of third attribute.
value3 - Value of third attribute.
Returns:
Resulting attribute-value list.

createAttributes

public static final Attributes createAttributes(String attribute1,
                                                String value1,
                                                String attribute2,
                                                String value2,
                                                String attribute3,
                                                String value3,
                                                String attribute4,
                                                String value4)
Create an attributes list with the specified four attributes and values.

Parameters:
attribute1 - Name of first attribute.
value1 - Value of first attribute.
attribute2 - Name of second attribute.
value2 - Value of second attribute.
attribute3 - Name of third attribute.
value3 - Value of third attribute.
attribute4 - Name of fourth attribute.
value4 - Value of fourth attribute.
Returns:
Resulting attribute-value list.

createAttributes

public static final Attributes createAttributes(String attribute1,
                                                String value1,
                                                String attribute2,
                                                String value2,
                                                String attribute3,
                                                String value3,
                                                String attribute4,
                                                String value4,
                                                String attribute5,
                                                String value5)
Create an attributes list with the specified five attributes and values.

Parameters:
attribute1 - Name of first attribute.
value1 - Value of first attribute.
attribute2 - Name of second attribute.
value2 - Value of second attribute.
attribute3 - Name of third attribute.
value3 - Value of third attribute.
attribute4 - Name of fourth attribute.
value4 - Value of fourth attribute.
attribute5 - Name of fifth attribute.
value5 - Value of fifth attribute.
Returns:
Resulting attribute-value list.

createAttributes

public static final Attributes createAttributes(String attribute1,
                                                String value1,
                                                String attribute2,
                                                String value2,
                                                String attribute3,
                                                String value3,
                                                String attribute4,
                                                String value4,
                                                String attribute5,
                                                String value5,
                                                String attribute6,
                                                String value6)
Create an attributes list with the specified six attributes and values.

Parameters:
attribute1 - Name of first attribute.
value1 - Value of first attribute.
attribute2 - Name of second attribute.
value2 - Value of second attribute.
attribute3 - Name of third attribute.
value3 - Value of third attribute.
attribute4 - Name of fourth attribute.
value4 - Value of fourth attribute.
attribute5 - Name of fifth attribute.
value5 - Value of fifth attribute.
attribute6 - Name of sixth attribute.
value6 - Value of sixth attribute.
Returns:
Resulting attribute-value list.

characters

public static void characters(DefaultHandler handler,
                              String s)
                       throws SAXException
Converts the string to a character array in order to call DefaultHandler.characters(char[],int,int) to handle the characters.

Parameters:
handler - Handler for resulting event.
s - String whose characters are to be handled.
Throws:
SAXException - if the handler throws a SAX exception.

characters

public static void characters(DefaultHandler handler,
                              char[] cs)
                       throws SAXException
Handls the specified character array by delegation to DefaultHandler.characters(char[],int,int).

Parameters:
handler - Handler for resulting event.
cs - Character array to be handled.
Throws:
SAXException - if the handler throws a SAX exception.

startSimpleElement

public static void startSimpleElement(DefaultHandler handler,
                                      String name)
                               throws SAXException
Starts an element with a null namespace and no attributes.

Parameters:
handler - Handler for resulting event.
name - Name of element to start.
Throws:
SAXException - if the contained hanlder throws a SAX exception.

startSimpleElement

public static void startSimpleElement(DefaultHandler handler,
                                      String name,
                                      String att,
                                      String value)
                               throws SAXException
Starts an element with a null namespace and a single attribute and value.

Parameters:
handler - Handler for resulting event.
name - Name of element to start.
att - Name of single attribute.
value - The attribute's value.
Throws:
SAXException - if the contained hanlder throws a SAX exception.
See Also:
startSimpleElement(String,Attributes)

startSimpleElement

public static void startSimpleElement(DefaultHandler handler,
                                      String localName,
                                      Attributes atts)
                               throws SAXException
Starts an element with a null namespace and the specified local name, which is also provided as the qualified name.

Parameters:
handler - Handler for resulting event.
localName - Local name of element to start.
atts - Attributes for this element.
Throws:
SAXException - if the contained hanlder throws a SAX exception.

endSimpleElement

public static void endSimpleElement(DefaultHandler handler,
                                    String localName)
                             throws SAXException
End an element for the specified handler with a null namespace, using the local name for both local and qualified names.

Parameters:
handler - Handler for resulting event.
localName - Local name of element to end.
Throws:
SAXException - if the contained hanlder throws a SAX exception.