org.gersteinlab.tyna.webapp.util
Class TextUtil

java.lang.Object
  extended by org.gersteinlab.tyna.webapp.util.TextUtil

public class TextUtil
extends java.lang.Object

        This class provides utility methods for converting text between
        different formats.
        

Version:
1.0 (October 1, 2005) Change History: 1.0 - Initial version
Author:
Kevin Yuk-Lap Yip

Constructor Summary
TextUtil()
           
 
Method Summary
static java.lang.String leftPad(java.lang.String str, int len, char ch)
          Left-pad a string to a certain length by a character.
static java.lang.String toHTMLValue(java.lang.String text)
          Convert a string into a format suitable for HTML values.
static java.lang.String toXMLTagName(java.lang.String text)
          Convert a string into a format suitable for XML tag names.
static java.lang.String toXMLValue(java.lang.String text)
          Convert a string into a format suitable for XML tag values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextUtil

public TextUtil()
Method Detail

leftPad

public static java.lang.String leftPad(java.lang.String str,
                                       int len,
                                       char ch)
Left-pad a string to a certain length by a character. If the input string is longer than the target length, do nothing. If the input string is null, return null.

Parameters:
str - The input string
len - The target length
ch - The padding character
Returns:
null if str is null, the padded string otherwise

toXMLTagName

public static java.lang.String toXMLTagName(java.lang.String text)
Convert a string into a format suitable for XML tag names.

Parameters:
text - The input string
Returns:
empty string if text is null, the converted string otherwise

toXMLValue

public static java.lang.String toXMLValue(java.lang.String text)
Convert a string into a format suitable for XML tag values.

Parameters:
text - The input string
Returns:
empty string if text is null, the converted string otherwise

toHTMLValue

public static java.lang.String toHTMLValue(java.lang.String text)
Convert a string into a format suitable for HTML values.

Parameters:
text - The input string
Returns:
empty string if text is null, the converted string otherwise