@Entity public class PolytomousKeyNode extends VersionableEntity implements IMultiLanguageTextHolder
polytomous key
structure. The structure of such a key is a directed tree like acyclic graph
of PolytomousKeyNode
s.
A PolytomousKeyNode
represents both the node and the edges that lead
to this
node, therefore an extra class representing the edges
does not exist.
this
node is the statement
, attributes leading to the child nodes
are either the question
or the feature
.
While statements
are required, questions
and
features
are optional and do typically not exist in classical keys.
Both, questions
and features
, will be "answered" by the
statements
of the child nodes, where questions
are usually free text used in manually created keys while features
are
typically used in automatically created keys based on structured descriptive data.
Only one of them should be defined in a node. However, if both exist the question
should always be given priority over the feature
.taxon
. The later, if taken as part of the tree, are usually
the leaves of the represented tree like structure (taxonomically they are the
end point of the decision process).link to a taxon
.
In this case the taxonomic determination process may be either terminated
at the given taxon
or can proceed with the children if a more accurate
determination is wanted. This may be the case e.g. in a key that generally
covers all taxa of rank species and at the same time allows identification of
subspecies or varieties of these taxa.Other nodes
: another node
(with a different parent) of either the same key
or another key.
otherNode
represents a node
of the same tree the key does not represent a strict tree structure
anymore. However, as this is a rare case we will still use this term
at some places.Subkey
:subkey
) as a whole, which is
equal to an otherNode
link to the root node of the other key.
In this case the path in the decision graph spans over multiple keys.statements
for each such taxon (in all other cases - except for
root nodes - the statement
is required).
Applications that do visualize the key should handle such a node-subnode structure as one
node with multiple taxon links. This complicated data structure has been chosen for
this rare to avoid a more complicated List
structure for the standard
case.root node of the key
may represent the entry point
question or feature but does naturally neither have a statement nor a linked taxon as
there is no prior decision yet.
A polytomous key node can be referenced from multiple other nodes via the
otherNode
attribute of the other nodes. Therefore, though
we speek about a "decision tree" structure a node does not necessarily have only
one parent.
However, nodes are mainly represented in a tree structure and therefore do have
a defined parent
which is the "main" parent. But when implementing
visualizing or editing tools one should keep in mind that this parent may not be
the only node linking the child node.
CLOB_LENGTH, uuid
Modifier | Constructor and Description |
---|---|
protected |
PolytomousKeyNode()
Class constructor: creates a new empty feature node instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(PolytomousKeyNode child)
Adds the given polytomous key node at the end of the list of children of
this polytomous key node.
|
void |
addChild(PolytomousKeyNode child,
int index)
Inserts the given child node in the list of children of this
polytomous key node at the given (index + 1) position.
|
LanguageString |
addQuestionText(java.lang.String text,
Language language)
This is a convenience method to sets the question text for this node in
the given language.
|
LanguageString |
addStatementText(java.lang.String text,
Language language)
This is a convenience method to set the statement text for this node in
the given language.
|
int |
childCount()
Returns the number of children nodes of this feature node.
|
java.lang.Object |
clone()
Clones this PolytomousKeyNode.
|
PolytomousKeyNode |
getChildAt(int childIndex)
Returns the feature node placed at the given (childIndex + 1) position
within the list of
children of this feature
node. |
java.util.List<PolytomousKeyNode> |
getChildren()
Returns the (ordered) list of feature nodes which are children nodes of
this feature node.
|
Feature |
getFeature() |
int |
getIndex(PolytomousKeyNode node)
Returns the integer indicating the position of the given feature node
within the list of
children of this feature
node. |
PolytomousKey |
getKey() |
java.util.Map<Language,LanguageString> |
getModifyingText()
Returns the
MultilanguageText like "an unusual form of",
commenting the determined taxon. |
java.lang.Integer |
getNodeNumber()
The node number is the number of the node within the key.
|
PolytomousKeyNode |
getOtherNode()
A link to another sub-node, which has not *this*
node as primary parent.
|
PolytomousKeyNode |
getParent()
Returns the parent node of
this child. |
KeyStatement |
getQuestion()
Returns the question for
this PolytomousKeyNode. |
KeyStatement |
getStatement()
Returns the statement for
this PolytomousKeyNode. |
PolytomousKey |
getSubkey() |
Taxon |
getTaxon()
Returns the taxon this node links to.
|
boolean |
isLeaf()
Returns the boolean value indicating if this feature node has
children (false) or not (true).
|
static PolytomousKeyNode |
NewInstance()
Creates a new empty polytomous key node instance.
|
static PolytomousKeyNode |
NewInstance(java.lang.String statement)
Creates a new polytomous key node instance.
|
static PolytomousKeyNode |
NewInstance(java.lang.String statement,
java.lang.String question,
Taxon taxon,
Feature feature)
Creates a new polytomous key node instance.
|
LanguageString |
putModifyingText(LanguageString description)
|
LanguageString |
putModifyingText(Language language,
java.lang.String text)
|
void |
refreshNodeNumbering()
Refresh numbering of key nodes starting from root.
|
void |
removeChild(int index)
Removes the feature node placed at the given (index + 1) position from
the list of
children of this feature node. |
void |
removeChild(PolytomousKeyNode child)
Removes the given polytomous key node from the list of
children of this polytomous key node. |
LanguageString |
removeModifyingText(Language language)
|
void |
removeNullValueFromChildren() |
Taxon |
removeTaxon() |
void |
setFeature(Feature feature) |
void |
setKey(PolytomousKey key) |
void |
setNodeNumber(java.lang.Integer nodeNumber)
Is computed automatically and therefore should not be set by the user.
|
PolytomousKeyNode |
setOrAddTaxon(Taxon taxon)
Sets the taxon of this
PolytomousKeyNode . |
void |
setOtherNode(PolytomousKeyNode otherNode) |
protected void |
setParent(PolytomousKeyNode parent)
For bidirectional use only !
|
void |
setQuestion(KeyStatement question) |
protected void |
setSortIndex(java.lang.Integer sortIndex) |
void |
setStatement(KeyStatement statement) |
void |
setSubkey(PolytomousKey subkey) |
void |
setTaxon(Taxon taxon)
Sets the taxon this node links to.
|
cloneLanguageString, equals, getUpdated, getUpdatedBy, setUpdated, setUpdatedBy
addPropertyChangeListener, addPropertyChangeListener, addToSetWithChangeEvent, deproxy, deproxy, fireOnCreateEvent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getCreated, getCreatedBy, getId, getUserFriendlyDescription, getUserFriendlyFieldName, getUserFriendlyTypeName, getUuid, hashCode, hasListeners, initListener, instanceToString, invokeSetMethod, invokeSetMethodWithNull, isBlank, isInstanceOf, isNotBlank, isPersited, removeFromSetWithChangeEvent, removePropertyChangeListener, removePropertyChangeListener, replaceInList, setCreated, setCreatedBy, setId, setNewEntityListener, setUuid, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
getCreated, getCreatedBy, getId, getUuid, isInstanceOf, isPersited, setCreated, setCreatedBy, setId, setUuid
protected PolytomousKeyNode()
public static PolytomousKeyNode NewInstance()
public static PolytomousKeyNode NewInstance(java.lang.String statement)
public static PolytomousKeyNode NewInstance(java.lang.String statement, java.lang.String question, Taxon taxon, Feature feature)
protected void setSortIndex(java.lang.Integer sortIndex)
public PolytomousKey getKey()
public void setKey(PolytomousKey key)
key
- public java.lang.Integer getNodeNumber()
public void setNodeNumber(java.lang.Integer nodeNumber)
public Taxon getTaxon()
setTaxon(Taxon)
,
getSubkey()
,
getChildren()
,
getOtherNode()
public void setTaxon(Taxon taxon)
taxon
- getTaxon()
public PolytomousKey getSubkey()
setSubkey(PolytomousKey)
,
getTaxon()
,
getChildren()
,
getOtherNode()
public void setSubkey(PolytomousKey subkey)
subkey
- getSubkey()
public PolytomousKeyNode getOtherNode()
public void setOtherNode(PolytomousKeyNode otherNode)
otherNode
- getOtherNode()
public void setFeature(Feature feature)
public Feature getFeature()
public PolytomousKeyNode getParent()
this
child.protected void setParent(PolytomousKeyNode parent)
parent
- public java.util.List<PolytomousKeyNode> getChildren()
public void addChild(PolytomousKeyNode child)
child
- the feature node to be addedgetChildren()
,
#setChildren(List)
,
addChild(PolytomousKeyNode, int)
,
removeChild(PolytomousKeyNode)
,
removeChild(int)
public void addChild(PolytomousKeyNode child, int index)
child
- the polytomous key node to be addedindex
- the integer indicating the position at which the child should
be addedgetChildren()
,
#setChildren(List)
,
addChild(PolytomousKeyNode)
,
removeChild(PolytomousKeyNode)
,
removeChild(int)
public void removeChild(PolytomousKeyNode child)
children
of this polytomous key node.child
- the feature node which should be removedgetChildren()
,
addChild(PolytomousKeyNode, int)
,
addChild(PolytomousKeyNode)
,
removeChild(int)
public void removeChild(int index)
children
of this feature node.
If the given index is out of bounds no child will be removed.index
- the integer indicating the position of the feature node to be
removedgetChildren()
,
addChild(PolytomousKeyNode, int)
,
addChild(PolytomousKeyNode)
,
removeChild(PolytomousKeyNode)
public void refreshNodeNumbering()
public PolytomousKeyNode getChildAt(int childIndex)
children
of this feature
node. If the given index is out of bounds no child will be returned.childIndex
- the integer indicating the position of the feature nodegetChildren()
,
addChild(PolytomousKeyNode, int)
,
removeChild(int)
public int childCount()
getChildren()
public int getIndex(PolytomousKeyNode node)
children
of this feature
node. If the list does not contain this node then -1 will be returned.node
- the feature node the position of which is being searchedaddChild(PolytomousKeyNode, int)
,
removeChild(int)
public boolean isLeaf()
getChildren()
,
#getChildCount()
public KeyStatement getStatement()
this
PolytomousKeyNode. When coming
from the parent node the user needs to agree with the statement (and disagree
with all statements of sibling nodes) to follow this
node.question
or the
value for the feature
of the parent node.getQuestion()
public LanguageString addStatementText(java.lang.String text, Language language)
null
the default language is used instead.text
- the statement textlanguage
- the language of the statement textpublic void setStatement(KeyStatement statement)
statement
- getStatement()
public KeyStatement getQuestion()
this
PolytomousKeyNode. getStatement()
public LanguageString addQuestionText(java.lang.String text, Language language)
null
the
default language is used instead.text
- language
- public void setQuestion(KeyStatement question)
question
- getQuestion()
public java.util.Map<Language,LanguageString> getModifyingText()
MultilanguageText
like "an unusual form of",
commenting the determined taxon. That is a modifyingText may by used to
comment or to constraint the decision step represented by the edge
leading to this node
All language strings
contained in the
multilanguage texts should all have the same meaning.
public LanguageString putModifyingText(LanguageString description)
description
- the language string describing the validity in a particular
languagegetModifyingText()
,
putModifyingText(Language, String)
public LanguageString putModifyingText(Language language, java.lang.String text)
text
- the string describing the validity in a particular languagelanguage
- the language in which the text string is formulatedgetModifyingText()
,
putModifyingText(LanguageString)
public LanguageString removeModifyingText(Language language)
language
- the language in which the language string to be removed has
been formulatedgetModifyingText()
public PolytomousKeyNode setOrAddTaxon(Taxon taxon)
PolytomousKeyNode
.
If this node already has a taxon removes the taxon
and puts it to a new empty child node. taxon
- public java.lang.Object clone()
clone
in class VersionableEntity
VersionableEntity.clone()
,
Object.clone()
public Taxon removeTaxon()
public void removeNullValueFromChildren()
Copyright © 2007-2020 EDIT. All Rights Reserved.