|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.derby.iapi.util.StringUtil
public class StringUtil
A set of public static methods for dealing with Strings
| Field Summary | |
|---|---|
private static char[] |
hex_table
|
| Constructor Summary | |
|---|---|
StringUtil()
|
|
| Method Summary | |
|---|---|
static java.lang.String |
compressQuotes(java.lang.String source,
java.lang.String quotes)
Compress 2 adjacent (single or double) quotes into a single (s or d) quote when found in the middle of a String. |
private static java.lang.String |
doRegExpA(java.lang.String src,
java.lang.String indent)
Reg.exp substitute: Pattern pat_a = Pattern.compile("\\A\\t*"); Matcher m_a = pat_a.matcher(src); src = m_a.replaceFirst(indent.toString()); |
private static java.lang.String |
doRegExpB(java.lang.String src)
Reg.exp substitute: Pattern pat_b = Pattern.compile("\\n+\\Z"); Matcher m_b = pat_b.matcher(formatted); formatted = m_b.replaceFirst(""); |
private static java.lang.String |
doRegExpC(java.lang.String src,
java.lang.String indent)
Reg.exp substitute: Pattern pat_c = Pattern.compile("\\n\\t*"); Matcher m_c = pat_c.matcher(formatted); formatted = m_c.replaceAll("\n" + indent.toString()); |
static java.lang.String |
ensureIndent(java.lang.String formatted,
int depth)
Utility for formatting which bends a multi-line string into shape for outputting it in a context where there is depth tabs. |
static java.lang.String |
formatForPrint(java.lang.String input)
Used to print out a string for error messages, chops is off at 60 chars for historical reasons. |
static byte[] |
fromHexString(java.lang.String s,
int offset,
int length)
Convert a hexidecimal string generated by toHexString() back into a byte array. |
static byte[] |
getAsciiBytes(java.lang.String input)
Get 7-bit ASCII character array from input String. |
static java.lang.String |
hexDump(byte[] data)
Convert a byte array to a human-readable String for debugging purposes. |
static java.lang.String |
normalizeSQLIdentifier(java.lang.String id)
Normalize a SQL identifer, up-casing if |
(package private) static java.lang.String |
quoteString(java.lang.String source,
char quote)
Quote a string so that it can be used as an identifier or a string literal in SQL statements. |
static java.lang.String |
quoteStringLiteral(java.lang.String string)
Quote a string so that it can be used as a string literal in an SQL statement. |
static java.lang.String |
slice(java.lang.String value,
int beginOffset,
int endOffset,
boolean trim)
Return a slice (substring) of the passed in value, optionally trimmed. |
static java.lang.String[] |
split(java.lang.String str,
char delim)
Splits a string around matches of the given delimiter character. |
static boolean |
SQLEqualsIgnoreCase(java.lang.String s1,
java.lang.String s2)
Compares two strings Strings will be uppercased in english and compared equivalent to s1.equalsIgnoreCase(s2) throws NPE if s1 is null |
static java.lang.String |
SQLToUpperCase(java.lang.String s)
Convert string to uppercase Always use the java.util.ENGLISH locale |
static java.lang.String |
stringify(int[] raw)
Turn an array of ints into a printable string. |
static java.lang.String |
toHexString(byte[] data,
int offset,
int length)
Convert a byte array to a String with a hexidecimal format. |
static java.lang.String[] |
toStringArray(java.lang.Object[] objArray)
A method that receive an array of Objects and return a String array representation of that array. |
static java.lang.String |
trimTrailing(java.lang.String str)
Trim off trailing blanks but not leading blanks |
static java.lang.String |
truncate(java.lang.String value,
int length)
Truncate a String to the given length with no warnings or error raised if it is bigger. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static char[] hex_table
| Constructor Detail |
|---|
public StringUtil()
| Method Detail |
|---|
public static java.lang.String[] split(java.lang.String str,
char delim)
String.split(String regex), which is not available
on a JSR169/Java ME platform.
str - the string to be splitdelim - the delimiter
java.lang.NullPointerException - if str is nullpublic static final java.lang.String formatForPrint(java.lang.String input)
public static java.lang.String[] toStringArray(java.lang.Object[] objArray)
public static byte[] getAsciiBytes(java.lang.String input)
public static java.lang.String trimTrailing(java.lang.String str)
str -
public static java.lang.String truncate(java.lang.String value,
int length)
value - String to be truncatedlength - Maximum length of string
public static java.lang.String slice(java.lang.String value,
int beginOffset,
int endOffset,
boolean trim)
value - Value to slice, must be non-null.beginOffset - Inclusive start characterendOffset - Inclusive end charactertrim - To trim or not to trim
public static java.lang.String toHexString(byte[] data,
int offset,
int length)
b & 0xf0), the second character
represents the low nibble (b & 0x0f).
data[offset] is represented by the first two characters in the returned String.
data - byte arrayoffset - starting byte (zero based) to convert.length - number of bytes to convert.
public static byte[] fromHexString(java.lang.String s,
int offset,
int length)
s - String to convertoffset - starting character (zero based) to convert.length - number of characters to convert.
public static java.lang.String hexDump(byte[] data)
public static java.lang.String SQLToUpperCase(java.lang.String s)
s - string to uppercase
public static boolean SQLEqualsIgnoreCase(java.lang.String s1,
java.lang.String s2)
s1 - first string to compares2 - second string to compare
public static java.lang.String normalizeSQLIdentifier(java.lang.String id)
id - syntacically correct SQL identifier
public static java.lang.String compressQuotes(java.lang.String source,
java.lang.String quotes)
source - string to be compressedquotes - string containing two single or double quotes.
static java.lang.String quoteString(java.lang.String source,
char quote)
source - the string to quotequote - the character to quote the string with (' or ")
quoteStringLiteral(String),
IdUtil.normalToDelimited(String)public static java.lang.String quoteStringLiteral(java.lang.String string)
string - the string to quote
public static java.lang.String stringify(int[] raw)
public static java.lang.String ensureIndent(java.lang.String formatted,
int depth)
Replace "^[\t]*" with "depth" number of tabs.
Replace "\n+$" with "".
Replace all "\n[\t]*" with "\n" + "depth" number of tabs.
formatted - string to sanitizedepth - indentation level the string is to be printed at (0,1,2..)
private static java.lang.String doRegExpA(java.lang.String src,
java.lang.String indent)
src - source string in which to substitute indentindent - indentation to lead source
private static java.lang.String doRegExpB(java.lang.String src)
src - source string in which to substitute
private static java.lang.String doRegExpC(java.lang.String src,
java.lang.String indent)
src - source string in which to substitute indentindent - indentation to lead source
|
Built on Wed 2013-06-12 15:21:56+0000, from revision ??? | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||