ReparentContext (BioJava-1.5-beta API)
Keywords: org.biojava.bio.seq.projection.ReparentContext class

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.seq.projection
Class ReparentContext

    java.lang.Object
      org.biojava.bio.seq.projection.ReparentContext

All Implemented Interfaces:
  Serializable, ProjectionContext

Direct Known Subclasses:
  SimpleGappedSequence.GappedContext, SubSequence.SubProjectedFeatureContext, TranslateFlipContext

    public class ReparentContext

extends Object
implements ProjectionContext, Serializable

A good base class to implement ProjectionContext from.

ReparentContext takes care of much of the ugliness of implementing ProjectionContext, such as handling listeners and grafting features onto a new parent. It also sets up a framework for mutating feature filters. Think carefully before overriding methods in this class.

Author:
  Matthew Pocock, Thomas Down
See Also:
  Serialized Form

Constructor Summary
`ReparentContext(FeatureHolder parent, FeatureHolder wrapped)`

Method Summary
`void` | `addChangeListener(Feature f, ChangeListener cl, ChangeType ct)` Add a ChangeListener to a projected feature.
`Feature` | `createFeature(Feature.Template projTempl)` Create a projected feature with properties matching the template.
`Feature` | `createFeature(Feature f, Feature.Template projTempl)` Create a new projected feature.
`FeatureHolder` | `getParent()`
`FeatureHolder` | `getParent(Feature f)`
`protected FilterUtils.FilterTransformer` | `getReverter()`
`FeatureFilter` | `getSchema(Feature f)`
`Sequence` | `getSequence(Feature f)` Get the sequence for a feature.
`protected FilterUtils.FilterTransformer` | `getTransformer()`
`FeatureHolder` | `getUnprojectedFeatures()` Get the features before projection.
`FeatureHolder` | `projectChildFeatures(Feature f, FeatureHolder parent)` Project all features that are children of feature so that they become children of parent.
`Feature` | `projectFeature(Feature feat)` Create a single projected feature using the rules of this `ProjectedFeatureHolder`.
`FeatureHolder` | `projectFeatures(FeatureHolder fh)` Project all of the features in a FeatureHolder.
`FeatureFilter` | `projectFilter(FeatureFilter ff)` Transform a filter on unprojected features so that it applies to projected features.
`void` | `removeChangeListener(Feature f, ChangeListener cl, ChangeType ct)` Remove a ChangeListener from a projected feature.
`void` | `removeFeature(Feature dyingChild)` Remove the dying child.
`void` | `removeFeature(Feature f, Feature f2)` Remove the dying child.
`Feature` | `revertFeature(Feature feat)` Unproject a feature.
`FeatureFilter` | `revertFilter(FeatureFilter ff)` Transform a filter on projected features so that it applies to unprojected features.

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

Constructor Detail

### ReparentContext

    public ReparentContext(FeatureHolder parent,
                           FeatureHolder wrapped)

Method Detail

### getParent

    public final FeatureHolder getParent()

### getUnprojectedFeatures

    public final FeatureHolder getUnprojectedFeatures()

  Description copied from interface: `ProjectionContext`
  Get the features before projection.

  If you are projecting all the features in some feature holder, that is what this method should return.

  Specified by:
    `getUnprojectedFeatures` in interface `ProjectionContext`
  Returns:
    the features before projection

### projectFeature

    public Feature projectFeature(Feature feat)

  Create a single projected feature using the rules of this `ProjectedFeatureHolder`.

  Specified by:
    `projectFeature` in interface `ProjectionContext`
  Parameters:
    `feat` - the Feature to project
  Returns:
    a Feature representing feat after being transformed by this context

### revertFeature

    public Feature revertFeature(Feature feat)

  Description copied from interface: `ProjectionContext`
  Unproject a feature.

  This is the inverse opperation to @link projectFeature().

  Note: The result of calling this method for a feature that is not projected through this context is not specified by this API, but it is reasonable to assume that bad things will happen.

  Specified by:
    `revertFeature` in interface `ProjectionContext`
  Parameters:
    `feat` - the Feature to un-project
  Returns:
    the unprojected feature

### projectFilter

    public final FeatureFilter projectFilter(FeatureFilter ff)

  Description copied from interface: `ProjectionContext`
  Transform a filter on unprojected features so that it applies to projected features.

  Specified by:
    `projectFilter` in interface `ProjectionContext`
  Parameters:
    `ff` - the FeatureFilter to transform
  Returns:
    the transformed FeatureFilter

### revertFilter

    public final FeatureFilter revertFilter(FeatureFilter ff)

  Description copied from interface: `ProjectionContext`
  Transform a filter on projected features so that it applies to unprojected features.

  Specified by:
    `revertFilter` in interface `ProjectionContext`
  Parameters:
    `ff` - the FeatureFilter to transform
  Returns:
    the transformed FeatureFilter

### getTransformer

    protected FilterUtils.FilterTransformer getTransformer()

