|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--uk.ac.bbk.dcs.automed.xml.NodeUtility
Implements useful operation on nodes.
| Constructor Summary | |
NodeUtility()
|
|
| Method Summary | |
static org.w3c.dom.Document |
addGenericRoot(org.w3c.dom.Document doc,
java.lang.String newRootName)
Method that adds a generic root named newRootName on top of the old root and returns the new document. |
static void |
banner()
Prints a line of 90 stars. |
static void |
banner(int num)
Prints a line of num stars. |
static org.w3c.dom.Document |
duplicateDOM(org.w3c.dom.Document doc)
Method that creates and returns a new DOM representation of the input one. |
static org.w3c.dom.Document |
duplicateDOM(java.lang.String URI,
boolean validating)
|
static org.apache.xpath.domapi.XPathResultImpl |
evaluateXPath(org.w3c.dom.Document doc,
java.lang.String xpathExpression,
int resultType)
|
static org.w3c.dom.Document |
fileCreate(java.lang.String rootName,
java.lang.String filePath,
java.lang.String fileName)
Creates a new file named "fileName" in path "filePath", with only the root, named "rootName", and returns its DOM representation. |
static int |
findPath(org.w3c.dom.Node supposedChild,
org.w3c.dom.Node supposedParent,
java.util.LinkedList goingUpPath,
java.util.LinkedList goingDownPath)
|
static int |
getChildCount(org.w3c.dom.Node parentNode)
Counts the children of the given node. |
static int |
getDepth(org.w3c.dom.Document document)
|
static org.w3c.dom.Node |
getElementByUID(org.w3c.dom.Document doc,
java.lang.String elementUID)
Returns the node in the input doc that has an AutoMedID with the value of elementUID |
static org.w3c.dom.Node |
getElementByUIDNoSchema(org.w3c.dom.Document doc,
java.lang.String elementUID)
This method will return the first occurrence of an element containing an AutoMedID whose suffix after "schemaName:" matches the input elementUID. |
static int |
getElementChildCount(org.w3c.dom.Node parentNode)
Counts the element children of the given node. |
static java.util.LinkedList |
getElementLevel(org.w3c.dom.Node n,
int level)
Returns all the element nodes in a given level. |
static int |
getElementNodeOrder(org.w3c.dom.Node n)
Returns the order of element node n in its parent's children NodeList - takes into account only elements. |
static java.util.LinkedList |
getElementsByUID(org.w3c.dom.Document doc,
java.lang.String id)
Given a schema UID (schemaName:elementName:counter), this method runs through the given instance, and returns all elements with an instance UID starting with the given schema UID. |
static java.util.LinkedList |
getLevel(org.w3c.dom.Node n,
int level)
Returns all the nodes in a given level. |
static int |
getNodeDepth(org.w3c.dom.Node n)
Returns the depth of node n. |
static int |
getNodeOrder(org.w3c.dom.Node n)
|
static java.lang.String |
getPath(org.w3c.dom.Node n)
|
static int |
getPCDATAChildCount(org.w3c.dom.Node parentNode)
Counts the element children of the given node. |
static int |
getPCDATANodeOrder(org.w3c.dom.Node n)
|
static java.util.LinkedList |
getTextNodes(org.w3c.dom.Node n)
|
static java.lang.String |
getUnderlyingText(org.w3c.dom.Node n,
java.lang.String separator)
Returns a concatenated string of all text nodes under this node - not only its children's text nodes. |
static boolean |
hasTextNodes(org.w3c.dom.Node n)
|
static boolean |
isElementNode(org.w3c.dom.Node n)
Returns true if node n is an element node, false otherwise |
static boolean |
isTextNode(org.w3c.dom.Node n)
Returns true if node n is a text node, false otherwise |
static void |
main(java.lang.String[] args)
|
static org.w3c.dom.Document |
parseFile(java.lang.String inputFile,
boolean validating)
Parses the input file and returns its DOM representation |
static void |
prettyPrint(org.w3c.dom.Node n)
Outputs the subtree with root n to System.out with identation, without any respect to the file's original identation |
static void |
prettyPrint(org.w3c.dom.Node n,
java.lang.String title)
Outputs the subtree with root n to System.out with identation, without any respect to the file's original identation. |
static void |
printDocument(org.w3c.dom.Document doc)
Outputs Document doc in System.out exactly as it is in the DOM. |
static void |
printDocument(org.w3c.dom.Document doc,
java.io.File f)
Outputs Document doc in File f exactly as it is in the DOM. |
static org.w3c.dom.Document |
stripUIDs(org.w3c.dom.Document inputDoc)
This method takes as input an XML document in DOM format, duplicates it, then strips the uids from the duplicated DOM. |
static void |
title(java.lang.String title)
Prints a line of stars, then the input title centered inside a line of stars, then another line of stars. |
static void |
writeDOM(org.w3c.dom.Document doc,
java.lang.String url)
Serializes the input DOM representation into file "fileName" in path "filePath". |
static void |
writeDOM(org.w3c.dom.Document doc,
java.lang.String filePath,
java.lang.String fileName)
Serializes the input DOM representation into file "fileName" in path "filePath". |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public NodeUtility()
| Method Detail |
public static void printDocument(org.w3c.dom.Document doc,
java.io.File f)
public static void printDocument(org.w3c.dom.Document doc)
public static void banner(int num)
public static void title(java.lang.String title)
public static void banner()
public static void prettyPrint(org.w3c.dom.Node n,
java.lang.String title)
n - the root of the subtree - will accept a Document variablepublic static void prettyPrint(org.w3c.dom.Node n)
n - the root of the subtree - will accept a Document variablepublic static java.lang.String getPath(org.w3c.dom.Node n)
n - the input node
public static int findPath(org.w3c.dom.Node supposedChild,
org.w3c.dom.Node supposedParent,
java.util.LinkedList goingUpPath,
java.util.LinkedList goingDownPath)
supposedChild - the node from where the path beginssupposedParent - the node the path ends atgoingUpPath - a LinkedList object containing the nodes from supposedChild to supposedParent. Should be given empty, is returned full.
Contains the whole path only if the path contains only upwards edges.goingDownPath - a LinkedList object containing the nodes from common ancestor to supposedParent. Should be given empty, is returned full
if the path includes a downwards sub-path.
public static java.util.LinkedList getLevel(org.w3c.dom.Node n,
int level)
n - the root of the subtree - will accept a Document variablelevel - the needed level - remember that the root has a level of 0
public static java.util.LinkedList getTextNodes(org.w3c.dom.Node n)
public static java.util.LinkedList getElementLevel(org.w3c.dom.Node n,
int level)
n - the root of the subtree - will accept a Document variablelevel - the needed level - remember that the root has a level of 0
public static int getDepth(org.w3c.dom.Document document)
document - the input document
public static int getNodeDepth(org.w3c.dom.Node n)
public static java.util.LinkedList getElementsByUID(org.w3c.dom.Document doc,
java.lang.String id)
doc - the instance documentid - the schema AutoMedID
public static org.w3c.dom.Node getElementByUID(org.w3c.dom.Document doc,
java.lang.String elementUID)
public static org.w3c.dom.Node getElementByUIDNoSchema(org.w3c.dom.Document doc,
java.lang.String elementUID)
throws NotFoundException
doc - the instance document from which to get the element neededelementUID - the UID without the "schemaName:" prefix
NotFoundExceptionpublic static int getChildCount(org.w3c.dom.Node parentNode)
public static int getElementChildCount(org.w3c.dom.Node parentNode)
public static int getPCDATAChildCount(org.w3c.dom.Node parentNode)
public static int getNodeOrder(org.w3c.dom.Node n)
n - the input node
public static int getPCDATANodeOrder(org.w3c.dom.Node n)
public static int getElementNodeOrder(org.w3c.dom.Node n)
public static boolean isTextNode(org.w3c.dom.Node n)
public static boolean isElementNode(org.w3c.dom.Node n)
public static boolean hasTextNodes(org.w3c.dom.Node n)
public static org.w3c.dom.Document parseFile(java.lang.String inputFile,
boolean validating)
inputFile - the location of the input filevalidating - whether the parser should consult the accompanying (?) schema
public static void writeDOM(org.w3c.dom.Document doc,
java.lang.String url)
public static void writeDOM(org.w3c.dom.Document doc,
java.lang.String filePath,
java.lang.String fileName)
public static org.w3c.dom.Document fileCreate(java.lang.String rootName,
java.lang.String filePath,
java.lang.String fileName)
public static org.w3c.dom.Document duplicateDOM(org.w3c.dom.Document doc)
public static org.w3c.dom.Document duplicateDOM(java.lang.String URI,
boolean validating)
URI - the location of the XML filevalidating - set to true in order to validate file against referenced DTD/XML Schema
public static org.w3c.dom.Document stripUIDs(org.w3c.dom.Document inputDoc)
inputDoc - the input document
public static org.apache.xpath.domapi.XPathResultImpl evaluateXPath(org.w3c.dom.Document doc,
java.lang.String xpathExpression,
int resultType)
doc - the document against which to evaluate the XPath expressionxpathExpression - the XPath expression to evaluateresultType - 0 for ORDERED_NODE_SNAPSHOT_TYPE, 1 for ORDERED_NODE_ITERATOR_TYPE
public static java.lang.String getUnderlyingText(org.w3c.dom.Node n,
java.lang.String separator)
n - the root of the subtree - will accept a Document variableseparator - the string separating the strings of the underlying text nodes
public static org.w3c.dom.Document addGenericRoot(org.w3c.dom.Document doc,
java.lang.String newRootName)
public static void main(java.lang.String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||