org.jdom.contrib.helpers
Class TextHelper

java.lang.Object
  extended by org.jdom.contrib.helpers.TextHelper

public class TextHelper
extends java.lang.Object

This class contains static helper methods.

Author:
Alex Rosen

Constructor Summary
TextHelper()
           
 
Method Summary
static java.lang.String getChildText(org.jdom.Element parent, java.lang.String name)
           This convenience method returns the textual content of the named child element, or returns an empty String ("") if the child has no textual content.
static java.lang.String getChildText(org.jdom.Element parent, java.lang.String name, org.jdom.Namespace ns)
           This convenience method returns the textual content of the named child element, or returns an empty String ("") if the child has no textual content.
static java.lang.String getChildTextNormalize(org.jdom.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(org.jdom.Element parent, java.lang.String name, org.jdom.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(org.jdom.Element parent, java.lang.String name)
           This convenience method returns the trimmed textual content of the named child element, or returns null if there's no such child.
static java.lang.String getChildTextTrim(org.jdom.Element parent, java.lang.String name, org.jdom.Namespace ns)
           This convenience method returns the trimmed textual content of the named child element, or returns null if there's no such child.
static java.lang.String normalize(java.lang.String text)
           This returns the text with surrounding whitespace removed and internal whitespace normalized to a single space.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextHelper

public TextHelper()
Method Detail

normalize

public static java.lang.String normalize(java.lang.String text)

This returns the text with surrounding whitespace removed and internal whitespace normalized to a single space.


getChildText

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

This convenience method returns the textual content of the 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
Returns:
text content for the named child, or null if no such child exists

getChildText

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

This convenience method returns the textual content of the 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

getChildTextTrim

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

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
Returns:
trimmed text content for the named child, or null if no such child exists

getChildTextTrim

public static java.lang.String getChildTextTrim(org.jdom.Element parent,
                                                java.lang.String name,
                                                org.jdom.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

getChildTextNormalize

public static java.lang.String getChildTextNormalize(org.jdom.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 normalize(java.lang.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

getChildTextNormalize

public static java.lang.String getChildTextNormalize(org.jdom.Element parent,
                                                     java.lang.String name,
                                                     org.jdom.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 normalize(java.lang.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


Copyright © 2011 Jason Hunter, Brett McLaughlin. All Rights Reserved.