public class XmlUtil
extends java.lang.Object
| Modifier and Type | Field and Description | 
|---|---|
| static java.lang.String | REVISION | 
| static java.lang.String | XML_HEADER | 
| Modifier and Type | Method and Description | 
|---|---|
| static void | addLangElement(org.jdom.Element parentElt,
              java.lang.String eltName,
              java.util.Map<java.lang.String,java.lang.String> langMap)Constructs a sub element base on the given language map. | 
| static java.lang.String | extractText(java.lang.String str)Extract the text of the given XML/HTML string. | 
| static java.lang.String | extractText(java.lang.String str,
           boolean collapseBlank)Extract the text of the given XML/HTML string. | 
| static java.util.HashMap<java.lang.String,java.lang.String> | getAttributesAsMap(org.jdom.Element elt)Return a map of attribute (key, value) from the attributes of the JDom Element | 
| static boolean | getBoolean(java.lang.Object node,
          java.lang.String xpathExpression,
          boolean def)Gives a boolean representation of the first node wich if the result of the XPath expression into
 the given node in parameter. | 
| static org.jdom.input.SAXBuilder | getBuilder()Get a SAXBuilder | 
| static java.util.Date | getDate(java.lang.Object node,
       java.lang.String xpathExpression,
       java.util.Date def)Gives a Date representation of the first node wich if the result of the XPath expression into
 the given node in parameter. | 
| static org.jdom.Document | getDocument(java.io.File file)Returns the JDOM document for the given file. | 
| static org.jdom.Document | getDocument(java.io.InputStream in)Returns the JDOM document for the given input stream. | 
| static org.jdom.Document | getDocument(java.io.Reader reader)Returns the JDOM document for the given reader. | 
| static org.jdom.Document | getDocument(java.lang.String text)Returns a JDOM document for the given text. | 
| static org.jdom.Element | getFirstChild(org.jdom.Element parent,
             java.lang.String childName)Returns the first child of the given parent with the given name. | 
| static org.jdom.Element | getLangChild(org.jdom.Element elt,
            java.lang.String childName,
            java.lang.String lang,
            java.lang.String defaultLang)Returns the first child of  eltif possible which useslangordefaultLangas value
 for itsxml:langattribute. | 
| static java.util.List<org.jdom.Element> | getLangChildren(org.jdom.Element elt,
               java.lang.String childName,
               java.lang.String lang)Returns all the children of  eltwhich uselangas value
 for theirxml:langattribute. | 
| static java.util.Map<java.lang.String,java.lang.String> | getLangChildrenMap(org.jdom.Element elt,
                  java.lang.String childName)Returns the map of the children of  eltwith theirxml:langas key. | 
| static java.lang.String | getLangChildText(org.jdom.Element elt,
                java.lang.String childName,
                java.lang.String lang)Returns the text of the first child of  eltwhich useslangas value
 for itsxml:langattribute. | 
| static java.lang.String | getLangChildText(org.jdom.Element elt,
                java.lang.String childName,
                java.lang.String lang,
                java.lang.String defaultLang)Returns the text of the first child of  eltwhich useslangordefaultLangas value for itsxml:langattribute. | 
| static long | getLong(java.lang.Object node,
       java.lang.String xpathExpression,
       long def)Gives a long representation of the first node wich if the result of the XPath expression into
 the given node in parameter. | 
| static java.util.List<?> | getNodeList(org.jdom.Document doc,
           java.lang.String xpathExpression)Provide XPath feature : returns the list of Nodes in the xml in first argument,
 with the xPathExpression in second argument. | 
| static java.util.List<?> | getNodeList(org.jdom.Element element,
           java.lang.String xpathExpression)Provide XPath feature : returns the list of Nodes in the xml in first argument,
 with the xPathExpression in second argument. | 
| static java.util.List<?> | getNodeList(java.lang.String xmlString,
           java.lang.String xpathExpression)Provide XPath feature : returns the list of Nodes in the xml in first argument,
 with the xPathExpression in second argument. | 