### getReverter

    protected FilterUtils.FilterTransformer getReverter()

### getParent

    public final FeatureHolder getParent(Feature f)

  Specified by:
    `getParent` in interface `ProjectionContext`

### getSequence

    public final Sequence getSequence(Feature f)

  Description copied from interface: `ProjectionContext`
  Get the sequence for a feature.

  This will be the return value of `projFeat.getParent()`.

  Specified by:
    `getSequence` in interface `ProjectionContext`
  Parameters:
    `f` - the projected Feature
  Returns:
    the Sequence of the Feature

### projectChildFeatures

    public FeatureHolder projectChildFeatures(Feature f,
                                              FeatureHolder parent)

  Description copied from interface: `ProjectionContext`
  Project all features that are children of feature so that they become children of parent.

  Specified by:
    `projectChildFeatures` in interface `ProjectionContext`
  Parameters:
    `f` - the Feature to project all children of
    `parent` - the new parent feature holder
  Returns:
    a FeatureHolder containing projections of all children of feature so that f.getParent() is equal to parent

### createFeature

    public final Feature createFeature(Feature.Template projTempl)
                                throws BioException,
                                       ChangeVetoException

  Description copied from interface: `ProjectionContext`
  Create a projected feature with properties matching the template.

  You will probably implement this by delegating to the unprojected feature holder. It is imperative that the template properties are unprojected first so that when the newly created feature is projected, the properties match up.

  Not every projection context has fully reversible semantics. Use your discression and come up with a reasonable plan that causes least supprise to the user.

  Specified by:
    `createFeature` in interface `ProjectionContext`
  Parameters:
    `projTempl` - the Feature.Template to instantiate
  Returns:
    a new projected Feature matching the template as closely as possible
  Throws:
    `BioException` - if there was a problem instantiating the template
    `ChangeVetoException` - if the feature creation was vetoed

### removeFeature

    public final void removeFeature(Feature dyingChild)
                             throws BioException,
                                    ChangeVetoException

  Description copied from interface: `ProjectionContext`
  Remove the dying child.

  Specified by:
    `removeFeature` in interface `ProjectionContext`
  Parameters:
    `dyingChild` - a projected feature to remove
  Throws:
    `BioException` - if there is an error removing the feature
    `ChangeVetoException` - if the removal of the feature was vetoed

### createFeature

    public final Feature createFeature(Feature f,
                                       Feature.Template projTempl)
                                throws BioException,
                                       ChangeVetoException

  Description copied from interface: `ProjectionContext`
  Create a new projected feature.

  See the notes for @link createFeature(Feature.Template) for implementation advice.

  Specified by:
    `createFeature` in interface `ProjectionContext`
  Parameters:
    `f` - the parent for the newly created feature
    `projTempl` - the Feature.Template specifying the new feature
  Returns:
    a new ProjectedFeature that is a child of projParent
  Throws:
    `BioException` - if there was a problem creating the feature
    `ChangeVetoException` - if the creation of the feature was vetoed

### removeFeature

    public final void removeFeature(Feature f,
                                    Feature f2)
                             throws ChangeVetoException,
                                    BioException

  Description copied from interface: `ProjectionContext`
  Remove the dying child.

  Specified by:
    `removeFeature` in interface `ProjectionContext`
  Parameters:
    `f` - the projected parent Feature
    `f2` - the child Feature to remove
  Throws:
    `ChangeVetoException` - if the removal of the feature was vetoed
    `BioException`

### getSchema

    public final FeatureFilter getSchema(Feature f)

### addChangeListener

    public final void addChangeListener(Feature f,
                                        ChangeListener cl,
                                        ChangeType ct)

  Description copied from interface: `ProjectionContext`
  Add a ChangeListener to a projected feature.

  Specified by:
    `addChangeListener` in interface `ProjectionContext`
  Parameters:
    `f` - the projected Feature to add the listener for
    `cl` - the ChangeListener to add
    `ct` - the ChangeType to register it for

### removeChangeListener

    public final void removeChangeListener(Feature f,
                                           ChangeListener cl,
                                           ChangeType ct)

  Description copied from interface: `ProjectionContext`
  Remove a ChangeListener from a projected feature.

  Specified by:
    `removeChangeListener` in interface `ProjectionContext`
  Parameters:
    `f` - the projected Feature to remove the listener for
    `cl` - the ChangeListener to remove
    `ct` - the ChangeType it is registered for

### projectFeatures

    public final FeatureHolder projectFeatures(FeatureHolder fh)

  Description copied from interface: `ProjectionContext`
  Project all of the features in a FeatureHolder.

  Warning: The results of calling this method for features that are not in getUnprojectedFeatures() is not specified by this API, but it is reasonable to assume that bad things will happen.

  Specified by:
    `projectFeatures` in interface `ProjectionContext`
  Parameters:
    `fh` - the FeatureHolder containing the features to project
  Returns:
    a FeatureHolder containing all the features projected

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