Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.sourceforge.pmd.util
Class StringUtil

    java.lang.Object
      net.sourceforge.pmd.util.StringUtil

public class StringUtil
extends java.lang.Object

Field Summary
`static java.lang.String[]` | `EMPTY_STRINGS`

Constructor Summary
`StringUtil()`

Method Summary
`static void` | `appendXmlEscaped(java.lang.StringBuffer buf, java.lang.String src)` Appends to a StringBuffer the String src where non-ASCII and XML special chars are escaped.
`static void` | `asStringOn(java.lang.StringBuffer sb, java.util.Iterator iter, java.lang.String separator)` Copies the elements returned by the iterator onto the string buffer each delimited by the separator.
`static java.lang.String` | `htmlEncode(java.lang.String string)`
`static int` | `lengthOfShortestIn(java.lang.String[] strings)` Return the length of the shortest string in the array.
`static int` | `maxCommonLeadingWhitespaceForAll(java.lang.String[] strings)` Determine the maximum number of common leading whitespace characters the strings share in the same sequence.
`static java.lang.String` | `replaceString(java.lang.String original, char oldChar, java.lang.String newString)`
`static java.lang.String` | `replaceString(java.lang.String original, java.lang.String oldString, java.lang.String newString)`
`static java.lang.String[]` | `substringsOf(java.lang.String source, char delimiter)` Parses the input source using the delimiter specified.
`static java.lang.String[]` | `substringsOf(java.lang.String str, java.lang.String separator)` Much more efficient than StringTokenizer.
`static java.lang.String[]` | `trimStartOn(java.lang.String[] strings, int trimDepth)` Trims off the leading characters off the strings up to the trimDepth specified.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### EMPTY_STRINGS

    public static final java.lang.String[] EMPTY_STRINGS

Constructor Detail

### StringUtil

    public StringUtil()

Method Detail

### replaceString

    public static java.lang.String replaceString(java.lang.String original,
                                                 char oldChar,
                                                 java.lang.String newString)

### replaceString

    public static java.lang.String replaceString(java.lang.String original,
                                                 java.lang.String oldString,
                                                 java.lang.String newString)

### appendXmlEscaped

    public static void appendXmlEscaped(java.lang.StringBuffer buf,
                                        java.lang.String src)

  Appends to a StringBuffer the String src where non-ASCII and XML special chars are escaped.

  Parameters:
    `buf` - The destination XML stream
    `src` - The String to append to the stream

### htmlEncode

    public static java.lang.String htmlEncode(java.lang.String string)

### substringsOf

    public static java.lang.String[] substringsOf(java.lang.String source,
                                                  char delimiter)

  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.

  Parameters:
    `source` - String
    `delimiter` - char
  Returns:
    String[]

### substringsOf

    public static java.lang.String[] substringsOf(java.lang.String str,
                                                  java.lang.String separator)

  Much more efficient than StringTokenizer.

  Parameters:
    `str` - String
    `separator` - char
  Returns:
    String[]

### asStringOn

    public static void asStringOn(java.lang.StringBuffer sb,
                                  java.util.Iterator iter,
                                  java.lang.String separator)

  Copies the elements returned by the iterator onto the string buffer each delimited by the separator.

  Parameters:
    `sb` - StringBuffer
    `iter` - Iterator
    `separator` - String

### lengthOfShortestIn

    public static int lengthOfShortestIn(java.lang.String[] strings)

  Return the length of the shortest string in the array. If any one of them is null then it returns 0.

  Parameters:
    `strings` - String[]
  Returns:
    int

### maxCommonLeadingWhitespaceForAll

    public static int maxCommonLeadingWhitespaceForAll(java.lang.String[] strings)

  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[]
  Returns:
    int

### trimStartOn

    public static java.lang.String[] trimStartOn(java.lang.String[] strings,
                                                 int trimDepth)

  Trims off the leading characters off the strings up to the trimDepth specified. Returns the same strings if trimDepth = 0

  Parameters:
    `strings` -
    `trimDepth` -
  Returns:
    String[]

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2006 InfoEther. All Rights Reserved.