| static java.lang.Object | getSingleNode(java.lang.Object doc,
             java.lang.String xpathExpression)Provide XPath feature : returns the first of the Nodes in the xml in first argument,
 with the xPathExpression in second argument. | 
| static java.lang.Object | getSingleNode(java.lang.String xmlString,
             java.lang.String xpathExpression)Provide XPath feature : returns the first of the Nodes in the xml in first argument,
 with the xPathExpression in second argument. | 
| static java.lang.String | getString(java.lang.Object node,
         java.lang.String xpathExpression)Return the most pertinent String for the result of the XPath query in the body content
 of the given resource. | 
| static java.lang.String | getStringNode(java.lang.Object node)Return the most pertinent String representation for this node. | 
| static java.lang.String | getTextValue(org.w3c.dom.Element parentElement,
            java.lang.String tagName)Returns the text value of the given tag of the given DOM element | 
| static java.lang.String | getTextValue(org.w3c.dom.Element parentElement,
            java.lang.String tagName,
            java.lang.String defaultValue)Returns the text value of the given tag of the given DOM element
 or the default value. | 
| static java.lang.String | getXmlString(org.jdom.Element elt)Returns a String representation of the given element. | 
| static int | lastIndexOfElement(org.jdom.Element parentElt,
                  java.lang.String eltName)Returns the position of the latest element with the given name
 in the parent's childrens or -1 if there is no elements. | 
| static java.lang.String | normalize(java.lang.String str)Normalizes the String for XML. | 
| static void | removeEmptyElement(org.jdom.Element element)Remove element if it is no longer a node. | 
| static org.jdom.Element | searchChild(org.jdom.Element elt,
           java.lang.String tagName,
           java.lang.String attName,
           java.lang.String attValue)Returns the first child having a given attribute value. | 
| static java.util.List<org.jdom.Element> | searchChildren(org.jdom.Element elt,
              java.lang.String tagName,
              java.lang.String attName,
              java.lang.String attValue)Returns all the children having the given attribute value. | 
| static org.jdom.Element | searchElement(org.jdom.Document document,
             java.lang.String tagName,
             java.lang.String attName,
             java.lang.String attValue)Returns the first element having a given attribute value | 
| static java.lang.String | searchValue(org.jdom.Element element,
           java.lang.String tagName,
           java.lang.String attName)Returns the first element having a given attribute name | 
| static void | updateAttribute(org.jdom.Element elt,
               java.lang.String attr,
               java.lang.String value)Updates a given attribute value on a given element. | 
| static void | updateElements(org.jdom.Element parent,
              java.lang.String childName,
              java.lang.String attName,
              java.util.Set<java.lang.String> attrSet)Update all children attribute value, with the given name, under a given parent Element. | 
| static void | updateLangElement(org.jdom.Element parentElt,
                 java.lang.String eltName,
                 java.util.Map<java.lang.String,java.lang.String> langMap)Constructs a sub element base on the given language map. | 
| static void | write(org.jdom.Document doc,
     java.io.File file) | 
public static final java.lang.String REVISION
public static final java.lang.String XML_HEADER
public static java.lang.String normalize(java.lang.String str)
<,
 >, &, \,
 ", \r, \n.
 All char < 0x20 are ignored except \t, \r, \nstr - the string to normalizepublic static org.jdom.Element searchChild(org.jdom.Element elt,
                           java.lang.String tagName,
                           java.lang.String attName,
                           java.lang.String attValue)
elt - the element to start the search.tagName - the elements to be searched for.attName - the attributes to be searched for.attValue - the value to be searched for.public static java.util.List<org.jdom.Element> searchChildren(org.jdom.Element elt,
                                              java.lang.String tagName,
                                              java.lang.String attName,
                                              java.lang.String attValue)
elt - the element to start the search.tagName - the elements to be searched for.attName - the attributes to be searched for.attValue - the value to be searched for.public static org.jdom.Element searchElement(org.jdom.Document document,
                             java.lang.String tagName,
                             java.lang.String attName,
                             java.lang.String attValue)
document - the document to start the search.tagName - the elements to be searched for.attName - the attributes to be searched for.attValue - the value to be searched for.public static java.lang.String searchValue(org.jdom.Element element,
                           java.lang.String tagName,
                           java.lang.String attName)
element - the element to search on.tagName - the elements of this document to be searched.attName - the attributes of this element to be searched.public static java.util.HashMap<java.lang.String,java.lang.String> getAttributesAsMap(org.jdom.Element elt)
elt - the Element to get the attributepublic static org.jdom.input.SAXBuilder getBuilder()
public static org.jdom.Document getDocument(java.io.File file)
                                     throws org.jdom.JDOMException,
                                            java.io.IOException
file - the file.org.jdom.JDOMException - JDOMException thrown during parsingjava.io.IOException - IOException thrown during parsingpublic static org.jdom.Document getDocument(java.io.InputStream in)
                                     throws org.jdom.JDOMException,
                                            java.io.IOException
in - the input stream.org.jdom.JDOMException - JDOMException thrown during parsingjava.io.IOException - IOException thrown during parsingpublic static org.jdom.Document getDocument(java.io.Reader reader)
                                     throws org.jdom.JDOMException,
                                            java.io.IOException
reader - the reader.org.jdom.JDOMException - JDOMException thrown during parsingjava.io.IOException - IOException thrown during parsingpublic static org.jdom.Document getDocument(java.lang.String text)
                                     throws org.jdom.JDOMException,
                                            java.io.IOException
text - the text.org.jdom.JDOMException - JDOMException thrown during parsingjava.io.IOException - IOException thrown during parsingpublic static void write(org.jdom.Document doc,
         java.io.File file)
                  throws java.io.IOException
java.io.IOExceptionpublic static java.lang.String getXmlString(org.jdom.Element elt)
elt - the elementpublic static org.jdom.Element getLangChild(org.jdom.Element elt,
                            java.lang.String childName,
                            java.lang.String lang,
                            java.lang.String defaultLang)
elt if possible which uses lang or
 defaultLang as value
 for its xml:lang attribute.elt - the ElementchildName - the name of the childlang - the languagedefaultLang - the default languageelt which uses lang as value
 for its xml:lang attribute.public static java.lang.String getLangChildText(org.jdom.Element elt,
                                java.lang.String childName,
                                java.lang.String lang)
elt which uses lang as value
 for its xml:lang attribute.elt - the ElementchildName - the name of the childlang - the languageelt which uses lang as value
 for its xml:lang attribute.getLangChildText(Element, String, String, String)public static java.lang.String getLangChildText(org.jdom.Element elt,
                                java.lang.String childName,
                                java.lang.String lang,
                                java.lang.String defaultLang)
elt which uses lang or 
 defaultLang as value for its xml:lang attribute.elt - the ElementchildName - the name of the childlang - the languagedefaultLang - the default languageelt which uses lang or defaultLang as value
 for its xml:lang attribute.public static java.util.List<org.jdom.Element> getLangChildren(org.jdom.Element elt,
                                               java.lang.String childName,
                                               java.lang.String lang)
elt which use lang as value
 for their xml:lang attribute.elt - the ElementchildName - the name of the childlang - the languageelt which uses lang as value
 for its xml:lang attribute.public static java.util.Map<java.lang.String,java.lang.String> getLangChildrenMap(org.jdom.Element elt,
                                                                  java.lang.String childName)
elt with their xml:lang as key.elt - the ElementchildName - the name of the childlang, elt}.public static int lastIndexOfElement(org.jdom.Element parentElt,
                     java.lang.String eltName)
parentElt - the parent elementeltName - the name of the sub elementpublic static void addLangElement(org.jdom.Element parentElt,
                  java.lang.String eltName,
                  java.util.Map<java.lang.String,java.lang.String> langMap)
parentElt - the parent elementeltName - the name of the sub elementlangMap - the language mappublic static void updateLangElement(org.jdom.Element parentElt,
                     java.lang.String eltName,
                     java.util.Map<java.lang.String,java.lang.String> langMap)
