com.atlassian.core.util
Class XMLUtils

java.lang.Object
  extended bycom.atlassian.core.util.XMLUtils

public class XMLUtils
extends java.lang.Object


Constructor Summary
XMLUtils()
           
 
Method Summary
static java.lang.String escape(char ch)
          If there is a suitable entity reference for this character, return it.
static java.lang.String escape(java.lang.String source)
          Escapes a string so it may be returned as text content or attribute value.
static java.lang.String escapeForCdata(java.lang.String source)
           
static java.lang.String getAttributeWithDefault(org.w3c.dom.Element element, java.lang.String attributeName, java.lang.String defaultValue)
          Get an attribute of a given element, with a default value if the attribute is not present or blank.
static java.lang.String getContainedText(org.w3c.dom.Node parent, java.lang.String childTagName)
          With a given parent XML Element, find the text contents of the child element with supplied name.
static org.w3c.dom.Element getSingleChildElement(org.w3c.dom.Element el, java.lang.String name)
          Given one element, get a single named child element of it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLUtils

public XMLUtils()
Method Detail

getContainedText

public static java.lang.String getContainedText(org.w3c.dom.Node parent,
                                                java.lang.String childTagName)
With a given parent XML Element, find the text contents of the child element with supplied name.


getSingleChildElement

public static org.w3c.dom.Element getSingleChildElement(org.w3c.dom.Element el,
                                                        java.lang.String name)
Given one element, get a single named child element of it.


getAttributeWithDefault

public static java.lang.String getAttributeWithDefault(org.w3c.dom.Element element,
                                                       java.lang.String attributeName,
                                                       java.lang.String defaultValue)
Get an attribute of a given element, with a default value if the attribute is not present or blank.


escape

public static java.lang.String escape(java.lang.String source)
Escapes a string so it may be returned as text content or attribute value. Non printable characters are escaped using character references. Where the format specifies a deault entity reference, that reference is used (e.g. <).

Parameters:
source - the string to escape or "" for null.

escapeForCdata

public static java.lang.String escapeForCdata(java.lang.String source)

escape

public static java.lang.String escape(char ch)
If there is a suitable entity reference for this character, return it. The list of available entity references is almost but not identical between XML and HTML.



Copyright © 2008 Atlassian Pty Ltd. All Rights Reserved.