## org.biojava.bio.seq.io.agave
Class StAXFeatureHandler

    java.lang.Object
      org.biojava.bio.seq.io.agave.StAXContentHandlerBase
          org.biojava.bio.seq.io.agave.StAXFeatureHandler

All Implemented Interfaces:
  StAXContentHandler

Direct Known Subclasses:
  AGAVEAssemblyHandler, AGAVEBioSeqHandler, AGAVEBioSequenceHandler, AGAVECdsHandler, AGAVEChromosomeHandler, AGAVEClassificationHandler, AGAVECompResultHandler, AGAVEComputationHandler, AGAVEContigHandler, AGAVEEvidenceHandler, AGAVEFragmentOrderHandler, AGAVEFragmentOrientationHandler, AGAVEGeneHandler, AGAVEHandler, AGAVEMrnaHandler, AGAVEPredictedProteinHandler, AGAVEQueryRegionPropHandler, AGAVEResultGroupHandler, AGAVESeqFeatureHandler, AGAVESeqMapHandler, AGAVETranscriptHandler, AGAVEUnorderedFragmentsHandler

    public class StAXFeatureHandler

extends StAXContentHandlerBase

StAX handler shamelessly ripped off from Thomas Down's XFFFeatureSetHandler. It was modified for greater generality. NOTE This class is not thread-safe -- it must only be used for one parse at any time.

Because AGAVE has nested feature and each feature must attached to some parent feature-holder in biojava, which means we need to generate parents first, so we have to keep the tree structure of features in memory, which is really bad. anyway, we still saved a lot of memory compared with DOM tree . Hanning Ni)

Author:
  copied from Thomas Down, copied from David Huen, Hanning Ni Doubletwist Inc

Field Summary
`protected SimpleAnnotation` `annot`
`protected List` `callbackStack` this is the stack of handler objects for the current feature.
`protected int` `endLoc`
`protected SeqIOListener` `featureListener`
`protected Feature.Template` `featureTemplate`
`protected String` `myLocalName`
`protected int` `stackLevel`
`protected int` `startLoc`
`protected StAXFeatureHandler` `staxenv`
`protected List` `subFeatures`

Method Summary
`protected void` `addFeatureToSequence(Sequence seq)`
`protected void` `addHandler(ElementRecognizer rec, StAXHandlerFactory handler)`
`protected Feature.Template` `createTemplate()` generates a very basic Template for the feature with SmallAnnotation in the annotation field.
`void` `endElement(String nsURI, String localName, String qName, StAXContentHandler handler)` Handles basic exit processing.
`void` `endElementHandler(String nsURI, String localName, String qName, StAXContentHandler handler)` Element specific exit handler Subclass to do anything useful.
`SeqIOListener` `getFeatureListener()` Return current feature listener
`protected ListIterator` `getHandlerStackIterator(int level)` return iterator to callbackStack
`protected int` `getLevel()` return current stack level.
`protected void` `pop()` pop a StAXContentHandler off the stack.
`protected void` `push(StAXContentHandler handler)` Push StAXContentHandler object onto stack
`protected void` `realizeSubFeatures(Feature feature)` recursively attach children features to parent
`void` `setFeatureListener(SeqIOListener siol)`
`void` `setHandlerCharacteristics(String localName, boolean hasCallback)` Sets the element name that the class responds to.
`protected void` `setProperty(String name, String value, boolean forFeature)`
`void` `startElement(String nsURI, String localName, String qName, Attributes attrs, DelegationManager dm)` Handles basic entry processing for all feature handlers.
`void` `startElementHandler(String nsURI, String localName, String qName, Attributes attrs)` Element-specific handler.

Methods inherited from class org.biojava.bio.seq.io.agave.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

### myLocalName

    protected String myLocalName

### featureTemplate

    protected Feature.Template featureTemplate

### staxenv

    protected StAXFeatureHandler staxenv

### featureListener

    protected SeqIOListener featureListener

### startLoc

    protected int startLoc

### endLoc

    protected int endLoc

### callbackStack

    protected List callbackStack

  this is the stack of handler objects for the current feature. The base value is the FeatureHandler itself. your feature and property handlers place and remove themselves from this stack. the purpose of all this is to implement context sensitivty for property handlers translucently. Property handlers can pop the stack for other handlers that implement interfaces that process that element. This way the context code is within the object that defines that context rather than in a child property handler.

### stackLevel

    protected int stackLevel

### subFeatures

    protected List subFeatures

### annot

    protected SimpleAnnotation annot

Method Detail

### setHandlerCharacteristics

    public void setHandlerCharacteristics(String localName,
                                          boolean hasCallback)

  Sets the element name that the class responds to.

### setFeatureListener

    public void setFeatureListener(SeqIOListener siol)

### addHandler

    protected void addHandler(ElementRecognizer rec,
                              StAXHandlerFactory handler)

### createTemplate

    protected Feature.Template createTemplate()

  generates a very basic Template for the feature with SmallAnnotation in the annotation field.

  Override if you wish a more specialised Template.

### realizeSubFeatures

    protected void realizeSubFeatures(Feature feature)

  recursively attach children features to parent

### addFeatureToSequence

    protected void addFeatureToSequence(Sequence seq)
                                 throws Exception

  Throws:
    `Exception`

### getLevel

    protected int getLevel()

  return current stack level. Remember that the stack level is incremented/decremented AFTER the push()/pop() calls and superclass startElement()/StopElement calls.

### getHandlerStackIterator

    protected ListIterator getHandlerStackIterator(int level)

  return iterator to callbackStack

### push

    protected void push(StAXContentHandler handler)

  Push StAXContentHandler object onto stack

### pop

    protected void pop()

  pop a StAXContentHandler off the stack.

### getFeatureListener

    public SeqIOListener getFeatureListener()

  Return current feature listener

### setProperty

    protected void setProperty(String name,
                               String value,
                               boolean forFeature)

### startElementHandler

    public void startElementHandler(String nsURI,
                                    String localName,
                                    String qName,
                                    Attributes attrs)
                             throws SAXException

  Element-specific handler. Subclass this to do something useful!

  Throws:
    `SAXException`

### startElement

    public void startElement(String nsURI,
                             String localName,
                             String qName,
                             Attributes attrs,
                             DelegationManager dm)
                      throws SAXException

  Handles basic entry processing for all feature handlers.

  Specified by:
    `startElement` in interface `StAXContentHandler`
  Overrides:
    `startElement` in class `StAXContentHandlerBase`
  Throws:
    `SAXException`

### endElementHandler

    public void endElementHandler(String nsURI,
                                  String localName,
                                  String qName,
                                  StAXContentHandler handler)
                           throws SAXException

  Element specific exit handler Subclass to do anything useful.

  Throws:
    `SAXException`

### endElement

    public void endElement(String nsURI,
                           String localName,
                           String qName,
                           StAXContentHandler handler)
                    throws SAXException

  Handles basic exit processing.

  Specified by:
    `endElement` in interface `StAXContentHandler`
  Overrides:
    `endElement` in class `StAXContentHandlerBase`
  Throws:
    `SAXException`