ProgramixGenericLib v5.0.1

com.programix.saxplus
Class BaseTagHandler

java.lang.Object
  extended by com.programix.saxplus.BaseTagHandler
All Implemented Interfaces:
TagHandler
Direct Known Subclasses:
SimpleTagHandler

public abstract class BaseTagHandler
extends Object
implements TagHandler

Implements all methods of TagHandler and can serve as a class to extend for your TagHandler's. In your subclass, just override the methods that you are interested in.

BaseTagHandler also supports a name-handler mapping for all of the sub-tags of a tag (see setSubTagHandler(String, TagHandler) and setSubTagHandler(NameDetail, TagHandler)). Therefore, the implementation of startSubTag(NameDetail) rarely needs to be overridden.

Author:
Paul Hyde

Constructor Summary
protected BaseTagHandler()
           
 
Method Summary
 void endSubTag(NameDetail subTagName, Value subTagResult)
          Called after a sub tag has completed.
 void endTag()
           
 Value getResult()
          This implementation returns ValueFactory.NULL_INSTANCE.
protected  TagHandler getSubTagHandler(NameDetail tagName)
          Pulls of the plain name (using NameDetail.getName()) and calls getSubTagHandler(String).
protected  TagHandler getSubTagHandler(String tagName)
          Returns the handler for the specified tag, or null if no handler is found for the name.
protected  void setSubTagHandler(NameDetail tagName, TagHandler handler)
          Pulls of the plain name (using NameDetail.getName()) and calls setSubTagHandler(String, TagHandler).
protected  void setSubTagHandler(String tagName, TagHandler handler)
           
 TagHandler startSubTag(NameDetail subTagName)
          This implementation returns whatever getSubTagHandler(NameDetail) finds for the specified sub tag.
 void startTag(NameDetail tagName, AttributeGroup attr)
           
 void text(Value tagText)
          Delivers textual content within this tag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseTagHandler

protected BaseTagHandler()
Method Detail

setSubTagHandler

protected void setSubTagHandler(String tagName,
                                TagHandler handler)

setSubTagHandler

protected void setSubTagHandler(NameDetail tagName,
                                TagHandler handler)
Pulls of the plain name (using NameDetail.getName()) and calls setSubTagHandler(String, TagHandler).


getSubTagHandler

protected TagHandler getSubTagHandler(String tagName)
Returns the handler for the specified tag, or null if no handler is found for the name.


getSubTagHandler

protected TagHandler getSubTagHandler(NameDetail tagName)
Pulls of the plain name (using NameDetail.getName()) and calls getSubTagHandler(String).


startTag

public void startTag(NameDetail tagName,
                     AttributeGroup attr)
              throws SAXException
Specified by:
startTag in interface TagHandler
Throws:
SAXException

endTag

public void endTag()
            throws SAXException
Specified by:
endTag in interface TagHandler
Throws:
SAXException

text

public void text(Value tagText)
          throws SAXException
Description copied from interface: TagHandler
Delivers textual content within this tag. If this tag has no sub tags, then this method is called at most once. If this tag is empty or has no text other than whitespace, this method is not called. If this tag has sub tags and only whitespace between the sub tags, this method is not called. If there is a mixture of (non-whitespace) text and sub tags, this method is called multiple times.

For example:

 <apple>
     <excellent>Red Delicious</excellent>
     <good>Granny Smith</good>
 </apple>
 <fresh value="yes" />
 <mango>
      </mango>
 <story>They are <bold>very</bold> tasty.</story>
 
The text() method is called:

Specified by:
text in interface TagHandler
Throws:
SAXException

startSubTag

public TagHandler startSubTag(NameDetail subTagName)
                       throws SAXException
This implementation returns whatever getSubTagHandler(NameDetail) finds for the specified sub tag. If no sub tag handler is found, then null is returned, indicating that the sub tag is ignored. Overridden by subclasses as appropriate.

Specified by:
startSubTag in interface TagHandler
Throws:
SAXException

endSubTag

public void endSubTag(NameDetail subTagName,
                      Value subTagResult)
               throws SAXException
Description copied from interface: TagHandler
Called after a sub tag has completed.

Specified by:
endSubTag in interface TagHandler
Throws:
SAXException

getResult

public Value getResult()
                throws SAXException
This implementation returns ValueFactory.NULL_INSTANCE. Overridden by subclasses as appropriate.

Specified by:
getResult in interface TagHandler
Returns:
the value calculated, never null.
Throws:
SAXException - if the result can not be assembled (e.g. a required piece of data is missing).

ProgramixGenericLib v5.0.1

Copyright © 2001-2009 Programix Incorporated. All rights reserved. ProgramixGenericLib is free and is OSI Certified Open Source Software under the BSD license.