|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.xolite.dom.DomUtils
public abstract class DomUtils
Utilities for DOM.
Field Summary | |
---|---|
static int |
EMPTY_EQUALS_NULL
Flag for comparison: empty elements (like <el/> or <el></el>) are equivalent to no-existent elements. |
static int |
IGNORE_CASE
Flag for comparison: ignore case for string values. |
static int |
IGNORE_SEQUENCE_ORDER
Flag for comparison: ignore order of elements in sequences. |
static int |
NORMALIZE_STRING_VALUES
Flag for comparison: normalize whitespaces in string values . |
static int |
TRIM_STRING_VALUES
Flag for comparison: trim string values. |
Method Summary | |
---|---|
static boolean |
checkObjectSerialisation(XMLSerializable src,
InputStream is)
Check that result of the given XMLSerializable serialisation is the same XML as the given inputStream content. |
static boolean |
checkObjectSerialisation(XMLSerializable src,
InputStream is,
int flags)
|
static boolean |
documentsAreEquals(Document doc1,
Document doc2)
|
static boolean |
documentsAreEquals(Document doc1,
Document doc2,
int flags)
|
static String |
domToString(Document doc)
Serialize a DOM document to a String with multiple lines and 4 indentation spaces. |
static String |
domToString(Document doc,
int nbrIndentationSpace,
boolean multiLine)
Serialize a DOM document to a String. |
static boolean |
elementsAreEquals(Element elem1,
Element elem2,
int flags)
|
static String |
elementToString(Element elem)
Serialize a DOM document to a String with multiple lines and 4 indentation spaces. |
static String |
elementToString(Element elem,
int nbrIndentationSpace,
boolean multiLine)
Serialize a DOM element (and all it's sub-elements) to a String. |
static String |
getDefinedPerfix(Node startNode,
String uri)
Get the prefix already defined in the DOM at the node location for the given namespace URI. |
static List<String> |
getDefinedPerfixes(Node startNode,
String uri)
Get the list of prefixs already defined in the DOM at the node location for the given namespace URI. |
static String |
getDefinedUri(Node startNode,
String prefix)
Get the URI already defined in the DOM and associated to the given prefix. |
static Element |
getDirectChild(Element parent,
String namespaceURI,
String localName,
int index)
Get the direct child of an element matching the given namespace+tag+index. |
static List<Node> |
getDirectChildElementsByTagNameNS(Element parent,
String namespaceURI,
String localName)
Get the list of direct child of an element matching the given namespace+tag. |
static String |
getEncoding(String xml)
Get the encoding declared in the given XML or "UTF-8" by default. |
static String |
getTextValue(Node nod)
Get the text value of an element or attribute node. |
static boolean |
isEmpty(Element el)
An empty element means an element without attributes and without text or with white text. |
static boolean |
matchElement(Node nod,
String uri,
String tag)
Check if the given node is an element matching the given namespace+tag. |
static Document |
resourceToDom(Class<?> resolver,
String resourcePath)
|
static void |
setTextValue(Node nod,
String text)
Set the text value of an element or attribute node. |
static Document |
streamToDom(InputStream is)
|
static Document |
stringToDom(String xml)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int IGNORE_CASE
public static final int TRIM_STRING_VALUES
public static final int NORMALIZE_STRING_VALUES
public static final int IGNORE_SEQUENCE_ORDER
public static final int EMPTY_EQUALS_NULL
Method Detail |
---|
public static List<Node> getDirectChildElementsByTagNameNS(Element parent, String namespaceURI, String localName)
parent
- parent node when the child are searched.namespaceURI
- requested element namespace URI.localName
- requested element local name (tag).
public static Element getDirectChild(Element parent, String namespaceURI, String localName, int index)
parent
- parent node when the child are searched.namespaceURI
- requested element namespace URI.localName
- requested element local name (tag).index
- the child element index (among the elements matching the namespace+localName). Note: Unlike XPath standard,
this index is zero-based.
public static String getDefinedPerfix(Node startNode, String uri)
startNode
- the context node where we search for prefix.uri
- the namespace URI to search.
public static List<String> getDefinedPerfixes(Node startNode, String uri)
startNode
- the context node where we search for prefix.uri
- the namespace URI to search.
public static String getDefinedUri(Node startNode, String prefix)
startNode
- the context node where we search for prefix.prefix
- the prefix to search.
public static boolean matchElement(Node nod, String uri, String tag)
nod
- the nodeuri
- namespace for the elementtag
- local name for the element
public static String getTextValue(Node nod)
nod
- The element or attribute node.
public static void setTextValue(Node nod, String text)
nod
- The element or attribute node.text
- it's new text value.public static boolean checkObjectSerialisation(XMLSerializable src, InputStream is)
src
- a XML serializable objectis
- a stream containing the expected serialisation result.
public static boolean checkObjectSerialisation(XMLSerializable src, InputStream is, int flags)
public static boolean documentsAreEquals(Document doc1, Document doc2)
public static boolean documentsAreEquals(Document doc1, Document doc2, int flags)
public static boolean elementsAreEquals(Element elem1, Element elem2, int flags)
public static boolean isEmpty(Element el)
public static String domToString(Document doc)
public static String domToString(Document doc, int nbrIndentationSpace, boolean multiLine)
public static String elementToString(Element elem)
public static String elementToString(Element elem, int nbrIndentationSpace, boolean multiLine)
public static Document stringToDom(String xml)
public static String getEncoding(String xml)
public static Document resourceToDom(Class<?> resolver, String resourcePath)
public static Document streamToDom(InputStream is)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |