Package org.biojava.bio.program.xff
Class FeatureHandler
java.lang.Object
org.biojava.utils.stax.StAXContentHandlerBase
org.biojava.bio.program.xff.FeatureHandler
- All Implemented Interfaces:
StAXContentHandler
- Direct Known Subclasses:
StrandedFeatureHandler
StAX handler for the basic
feature
type of XFF.
This class can also be subclassed to handle other XFF types.
In general, to handle a feature
subclass, you will
with to:
- If necessary, override createFeatureTemplate to build the appropriate BioJava Feature.Template
- Add your own
startElement
andendElement
methods which handle extra extra elements in your feature type. These should normally pass on all the standard elements tosuper.startElement
andsuper.endElement
.
Note that, since FeatureHandler
does some basic housekeeping,
if you `consume' a startElement notification (i.e. don't pass it on to the
superclass) you must also consume the matching endElement. Since FeatureHandler
silently ignores all unrecognized elements, it is usually safe to pass on
all startElement and endElement notifications -- even those which are specific
to your feature type.
- Since:
- 1.2
- Author:
- Thomas Down
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFeatureHandler
(XFFFeatureSetHandler xffenv) Construct a new Feature handler, passing in an XFF-parsing environment. -
Method Summary
Modifier and TypeMethodDescriptionprotected Feature.Template
Create a new template of the appropriate type.void
endElement
(String nsURI, String localName, String qName, StAXContentHandler handler) StAX callback for element ends.protected void
Fire the endFeature event.protected void
Fire the startFeature event.protected Feature.Template
Get the template for the feature being constructed.protected StAXContentHandler
protected StAXContentHandler
protected StAXContentHandler
protected StAXContentHandler
Return the XFF processing environment passed in when this handler was created.protected void
setFeatureProperty
(Object key, Object value) Set a property.void
startElement
(String nsURI, String localName, String qName, Attributes attrs, DelegationManager dm) StAX callback for element starts.Methods inherited from class org.biojava.utils.stax.StAXContentHandlerBase
characters, endPrefixMapping, endTree, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startPrefixMapping, startTree
-
Field Details
-
FEATURE_HANDLER_FACTORY
-
-
Constructor Details
-
FeatureHandler
Construct a new Feature handler, passing in an XFF-parsing environment.
-
-
Method Details
-
getXFFEnvironment
Return the XFF processing environment passed in when this handler was created. -
getFeatureTemplate
Get the template for the feature being constructed. This should usually not be overridden. Delegates tocreateFeatureTemplate
for template construction. -
createFeatureTemplate
Create a new template of the appropriate type. Override this method if you wish to use a template type other than Feature.Template. -
fireStartFeature
Fire the startFeature event. You should wrap this method if you want to perform any validation on the Feature.Template before the startFeature is fired.- Throws:
ParseException
- if the startFeature notification fails, or if it has already been made.
-
fireEndFeature
Fire the endFeature event.- Throws:
ParseException
-
setFeatureProperty
protected void setFeatureProperty(Object key, Object value) throws ChangeVetoException, ParseException Set a property. If the startFeature notification has not yet been fired, the property is added directly to the annotation bundle in the feature template, otherwise an addFeatureProperty event is generated.- Throws:
ChangeVetoException
ParseException
-
startElement
public void startElement(String nsURI, String localName, String qName, Attributes attrs, DelegationManager dm) throws SAXException StAX callback for element starts. Wrap this method to handle extra elements within your own feature types.- Specified by:
startElement
in interfaceStAXContentHandler
- Overrides:
startElement
in classStAXContentHandlerBase
- Throws:
SAXException
-
endElement
public void endElement(String nsURI, String localName, String qName, StAXContentHandler handler) throws SAXException StAX callback for element ends. Wrap this method to handle extra elements within your own feature types.- Specified by:
endElement
in interfaceStAXContentHandler
- Overrides:
endElement
in classStAXContentHandlerBase
- Throws:
SAXException
-
getTypeHandler
-
getSourceHandler
-
getOldIDHandler
-
getLocationHandler
-