|
Jitsi: the OpenSource Java VoIP and Instant Messaging client. | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.java.sip.communicator.util.xml.XMLUtils
public class XMLUtils
Common XML Tasks
| Constructor Summary | |
|---|---|
XMLUtils()
|
|
| Method Summary | |
|---|---|
static Document |
createDocument()
Creates W3C Document. |
static Document |
createDocument(String xml)
Creates W3C Document from the xml. |
static String |
createXml(Document document)
Creates XML from W3C Document from the xml. |
static Element |
findChild(Element parent,
String tagName)
Returns the child element with the specified tagName for the specified parent element. |
static List<Element> |
findChildren(Element parent,
String tagName)
Returns the children elements with the specified tagName for the specified parent element. |
static String |
getAttribute(Node node,
String name)
Extracts from node the attribute with the specified name. |
static String |
getCData(Element element)
Extract the CDATA content of the specified element. |
static CDATASection |
getCDataNode(Element element)
Returns element's CDATA child node (if it has one). |
static Node |
getChildByType(Element element,
short nodeType)
Returns first of the element's child nodes that is of type nodeType. |
static String |
getNamespaceUri(Node node)
Gets the node namespace. |
static String |
getText(Element parentNode)
Extracts the String content of a TXT element. |
static Text |
getTextNode(Element element)
Returns element's TEXT child node (if it has one). |
static boolean |
hasChildElements(Element element)
Indicates whether element has any child element. |
static void |
indentedWriteXML(Document doc,
OutputStream out)
A simple implementation of XML writing that also allows for indentation. |
static boolean |
isStandartXmlNamespace(String namespace)
Indicates whether namespace is one of the standart xml namespace. |
static Element |
locateElement(Element root,
String tagName,
String keyAttributeName,
String keyAttributeValue)
Looks through all child elements of the specified root (recursively) and returns the first element that corresponds to all parameters. |
static List<Element> |
locateElements(Element root,
String tagName,
String keyAttributeName,
String keyAttributeValue)
Looks through all child elements of the specified root (recursively) and returns the elements that corresponds to all parameters. |
static void |
printChildElements(Element root,
PrintStream out,
boolean recurse,
String prefix)
Whenever you'd need to print a configuration node and/or its children. |
static void |
setCData(Element element,
String data)
Sets data to be the CDATA content of element |
static void |
setText(Element parentNode,
String data)
Sets data to be the TEXT content of element |
static void |
writeXML(Document document,
File out)
Writes the specified document to the given file adding indentatation. |
static void |
writeXML(Document document,
StreamResult streamResult,
String doctypeSystem,
String doctypePublic)
Writes the specified document to the given file adding indentatation. |
static void |
writeXML(Document document,
Writer writer)
Writes the specified document to the given file adding indentatation. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public XMLUtils()
| Method Detail |
|---|
public static String getAttribute(Node node,
String name)
node - the node whose attribute we'd like to extract.name - the name of the attribute to extract.
public static String getText(Element parentNode)
parentNode - the node containing the data that we'd like to get.
public static void setText(Element parentNode,
String data)
parentNode - the parent element.data - the data to set.
public static void setCData(Element element,
String data)
element - the parent element.data - the data to set.public static String getCData(Element element)
element - the element whose data we need
public static CDATASection getCDataNode(Element element)
element - the element whose CDATA we need to get.
public static Text getTextNode(Element element)
element - the element whose TEXT we need to get.
public static Node getChildByType(Element element,
short nodeType)
element - the element whose child we need.nodeType - the type of the child we need.
public static void writeXML(Document document,
File out)
throws IOException
out - the output Filedocument - the document to write
IOException - in case a TransformerException is thrown by
the underlying Transformer.
public static void writeXML(Document document,
Writer writer)
throws IOException
writer - the writer to use when writing the Filedocument - the document to write
IOException - in case a TransformerException is thrown by
the underlying Transformer.
public static void writeXML(Document document,
StreamResult streamResult,
String doctypeSystem,
String doctypePublic)
throws IOException
streamResult - the streamResult object where the document should be
writtendocument - the document to writedoctypeSystem - the doctype system of the xml document that we should
record in the file or null if none is specified.doctypePublic - the public identifier to be used in the document
type declaration.
IOException - in case a TransformerException is thrown by
the underlying Transformer.
public static void indentedWriteXML(Document doc,
OutputStream out)
doc - the Document that we will be writing.out - an OutputStream to write the document through.
public static void printChildElements(Element root,
PrintStream out,
boolean recurse,
String prefix)
root - the root node to print.out - the print stream that should be used to outpurecurse - booleanprefix - String
public static Element findChild(Element parent,
String tagName)
parent - The parent whose child we're looking for.tagName - the name of the child to find
NullPointerException - if parent or tagName are null
public static List<Element> findChildren(Element parent,
String tagName)
parent - The parent whose children we're looking for.tagName - the name of the child to find
NullPointerException - if parent or tagName are null
public static Element locateElement(Element root,
String tagName,
String keyAttributeName,
String keyAttributeValue)
root - the Element where the search should begintagName - the name of the node we're looking forkeyAttributeName - the name of an attribute that the node has to
havekeyAttributeValue - the value that attribute must have
NullPointerException - if any of the arguments is null.
public static List<Element> locateElements(Element root,
String tagName,
String keyAttributeName,
String keyAttributeValue)
root - the Element where the search should begintagName - the name of the node we're looking forkeyAttributeName - the name of an attribute that the node has to
havekeyAttributeValue - the value that attribute must have
NullPointerException - if any of the arguments is null.public static boolean isStandartXmlNamespace(String namespace)
namespace - the namespace to analyze.
public static String getNamespaceUri(Node node)
node - the Element or Attr node to analyze.
public static boolean hasChildElements(Element element)
element - the namespace to analyze.
public static Document createDocument()
throws Exception
Exception - is there is some error during operation.
public static Document createDocument(String xml)
throws Exception
xml - the xml that needs to be converted.
Exception - is there is some error during operation.
public static String createXml(Document document)
throws Exception
document - the xml that needs to be converted.
Exception - is there is some error during operation.
|
Jitsi: the OpenSource Java VoIP and Instant Messaging client. | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||