|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--hypercast.util.XmlUtil
This is a class to implement some special functions for Xml document, for example, writing a Xml document to a file.
Constructor Summary | |
XmlUtil()
|
Method Summary | |
static void |
changeNodeOwner(org.w3c.dom.Document doc,
org.w3c.dom.Node node)
change the owner of a node and all its subnodes |
static org.w3c.dom.Document |
createDocument()
Creates a new Document class for the root of DOM trees. |
static org.w3c.dom.Document |
createDocument(byte[] array)
|
static org.w3c.dom.Document |
createDocument(java.io.File xmlFile)
Creates a new Document class from given XML File instance. |
static org.w3c.dom.Document |
createDocument(java.io.InputStream xmlFileStream,
java.lang.String fileName)
Creates a new Document class from given XML File instance. |
static org.w3c.dom.Document |
createDocument(java.lang.String xmlFilename)
|
static org.w3c.dom.Document |
createDocumentFromString(java.lang.String xmlDocString)
Creates a new Document class from given XML string. |
static org.w3c.dom.Element[] |
createSchemaElement(org.w3c.dom.Document doc,
java.lang.String name,
java.lang.String type,
java.lang.String restrictionBase,
java.lang.String patternValue)
Return the element which represents a statistic in the schema document. |
static org.apache.xpath.XPath |
createXPath(java.lang.String xpathStr)
|
static org.w3c.dom.Node |
findChildNode(org.w3c.dom.Node node,
java.lang.String name)
Find a children node by name |
static java.lang.String |
getScalarStatsResult(hypercast.I_Stats stats,
java.lang.String name)
A static function to get the stats in an old fashion way to eliminate the hassle of dealing with XML |
static java.lang.String |
getScalarValue(org.w3c.dom.Element result)
Extract scalar value from a single Element result |
static java.lang.String |
getScalarValue(org.w3c.dom.Element[] result)
|
static java.lang.String |
getStringFromDocument(org.w3c.dom.Document doc)
Method to convert Document to String. |
static org.w3c.dom.Element |
getXmlValue(org.w3c.dom.Document doc,
java.lang.String xpath,
java.lang.String value)
Convert a String to an Xml Element that can be passed to a I_Stats |
static org.w3c.dom.Element[] |
getXmlValues(org.w3c.dom.Document doc,
java.lang.String xpath,
java.lang.String value)
|
static void |
removeComments(org.w3c.dom.Document d,
org.w3c.dom.Node n)
Remove comments in a document. |
static java.lang.String |
setScalarStatsResult(hypercast.I_Stats stats,
java.lang.String xpath,
java.lang.String value)
A static function to set the stats in an old fashion way to eliminate the hassle of dealing with XML |
static org.w3c.dom.Element[] |
valueToList(org.w3c.dom.Element value)
Make a single Element value to a Element list |
static void |
writeXml(org.w3c.dom.Document saveDoc,
java.io.OutputStream output)
Write Xml document to output stream |
static void |
writeXml(org.w3c.dom.Document saveDoc,
java.io.OutputStream output,
boolean omit_declaration)
Write Xml document to output stream |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public XmlUtil()
Method Detail |
public static org.w3c.dom.Document createDocument()
public static org.w3c.dom.Document createDocument(java.lang.String xmlFilename) throws java.io.FileNotFoundException, java.text.ParseException, java.io.IOException
java.io.FileNotFoundException
java.text.ParseException
java.io.IOException
public static org.w3c.dom.Document createDocument(java.io.File xmlFile) throws java.io.FileNotFoundException, java.text.ParseException, java.io.IOException
xmlFile
- a XML File instance.
java.io.FileNotFoundException
- If the file cannot be opened.
java.lang.NullPointerException
- If the argument is null
java.io.IOException
- on parse error
java.text.ParseException
public static org.w3c.dom.Document createDocument(java.io.InputStream xmlFileStream, java.lang.String fileName) throws java.io.IOException
java.io.IOException
public static org.w3c.dom.Document createDocumentFromString(java.lang.String xmlDocString) throws java.text.ParseException
xmlDocString
- a XML document in string format.
java.text.ParseException
getStringFromDocument(Document)
public static org.w3c.dom.Document createDocument(byte[] array) throws java.text.ParseException
java.text.ParseException
public static java.lang.String getStringFromDocument(org.w3c.dom.Document doc)
doc
- a Document instance.createDocumentFromString(String)
public static void removeComments(org.w3c.dom.Document d, org.w3c.dom.Node n)
d
- A Document instance.n
- Node which represents the subtree from which comments
are removed.public static void writeXml(org.w3c.dom.Document saveDoc, java.io.OutputStream output) throws java.io.IOException
saveDoc
- the Xml document to writeoutput
- the output stream
java.io.IOException
java.io.IOException
- if writing failspublic static void writeXml(org.w3c.dom.Document saveDoc, java.io.OutputStream output, boolean omit_declaration) throws java.io.IOException
saveDoc
- the Xml document to writeoutput
- the output streamomit_declaration
- whether to omit the XML delcaration when outputing.
Used "true "when want to put several XML docs in a single file.
java.io.IOException
java.io.IOException
- if writing failspublic static org.w3c.dom.Node findChildNode(org.w3c.dom.Node node, java.lang.String name)
node
- the node to find the child node inname
- the name of child node to find
public static void changeNodeOwner(org.w3c.dom.Document doc, org.w3c.dom.Node node)
doc
- the new ownernode
- the node to change owner ofpublic static java.lang.String getScalarStatsResult(hypercast.I_Stats stats, java.lang.String name) throws HyperCastStatsException, javax.xml.transform.TransformerException
stats
- the I_Stas objectname
- the name of the stats
javax.xml.transform.TransformerException
HyperCastStatsException
public static java.lang.String getScalarValue(org.w3c.dom.Element result)
public static org.w3c.dom.Element[] valueToList(org.w3c.dom.Element value)
public static java.lang.String getScalarValue(org.w3c.dom.Element[] result)
public static org.w3c.dom.Element[] createSchemaElement(org.w3c.dom.Document doc, java.lang.String name, java.lang.String type, java.lang.String restrictionBase, java.lang.String patternValue)
doc
- The document to create the Elementname
- The name of the created Elementtype
- The type of the statistic. It can be either SimpleType or ComplexType.restrictionBase
- When type is "simpleType", it is to specify the specific type
of this statistic, such as "xsd:string". For ComplexType statistic, it
is null.patternValue
- When type is "simpleType", it is to specify the format of the
value under the specific restriction base. For ComplexType statistic, it
is null.
public static org.apache.xpath.XPath createXPath(java.lang.String xpathStr)
xpathStr
- xpath string.
public static org.w3c.dom.Element getXmlValue(org.w3c.dom.Document doc, java.lang.String xpath, java.lang.String value)
doc
- The document to create the Elementxpath
- The xpath stringvalue
- The String value to convert
public static org.w3c.dom.Element[] getXmlValues(org.w3c.dom.Document doc, java.lang.String xpath, java.lang.String value)
public static java.lang.String setScalarStatsResult(hypercast.I_Stats stats, java.lang.String xpath, java.lang.String value) throws HyperCastStatsException, javax.xml.transform.TransformerException
stats
- the stats objectvalue
- the new value in String format
HyperCastStatsException
javax.xml.transform.TransformerException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |