|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jopendocument.util.JDOMUtils
public final class JDOMUtils
Field Summary | |
---|---|
static org.jdom.output.XMLOutputter |
OUTPUTTER
|
Constructor Summary | |
---|---|
JDOMUtils()
|
Method Summary | |
---|---|
static void |
addNamespaces(org.jdom.Element elem,
Collection<org.jdom.Namespace> c)
Add namespace declaration to elem if needed. |
static void |
addNamespaces(org.jdom.Element elem,
org.jdom.Namespace... l)
|
static boolean |
equals(org.jdom.Element elem1,
org.jdom.Element elem2)
Test if two elements have the same namespace and name. |
static boolean |
equalsDeep(org.jdom.Element elem1,
org.jdom.Element elem2)
Compare two elements and their descendants (only Element and Text). |
static boolean |
equalsDeep(org.jdom.Element elem1,
org.jdom.Element elem2,
boolean normalizeText)
|
static org.jdom.Element |
getAncestor(org.jdom.Element element,
IPredicate<org.jdom.Element> pred)
|
static org.jdom.Element |
getAncestor(org.jdom.Element element,
String name,
org.jdom.Namespace ns)
|
static Iterator<org.jdom.Content> |
getContent(org.jdom.Element elem,
IPredicate<? super org.jdom.Content> pred,
boolean mergeText)
Get the filtered content of an element, optionnaly merging adjacent Text . |
static org.jdom.Element |
getOrCreateChild(org.jdom.Element parent,
String name,
org.jdom.Namespace ns)
Get the requested child of parent or create one if necessary. |
static org.jdom.Element |
getOrCreateChild(org.jdom.Element parent,
String name,
org.jdom.Namespace ns,
int index)
|
static void |
insertAfter(org.jdom.Element insertAfter,
Collection<? extends org.jdom.Content> toAdd)
|
static void |
insertBefore(org.jdom.Element insertBefore,
Collection<? extends org.jdom.Content> toAdd)
|
static void |
insertSiblings(org.jdom.Element sibling,
Collection<? extends org.jdom.Content> toAdd,
boolean after)
Add content before or after an element. |
org.jdom.Element |
mkElem(org.jdom.Element current,
String path)
Aka mkdir -p. |
static String |
output(org.jdom.Document xml)
Ecrit l'XML en chaine, contrairement a toString(). |
static String |
output(org.jdom.Element xml)
Ecrit l'XML en chaine, contrairement a toString(). |
static org.jdom.Element |
parseElementString(String xml,
org.jdom.Namespace[] namespaces)
Analyse la chaine passée et retourne l'Element correspondant. |
static org.jdom.Element |
parseString(String xml)
Analyse la chaine passée et retourne l'Element correspondant. |
static List |
parseString(String xml,
org.jdom.Namespace[] namespaces)
Analyse la chaine passée et retourne la liste correspondante. |
static org.jdom.Document |
parseStringDocument(String xml)
Analyse la chaine passée avec un builder par défaut et retourne le Document correspondant. |
static org.jdom.Document |
parseStringDocument(String xml,
org.jdom.input.SAXBuilder builder)
Analyse la chaine passée et retourne le Document correspondant. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final org.jdom.output.XMLOutputter OUTPUTTER
Constructor Detail |
---|
public JDOMUtils()
Method Detail |
---|
public static org.jdom.Element parseElementString(String xml, org.jdom.Namespace[] namespaces) throws org.jdom.JDOMException
xml
- une chaine contenant un élément XML.namespaces
- les namespaces utilisés dans la chaine.
org.jdom.JDOMException
- si l'xml n'est pas bien formé.public static List parseString(String xml, org.jdom.Namespace[] namespaces) throws org.jdom.JDOMException
xml
- une chaine contenant de l'XML.namespaces
- les namespaces utilisés dans la chaine.
org.jdom.JDOMException
- si l'xml n'est pas bien formé.public static org.jdom.Element parseString(String xml) throws org.jdom.JDOMException
xml
- une chaine contenant de l'XML.
org.jdom.JDOMException
- si l'xml n'est pas bien formé.parseElementString(String, Namespace[])
public static org.jdom.Document parseStringDocument(String xml) throws org.jdom.JDOMException
xml
- une chaine représentant un document XML.
org.jdom.JDOMException
- si l'xml n'est pas bien formé.parseStringDocument(String, SAXBuilder)
public static org.jdom.Document parseStringDocument(String xml, org.jdom.input.SAXBuilder builder) throws org.jdom.JDOMException
xml
- une chaine représentant un document XML.builder
- le builder à utiliser.
org.jdom.JDOMException
- si l'xml n'est pas bien formé.public static String output(org.jdom.Element xml)
xml
- l'élément à écrire.
public static String output(org.jdom.Document xml)
xml
- l'élément à écrire.
public static org.jdom.Element getAncestor(org.jdom.Element element, String name, org.jdom.Namespace ns)
public static org.jdom.Element getAncestor(org.jdom.Element element, IPredicate<org.jdom.Element> pred)
public static void addNamespaces(org.jdom.Element elem, Collection<org.jdom.Namespace> c)
elem
if needed. Necessary since JDOM uses a simple
list.
elem
- the element where namespaces should be available.c
- the namespaces to add.Element.addNamespaceDeclaration(Namespace)
public static void addNamespaces(org.jdom.Element elem, org.jdom.Namespace... l)
public static org.jdom.Element getOrCreateChild(org.jdom.Element parent, String name, org.jdom.Namespace ns)
parent
or create one if necessary. The created child
is added at the end
.
parent
- the parent.name
- the name of the requested child.ns
- the namespace of the requested child.
parent
.Element.getChild(String, Namespace)
public static org.jdom.Element getOrCreateChild(org.jdom.Element parent, String name, org.jdom.Namespace ns, int index)
public org.jdom.Element mkElem(org.jdom.Element current, String path)
current
- l'élément dans lequel créer la hierarchie.path
- le chemin des éléments à créer, chaque niveau séparé par "/".
public static void insertAfter(org.jdom.Element insertAfter, Collection<? extends org.jdom.Content> toAdd)
public static void insertBefore(org.jdom.Element insertBefore, Collection<? extends org.jdom.Content> toAdd)
public static void insertSiblings(org.jdom.Element sibling, Collection<? extends org.jdom.Content> toAdd, boolean after)
sibling
- an element with a parent.toAdd
- the content to add alongside sibling
.after
- true
to add it after sibling
.public static boolean equals(org.jdom.Element elem1, org.jdom.Element elem2)
elem1
- an element, can be null
.elem2
- an element, can be null
.
true
if both elements have the same name and namespace, or if both are
null
.public static boolean equalsDeep(org.jdom.Element elem1, org.jdom.Element elem2)
elem1
- first element.elem2
- second element.
true
if both elements are equal.getContent(Element, IPredicate, boolean)
public static boolean equalsDeep(org.jdom.Element elem1, org.jdom.Element elem2, boolean normalizeText)
public static Iterator<org.jdom.Content> getContent(org.jdom.Element elem, IPredicate<? super org.jdom.Content> pred, boolean mergeText)
Text
. Adjacent
text can only happen programmatically.
elem
- the parent.pred
- which content to return.mergeText
- true
if adjacent Text should be merged into one,
false
to leave the list as it is.
Iterator.remove()
).
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |