Top Description Fields Constructors Methods
org.mortbay.util

public Class StringUtil

extends Object
Class Inheritance
Imports
java.io.UnsupportedEncodingException, org.mortbay.log.Log

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.
Author
Greg Wilkins (gregw)

Field Summary

Modifier and TypeField and Description
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
private static char[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
append(StringBuilder
StringBuilder to append to
buf
,
String
String to append from
s
,
int
The offset of the substring
offset
,
int
The length of the substring
length
)

Append substring to StringBuilder

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

append hex digit

public static void
public static void
public static String

Returns:

a lower case version of s
asciiToLowerCase
(String
the string to convert
s
)

fast lower case conversion.

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

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

public static int
indexFrom(String s, String chars)

returns the next index of a character from the chars string

public static boolean
isUTF8(String charset)

public static String

Returns:

The string passed in or empty string if it is null.
nonNull
(String
String
s
)

Return a non null string.

public static String
public static String
replace(String s, String sub, String with)

replace substrings within string.

public static boolean
public static String
toString(byte[] b, int offset, int length, String charset)

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

public static String
unquote(String s)

Remove single or double quotes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

__ISO_8859_1back to summary
public static final String __ISO_8859_1
__LINE_SEPARATORback to summary
public static final String __LINE_SEPARATOR
__UTF16back to summary
public static final String __UTF16
__UTF8back to summary
public static final String __UTF8
__UTF8Altback to summary
public static final String __UTF8Alt
ALL_INTERFACESback to summary
public static final String ALL_INTERFACES
CRLFback to summary
public static final String CRLF
lowercasesback to summary
private static char[] lowercases

Constructor Detail

StringUtilback to summary
public StringUtil()

Method Detail

appendback to summary
public static void append(StringBuilder buf, String s, int offset, int length)

Append substring to StringBuilder

Parameters
buf:StringBuilder

StringBuilder to append to

s:String

String to append from

offset:int

The offset of the substring

length:int

The length of the substring

appendback to summary
public static void append(StringBuilder buf, byte b, int base)

append hex digit

append2digitsback to summary
public static void append2digits(StringBuffer buf, int i)
append2digitsback to summary
public static void append2digits(StringBuilder buf, int i)
asciiToLowerCaseback to summary
public static String asciiToLowerCase(String s)

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

Parameters
s:String

the string to convert

Returns:String

a lower case version of s

endsWithIgnoreCaseback to summary
public static boolean endsWithIgnoreCase(String s, String w)
equalsback to summary
public static boolean equals(String s, char[] buf, int offset, int length)
getBytesback to summary
public static byte[] getBytes(String s)
getBytesback to summary
public static byte[] getBytes(String s, String charset)
indexFromback to summary
public static int indexFrom(String s, String chars)

returns the next index of a character from the chars string

isUTF8back to summary
public static boolean isUTF8(String charset)
nonNullback to summary
public static String nonNull(String s)

Return a non null string.

Parameters
s:String

String

Returns:String

The string passed in or empty string if it is null.

printableback to summary
public static String printable(String name)
replaceback to summary
public static String replace(String s, String sub, String with)

replace substrings within string.

startsWithIgnoreCaseback to summary
public static boolean startsWithIgnoreCase(String s, String w)
toStringback to summary
public static String toString(byte[] b, int offset, int length, String charset)
toUTF8Stringback to summary
public static String toUTF8String(byte[] b, int offset, int length)
unquoteback to summary
public static String unquote(String s)

Remove single or double quotes.