#include <projectiontreelabel.h>
Public Member Functions | |
ProjectionTreeLabel (ProjectionTreeNode *_n, unsigned _position, unsigned _id, ProjectionTreeLabel *_same_level_successor, vector< ProjectionTreeLabel * >_child_successors, vector< ProjectionTreeLabel * >_self_successors) | |
Constructor. | |
virtual | ~ProjectionTreeLabel () |
void | updateParentPredecessorInformation (ProjectionTreeLabel *_parent, ProjectionTreeLabel *_predecessor) |
Recursively brings the parent and predecessor links up to date. | |
void | print (OutputStream &dos) |
Prints the projection tree label. | |
ProjectionTreeLabel * | getParent () |
Returns the parent label. | |
ProjectionTreeLabel * | getPredecessor () |
Returns the predecessor label. | |
ProjectionTreeLabel * | getLeftmostSLPredecessor () |
Returns the first label associated with the same path step. | |
unsigned | getDependingVar () |
Returns the id of the variable the label ultimately depends on. | |
PathExpression * | getPath () |
Return the path that is referenced by this label. | |
PathStepExpression * | getPathStep () |
Get the path step that is references by this label. | |
TAG | getTag () |
Returns the tag carried by the associated path step expression. | |
AXIS_TYPE | getAxisFollowingFSA () |
Returns the axis type that, going up from this label, immediately follows its first straight ancestor (FSA) label. | |
AXIS_TYPE | getAxisFollowingFSA (unsigned fsa) |
Returns the axis type that, going up from this label, immediately follows the given first straight ancestor (FSA) id. | |
ProjectionTreeLabel * | getFSALabel () |
Returns the first straight ancestor (FSA) label. | |
unsigned | getId () |
The ID of the label. | |
unsigned | getPosition () |
Returns the path step position inside the path. | |
ProjectionTreeLabel * | getSameLevelSuccessor () |
Returns the same level successor. | |
vector< ProjectionTreeLabel * > * | getChildSuccessors () |
Returns the child successors. | |
vector< ProjectionTreeLabel * > * | getSelfSuccessors () |
Returns the self successors. | |
ProjectionTreeNode * | getProjectionTreeNode () |
Returns the associated projection tree node. | |
bool | isChildOrDescendantLabel () |
Returns true if the associated path step carries a child or descendant axis. | |
bool | isDescendantLabel () |
Returns true if the associated path step carries a descendant axis. | |
bool | isChildLabel () |
Returns true if the associated path step carries a child axis. | |
bool | isDosLabel () |
Returns true if the associated path step carries a dos axis. | |
bool | isDosNodeLabel () |
Returns true if the associated path step is dos::node. | |
bool | isDosOrDescendantLabel () |
Returns true if the associated path step carries either a descendant or dos path step. | |
bool | isNodeLabel () |
Returns true if the associated path step is of the form axis::node(). | |
bool | isStarLabel () |
Returns true if the associated path step is of the form axis::*. | |
bool | hasSameLevelOrChildSuccessors () |
Checks if the path step has a same-level or some child successors. | |
bool | atEndOfPath () |
Returns true if the label describes the final step in a path. | |
ProjectionTreeLabel * | locateVarAncestorLabel (unsigned var) |
Returns the ancestor label with the given variable. | |
bool | matchesTag (TAG t) |
Checks if the associated path step referenced by this label matches tag t. | |
bool | matchesText () |
Checks if the associated path step matches text. | |
bool | descendantAxisBetw (unsigned basing_id, bool consider_final=false) |
Checks for a descendant axis being used between the the current state and the state referred to by basing_id. | |
Private Attributes | |
ProjectionTreeLabel * | parent |
The parent label. | |
ProjectionTreeLabel * | predecessor |
The predecessor label. | |
ProjectionTreeNode * | n |
unsigned | position |
Defines the position inside the path of the associated projection tree node (member variable n). | |
unsigned | id |
The id of the projection tree label. | |
ProjectionTreeLabel * | same_level_successor |
The successor label in the path, if any. | |
vector< ProjectionTreeLabel * > | child_successors |
The set of successor child labels. | |
vector< ProjectionTreeLabel * > | self_successors |
The self successor labels. |
More precisely, each path step expression in the projection tree is assigned a unique label. In addition, projection tree nodes with NULL path get assigned a label, too. For each label, we store different types of successor labels, such as vertical and horizontal successors.
Definition at line 53 of file projectiontreelabel.h.
ProjectionTreeLabel::ProjectionTreeLabel | ( | ProjectionTreeNode * | _n, | |
unsigned | _position, | |||
unsigned | _id, | |||
ProjectionTreeLabel * | _same_level_successor, | |||
vector< ProjectionTreeLabel * > | _child_successors, | |||
vector< ProjectionTreeLabel * > | _self_successors | |||
) |
Constructor.
Constructor - creating object.
[in] | _n | The projection tree node the label is assigned to. |
[in] | _position | The position of the path step stored in node _n. |
[in] | _id | The id of the ProjectionTreeLabel. |
[in] | _same_level_successor | The ProjectionTreeLabel that describes the path step to the right (in the same node _n) of this label. May be NULL. |
[in] | _child_successors | The set of ProjectionTreeLabels in the first position of paths contained in child nodes of _n, but only if this label is set to the last position of _n's path. Otherwise, the vector is empty. |
[in] | _self_successors | The set of labels that describes child nodes of _n that carry no path, i.e. the NULL path, and recursively their children if these satisfy the same condition. |
Definition at line 40 of file projectiontreelabel.cpp.
ProjectionTreeLabel::~ProjectionTreeLabel | ( | ) | [virtual] |
Destructor.
Definition at line 59 of file projectiontreelabel.cpp.
bool ProjectionTreeLabel::atEndOfPath | ( | ) |
Returns true if the label describes the final step in a path.
Always returns true for the empty path.
bool | True if the label describes the final step in a path, false otherwise. |
Definition at line 238 of file projectiontreelabel.cpp.
References ProjectionTreeNode::getPath(), PathExpression::getPathSize(), n, and position.
Referenced by TokenConfiguration::createRoleList().
bool ProjectionTreeLabel::descendantAxisBetw | ( | unsigned | basing_id, | |
bool | consider_final = false | |||
) |
Checks for a descendant axis being used between the the current state and the state referred to by basing_id.
Recursively climbs up to the label with basing_id.
[in] | basing_id | The id of the label where to abort the check. |
[in] | consider_final | True if basing_id is to be considered. |
bool | Returns true if a descendant axis exists, false otherwise. |
Definition at line 270 of file projectiontreelabel.cpp.
References descendantAxisBetw(), PathStepExpression::getAxisType(), getPathStep(), and getPredecessor().
Referenced by TokenConfiguration::applyTag(), TokenConfiguration::applyText(), and descendantAxisBetw().
AXIS_TYPE ProjectionTreeLabel::getAxisFollowingFSA | ( | unsigned | fsa | ) |
Returns the axis type that, going up from this label, immediately follows the given first straight ancestor (FSA) id.
This is a help function for method getAxisFollowingFSA().
[in] | fsa | The first straight ancestor (FSA). |
AXIS_TYPE | The type of the computed axis. |
Definition at line 179 of file projectiontreelabel.cpp.
References getAxisFollowingFSA(), PathStepExpression::getAxisType(), getPathStep(), getProjectionTreeNode(), ProjectionTreeNode::getVar(), and predecessor.
AXIS_TYPE ProjectionTreeLabel::getAxisFollowingFSA | ( | ) |
Returns the axis type that, going up from this label, immediately follows its first straight ancestor (FSA) label.
Used to determinde the multiplicity of role assignments.
AXIS_TYPE | The type of the computed axis. |
Definition at line 174 of file projectiontreelabel.cpp.
References getDependingVar(), and FSAMap::getInstance().
Referenced by getAxisFollowingFSA().
vector< ProjectionTreeLabel * > * ProjectionTreeLabel::getChildSuccessors | ( | ) | [inline] |
Returns the child successors.
Returns the set of all child successors of the current label.
vector<ProjectionTreeLabel*>* | Pointer to the vector containing the child successors. |
Definition at line 215 of file projectiontreelabel.h.
References child_successors.
Referenced by TokenConfiguration::applyTag(), TokenConfiguration::applyText(), ProjectionTreeLabels::computeProjectionTreeLabels(), TokenConfiguration::forceChildKeep(), and ProjectionTreeLabels::getAllRecursiveDosNodeSuccessors().
unsigned ProjectionTreeLabel::getDependingVar | ( | ) |
Returns the id of the variable the label ultimately depends on.
This is the variable that is associated with the associated projection tree node.
unsigned | The variable id. |
Definition at line 143 of file projectiontreelabel.cpp.
References getDependingVar(), getProjectionTreeNode(), ProjectionTreeNode::getVar(), and parent.
Referenced by getAxisFollowingFSA(), getDependingVar(), and getFSALabel().
ProjectionTreeLabel * ProjectionTreeLabel::getFSALabel | ( | ) |
Returns the first straight ancestor (FSA) label.
The first straight ancestor (FSA) label is the label of the last path step of the path that is bound to the first straight ancestor (FSA) variable
ProjectionTreeLabel* | Pointer to the FSA ProjectionTreeLabel. |
Definition at line 184 of file projectiontreelabel.cpp.
References getDependingVar(), FSAMap::getFSA(), FSAMap::getInstance(), and locateVarAncestorLabel().
Referenced by TokenConfiguration::applyTag(), and TokenConfiguration::applyText().
unsigned ProjectionTreeLabel::getId | ( | ) | [inline] |
The ID of the label.
The uniqu ID of the current label.
unsigned | The ID of the label. |
Definition at line 186 of file projectiontreelabel.h.
References id.
Referenced by TokenConfiguration::applyTag(), TokenConfiguration::applyText(), TokenConfiguration::createRoleList(), ProjectionTreeLabels::getAllRecursiveDosNodeSuccessors(), and print().
ProjectionTreeLabel * ProjectionTreeLabel::getLeftmostSLPredecessor | ( | ) |
Returns the first label associated with the same path step.
Steps back in the current path step and returns the label associated with the leftmost path step.
ProjectionTreeLabel* | The first label associated with this path step. |
Definition at line 135 of file projectiontreelabel.cpp.
References getLeftmostSLPredecessor(), parent, and predecessor.
Referenced by TokenConfiguration::applyTag(), TokenConfiguration::applyText(), and getLeftmostSLPredecessor().
ProjectionTreeLabel * ProjectionTreeLabel::getParent | ( | ) | [inline] |
Returns the parent label.
A projection tree label is called parent label if it refers the last past step in the parent projection tree node.
ProjectionTreeLabel* | The parent label. |
Definition at line 105 of file projectiontreelabel.h.
References parent.
PathExpression * ProjectionTreeLabel::getPath | ( | ) |
Return the path that is referenced by this label.
The path may be NULL.
PathExpression* | Pointer to the path expression. |
Definition at line 149 of file projectiontreelabel.cpp.
References ProjectionTreeNode::getPath(), and n.
Referenced by TokenConfiguration::applyTag(), and TokenConfiguration::applyText().
PathStepExpression * ProjectionTreeLabel::getPathStep | ( | ) |
Get the path step that is references by this label.
The path step may be NULL (if and only if the path is NULL).
PathStepExpression* | Pointer to the path step expression. |
Definition at line 153 of file projectiontreelabel.cpp.
References ProjectionTreeNode::getPath(), PathExpression::getPathStepAt(), n, and position.
Referenced by TokenConfiguration::applyTag(), TokenConfiguration::applyText(), descendantAxisBetw(), getAxisFollowingFSA(), getTag(), isChildLabel(), isChildOrDescendantLabel(), isDescendantLabel(), isDosLabel(), isDosNodeLabel(), isDosOrDescendantLabel(), isNodeLabel(), isStarLabel(), matchesTag(), and matchesText().
unsigned ProjectionTreeLabel::getPosition | ( | ) | [inline] |
Returns the path step position inside the path.
Starts counting at 0, i.e. the first path step position is position 0.
unsigned | The path step position inside the path. |
Definition at line 196 of file projectiontreelabel.h.
References position.
ProjectionTreeLabel * ProjectionTreeLabel::getPredecessor | ( | ) | [inline] |
Returns the predecessor label.
A projection tree label is called predecessor if it is reached by going one path step back. The predecessor (in contrast to the parent) might also be in the same level. If it is not, it equals to the parent.
ProjectionTreeLabel* | The predecessor label. |
Definition at line 114 of file projectiontreelabel.h.
Referenced by TokenConfiguration::applyTag(), TokenConfiguration::applyText(), TokenConfiguration::createRoleList(), and descendantAxisBetw().
ProjectionTreeNode * ProjectionTreeLabel::getProjectionTreeNode | ( | ) | [inline] |
Returns the associated projection tree node.
Will always be different from NULL.
ProjectionTreeNode* | The associated projection tree node. |
Definition at line 234 of file projectiontreelabel.h.
References n.
Referenced by ProjectionTreeLabels::computeProjectionTreeLabels(), TokenConfiguration::createRoleList(), getAxisFollowingFSA(), getDependingVar(), locateVarAncestorLabel(), and print().
ProjectionTreeLabel * ProjectionTreeLabel::getSameLevelSuccessor | ( | ) | [inline] |
Returns the same level successor.
May return NULL if no same level successor exists.
ProjectionTreeLabel* | Pointer to the same level successor. |
Definition at line 205 of file projectiontreelabel.h.
References same_level_successor.
Referenced by TokenConfiguration::applyTag(), TokenConfiguration::applyText(), TokenConfiguration::forceChildKeep(), and ProjectionTreeLabels::getAllRecursiveDosNodeSuccessors().
vector< ProjectionTreeLabel * > * ProjectionTreeLabel::getSelfSuccessors | ( | ) | [inline] |
Returns the self successors.
Returns the set of all self-axis successors of the current label.
vector<ProjectionTreeLabel*>* | Pointer to the vector containing the self successors. |
Definition at line 225 of file projectiontreelabel.h.
References self_successors.
Referenced by ProjectionTreeLabels::computeProjectionTreeLabels(), and TokenConfiguration::createRoleList().
TAG ProjectionTreeLabel::getTag | ( | ) |
Returns the tag carried by the associated path step expression.
The caller must ensure that the associated path step expression differs from NULL.
TAG | The tag id of the associated path step expression. |
Throws | a RuntmeException if the path step is (errorneously) applied to a non-tag node test. |
Definition at line 157 of file projectiontreelabel.cpp.
References PathStepTagExpression::getNodeTest(), getPathStep(), ProjectionTreeNode::isRoot(), PathStepExpression::isTagNodeTest(), n, and TAGID_ROOT.
Referenced by TokenConfiguration::forceChildKeep().
bool ProjectionTreeLabel::hasSameLevelOrChildSuccessors | ( | ) |
Checks if the path step has a same-level or some child successors.
This condition is true if the label has a successor label in the same path or some child path.
bool | True if the path step has a same-level or some child child successors, false otherwise. |
Definition at line 234 of file projectiontreelabel.cpp.
References child_successors, and same_level_successor.
bool ProjectionTreeLabel::isChildLabel | ( | ) |
Returns true if the associated path step carries a child axis.
Returns true if the associated path step carries a child axis.
bool | True if the associated path step carries a child axis, false otherwise. |
Definition at line 202 of file projectiontreelabel.cpp.
References PathStepExpression::getAxisType(), ProjectionTreeNode::getPath(), getPathStep(), PathExpression::isEmptyPath(), and n.
Referenced by TokenConfiguration::applyTag(), TokenConfiguration::applyText(), and TokenConfiguration::forceChildKeep().
bool ProjectionTreeLabel::isChildOrDescendantLabel | ( | ) |
Returns true if the associated path step carries a child or descendant axis.
In particular, the method returns false for dos-axis path steps.
bool | True if the associated path step carries a child or descendant axis label, false otherwise. |
Definition at line 190 of file projectiontreelabel.cpp.
References PathStepExpression::getAxisType(), ProjectionTreeNode::getPath(), getPathStep(), and n.
bool ProjectionTreeLabel::isDescendantLabel | ( | ) |
Returns true if the associated path step carries a descendant axis.
Returns true if the associated path step carries a descendant axis.
bool | True if the associated path step carries a descendant axis label, false otherwise. |
Definition at line 197 of file projectiontreelabel.cpp.
References PathStepExpression::getAxisType(), ProjectionTreeNode::getPath(), getPathStep(), PathExpression::isEmptyPath(), and n.
Referenced by TokenConfiguration::applyTag(), TokenConfiguration::applyText(), and TokenConfiguration::forceChildKeep().
bool ProjectionTreeLabel::isDosLabel | ( | ) |
Returns true if the associated path step carries a dos axis.
Returns true if the associated path step carries a dos axis.
bool | True if the associated path step carries a dos axis, false otherwise. |
Definition at line 207 of file projectiontreelabel.cpp.
References PathStepExpression::getAxisType(), ProjectionTreeNode::getPath(), getPathStep(), PathExpression::isEmptyPath(), and n.
bool ProjectionTreeLabel::isDosNodeLabel | ( | ) |
Returns true if the associated path step is dos::node.
Returns true if the associated path step is dos::node.
bool | True if the associated path step is dos::node, false otherwise. |
Definition at line 212 of file projectiontreelabel.cpp.
References PathStepExpression::getAxisType(), ProjectionTreeNode::getPath(), getPathStep(), PathExpression::isEmptyPath(), PathStepExpression::isNodeNodeTest(), and n.
Referenced by TokenConfiguration::applyTag(), TokenConfiguration::applyText(), TokenConfiguration::createRoleList(), ProjectionTreeLabels::getAllRecursiveDosNodeSuccessors(), TokenConfiguration::isOutput(), and TokenConfiguration::keepSubtree().
bool ProjectionTreeLabel::isDosOrDescendantLabel | ( | ) |
Returns true if the associated path step carries either a descendant or dos path step.
Returns true if the associated path step carries either a descendant or dos path step.
bool | True if the associated path step carries a descendant or dos axis, false otherwise. |
Definition at line 218 of file projectiontreelabel.cpp.
References PathStepExpression::getAxisType(), ProjectionTreeNode::getPath(), getPathStep(), PathExpression::isEmptyPath(), and n.
Referenced by TokenConfiguration::applyTag().
bool ProjectionTreeLabel::isNodeLabel | ( | ) |
Returns true if the associated path step is of the form axis::node().
Returns true if the associated path step is of the form axis::node().
bool | True if the associated path step is of the form axis::node() false otherwise. |
Definition at line 224 of file projectiontreelabel.cpp.
References ProjectionTreeNode::getPath(), getPathStep(), PathExpression::isEmptyPath(), PathStepExpression::isNodeNodeTest(), and n.
Referenced by TokenConfiguration::forceChildKeep().
bool ProjectionTreeLabel::isStarLabel | ( | ) |
Returns true if the associated path step is of the form axis::*.
Returns true if the associated path step is of the form axis::*.
bool | True if the associated path step is of the form axis::* false otherwise. |
Definition at line 229 of file projectiontreelabel.cpp.
References ProjectionTreeNode::getPath(), getPathStep(), PathExpression::isEmptyPath(), PathStepExpression::isStarNodeTest(), and n.
Referenced by TokenConfiguration::forceChildKeep().
ProjectionTreeLabel * ProjectionTreeLabel::locateVarAncestorLabel | ( | unsigned | var | ) |
Returns the ancestor label with the given variable.
The caller must make sure that the passed variable var exists.
[in] | var | The variable for which the ancestor label is searched. |
ProjectionTreeLabel* | The ancestor projection tree label. |
Definition at line 242 of file projectiontreelabel.cpp.
References getProjectionTreeNode(), ProjectionTreeNode::getVar(), locateVarAncestorLabel(), parent, and self_successors.
Referenced by getFSALabel(), and locateVarAncestorLabel().
bool ProjectionTreeLabel::matchesTag | ( | TAG | t | ) |
Checks if the associated path step referenced by this label matches tag t.
This method takes into consideration possible node() or * labels.
[in] | t | The tag to be compared. |
bool | True if the tag matches, false otherwise. |
Definition at line 258 of file projectiontreelabel.cpp.
References ProjectionTreeNode::getPath(), getPathStep(), PathStepExpression::isMatchingTag(), and n.
Referenced by TokenConfiguration::applyTag().
bool ProjectionTreeLabel::matchesText | ( | ) |
Checks if the associated path step matches text.
This method returns true if the associated node test is of the form text() or node().
bool | True if text is matched, false otherwise. |
Definition at line 265 of file projectiontreelabel.cpp.
References ProjectionTreeNode::getPath(), getPathStep(), PathStepExpression::isNodeNodeTest(), PathStepExpression::isTextNodeTest(), and n.
Referenced by TokenConfiguration::applyText(), and TokenConfiguration::forceChildKeep().
void ProjectionTreeLabel::print | ( | OutputStream & | dos | ) |
Prints the projection tree label.
Used for debugging purpose only.
[in] | dos | Reference to the (debug) OutputStream. |
void |
Definition at line 77 of file projectiontreelabel.cpp.
References child_successors, getId(), VarName::getInstance(), ProjectionTreeNode::getPath(), getProjectionTreeNode(), ProjectionTreeNode::getVar(), VarName::getVarname(), ProjectionTreeNode::isRoot(), n, NEWLINE, parent, position, same_level_successor, and self_successors.
void ProjectionTreeLabel::updateParentPredecessorInformation | ( | ProjectionTreeLabel * | _parent, | |
ProjectionTreeLabel * | _predecessor | |||
) |
Recursively brings the parent and predecessor links up to date.
To be applied exactly once after all labels have been collected.
[in] | _parent | Pointer to the parent projection tree label. |
[in] | _predecessor | Pointer to the predecessor label. |
void |
Definition at line 63 of file projectiontreelabel.cpp.
References child_successors, parent, predecessor, same_level_successor, and updateParentPredecessorInformation().
Referenced by updateParentPredecessorInformation().
vector< ProjectionTreeLabel * > ProjectionTreeLabel::child_successors [private] |
The set of successor child labels.
More precisely, the set of ProjectionTreeLabels in the first position of paths contained in child nodes of _n, but only if this object's label is set to the last position of _n's path. Otherwise, the vector is empty.
Definition at line 405 of file projectiontreelabel.h.
Referenced by getChildSuccessors(), hasSameLevelOrChildSuccessors(), print(), and updateParentPredecessorInformation().
unsigned ProjectionTreeLabel::id [private] |
The id of the projection tree label.
When extracted regularly, this id is globally unique.
Definition at line 388 of file projectiontreelabel.h.
Referenced by getId().
ProjectionTreeNode * ProjectionTreeLabel::n [private] |
The associated node in the projection tree.
Definition at line 374 of file projectiontreelabel.h.
Referenced by atEndOfPath(), getPath(), getPathStep(), getProjectionTreeNode(), getTag(), isChildLabel(), isChildOrDescendantLabel(), isDescendantLabel(), isDosLabel(), isDosNodeLabel(), isDosOrDescendantLabel(), isNodeLabel(), isStarLabel(), matchesTag(), matchesText(), and print().
ProjectionTreeLabel * ProjectionTreeLabel::parent [private] |
The parent label.
May be NULL.
Definition at line 362 of file projectiontreelabel.h.
Referenced by getDependingVar(), getLeftmostSLPredecessor(), getParent(), locateVarAncestorLabel(), print(), and updateParentPredecessorInformation().
unsigned ProjectionTreeLabel::position [private] |
Defines the position inside the path of the associated projection tree node (member variable n).
If the path of the associated projection tree node is NULL, the variable is set to 0 and has no meaning.
Definition at line 382 of file projectiontreelabel.h.
Referenced by atEndOfPath(), getPathStep(), getPosition(), and print().
ProjectionTreeLabel * ProjectionTreeLabel::predecessor [private] |
The predecessor label.
May be NULL.
Definition at line 368 of file projectiontreelabel.h.
Referenced by getAxisFollowingFSA(), getLeftmostSLPredecessor(), and updateParentPredecessorInformation().
The successor label in the path, if any.
The successor label is defined as the ProjectionTreeLabel that describes the path step to the right (in the same node _n) of this label. May be NULL.
Definition at line 396 of file projectiontreelabel.h.
Referenced by getSameLevelSuccessor(), hasSameLevelOrChildSuccessors(), print(), and updateParentPredecessorInformation().
vector< ProjectionTreeLabel * > ProjectionTreeLabel::self_successors [private] |
The self successor labels.
More precisely, the set of labels associated to child projection tree nodes of _n that carry no path, i.e. the NULL path, and recursively their children if these satisfy the same condition.
Definition at line 413 of file projectiontreelabel.h.
Referenced by getSelfSuccessors(), locateVarAncestorLabel(), and print().