edu.mit.jverbnet.util.parse
Class ListHandler<T>

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by edu.mit.jverbnet.util.parse.MappedHandler<java.util.List<T>>
          extended by edu.mit.jverbnet.util.parse.ListHandler<T>
All Implemented Interfaces:
IHasParserHandler, ITaggedBlockTaskHandler, ITaggedHandler<java.util.List<T>>, org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class ListHandler<T>
extends MappedHandler<java.util.List<T>>

A mapped handler that specifically handles lists of elements.

Since:
JVerbnet 1.0.0
Version:
1.2.0
Author:
Mark A. Finlayson

Field Summary
 
Fields inherited from class edu.mit.jverbnet.util.parse.MappedHandler
messageIgnoringElementBlockExternal, messageMatcherIgnoreExternal, messageMatcherIgnoreInternal, messageParserNotSet, messageUnmappedElementBlockInternal, tagStack
 
Constructor Summary
ListHandler(IHasParserHandler parent, java.lang.String tag, ITaggedHandler<? extends T> elementHandler)
          Creates a new CDATA handler with the specified parent and tag.
ListHandler(java.lang.String tag, ITaggedHandler<? extends T> elementHandler)
          Creates a new CDATA handler with the specified tag.
ListHandler(org.xml.sax.XMLReader parser, org.xml.sax.ContentHandler parent, java.lang.String tag, ITaggedHandler<? extends T> elementHandler)
          Creates a new CDATA handler with the specified parser, parent and tag.
ListHandler(org.xml.sax.XMLReader parser, java.lang.String tag, ITaggedHandler<? extends T> elementHandler)
          Creates a new CDATA handler with the specified parser and tag.
 
Method Summary
 boolean allowsNullElements()
          Returns the status of the allowNullElements flag: true if null elements are currently allowed; false otherwise.
 void clearLocal()
          Subclasses may override this method to add code to be invoked when MappedHandler.clear() is called.
 java.util.List<T> doGetElement()
          If subclasses intend to use the MappedHandler.getElement() method, they should override this method to provide the code that constructs the object corresponding to the tagged block.
protected  void initHandlerMap(java.util.Map<java.lang.String,org.xml.sax.ContentHandler> map)
          Adds handlers to the element map.
 void setAllowNullElements(boolean value)
          Sets whether this handler allows null elements in its list, or whether it will throw an exception when null elements are encountered.
 
Methods inherited from class edu.mit.jverbnet.util.parse.MappedHandler
checkParserSet, clear, endElement, endTaggedBlock, getDocumentLocator, getElement, getHandlerMappings, getParent, getParser, getTag, getTaggedBlockTasks, handleUnmappedEndElement, handleUnmappedStartElement, isInsideTaggedBlock, reportWarning, reportWarnings, setDocumentLocator, setParent, setParser, setReportWarnings, startElement, startTaggedBlock
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xml.sax.ContentHandler
characters, endDocument, endPrefixMapping, ignorableWhitespace, processingInstruction, skippedEntity, startDocument, startPrefixMapping
 

Constructor Detail

ListHandler

public ListHandler(java.lang.String tag,
                   ITaggedHandler<? extends T> elementHandler)
Creates a new CDATA handler with the specified tag.

Parameters:
tag - the tag for the block that this handler handles; may not be null, empty, or all whitespace.
elementHandler - the handler for the elements of the list
Throws:
java.lang.NullPointerException - if the specified tag is null
java.lang.IllegalArgumentException - if the specified tag is empty or all whitespace
Since:
JVerbnet 1.0.0

ListHandler

public ListHandler(org.xml.sax.XMLReader parser,
                   java.lang.String tag,
                   ITaggedHandler<? extends T> elementHandler)
Creates a new CDATA handler with the specified parser and tag.

Parameters:
parser - the parser for this handler; may be null
tag - the tag for the block that this handler handles; may not be null, empty, or all whitespace.
elementHandler - the handler for the elements of the list
Throws:
java.lang.NullPointerException - if the specified tag is null
java.lang.IllegalArgumentException - if the specified tag is empty or all whitespace
Since:
JVerbnet 1.0.0

ListHandler

public ListHandler(IHasParserHandler parent,
                   java.lang.String tag,
                   ITaggedHandler<? extends T> elementHandler)
Creates a new CDATA handler with the specified parent and tag.

Parameters:
parent - the parent for this handler; may be null
tag - the tag for the block that this handler handles; may not be null, empty, or all whitespace.
elementHandler - the handler for the elements of the list
Throws:
java.lang.NullPointerException - if the specified tag is null
java.lang.IllegalArgumentException - if the specified tag is empty or all whitespace
Since:
JVerbnet 1.0.0

ListHandler

public ListHandler(org.xml.sax.XMLReader parser,
                   org.xml.sax.ContentHandler parent,
                   java.lang.String tag,
                   ITaggedHandler<? extends T> elementHandler)
Creates a new CDATA handler with the specified parser, parent and tag.

Parameters:
parser - the parser for this handler; may be null
parent - this handler's parent; may be null
tag - the tag for the block that this handler handles; may not be null, empty, or all whitespace.
elementHandler - the handler for the elements of the list
Throws:
java.lang.NullPointerException - if the specified tag is null
java.lang.IllegalArgumentException - if the specified tag is empty or all whitespace
Since:
JVerbnet 1.0.0
Method Detail

initHandlerMap

protected void initHandlerMap(java.util.Map<java.lang.String,org.xml.sax.ContentHandler> map)
Description copied from class: MappedHandler
Adds handlers to the element map. Subclasses may override this to provide handlers for different tags.

Overrides:
initHandlerMap in class MappedHandler<java.util.List<T>>
Parameters:
map - the map to which handlers should be added

clearLocal

public void clearLocal()
Description copied from class: MappedHandler
Subclasses may override this method to add code to be invoked when MappedHandler.clear() is called.

Overrides:
clearLocal in class MappedHandler<java.util.List<T>>

setAllowNullElements

public void setAllowNullElements(boolean value)
Sets whether this handler allows null elements in its list, or whether it will throw an exception when null elements are encountered.

Parameters:
value - true if null elements are allowed; false otherwise
Since:
JVerbnet 1.0.0

allowsNullElements

public boolean allowsNullElements()
Returns the status of the allowNullElements flag: true if null elements are currently allowed; false otherwise.

Returns:
true if null elements are allowed; false otherwise
Since:
JVerbnet 1.0.0

doGetElement

public java.util.List<T> doGetElement()
Description copied from class: MappedHandler
If subclasses intend to use the MappedHandler.getElement() method, they should override this method to provide the code that constructs the object corresponding to the tagged block.

Overrides:
doGetElement in class MappedHandler<java.util.List<T>>
Returns:
the object corresponding to the tagged block


Copyright © 2012 ${project.organization.name}. All Rights Reserved.