## org.eclipse.jetty.util
Class StringUtil

    java.lang.Object
      org.eclipse.jetty.util.StringUtil

    public class StringUtil

extends java.lang.Object

Fast String Utilities. These string utilities provide both conveniance methods and performance improvements over most standard library versions. The main aim of the optimizations is to avoid object creation unless absolutely required.

Field Summary
`static java.lang.String` `__ISO_8859_1`
`static java.lang.String` `__LINE_SEPARATOR`
`static java.lang.String` `__UTF16`
`static java.lang.String` `__UTF8`
`static java.lang.String` `__UTF8Alt`
`static java.lang.String` `ALL_INTERFACES`
`static java.lang.String` `CRLF`

Constructor Summary
`StringUtil()`

Method Summary
`static void` `append(java.lang.StringBuilder buf, byte b, int base)` append hex digit
`static void` `append(java.lang.StringBuilder buf, java.lang.String s, int offset, int length)` Append substring to StringBuilder
`static void` `append2digits(java.lang.StringBuffer buf, int i)`
`static void` `append2digits(java.lang.StringBuilder buf, int i)`
`static java.lang.String` `asciiToLowerCase(java.lang.String s)` fast lower case conversion.
`static boolean` `endsWithIgnoreCase(java.lang.String s, java.lang.String w)`
`static boolean` `equals(java.lang.String s, char[] buf, int offset, int length)`
`static byte[]` `getBytes(java.lang.String s)`
`static byte[]` `getBytes(java.lang.String s, java.lang.String charset)`
`static int` `indexFrom(java.lang.String s, java.lang.String chars)` returns the next index of a character from the chars string
`static boolean` `isUTF8(java.lang.String charset)`
`static java.lang.String` `nonNull(java.lang.String s)` Return a non null string.
`static java.lang.String` `printable(byte[] b)`
`static java.lang.String` `printable(java.lang.String name)`
`static java.lang.String` `replace(java.lang.String s, java.lang.String sub, java.lang.String with)` replace substrings within string.
`static java.lang.String` `sidBytesToString(byte[] sidBytes)` Converts a binary SID to a string SID http://en.wikipedia.org/wiki/Security_Identifier S-1-IdentifierAuthority-SubAuthority1-SubAuthority2-...-SubAuthorityn
`static byte[]` `sidStringToBytes(java.lang.String sidString)` Converts a string SID to a binary SID http://en.wikipedia.org/wiki/Security_Identifier S-1-IdentifierAuthority-SubAuthority1-SubAuthority2-...-SubAuthorityn
`static boolean` `startsWithIgnoreCase(java.lang.String s, java.lang.String w)`
`static java.lang.String` `toString(byte[] b, int offset, int length, java.lang.String charset)`
`static java.lang.String` `toUTF8String(byte[] b, int offset, int length)`
`static java.lang.String` `unquote(java.lang.String s)` Remove single or double quotes.

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

Field Detail

### ALL_INTERFACES

    public static final java.lang.String ALL_INTERFACES

See Also:
  Constant Field Values

### CRLF

    public static final java.lang.String CRLF

See Also:
  Constant Field Values

### __LINE_SEPARATOR

    public static final java.lang.String __LINE_SEPARATOR

### __ISO_8859_1

    public static final java.lang.String __ISO_8859_1

See Also:
  Constant Field Values

### __UTF8

    public static final java.lang.String __UTF8

See Also:
  Constant Field Values

### __UTF8Alt

    public static final java.lang.String __UTF8Alt

See Also:
  Constant Field Values

### __UTF16

    public static final java.lang.String __UTF16

See Also:
  Constant Field Values

Constructor Detail

### StringUtil

    public StringUtil()

Method Detail

### asciiToLowerCase

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

  fast lower case conversion. Only works on ascii (not unicode)

  Parameters:
    `s` - the string to convert
  Returns:
    a lower case version of s

### startsWithIgnoreCase

    public static boolean startsWithIgnoreCase(java.lang.String s,
                                               java.lang.String w)

### endsWithIgnoreCase

    public static boolean endsWithIgnoreCase(java.lang.String s,
                                             java.lang.String w)

### indexFrom

    public static int indexFrom(java.lang.String s,
                                java.lang.String chars)

  returns the next index of a character from the chars string

### replace

    public static java.lang.String replace(java.lang.String s,
                                           java.lang.String sub,
                                           java.lang.String with)

  replace substrings within string.

### unquote

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

  Remove single or double quotes.

### append

    public static void append(java.lang.StringBuilder buf,
                              java.lang.String s,
                              int offset,
                              int length)

  Append substring to StringBuilder

  Parameters:
    `buf` - StringBuilder to append to
    `s` - String to append from
    `offset` - The offset of the substring
    `length` - The length of the substring

### append

    public static void append(java.lang.StringBuilder buf,
                              byte b,
                              int base)

  append hex digit

### append2digits

    public static void append2digits(java.lang.StringBuffer buf,
                                     int i)

### append2digits

    public static void append2digits(java.lang.StringBuilder buf,
                                     int i)

### nonNull

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

  Return a non null string.

  Parameters:
    `s` - String
  Returns:
    The string passed in or empty string if it is null.

### equals

    public static boolean equals(java.lang.String s,
                                 char[] buf,
                                 int offset,
                                 int length)

### toUTF8String

    public static java.lang.String toUTF8String(byte[] b,
                                                int offset,
                                                int length)

### toString

    public static java.lang.String toString(byte[] b,
                                            int offset,
                                            int length,
                                            java.lang.String charset)

### isUTF8

    public static boolean isUTF8(java.lang.String charset)

### printable

    public static java.lang.String printable(java.lang.String name)

### printable

    public static java.lang.String printable(byte[] b)

### getBytes

    public static byte[] getBytes(java.lang.String s)

### getBytes

    public static byte[] getBytes(java.lang.String s,
                                  java.lang.String charset)

### sidBytesToString

    public static java.lang.String sidBytesToString(byte[] sidBytes)

  Converts a binary SID to a string SID http://en.wikipedia.org/wiki/Security_Identifier S-1-IdentifierAuthority-SubAuthority1-SubAuthority2-...-SubAuthorityn

### sidStringToBytes

    public static byte[] sidStringToBytes(java.lang.String sidString)

  Converts a string SID to a binary SID http://en.wikipedia.org/wiki/Security_Identifier S-1-IdentifierAuthority-SubAuthority1-SubAuthority2-...-SubAuthorityn

Copyright © 1995-2010 Mort Bay Consulting. All Rights Reserved.