|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectnet.ex_337.gradient.util.XMLUtils
Static XML utility methods.
| Field Summary | |
static String |
DIRECTIVE
The element name for a Gradient of an document modification directive. |
static String |
DIRECTIVE_SET
The element name for an XMPP extension enclosing a set of document modification directives. |
static String |
DOC_REQUEST
The element name for an Gradient document request extension. |
static String |
DOC_RESPONSE
The element name for the response to an a Gradient document request. |
static Document |
FACTORY_DOCUMENT
A generic factory document for use in creating Elements etc. |
static String |
GRADIENT_NAMESPACE
This is the namespace used for tagging Gradient document modification directives, Message/Presence target path/document request extensions, and thread attributes on outgoing IQs. |
static DOM2XmlPullBuilder |
PULL2DOM
A Pull-API to DOM converter. |
static String |
SVG_NAMESPACE
The namespace used by the W3C SVG 1.0 specification. |
static String |
TARGET_PATH
The element name for a Gradient XMPP extension specifying a target path for a given Message/Presence stanza. |
| Constructor Summary | |
XMLUtils()
|
|
| Method Summary | |
static void |
appendTo(Document document,
NamespaceContext context,
String xPathExpression,
List nodeList)
Appends the nodes in nodeList to each Node in the document matching the given XPath expression using the given namespace context. |
static Map |
getAttributesWithNS(Element element,
String namespaceURI)
Returns a Map of all attributes of the given element with the given namespace. |
static Map |
getAttributesWithPrefix(Element element,
String prefix)
This is an ugly hack, there must be a nicer way to do it. |
static String |
getChildCharacterData(Element parentEl)
Returns all child character data of the given element, including CDATA sections but NOT entity references. |
static List |
getChildElements(Element element)
Returns a List of all child Elements of the given Element. |
static Element |
getElementFromStream(InputStream input)
Uses the default DOM2PullParser to retrieve a DOM Element from an InputStream. |
static Element |
getElementFromString(String string)
Uses the default DOM2PullParser to retrieve a DOM Element from a String The parent document will be FACTORY_DOCUMENT. |
static List |
getMatchingNodes(Document document,
NamespaceContext context,
String xPathExpression)
Compiles the given XPath expression with the given namepace context, and returns a list of all matching nodes in the given document. |
static void |
insertBefore(Document document,
NamespaceContext context,
String xPathExpression,
List nodeList)
Inserts the nodes in nodeList before each Node in the document matching the given XPath expression using the given namespace context. |
static Document |
loadDocument(InputStream input)
For some reason this is really, really slow. |
static Element |
loadElement(InputStream input)
Returns the document element. |
static void |
main(String[] args)
Tests whatever method I last added to this class. |
static Document |
newDocument()
Creates a new Document. |
static void |
printElements(List l1)
Debug method. |
static void |
remove(Document document,
NamespaceContext context,
String xPathExpression)
Removes each node matching the given XPath expression in the given document. |
static List |
removeElementsWithNamespace(List elements,
String namespace)
Removes all elements with the given namespace from the provided list. |
static List |
removeElementsWithTagName(List elements,
String tagName)
Removes all elements with the given tag name from the given list |
static void |
replace(Document document,
NamespaceContext context,
String xPathExpression,
Node replacementNode)
Replaces each node in the document matching the given XPath expression with the given node. |
static String |
serialiseElement(Element element)
Returns the String serialisation of an Element. |
static String |
serialiseElementNicely(Element element)
Returns the String serialisation of an Element. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final Document FACTORY_DOCUMENT
public static final String SVG_NAMESPACE
public static final String DOC_REQUEST
public static final String GRADIENT_NAMESPACE
public static final String DIRECTIVE_SET
public static final String DIRECTIVE
public static final String TARGET_PATH
public static final String DOC_RESPONSE
public static DOM2XmlPullBuilder PULL2DOM
| Constructor Detail |
public XMLUtils()
| Method Detail |
public static String serialiseElementNicely(Element element)
element - the element to serialise
public static String serialiseElement(Element element)
element - the element to serialise
public static Document newDocument()
public static Document loadDocument(InputStream input)
input - the XML input stream
public static Element loadElement(InputStream input)
input - the inputstream containg an XML document.
public static List getChildElements(Element element)
element - the element from which to retrieve child elements
NullPointerException - if the element is null.
public static List removeElementsWithNamespace(List elements,
String namespace)
elements - the list of elementsnamespace - the namespace of the elements to remove
ClassCastException - if any of the list members are not Elements
public static List removeElementsWithTagName(List elements,
String tagName)
elements - the list of elementstagName - the tag name
ClassCastException - if any of the list members are not Elementspublic static String getChildCharacterData(Element parentEl)
parentEl - the parent element.
public static Map getAttributesWithNS(Element element,
String namespaceURI)
element - the elment from which to retrieve the attributes.namespaceURI - the namespace of the attributes to retrieve.
public static Map getAttributesWithPrefix(Element element,
String prefix)
element - the element from which to retrieve the attributes.prefix - the prefix of the attributes to retrieve
public static void printElements(List l1)
l1 - the list of elements to print.
public static List getMatchingNodes(Document document,
NamespaceContext context,
String xPathExpression)
document - the document to run the XPath expression against.context - the namespace context to use.xPathExpression - the XPath expression to use.
FailedDirectiveException - if the XPath exrpression is malformed.
public static void appendTo(Document document,
NamespaceContext context,
String xPathExpression,
List nodeList)
document - the document to run the XPath expression against.context - the namespace context of the XPath expression.xPathExpression - the XPath expression that retrieves the list of Nodes from the Document.nodeList - the list of nodes to append to each result of the XPath expression.
public static void insertBefore(Document document,
NamespaceContext context,
String xPathExpression,
List nodeList)
document - the document to run the XPath expression against.context - the namespace context of the XPath expression.xPathExpression - the XPath expression that retrieves the list of Nodes from the Document.nodeList - the list of nodes to insert before each result of the XPath expression.
public static void replace(Document document,
NamespaceContext context,
String xPathExpression,
Node replacementNode)
document - the document to run the XPath expression against.context - the namespace context of the XPath expression.xPathExpression - the XPath expression that retrieves the list of Nodes from the Document.replacementNode - the node with which to replace each result of the XPath expression.
public static void remove(Document document,
NamespaceContext context,
String xPathExpression)
document - the document to run the XPath expression against.context - the namespace context of the XPath expression.xPathExpression - the XPath expression that retrieves the list of Nodes to remove from the Document.public static Element getElementFromStream(InputStream input)
input - the InputStream from which to read the element markup
GeneralRuntimeException - if an IOException or XmlPullParserException is thrown during parsing.public static Element getElementFromString(String string)
string - the String containing the element markup
GeneralRuntimeException - if an IOException or XmlPullParserException is thrown during parsing.public static void main(String[] args)
args - the arguments, if you insist.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||