parentElt - the parent elementeltName - the name of the sub elementlangMap - the language mappublic static void updateAttribute(org.jdom.Element elt,
                   java.lang.String attr,
                   java.lang.String value)
elt - the XML Elementattr - String represents tha attribute namevalue - the attribute value to setpublic static void updateElements(org.jdom.Element parent,
                  java.lang.String childName,
                  java.lang.String attName,
                  java.util.Set<java.lang.String> attrSet)
parent - the parent ElementchildName - the children name elementattName - the children attribute name to work withattrSet - the set of new values.public static void removeEmptyElement(org.jdom.Element element)
element - the element to work withpublic static org.jdom.Element getFirstChild(org.jdom.Element parent,
                             java.lang.String childName)
parent - the Parent ElementchildName - the name of the child to look for or create.public static java.lang.String getTextValue(org.w3c.dom.Element parentElement,
                            java.lang.String tagName)
parentElement - the parenttagName - the name of the tag to get the text valuepublic static java.lang.String getTextValue(org.w3c.dom.Element parentElement,
                            java.lang.String tagName,
                            java.lang.String defaultValue)
parentElement - the parenttagName - the name of the tag to get the text valuedefaultValue - the defaultValuepublic static java.lang.String extractText(java.lang.String str)
str - the XML/HTML string .public static java.lang.String extractText(java.lang.String str,
                           boolean collapseBlank)
str - the XML/HTML string .collapseBlank - if true, series of blanks chars are collapsed in one blank.public static java.util.List<?> getNodeList(java.lang.String xmlString,
                            java.lang.String xpathExpression)
                                     throws org.jdom.JDOMException
xmlString - the full XML in a single StringxpathExpression - the XPath expressionorg.jdom.JDOMException - if the XPath expression is invalid or its evaluation on the specified context failed.public static java.util.List<?> getNodeList(org.jdom.Document doc,
                            java.lang.String xpathExpression)
                                     throws org.jdom.JDOMException
doc - the XML documentxpathExpression - the XPath expressionorg.jdom.JDOMException - if the XPath expression is invalid or its evaluation on the specified context failed.public static java.util.List<?> getNodeList(org.jdom.Element element,
                            java.lang.String xpathExpression)
                                     throws org.jdom.JDOMException
element - an XML nodexpathExpression - the XPath expressionorg.jdom.JDOMException - if the XPath expression is invalid or its evaluation on the specified context failed.public static java.lang.Object getSingleNode(java.lang.String xmlString,
                             java.lang.String xpathExpression)
                                      throws org.jdom.JDOMException
xmlString - the XML documentxpathExpression - the XPath expressionorg.jdom.JDOMException - if the XPath expression is invalid or its evaluation on the specified context failed.public static java.lang.Object getSingleNode(java.lang.Object doc,
                             java.lang.String xpathExpression)
                                      throws org.jdom.JDOMException
doc - the XML documentxpathExpression - the XPath expressionorg.jdom.JDOMException - if the XPath expression is invalid or its evaluation on the specified context failed.public static java.lang.String getString(java.lang.Object node,
                         java.lang.String xpathExpression)
node - the Element node used to execute xpath expressionxpathExpression - an xpath expression to dig into the nodepublic static java.lang.String getStringNode(java.lang.Object node)
node - the given resource get by a rest requestpublic static boolean getBoolean(java.lang.Object node,
                 java.lang.String xpathExpression,
                 boolean def)
node - the node we dig intoxpathExpression - the XPath expressiondef - the default valuepublic static java.util.Date getDate(java.lang.Object node,
                     java.lang.String xpathExpression,
                     java.util.Date def)
node - the node we dig intoxpathExpression - the XPath expressiondef - the default valuepublic static long getLong(java.lang.Object node,
           java.lang.String xpathExpression,
           long def)
node - the node we dig intoxpathExpression - the XPath expressiondef - the default valueCopyright © 2001-2010 Jalios SA. All Rights Reserved.