JDOM
0.0.5-BETA

org.jdom2.util
Class TextHelper

java.lang.Object
  extended by org.jdom2.util.TextHelper

public class TextHelper
extends java.lang.Object

This class contains static helper methods for accessing Text content of JDOM Elements.

Author:
Alex Rosen, Rolf Lear

Method Summary
static java.lang.String getChildText(Element parent, java.lang.String name)
           This convenience method returns the textual content of the first child element with the given name and in no Namespace, or returns an empty String ("") if the child has no textual content.
static java.lang.String getChildText(Element parent, java.lang.String name, Namespace ns)
           This convenience method returns the textual content of the first named child element, or returns an empty String ("") if the child has no textual content.
static java.lang.String getChildTextNormalize(Element parent, java.lang.String name)
           This convenience method returns the normalized textual content of the named child element, or returns null if there's no such child.
static java.lang.String getChildTextNormalize(Element parent, java.lang.String name, Namespace ns)
           This convenience method returns the normalized textual content of the named child element, or returns null if there's no such child.
static java.lang.String getChildTextTrim(Element parent, java.lang.String name)
           This convenience method returns the trimmed textual content of the first named child element, or returns null if there's no such child.
static java.lang.String getChildTextTrim(Element parent, java.lang.String name, Namespace ns)
           This convenience method returns the trimmed textual content of the named child element, or returns null if there's no such child.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getChildText

public static java.lang.String getChildText(Element parent,
                                            java.lang.String name)

This convenience method returns the textual content of the first child element with the given name and in no Namespace, or returns an empty String ("") if the child has no textual content. However, if the child does not exist, null is returned.

Parameters:
parent - the parent element
name - the name of the child
Returns:
text content for the named child, or null if no such child exists
See Also:
Element.getChild(String)

getChildText

public static java.lang.String getChildText(Element parent,
                                            java.lang.String name,
                                            Namespace ns)

This convenience method returns the textual content of the first named child element, or returns an empty String ("") if the child has no textual content. However, if the child does not exist, null is returned.

Parameters:
parent - the parent element
name - the name of the child
ns - the namespace of the child
Returns:
text content for the named child, or null if no such child exists
See Also:
Element.getChild(String, Namespace)

getChildTextTrim

public static java.lang.String getChildTextTrim(Element parent,
                                                java.lang.String name)

This convenience method returns the trimmed textual content of the first named child element, or returns null if there's no such child. See Format.trimBoth(String) for details of text trimming.

Parameters:
parent - the parent element
name - the name of the child
Returns:
trimmed text content for the named child, or null if no such child exists
See Also:
Element.getChild(String)

getChildTextTrim

public static java.lang.String getChildTextTrim(Element parent,
                                                java.lang.String name,
                                                Namespace ns)

This convenience method returns the trimmed textual content of the named child element, or returns null if there's no such child. See String.trim() for details of text trimming.

Parameters:
parent - the parent element
name - the name of the child
ns - the namespace of the child
Returns:
trimmed text content for the named child, or null if no such child exists
See Also:
Element.getChild(String, Namespace)

getChildTextNormalize

public static java.lang.String getChildTextNormalize(Element parent,
                                                     java.lang.String name)

This convenience method returns the normalized textual content of the named child element, or returns null if there's no such child. See Format.compact(String) for details of text normalization.

Parameters:
parent - the parent element
name - the name of the child
Returns:
normalized text content for the named child, or null if no such child exists
See Also:
Element.getChild(String)

getChildTextNormalize

public static java.lang.String getChildTextNormalize(Element parent,
                                                     java.lang.String name,
                                                     Namespace ns)

This convenience method returns the normalized textual content of the named child element, or returns null if there's no such child. See Format.compact(String) for details of text normalization.

Parameters:
parent - the parent element
name - the name of the child
ns - the namespace of the child
Returns:
normalized text content for the named child, or null if no such child exists
See Also:
Element.getChild(String, Namespace)

JDOM
0.0.5-BETA

Copyright � 2012 Jason Hunter, Brett McLaughlin. All Rights Reserved.