public class TreeDocument extends Object
Constructor and Description |
---|
TreeDocument(org.jdom2.Document d,
URI baseUri)
Instantiates a new tree document.
|
TreeDocument(org.jdom2.Document d,
URI baseUri,
boolean ordered)
Instantiates a new tree document.
|
TreeDocument(org.jdom2.Document d,
Weighter w,
URI baseUri)
Instantiates a new tree document.
|
TreeDocument(org.jdom2.Document d,
Weighter w,
URI baseUri,
boolean ordered)
Instantiates a new tree document.
|
TreeDocument(TreeDocument td)
Instantiates a new tree document as a copy of another tree document.
|
Modifier and Type | Method and Description |
---|---|
String |
dump()
Dump mech for debugging purposes.
|
boolean |
equals(Object anObject) |
URI |
getBaseUri()
Gets the base URI.
|
DocumentNode |
getNodeById(String id)
Gets the node by id.
|
TreeNode |
getNodeByPath(String path)
Gets the node by XPath expression.
|
List<TreeNode> |
getNodesByHash(String hash)
Gets the nodes by hash.
|
List<DocumentNode> |
getNodesByTag(String tag)
Gets the nodes sharing a certain tag name.
|
HashMap<String,Integer> |
getNodeStats()
Gets the node statistics as a map `tag name` => `nodes sharing this tag`.
|
int |
getNumNodes()
Gets the number of nodes in this document.
|
Set<String> |
getOccurringHashes()
Get all known hashes.
|
Set<String> |
getOccurringIds()
Get all known identifiers.
|
Set<String> |
getOccurringTags()
Get all known tag names.
|
Set<String> |
getOccurringXPaths()
Get all known XPaths.
|
DocumentNode |
getRoot()
Gets the root node.
|
TreeNode[] |
getSubtreesBySize()
Gets the subtrees ordered by size, biggest first.
|
List<TextNode> |
getTextNodes()
Gets all text nodes.
|
double |
getTreeWeight()
Gets the tree weight.
|
void |
integrate(TreeNode node,
boolean recursively)
Integrate an node into this tree.
|
void |
resetAllModifications()
Resets all modifications.
|
void |
resortSubtrees()
Deprecated.
We are now using a sorted set, no resorting necessary anymore. This method doesn't do anything anymore.
|
void |
separate(TreeNode node,
boolean recursively)
Extract a node from this tree.
|
String |
toString() |
boolean |
uniqueIds()
Are occurring IDs unique?.
|
public TreeDocument(org.jdom2.Document d, URI baseUri) throws XmlDocumentParseException
d
- the documentbaseUri
- the base URI (needed to resolve relative imports)XmlDocumentParseException
- the xml document parse exceptionpublic TreeDocument(org.jdom2.Document d, Weighter w, URI baseUri) throws XmlDocumentParseException
d
- the documentw
- the weighter to weight the nodes and subtreesbaseUri
- the base URI (needed to resolve relative imports)XmlDocumentParseException
- the xml document parse exceptionpublic TreeDocument(org.jdom2.Document d, URI baseUri, boolean ordered) throws XmlDocumentParseException
d
- the documentbaseUri
- the base URI (needed to resolve relative imports)ordered
- the ordered flag, if true we consider this tree to be orderedXmlDocumentParseException
- the xml document parse exceptionpublic TreeDocument(org.jdom2.Document d, Weighter w, URI baseUri, boolean ordered) throws XmlDocumentParseException
d
- the documentw
- the weighter to weight the nodes and subtreesbaseUri
- the base URI (needed to resolve relative imports)ordered
- the orderedXmlDocumentParseException
- the xml document parse exceptionpublic TreeDocument(TreeDocument td)
td
- the tree document to copy@Deprecated public void resortSubtrees()
public void integrate(TreeNode node, boolean recursively)
node
- the node to integraterecursively
- recursively integrate the node's childrenpublic void separate(TreeNode node, boolean recursively)
node
- the noderecursively
- recursively separate the node's childrenpublic URI getBaseUri()
public boolean uniqueIds()
public void resetAllModifications()
public DocumentNode getRoot()
public int getNumNodes()
public double getTreeWeight()
public List<DocumentNode> getNodesByTag(String tag)
tag
- the tag name to search forpublic TreeNode[] getSubtreesBySize()
public List<TreeNode> getNodesByHash(String hash)
hash
- the hashpublic DocumentNode getNodeById(String id)
id
- the idpublic TreeNode getNodeByPath(String path)
docB.getNodeByPath (nodeFromA.getXPath ());
to search for a node at the same path in another document.path
- the pathpublic Set<String> getOccurringXPaths()
public Set<String> getOccurringIds()
public Set<String> getOccurringTags()
public Set<String> getOccurringHashes()
public HashMap<String,Integer> getNodeStats()
public String dump()
Copyright © 2019 SEMS project @ University of Rostock. All rights reserved.