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

## com.mindprod.common15
Class StringToolsAugmented

    java.lang.Object
      com.mindprod.common11.StringTools
          com.mindprod.common15.StringToolsAugmented

    public final class StringToolsAugmented

extends com.mindprod.common11.StringTools

Miscellaneous static methods for dealing with Strings in JDK 1.5+.

Most are reimplementations of methods from com.mindprod.common1.StringTools using the more efficient StringBuilder instead of StringBuffer.

Since:
  2009-04-16
Version:
  2.1 2009-04-30 - add pruneExcessBlankLines
Author:
  Roedy Green, Canadian Mind Products

Constructor Summary
`protected` | `StringToolsAugmented()` Dummy constructor StringToolsAugmented contains only static methods.

Method Summary
`static java.lang.String` | `condense(java.lang.String s)` Collapse multiple spaces in string down to a single space.
`static void` | `main(java.lang.String[] args)` Test harness, used in debugging
`static java.lang.String[]` | `pruneExcessBlankLines(java.lang.String[] lines, int minBlankLinesToKeep)` Collapse multiple blank lines down to one.
`static java.lang.String` | `quoteSQL(java.lang.String sql)` used to prepare SQL string literals by doubling each embedded ' and wrapping in ' at each end.
`static java.lang.String` | `squish(java.lang.String s)` Remove all spaces from a String.

Methods inherited from class com.mindprod.common11.StringTools
`beep, canonical, chopLeadingString, chopTrailingString, countInstances, countInstances, countLeading, countLeading, countTrailing, countTrailing, firstWord, haveCommonChar, indexOfWhiteSpace, indexOfWhiteSpace, isDigit, isEmpty, isLegal, isLegal, isLetter, isUnaccentedLowerCase, isUnaccentedUpperCase, isVowel, lastWord, leftJustified, leftPad, parseDirtyLong, parseLongPennies, penniesToString, pluck, rep, rightJustified, rightPad, spaces, toBookTitleCase, toHexString, toLowerCase, toLowerCase, toLZ, toLZHexString, toString, toUpperCase, toUpperCase, trimLeading, trimLeading, trimLeading, trimTrailing, trimTrailing, trimTrailing`

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

Constructor Detail

### StringToolsAugmented

    protected StringToolsAugmented()

  Dummy constructor StringToolsAugmented contains only static methods.

Method Detail

### condense

    public static java.lang.String condense(java.lang.String s)

  Collapse multiple spaces in string down to a single space. Remove lead and trailing spaces. Does not collapse other whitespace.

  Parameters:
    `s` - String to strip of blanks.
  Returns:
    String with all blanks, lead/trail/embedded removed.
  See Also:
    `squish(String)`

### pruneExcessBlankLines

    public static java.lang.String[] pruneExcessBlankLines(java.lang.String[] lines,
                                                           int minBlankLinesToKeep)

  Collapse multiple blank lines down to one. Discards lead and trail blank lines. Blank lines are lines that when trimmed have length 0. Degraded version available in com.mindprod.common11.StringTools for JDK 1.1.

  Parameters:
    `lines` - array of lines to tidy.
    `minBlankLinesToKeep` - usually 1 meaning 1+ consecutive blank lines become 1, effectively collapsing runs of blank lines down to 1. if 2, 1 blank line is removed, and 2+ consecutive blanks lines become 1, effectively undouble spacing. if zero, non-blank lines will be separated by one blank line, even if there was not one there to begin with, completely independent of preexisting blank lines, effectively double spacing.. 9999 effectively removes all blank lines.
  Returns:
    array of lines with lead and trail blank lines removed, and excess blank lines collapsed down to one or 0. The results are NOT trimmed.

### quoteSQL

    public static java.lang.String quoteSQL(java.lang.String sql)

  used to prepare SQL string literals by doubling each embedded ' and wrapping in ' at each end. Further quoting is required to use the results in Java String literals. If you use PreparedStatement, then this method is not needed. The ' quoting is automatically handled for you.

  Parameters:
    `sql` - Raw SQL string literal
  Returns:
    sql String literal enclosed in '

### squish

    public static java.lang.String squish(java.lang.String s)

  Remove all spaces from a String. Does not touch other whitespace.

  Parameters:
    `s` - String to strip of blanks.
  Returns:
    String with all blanks, lead/trail/embedded removed.
  See Also:
    `condense(String)`

### main

    public static void main(java.lang.String[] args)

  Test harness, used in debugging

  Parameters:
    `args` - not used

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