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
public class FeatureHandler extends StAXContentHandlerBase
StAX handler for the basicfeaturetype of XFF. This class can also be subclassed to handle other XFF types.In general, to handle a
featuresubclass, you will with to:- If necessary, override createFeatureTemplate to build the appropriate BioJava Feature.Template
- Add your own
startElementandendElementmethods which handle extra extra elements in your feature type. These should normally pass on all the standard elements tosuper.startElementandsuper.endElement.
Note that, since
FeatureHandlerdoes 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 Modifier and Type Field Description static XFFPartHandlerFactoryFEATURE_HANDLER_FACTORY
-
Constructor Summary
Constructors Constructor Description FeatureHandler(XFFFeatureSetHandler xffenv)Construct a new Feature handler, passing in an XFF-parsing environment.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Feature.TemplatecreateFeatureTemplate()Create a new template of the appropriate type.voidendElement(String nsURI, String localName, String qName, StAXContentHandler handler)StAX callback for element ends.protected voidfireEndFeature()Fire the endFeature event.protected voidfireStartFeature()Fire the startFeature event.protected Feature.TemplategetFeatureTemplate()Get the template for the feature being constructed.protected StAXContentHandlergetLocationHandler()protected StAXContentHandlergetOldIDHandler()protected StAXContentHandlergetSourceHandler()protected StAXContentHandlergetTypeHandler()XFFFeatureSetHandlergetXFFEnvironment()Return the XFF processing environment passed in when this handler was created.protected voidsetFeatureProperty(Object key, Object value)Set a property.voidstartElement(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 Detail
-
FEATURE_HANDLER_FACTORY
public static final XFFPartHandlerFactory FEATURE_HANDLER_FACTORY
-
-
Constructor Detail
-
FeatureHandler
public FeatureHandler(XFFFeatureSetHandler xffenv)
Construct a new Feature handler, passing in an XFF-parsing environment.
-
-
Method Detail
-
getXFFEnvironment
public XFFFeatureSetHandler getXFFEnvironment()
Return the XFF processing environment passed in when this handler was created.
-
getFeatureTemplate
protected Feature.Template getFeatureTemplate()
Get the template for the feature being constructed. This should usually not be overridden. Delegates tocreateFeatureTemplatefor template construction.
-
createFeatureTemplate
protected Feature.Template 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
protected void fireStartFeature() throws ParseException
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
protected void fireEndFeature() throws ParseException
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:
ChangeVetoExceptionParseException
-
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:
startElementin interfaceStAXContentHandler- Overrides:
startElementin 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:
endElementin interfaceStAXContentHandler- Overrides:
endElementin classStAXContentHandlerBase- Throws:
SAXException
-
getTypeHandler
protected StAXContentHandler getTypeHandler()
-
getSourceHandler
protected StAXContentHandler getSourceHandler()
-
getOldIDHandler
protected StAXContentHandler getOldIDHandler()
-
getLocationHandler
protected StAXContentHandler getLocationHandler()
-
-