public class DocumentNode extends TreeNode
Constructor and Description |
---|
DocumentNode(org.jdom2.Element element,
DocumentNode parent,
TreeDocument doc,
Weighter w,
int numChild,
int level)
Instantiates a new document node.
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(DocumentNode toAdd)
Adds a child to this node.
|
String |
dump(String prefix)
Dump this node.
|
boolean |
evaluate(ConnectionManager conMgmr)
Evaluate the modifications of this node.
|
DocumentNode |
extract()
Extracts this subtree.
|
org.jdom2.Attribute |
getAttribute(String attr)
Gets the an attribute.
|
double |
getAttributeDistance(DocumentNode cmp)
Calculates the distance of attributes.
|
double |
getAttributeDistance(DocumentNode cmp,
boolean allowDifferentIds,
boolean careAboutNames,
boolean stricterNames)
Calculates the distance of attributes.
|
Set<String> |
getAttributes()
Gets set attributes.
|
String |
getAttributeValue(String attr)
Gets the value of an attribute.
|
String |
getAttributeValue(String attr,
String nsContains)
Gets the value of an attribute with matching name space.
|
List<TreeNode> |
getChildren()
Gets the children.
|
HashMap<String,List<TreeNode>> |
getChildrenTagMap()
Gets the children tag map.
|
List<TreeNode> |
getChildrenWithTag(String tag)
Gets the children sharing a certain tag.
|
String |
getId()
Gets the value of the id attribute.
|
org.jdom2.Namespace |
getNameSpace()
Gets the name space associated with this node.
|
String |
getNameSpacePrefix()
Gets the name space prefix.
|
String |
getNameSpaceUri()
Gets the name space uri.
|
void |
getNodeStats(HashMap<String,Integer> map)
Gets the node statistics of the subtree rooted in this node: tagname =>
number nodes having this tag name.
|
int |
getNoOfChild(TreeNode kid)
Gets the child number of a child.
|
int |
getNumChildren()
Gets the number of children in this node.
|
int |
getNumLeaves()
Gets the number of leaves in the subtree rooted by this node.
|
String |
getOwnHash()
Gets the calculated hash of this single element (ignoring subtree).
|
int |
getSizeSubtree()
Gets the size of this subtree (number of nodes under the current node,
current node excluded).
|
org.jdom2.Element |
getSubDoc(org.jdom2.Element parent)
Attaches the subtree rooted in this node to the node parent.
|
String |
getSubTreeHash()
Gets the calculated hash of the subtree rooted in this node.
|
String |
getTagName()
Gets the tag name.
|
double |
getWeight()
Gets the weight of this node.
|
Weighter |
getWeighter()
Gets the weighter used to compute the weight of this document.
|
boolean |
isBelow(DocumentNode parent)
Checks if this node is a child of some other node (multilevel).
|
protected void |
reSetupStructureDown(TreeDocument doc,
int numChild)
Re-setup the document structure downwards.
|
protected void |
reSetupStructureUp()
Re-setup the document structure upwards.
|
void |
rmAttribute(String attr)
Removes an attribute.
|
void |
rmChild(DocumentNode toRemove)
Remove a child.
|
void |
setAttribute(org.jdom2.Attribute attr)
Overrides an attribute.
|
void |
setAttribute(String attr,
String value)
Overrides an attribute.
|
static void |
setIdAttr(String id)
Sets the id attribute.
|
String |
toString() |
addModification, contentDiffers, getDocument, getLevel, getModification, getParent, getType, getXPath, hasModification, isRoot, networkDiffers, resetModifications, rmModification, setModification
public static String ID_ATTR
public DocumentNode(org.jdom2.Element element, DocumentNode parent, TreeDocument doc, Weighter w, int numChild, int level)
element
- the corresponding elementparent
- the parent nodedoc
- the corresponding documentw
- the weighternumChild
- the number among its siblingslevel
- the level in the treepublic DocumentNode extract()
public String getSubTreeHash()
getSubTreeHash
in class TreeNode
public String getOwnHash()
getOwnHash
in class TreeNode
public int getSizeSubtree()
public int getNumLeaves()
public static final void setIdAttr(String id)
metaid
instead of the id
as identifier)id
- the new id attributepublic String getTagName()
TreeNode
TreeNode.TEXT_TAG
.getTagName
in class TreeNode
public String getId()
public void addChild(DocumentNode toAdd)
toAdd
- the new childpublic void rmChild(DocumentNode toRemove) throws XmlDocumentConsistencyException
toRemove
- the child to removeXmlDocumentConsistencyException
- thrown if there is no such childpublic String getAttributeValue(String attr)
attr
- the name of the attributepublic org.jdom2.Attribute getAttribute(String attr)
attr
- the name of the attributepublic String getAttributeValue(String attr, String nsContains)
attr
- the name of the attributensContains
- the name space must contain nsContains
public void setAttribute(org.jdom2.Attribute attr)
attr
- the attributepublic void setAttribute(String attr, String value)
attr
- the name of the attributevalue
- the new valuepublic void rmAttribute(String attr)
attr
- the attributes namepublic boolean isBelow(DocumentNode parent)
parent
- the parent in questionpublic int getNumChildren()
public List<TreeNode> getChildrenWithTag(String tag)
tag
- the tagpublic HashMap<String,List<TreeNode>> getChildrenTagMap()
public int getNoOfChild(TreeNode kid)
kid
- the kidpublic double getAttributeDistance(DocumentNode cmp)
getAttributeDistance(DocumentNode, boolean, boolean, boolean)
allowing different ids, caring about names, but not stricter names.
Returns a double in [0,1]. If all attributes match the distance will be 0, if none of the attributes match the distance will be 1.cmp
- the node to comparepublic double getAttributeDistance(DocumentNode cmp, boolean allowDifferentIds, boolean careAboutNames, boolean stricterNames)
allowDifferentIds
is set to false, the distance will always be 1 if the two nodes do not share the same attribute.
careAboutNames
is set to true, we will treat the name attributes differently. That means the difference between Glucose5Phosphate and Glucose6Phosphate (might just be a typo) will be rated less and the difference between Glucose3Phosphate and MAPKK2 will be rated much higher. We are using the `Michaelis–Menten kinetics` (:-)) to calc the difference between names: vmax=6; km=min(length(name1),length(name2))/4; [S]=levenshteinDistance(name1,name2)
careAboutNames
is set to true AND stricterNames
is set to true a difference in the name is treated very strictly. So if you're sure that your names are very similar, you should go for that option: vmax=12; km=min(length(name1),length(name2))/6; [S]=levenshteinDistance(name1,name2)
cmp
- the node to compareallowDifferentIds
- are different ids allowed?careAboutNames
- should we care about names?stricterNames
- should we handle names very strictly?public Weighter getWeighter()
public String getNameSpaceUri()
public String getNameSpacePrefix()
public org.jdom2.Element getSubDoc(org.jdom2.Element parent)
TreeNode
parent == null && this.getType () == TreeNode.TEXT_NODE
That means a text node cannot become root.public void getNodeStats(HashMap<String,Integer> map)
TreeNode
getNodeStats
in class TreeNode
map
- the map to write our statistics topublic boolean evaluate(ConnectionManager conMgmr)
TreeNode
public double getWeight()
TreeNode
protected void reSetupStructureDown(TreeDocument doc, int numChild)
TreeNode
reSetupStructureDown
in class TreeNode
doc
- the document this node corresponds tonumChild
- the child number of this nodeprotected void reSetupStructureUp()
TreeNode
reSetupStructureUp
in class TreeNode
public String dump(String prefix)
TreeNode
public org.jdom2.Namespace getNameSpace()
Copyright © 2019 SEMS project @ University of Rostock. All rights reserved.