public class JDOMUtils
extends java.lang.Object
| Modifier | Constructor and Description | 
|---|---|
| protected  | JDOMUtils()Allow overrides but not instantiation. | 
| Modifier and Type | Method and Description | 
|---|---|
| static void | applyElementFilter(org.jdom2.Document document,
                  org.jdom2.filter.Filter<org.jdom2.Element> filter,
                  ElementProcessor processor)Process elements selected by an element filter. | 
| static org.jdom2.Attribute | getAttribute(org.jdom2.Element element,
            java.lang.String attributeName,
            boolean ignoreCase)Get attribute. | 
| static java.lang.String | getAttributeValue(org.jdom2.Element element,
                 java.lang.String attributeName,
                 boolean ignoreCase)Get attribute value. | 
| static java.lang.String | getAttributeValueIgnoreCase(org.jdom2.Element element,
                           java.lang.String attributeName)Get attribute value ignoring case. | 
| static java.util.Map<java.lang.String,java.lang.String> | getAttributeValues(org.jdom2.Element element)Get mapped attributes for an element. | 
| static org.jdom2.Document | parse(java.io.File file)Parses an XML file. | 
| static org.jdom2.Document | parse(java.lang.String path)Parses an XML file. | 
| static org.jdom2.Document | parse(java.net.URL url)Parses XML document from URL. | 
| static org.jdom2.Document | parseText(java.lang.String text)Parses XML document from a string. | 
| static void | removeAttribute(org.jdom2.Element element,
               java.lang.String attributeName)Remove attribute. | 
| static void | save(org.jdom2.Document document,
    java.lang.String path,
    org.jdom2.output.Format format)Saves a JDOM document to an XML file in utf-8. | 
| static void | savePretty(org.jdom2.Document document,
          java.lang.String path)Saves a JDOM document to an XML file in utf-8. | 
| static void | saveRaw(org.jdom2.Document document,
       java.lang.String path)Saves a JDOM document to an XML file in utf-8. | 
| static void | saveRawCompressed(org.jdom2.Document document,
                 java.lang.String path)Saves a JDOM document to a compressed XML file in utf-8. | 
| static java.lang.String | saveToString(org.jdom2.Document document,
            org.jdom2.output.Format format)Saves a JDOM document to a String. | 
| static void | setAttributeValue(org.jdom2.Element element,
                 java.lang.String attributeName,
                 java.lang.String attributeValue)Set attribute value. | 
| static java.util.List<ValidationError> | validateDocument(org.jdom2.Document document,
                Schema schema)Validate a JDOM document against a schema. | 
| static java.util.List<ValidationError> | validateDocument(org.jdom2.Document document,
                java.lang.String schemaURI)Validate a JDOM document against a schema. | 
public static org.jdom2.Document parse(java.io.File file)
                                throws java.io.IOException,
                                       org.jdom2.JDOMException,
                                       org.xml.sax.SAXException
file - File.java.lang.Exceptionjava.io.IOExceptionorg.jdom2.JDOMExceptionorg.xml.sax.SAXExceptionpublic static org.jdom2.Document parse(java.lang.String path)
                                throws java.io.IOException,
                                       org.jdom2.JDOMException,
                                       org.xml.sax.SAXException
path - File path.java.lang.Exceptionjava.io.IOExceptionorg.jdom2.JDOMExceptionorg.xml.sax.SAXExceptionpublic static org.jdom2.Document parse(java.net.URL url)
                                throws java.io.IOException,
                                       org.jdom2.JDOMException,
                                       org.xml.sax.SAXException
url - URL.java.lang.Exceptionjava.io.IOExceptionorg.jdom2.JDOMExceptionorg.xml.sax.SAXExceptionpublic static org.jdom2.Document parseText(java.lang.String text)
                                    throws java.io.IOException,
                                           org.jdom2.JDOMException,
                                           org.xml.sax.SAXException
