|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.biopax.paxtools.controller.Traverser
org.biopax.paxtools.controller.AbstractTraverser
org.biopax.paxtools.controller.PropertyReasoner
public class PropertyReasoner
A tool to set or infer a particular BioPAX property for an object and all its children. For best (consistent) results, it's recommended to generally start from a "root" element, or, at least, - the parent-most one that have given propertyName. However, for some (if not - most) BioPAX properties, except for, e.g., 'dataSource', 'xref', 'organism', 'cellularLocation', - using of this tool does NOT make sense; i.e., one should not normally "infer" (apply to children elements) such properties as 'displayName', 'ph', 'nextStep' (for sure!), etc.. Tip: use with care; write tests for your case!
| Field Summary |
|---|
| Fields inherited from class org.biopax.paxtools.controller.Traverser |
|---|
editorMap, filters, log, visitor |
| Constructor Summary | |
|---|---|
PropertyReasoner(java.lang.String property,
EditorMap editorMap)
Constructor, which additionally sets a BioPAX property filter for traverse(BioPAXElement, Model) to call
visit(Object, BioPAXElement, Model, PropertyEditor)
for each *object* property, except for 'nextStep'. |
|
PropertyReasoner(java.lang.String propertyName,
EditorMap editorMap,
Filter<PropertyEditor>... propertyFilters)
|
|
| Method Summary | |
|---|---|
void |
clearProperty(BioPAXElement element)
For the element and its children, where it's desired (in domains) and possible,
it sets the propertyName values to "unknown". |
java.lang.String |
getPropertyName()
|
void |
inferPropertyValue(BioPAXElement element)
For the element and its children, where it's empty, desired (in domains) and allowed,
it adds or sets the propertyName from parents's
(if they have any valueStack) |
void |
inferPropertyValue(BioPAXElement element,
java.lang.Object addValue)
For the element and its children, where it's empty, desired (in domains) and allowed,
it adds or sets the propertyName from parents's
(if the top-most, a parent element that has this propertyName,
does not have any valueStack, then given valueStack will be set, and
children may inherit it) |
boolean |
isGenerateComments()
|
boolean |
isOverride()
|
void |
resetPropertyValue(BioPAXElement element,
java.lang.Object defaultValue)
For the element and its children, where it's desired (in domains) and allowed (by BioPAX),
it forces the given propertyName valueStack replace existing ones. |
protected void |
run(BioPAXElement element,
java.lang.Object defaultValue)
Basic, universal method (used by others in this class) - updates the propertyName valueStack of a BioPAX element
and its children. |
void |
setDomains(java.lang.Class<? extends BioPAXElement>... domains)
When set (not empty list), only instances of the listed types can be updated by run(BioPAXElement, Object) method, although the
propertyName property valueStack of every element (where apply)
can be still considered for its children (of the specified type). |
void |
setGenerateComments(boolean generateComments)
|
protected void |
setOverride(boolean override)
Sets the override mode. |
void |
setPropertyName(java.lang.String propertyName)
|
void |
traverse(BioPAXElement bpe,
Model model)
This traverse method, first, takes care about the propertyName we are interested in, then proceeds-
as the basic Traverser.traverse(BioPAXElement, Model)
would normally do (i.e., - delivering to the method
visit(Object, BioPAXElement, Model, PropertyEditor)
for all properties without any predefined order). |
protected void |
visit(java.lang.Object range,
BioPAXElement bpe,
Model model,
PropertyEditor editor)
Simply, calls traverse(BioPAXElement, Model)
and goes deeper when the propertyName's range/valueStack is a BioPAX object. |
| Methods inherited from class org.biopax.paxtools.controller.AbstractTraverser |
|---|
getVisited, visit |
| Methods inherited from class org.biopax.paxtools.controller.Traverser |
|---|
filter, getVisitor, setVisitor |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PropertyReasoner(java.lang.String propertyName,
EditorMap editorMap,
Filter<PropertyEditor>... propertyFilters)
public PropertyReasoner(java.lang.String property,
EditorMap editorMap)
traverse(BioPAXElement, Model) to call
visit(Object, BioPAXElement, Model, PropertyEditor)
for each *object* property, except for 'nextStep'.
property - editorMap - | Method Detail |
|---|
public java.lang.String getPropertyName()
public void setPropertyName(java.lang.String propertyName)
propertyName - the BioPAX property name to usepublic void setDomains(java.lang.Class<? extends BioPAXElement>... domains)
run(BioPAXElement, Object) method, although the
propertyName property valueStack of every element (where apply)
can be still considered for its children (of the specified type).
domains - (optional) the types to modify (others won't be affected)public boolean isOverride()
setOverride(boolean),
run(BioPAXElement, Object)protected void setOverride(boolean override)
override mode.
Following the A,B,C example in the run(BioPAXElement, Object)
method:
- when override is true, and propertyName is
a functional BioPAX property: A, B and C all get the X valueStack
TODO ???(if default valueStack was null, otherwise - they get the default valueStack).
- when override is false, and propertyName is
a functional BioPAX property: A, B - stay unmodified, C acquires Y valueStack (B's).
- when override is false, and propertyName is
a multiple cardinality property: - B and C will have both X and Y values!
override - the override mode to set (see the above explanation)run(BioPAXElement, Object)public boolean isGenerateComments()
public void setGenerateComments(boolean generateComments)
generateComments - true/false to generate BioPAX comments on all changes
public void traverse(BioPAXElement bpe,
Model model)
propertyName we are interested in, then proceeds-
as the basic Traverser.traverse(BioPAXElement, Model)
would normally do (i.e., - delivering to the method
visit(Object, BioPAXElement, Model, PropertyEditor)
for all properties without any predefined order).
traverse in class Traverserbpe - BioPAX element to be traversedmodel - to be traversed, but not necessarily (depends on the Visitor implementation).
protected void visit(java.lang.Object range,
BioPAXElement bpe,
Model model,
PropertyEditor editor)
traverse(BioPAXElement, Model)
and goes deeper when the propertyName's range/valueStack is a BioPAX object.
visit in class AbstractTraverserrange - is property valuebpe - is parent BioPAX elementeditor - is the property editor
protected void run(BioPAXElement element,
java.lang.Object defaultValue)
propertyName valueStack of a BioPAX element
and its children. The root element (first parameter) does not
necessarily have the propertyName though.
For example, if X is the propertyName valueStack of A; Y - of B;
and C has unknown valueStack; and A has "child" B, which in turn has C
(not necessarily immediate); and A, B, C are instances of
one of classes listed in domains (if any), then
the following results are expected
(note: even if, e.g., B would not pass the domains filter,
the results for A and C will be the same):
- valueStack X will be considered a replacement/addition to Y for B,
and both X and Y - for C. The result depends on override,
the default valueStack and the propertyName's cardinality.
A default valueStack (or a Set or values, object or primitive)
is to apply when both current and parent's propertyName values are
yet unknown. However, if override is true, the default
valueStack, if given, will unconditionally replace all existing.
Warning: when defaultValue is null or empty set, and override==true,
it will clear the propertyName values of all corresponding elements.
element - defaultValue - a default valueStack or set of valuessetDomains(Class...),
setOverride(boolean)public void clearProperty(BioPAXElement element)
domains) and possible,
it sets the propertyName values to "unknown".
element - run(BioPAXElement, Object)
public void resetPropertyValue(BioPAXElement element,
java.lang.Object defaultValue)
domains) and allowed (by BioPAX),
it forces the given propertyName valueStack replace existing ones.
element - defaultValue - run(BioPAXElement, Object)
public void inferPropertyValue(BioPAXElement element,
java.lang.Object addValue)
domains) and allowed,
it adds or sets the propertyName from parents's
(if the top-most, a parent element that has this propertyName,
does not have any valueStack, then given valueStack will be set, and
children may inherit it)
element - addValue - run(BioPAXElement, Object)public void inferPropertyValue(BioPAXElement element)
domains) and allowed,
it adds or sets the propertyName from parents's
(if they have any valueStack)
element - run(BioPAXElement, Object)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||