com.atlassian.core.util
Class XMLUtils

java.lang.Object
  extended by com.atlassian.core.util.XMLUtils

public class XMLUtils
extends java.lang.Object


Nested Class Summary
static class XMLUtils.ReplacePolicy
           
static interface XMLUtils.TransformPolicy
           
 
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(char ch, XMLUtils.TransformPolicy policy)
          Escape XML characters with a user specified transformation policy for invalid characters.
static java.lang.String escape(java.lang.String source)
          Escape an XML string using a default policy of replacing invalid XML characters.
static java.lang.String escape(java.lang.String source, XMLUtils.TransformPolicy policy)
          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.
static boolean validXml(char ch)
           
 
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,
                                      XMLUtils.TransformPolicy policy)
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.
policy - how to handle invalid XML characters
Since:
3.19 / 3.10.1

escape

public static java.lang.String escape(java.lang.String source)
Escape an XML string using a default policy of replacing invalid XML characters.


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. This uses a default transformation policy of replacing invalid XML characters.


escape

public static java.lang.String escape(char ch,
                                      XMLUtils.TransformPolicy policy)
Escape XML characters with a user specified transformation policy for invalid characters.

Since:
3.19 / 3.10.1

validXml

public static boolean validXml(char ch)
Since:
3.19 / 3.10.1


Copyright © 2009 Atlassian Pty Ltd. All Rights Reserved.