text - Document text string.java.lang.Exceptionjava.io.IOExceptionorg.jdom2.JDOMExceptionorg.xml.sax.SAXExceptionpublic static org.jdom2.Attribute getAttribute(org.jdom2.Element element,
                               java.lang.String attributeName,
                               boolean ignoreCase)
element - The JDOM element.attributeName - The attribute name whose value we want.ignoreCase - true to ignore attribute name case.public static java.lang.String getAttributeValue(org.jdom2.Element element,
                                 java.lang.String attributeName,
                                 boolean ignoreCase)
element - The JDOM element.attributeName - The attribute name whose value we want.ignoreCase - true to ignore attribute name case.public static java.lang.String getAttributeValueIgnoreCase(org.jdom2.Element element,
                                           java.lang.String attributeName)
element - The JDOM element.attributeName - The attribute name whose value we want.public static java.util.Map<java.lang.String,java.lang.String> getAttributeValues(org.jdom2.Element element)
element - The JDOM element whose attributes are desired.public static void setAttributeValue(org.jdom2.Element element,
                     java.lang.String attributeName,
                     java.lang.String attributeValue)
element - The JDOM element.attributeName - The attribute name whose value should be set.attributeValue - The attribute value.public static void removeAttribute(org.jdom2.Element element,
                   java.lang.String attributeName)
element - The JDOM element.attributeName - The attribute name to remove.public static void applyElementFilter(org.jdom2.Document document,
                      org.jdom2.filter.Filter<org.jdom2.Element> filter,
                      ElementProcessor processor)
document - The document to which to apply the filter.filter - The filter.processor - The element processor.public static void save(org.jdom2.Document document,
        java.lang.String path,
        org.jdom2.output.Format format)
                 throws java.io.FileNotFoundException,
                        java.io.IOException
document - JDOM document.path - Output file path.format - The JDOM output format.FileNotFoundException, - IOExceptionjava.io.FileNotFoundExceptionjava.io.IOExceptionpublic static java.lang.String saveToString(org.jdom2.Document document,
                            org.jdom2.output.Format format)
                                     throws java.io.FileNotFoundException,
                                            java.io.IOException
document - JDOM document.format - The JDOM output format.FileNotFoundException, - IOExceptionjava.io.FileNotFoundExceptionjava.io.IOExceptionpublic static void savePretty(org.jdom2.Document document,
              java.lang.String path)
                       throws java.io.FileNotFoundException,
                              java.io.IOException
document - JDOM document.path - Output file path.java.io.IOException - The document is "pretty printed."
java.io.FileNotFoundExceptionpublic static void saveRaw(org.jdom2.Document document,
           java.lang.String path)
                    throws java.io.FileNotFoundException,
                           java.io.IOException
document - JDOM document.path - Output file path.java.io.IOException - The document is output raw, without "pretty printing."
java.io.FileNotFoundExceptionpublic static void saveRawCompressed(org.jdom2.Document document,
                     java.lang.String path)
                              throws java.io.FileNotFoundException,
                                     java.io.IOException
document - JDOM document.path - Output file path.java.io.IOException - The document is output raw, without "pretty printing."
java.io.FileNotFoundExceptionpublic static java.util.List<ValidationError> validateDocument(org.jdom2.Document document, java.lang.String schemaURI) throws org.jdom2.JDOMException, java.io.IOException
document - The parsed JDOM document to validate.schemaURI - The schema URI.java.io.IOException - if the schema URI cannot be read.org.jdom2.JDOMException - if the schema is invalid or
                      validation fails.public static java.util.List<ValidationError> validateDocument(org.jdom2.Document document, Schema schema) throws org.jdom2.JDOMException, java.io.IOException
document - The parsed JDOM document to validate.schema - A parsed schema.java.io.IOException - if the schema URI cannot be read.org.jdom2.JDOMException - if the schema is invalid or
                      validation fails.
  Simply returns without error if validation succeeds.