org.springframework.extensions.surf.util
Class XMLUtil

java.lang.Object
  extended by org.springframework.extensions.surf.util.XMLUtil

public class XMLUtil
extends Object

A set of XML utility functions that make use of the Dom4j package. This class originally existed as a means of accomplishing much of what Dom4j now allows us to do. As such, the expectation is that it will be phased out over time.

Author:
muzquiano

Field Summary
protected static org.apache.commons.logging.Log logger
          The logger.
 
Constructor Summary
XMLUtil()
           
 
Method Summary
static void addChildValue(org.dom4j.Element parent, String childName, String childValue)
          Adds the child value.
static String getAttribute(org.dom4j.Element element, String attributeName)
          Gets an attribute from the given element with the given attribute name
static org.dom4j.Element getChild(org.dom4j.Element parent, String name)
          Gets the child.
static List getChildren(org.dom4j.Element element)
          Gets the children.
static List getChildren(org.dom4j.Element element, String name)
          Gets the children.
static String getChildValue(org.dom4j.Element element, String name)
          Gets the child value.
static String getDocumentChildValue(org.dom4j.Document d, String name)
          Gets the document child value.
static String getValue(org.dom4j.Element element)
          Gets the value.
static org.dom4j.Document parse(InputStream stream)
          Parses the given stream to an XML document (in UTF-8 format).
static org.dom4j.Document parse(String xml)
          Parses the.
static void setChildValue(org.dom4j.Element element, String name, String value)
          Sets the child value.
static void setDocumentChildValue(org.dom4j.Document d, String name, String value)
          Sets the document child value.
static void setValue(org.dom4j.Element element, String value)
          Sets the value.
static String toXML(org.dom4j.Document document)
          Converts the document to XML.
static String toXML(org.dom4j.Document document, boolean pretty)
          Converts the document to XML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static org.apache.commons.logging.Log logger
The logger.

Constructor Detail

XMLUtil

public XMLUtil()
Method Detail

addChildValue

public static void addChildValue(org.dom4j.Element parent,
                                 String childName,
                                 String childValue)
Adds the child value.

Parameters:
parent - the parent
childName - the child name
childValue - the child value

getChild

public static org.dom4j.Element getChild(org.dom4j.Element parent,
                                         String name)
Gets the child.

Parameters:
parent - the parent
name - the name
Returns:
the child

getValue

public static String getValue(org.dom4j.Element element)
Gets the value.

Parameters:
element - the element
Returns:
the value

setValue

public static void setValue(org.dom4j.Element element,
                            String value)
Sets the value.

Parameters:
element - the element
value - the value

getChildValue

public static String getChildValue(org.dom4j.Element element,
                                   String name)
Gets the child value.

Parameters:
element - the element
name - the name
Returns:
the child value

setChildValue

public static void setChildValue(org.dom4j.Element element,
                                 String name,
                                 String value)
Sets the child value.

Parameters:
element - the element
name - the name
value - the value

getChildren

public static List getChildren(org.dom4j.Element element)
Gets the children.

Parameters:
element - the element
Returns:
the children

getChildren

public static List getChildren(org.dom4j.Element element,
                               String name)
Gets the children.

Parameters:
element - the element
name - the name
Returns:
the children

getAttribute

public static String getAttribute(org.dom4j.Element element,
                                  String attributeName)
Gets an attribute from the given element with the given attribute name

Parameters:
element - the element
attributeName - the attribute name
Returns:
the attribute

getDocumentChildValue

public static String getDocumentChildValue(org.dom4j.Document d,
                                           String name)
Gets the document child value.

Parameters:
d - the d
name - the name
Returns:
the document child value

setDocumentChildValue

public static void setDocumentChildValue(org.dom4j.Document d,
                                         String name,
                                         String value)
                                  throws Exception
Sets the document child value.

Parameters:
d - the d
name - the name
value - the value
Throws:
Exception - the exception

parse

public static org.dom4j.Document parse(String xml)
                                throws org.dom4j.DocumentException
Parses the.

Parameters:
xml - the xml
Returns:
the document
Throws:
org.dom4j.DocumentException - the document exception

parse

public static org.dom4j.Document parse(InputStream stream)
                                throws org.dom4j.DocumentException,
                                       IOException
Parses the given stream to an XML document (in UTF-8 format).

Parameters:
stream - the stream
Returns:
the document
Throws:
org.dom4j.DocumentException - the document exception
IOException - Signals that an I/O exception has occurred.

toXML

public static String toXML(org.dom4j.Document document)
Converts the document to XML. This uses an efficient approach so that the XML is kept to a minimal.

Parameters:
document - the document
Returns:
the string

toXML

public static String toXML(org.dom4j.Document document,
                           boolean pretty)
Converts the document to XML. The pretty switch can be used to produce human readable, or pretty, XML.

Parameters:
document - the document
pretty - whether to produce human readable XML
Returns:
the string


Copyright © 2009 SpringSource, Inc. All Rights Reserved.