| java.lang.Object net.sourceforge.pmd.util.StringUtil
StringUtil | public class StringUtil (Code) | | |
Method Summary | |
public static void | appendXmlEscaped(StringBuffer buf, String src) Appends to a StringBuffer the String src where non-ASCII and
XML special chars are escaped. | public static void | asStringOn(StringBuffer sb, Iterator iter, String separator) Copies the elements returned by the iterator onto the string buffer
each delimited by the separator. | public static String | htmlEncode(String string) | public static boolean | isSame(String s1, String s2, boolean trim, boolean ignoreCase, boolean standardizeWhitespace) Are the two String values the same.
The Strings can be optionally trimmed before checking.
The Strings can be optionally compared ignoring case.
The Strings can be have embedded whitespace standardized before comparing.
Two null values are treated as equal.
Parameters: s1 - The first String. Parameters: s2 - The second String. Parameters: trim - Indicates if the Strings should be trimmed before comparison. Parameters: ignoreCase - Indicates if the case of the Strings should ignored during comparison. Parameters: standardizeWhitespace - Indicates if the embedded whitespace should be standardized before comparison. | public static int | lengthOfShortestIn(String[] strings) Return the length of the shortest string in the array. | public static String | lpad(String s, int length) Left pads a string. | public static int | maxCommonLeadingWhitespaceForAll(String[] strings) Determine the maximum number of common leading whitespace characters
the strings share in the same sequence. | public static String | replaceString(String original, char oldChar, String newString) | public static String | replaceString(String original, String oldString, String newString) | public static String[] | substringsOf(String source, char delimiter) Parses the input source using the delimiter specified. | public static String[] | substringsOf(String str, String separator) Much more efficient than StringTokenizer. | public static String[] | trimStartOn(String[] strings, int trimDepth) Trims off the leading characters off the strings up to the trimDepth
specified. |
EMPTY_STRINGS | final public static String[] EMPTY_STRINGS(Code) | | |
appendXmlEscaped | public static void appendXmlEscaped(StringBuffer buf, String src)(Code) | | Appends to a StringBuffer the String src where non-ASCII and
XML special chars are escaped.
Parameters: buf - The destination XML stream Parameters: src - The String to append to the stream |
asStringOn | public static void asStringOn(StringBuffer sb, Iterator iter, String separator)(Code) | | Copies the elements returned by the iterator onto the string buffer
each delimited by the separator.
Parameters: sb - StringBuffer Parameters: iter - Iterator Parameters: separator - String |
isSame | public static boolean isSame(String s1, String s2, boolean trim, boolean ignoreCase, boolean standardizeWhitespace)(Code) | | Are the two String values the same.
The Strings can be optionally trimmed before checking.
The Strings can be optionally compared ignoring case.
The Strings can be have embedded whitespace standardized before comparing.
Two null values are treated as equal.
Parameters: s1 - The first String. Parameters: s2 - The second String. Parameters: trim - Indicates if the Strings should be trimmed before comparison. Parameters: ignoreCase - Indicates if the case of the Strings should ignored during comparison. Parameters: standardizeWhitespace - Indicates if the embedded whitespace should be standardized before comparison. true if the Strings are the same, false otherwise. |
lengthOfShortestIn | public static int lengthOfShortestIn(String[] strings)(Code) | | Return the length of the shortest string in the array.
If any one of them is null then it returns 0.
Parameters: strings - String[] int |
lpad | public static String lpad(String s, int length)(Code) | | Left pads a string.
Parameters: s - The String to pad Parameters: length - The desired minimum length of the resulting padded String The resulting left padded String |
maxCommonLeadingWhitespaceForAll | public static int maxCommonLeadingWhitespaceForAll(String[] strings)(Code) | | Determine the maximum number of common leading whitespace characters
the strings share in the same sequence. Useful for determining how
many leading characters can be removed to shift all the text in the
strings to the left without misaligning them.
Parameters: strings - String[] int |
substringsOf | public static String[] substringsOf(String source, char delimiter)(Code) | | Parses the input source using the delimiter specified. This method is much
faster than using the StringTokenizer or String.split(char) approach and
serves as a replacement for String.split() for JDK1.3 that doesn't have it.
FIXME - we're on JDK 1.4 now, can we replace this with String.split?
Parameters: source - String Parameters: delimiter - char String[] |
substringsOf | public static String[] substringsOf(String str, String separator)(Code) | | Much more efficient than StringTokenizer.
Parameters: str - String Parameters: separator - char String[] |
trimStartOn | public static String[] trimStartOn(String[] strings, int trimDepth)(Code) | | Trims off the leading characters off the strings up to the trimDepth
specified. Returns the same strings if trimDepth = 0
Parameters: strings - Parameters: trimDepth - String[] |
|
|