Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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 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` and `endElement` methods which handle extra extra elements in your feature type. These should normally pass on all the standard elements to `super.startElement` and `super.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
`static XFFPartHandlerFactory` | `FEATURE_HANDLER_FACTORY`

Constructor Summary
`FeatureHandler(XFFFeatureSetHandler xffenv)` Construct a new Feature handler, passing in an XFF-parsing environment.

Method Summary
`protected Feature.Template` | `createFeatureTemplate()` 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` | `fireEndFeature()` Fire the endFeature event.
`protected void` | `fireStartFeature()` Fire the startFeature event.
`protected Feature.Template` | `getFeatureTemplate()` Get the template for the feature being constructed.
`protected StAXContentHandler` | `getLocationHandler()`
`protected StAXContentHandler` | `getOldIDHandler()`
`protected StAXContentHandler` | `getSourceHandler()`
`protected StAXContentHandler` | `getTypeHandler()`
`XFFFeatureSetHandler` | `getXFFEnvironment()` 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`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

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 to `createFeatureTemplate` for 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:
    `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 interface `StAXContentHandler`
  Overrides:
    `startElement` in class `StAXContentHandlerBase`
  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 interface `StAXContentHandler`
  Overrides:
    `endElement` in class `StAXContentHandlerBase`
  Throws:
    `SAXException`

### getTypeHandler

    protected StAXContentHandler getTypeHandler()

### getSourceHandler

    protected StAXContentHandler getSourceHandler()

### getOldIDHandler

    protected StAXContentHandler getOldIDHandler()

### getLocationHandler

    protected StAXContentHandler getLocationHandler()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD