public class ReparentContext extends Object implements ProjectionContext, Serializable
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.
| Constructor and Description |
|---|
ReparentContext(FeatureHolder parent,
FeatureHolder wrapped) |
| Modifier and Type | Method and Description |
|---|---|
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.
|
public ReparentContext(FeatureHolder parent, FeatureHolder wrapped)
public final FeatureHolder getParent()
public final FeatureHolder getUnprojectedFeatures()
ProjectionContextIf you are projecting all the features in some feature holder, that is what this method should return.
getUnprojectedFeatures in interface ProjectionContextpublic Feature projectFeature(Feature feat)
ProjectedFeatureHolder.projectFeature in interface ProjectionContextfeat - the Feature to projectpublic Feature revertFeature(Feature feat)
ProjectionContextThis 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.
revertFeature in interface ProjectionContextfeat - the Feature to un-projectpublic final FeatureFilter projectFilter(FeatureFilter ff)
ProjectionContextprojectFilter in interface ProjectionContextff - the FeatureFilter to transformpublic final FeatureFilter revertFilter(FeatureFilter ff)
ProjectionContextrevertFilter in interface ProjectionContextff - the FeatureFilter to transformprotected FilterUtils.FilterTransformer getTransformer()
protected FilterUtils.FilterTransformer getReverter()
public final FeatureHolder getParent(Feature f)
getParent in interface ProjectionContextpublic final Sequence getSequence(Feature f)
ProjectionContext
This will be the return value of projFeat.getParent().
getSequence in interface ProjectionContextf - the projected Featurepublic FeatureHolder projectChildFeatures(Feature f, FeatureHolder parent)
ProjectionContextprojectChildFeatures in interface ProjectionContextf - the Feature to project all children ofparent - the new parent feature holderpublic final Feature createFeature(Feature.Template projTempl) throws BioException, ChangeVetoException
ProjectionContextYou 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.
createFeature in interface ProjectionContextprojTempl - the Feature.Template to instantiateBioException - if there was a problem instantiating the templateChangeVetoException - if the feature creation was vetoedpublic final void removeFeature(Feature dyingChild) throws BioException, ChangeVetoException
ProjectionContextremoveFeature in interface ProjectionContextdyingChild - a projected feature to removeBioException - if there is an error removing the featureChangeVetoException - if the removal of the feature was vetoedpublic final Feature createFeature(Feature f, Feature.Template projTempl) throws BioException, ChangeVetoException
ProjectionContextSee the notes for @link createFeature(Feature.Template) for implementation advice.
createFeature in interface ProjectionContextf - the parent for the newly created featureprojTempl - the Feature.Template specifying the new featureBioException - if there was a problem creating the featureChangeVetoException - if the creation of the feature was vetoedpublic final void removeFeature(Feature f, Feature f2) throws ChangeVetoException, BioException
ProjectionContextremoveFeature in interface ProjectionContextf - the projected parent Featuref2 - the child Feature to removeChangeVetoException - if the removal of the feature was vetoedBioExceptionpublic final FeatureFilter getSchema(Feature f)
public final void addChangeListener(Feature f, ChangeListener cl, ChangeType ct)
ProjectionContextaddChangeListener in interface ProjectionContextf - the projected Feature to add the listener forcl - the ChangeListener to addct - the ChangeType to register it forpublic final void removeChangeListener(Feature f, ChangeListener cl, ChangeType ct)
ProjectionContextremoveChangeListener in interface ProjectionContextf - the projected Feature to remove the listener forcl - the ChangeListener to removect - the ChangeType it is registered forpublic final FeatureHolder projectFeatures(FeatureHolder fh)
ProjectionContextWarning: 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.
projectFeatures in interface ProjectionContextfh - the FeatureHolder containing the features to projectCopyright © 2014 BioJava. All rights reserved.