org.mortbay.util

Class StringUtil

public class StringUtil extends 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.

Version: $Revision: 1.16 $

Author: Greg Wilkins (gregw)

Field Summary
static String__ISO_8859_1
static String__LINE_SEPARATOR
static String__UTF_8
Method Summary
static voidappend(StringBuffer buf, String s, int offset, int length)
Append substring to StringBuffer
static voidappend(StringBuffer buf, byte b, int base)
static voidappend2digits(StringBuffer buf, int i)
static StringasciiToLowerCase(String s)
fast lower case conversion.
static booleanendsWithIgnoreCase(String s, String w)
static booleanequals(String s, char[] buf, int offset, int length)
static intindexFrom(String s, String chars)
returns the next index of a character from the chars string
static StringnonNull(String s)
Return a non null string.
static Stringreplace(String s, String sub, String with)
replace substrings within string.
static booleanstartsWithIgnoreCase(String s, String w)
static Stringunquote(String s)
Remove single or double quotes.

Field Detail

__ISO_8859_1

public static final String __ISO_8859_1

__LINE_SEPARATOR

public static final String __LINE_SEPARATOR

__UTF_8

public static final String __UTF_8

Method Detail

append

public static void append(StringBuffer buf, String s, int offset, int length)
Append substring to StringBuffer

Parameters: buf StringBuffer 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(StringBuffer buf, byte b, int base)

append2digits

public static void append2digits(StringBuffer buf, int i)

asciiToLowerCase

public static String asciiToLowerCase(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

endsWithIgnoreCase

public static boolean endsWithIgnoreCase(String s, String w)

equals

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

indexFrom

public static int indexFrom(String s, String chars)
returns the next index of a character from the chars string

nonNull

public static String nonNull(String s)
Return a non null string.

Parameters: s String

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

replace

public static String replace(String s, String sub, String with)
replace substrings within string.

startsWithIgnoreCase

public static boolean startsWithIgnoreCase(String s, String w)

unquote

public static String unquote(String s)
Remove single or double quotes.
Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.