|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.h2.util.StringUtils
public class StringUtils
A few String utility functions.
Method Summary | |
---|---|
static java.lang.String |
addAsterisk(java.lang.String s,
int index)
Add an asterisk ('[*]') at the given position. |
static java.lang.String |
arrayCombine(java.lang.String[] list,
char separatorChar)
Combine an array of strings to one array using the given separator character. |
static java.lang.String[] |
arraySplit(java.lang.String s,
char separatorChar,
boolean trim)
Split a string into an array of strings using the given separator. |
static char[] |
cloneCharArray(char[] chars)
Create a new char array and copy all the data. |
static java.lang.String |
enclose(java.lang.String s)
Enclose a string with '(' and ')' if this is not yet done. |
static boolean |
equals(java.lang.String a,
java.lang.String b)
Check if two strings are equal. |
static java.lang.String |
formatDateTime(java.util.Date date,
java.lang.String format,
java.lang.String locale,
java.lang.String timeZone)
Formats a date using a format string. |
static boolean |
isNullOrEmpty(java.lang.String s)
Check if a String is null or empty (the length is null). |
static boolean |
isNumber(java.lang.String s)
Check if a string only contains numbers. |
static java.lang.String |
javaDecode(java.lang.String s)
Decode a text that is encoded as a Java string literal. |
static java.lang.String |
javaEncode(java.lang.String s)
Convert a string to the Java literal using the correct escape sequences. |
static java.lang.String |
pad(java.lang.String string,
int n,
java.lang.String padding,
boolean right)
Pad a string. |
static java.util.Date |
parseDateTime(java.lang.String date,
java.lang.String format,
java.lang.String locale,
java.lang.String timeZone)
Parses a date using a format string. |
static java.lang.String |
quoteIdentifier(java.lang.String s)
Enclose a string with double quotes. |
static java.lang.String |
quoteJavaIntArray(int[] array)
Convert an int array to the Java source code that represents this array. |
static java.lang.String |
quoteJavaString(java.lang.String s)
Convert a string to the Java literal and enclose it with double quotes. |
static java.lang.String |
quoteJavaStringArray(java.lang.String[] array)
Convert a string array to the Java source code that represents this array. |
static java.lang.String |
quoteRemarkSQL(java.lang.String sql)
In a string, replace block comment marks with /++ .. |
static java.lang.String |
quoteStringSQL(java.lang.String s)
Convert a string to a SQL literal. |
static java.lang.String |
replaceAll(java.lang.String s,
java.lang.String before,
java.lang.String after)
Replace all occurrences of the before string with the after string. |
static java.lang.String |
toLowerEnglish(java.lang.String s)
Convert a string to lowercase using the English locale. |
static java.lang.String |
toUpperEnglish(java.lang.String s)
Convert a string to uppercase using the English locale. |
static java.lang.String |
trim(java.lang.String s,
boolean leading,
boolean trailing,
java.lang.String sp)
Trim a character from a string. |
static java.lang.String |
unEnclose(java.lang.String s)
Remove enclosing '(' and ')' if this text is enclosed. |
static java.lang.String |
urlDecode(java.lang.String encoded)
Decode the URL to a string. |
static java.lang.String |
urlEncode(java.lang.String s)
Encode the string as an URL. |
static java.lang.String |
utf8Decode(byte[] utf8)
Convert a UTF-8 representation of a text to the text. |
static byte[] |
utf8Encode(java.lang.String s)
Convert the text to UTF-8 format. |
static java.lang.String |
xmlAttr(java.lang.String name,
java.lang.String value)
Creates an XML attribute of the form name="value". |
static java.lang.String |
xmlCData(java.lang.String data)
Converts the data to a CDATA element. |
static java.lang.String |
xmlComment(java.lang.String data)
Escapes a comment. |
static java.lang.String |
xmlNode(java.lang.String name,
java.lang.String attributes,
java.lang.String content)
Create an XML node with optional attributes and content. |
static java.lang.String |
xmlStartDoc()
Returns |
static java.lang.String |
xmlText(java.lang.String text)
Escapes an XML text element. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static boolean equals(java.lang.String a, java.lang.String b)
a
- the first valueb
- the second value
public static java.lang.String toUpperEnglish(java.lang.String s)
s
- the test to convert
public static java.lang.String toLowerEnglish(java.lang.String s)
s
- the text to convert
public static java.lang.String quoteStringSQL(java.lang.String s)
s
- the text to convert.
public static java.lang.String javaEncode(java.lang.String s)
s
- the text to convert
public static java.lang.String addAsterisk(java.lang.String s, int index)
s
- the textindex
- the position
public static java.lang.String javaDecode(java.lang.String s) throws java.sql.SQLException
s
- the encoded string
java.sql.SQLException
public static java.lang.String quoteJavaString(java.lang.String s)
s
- the text to convert
public static byte[] utf8Encode(java.lang.String s)
s
- the text
public static java.lang.String utf8Decode(byte[] utf8)
utf8
- the UTF-8 representation
public static java.lang.String quoteJavaStringArray(java.lang.String[] array)
array
- the string array
public static java.lang.String quoteJavaIntArray(int[] array)
array
- the int array
public static java.lang.String enclose(java.lang.String s)
s
- the string
public static java.lang.String unEnclose(java.lang.String s)
s
- the potentially enclosed string
public static java.lang.String urlEncode(java.lang.String s)
s
- the string to encode
public static java.lang.String urlDecode(java.lang.String encoded)
encoded
- the encoded URL
public static java.lang.String[] arraySplit(java.lang.String s, char separatorChar, boolean trim)
s
- the string to splitseparatorChar
- the separator charactertrim
- whether each element should be trimmed
public static java.lang.String arrayCombine(java.lang.String[] list, char separatorChar)
list
- the string arrayseparatorChar
- the separator character
public static java.lang.String formatDateTime(java.util.Date date, java.lang.String format, java.lang.String locale, java.lang.String timeZone) throws java.sql.SQLException
date
- the date to formatformat
- the format stringlocale
- the localetimeZone
- the timezone
java.sql.SQLException
public static java.util.Date parseDateTime(java.lang.String date, java.lang.String format, java.lang.String locale, java.lang.String timeZone) throws java.sql.SQLException
date
- the date to parseformat
- the parsing formatlocale
- the localetimeZone
- the timeZone
java.sql.SQLException
public static java.lang.String xmlAttr(java.lang.String name, java.lang.String value)
name
- the attribute namevalue
- the attribute value
public static java.lang.String xmlNode(java.lang.String name, java.lang.String attributes, java.lang.String content)
name
- the element nameattributes
- the attributes (may be null)content
- the content (may be null)
public static java.lang.String xmlComment(java.lang.String data)
data
- the comment text
public static java.lang.String xmlCData(java.lang.String data)
data
- the text data
public static java.lang.String xmlStartDoc()
public static java.lang.String xmlText(java.lang.String text)
text
- the text data
public static java.lang.String replaceAll(java.lang.String s, java.lang.String before, java.lang.String after)
s
- the stringbefore
- the old textafter
- the new text
public static java.lang.String quoteIdentifier(java.lang.String s)
s
- the text
public static boolean isNullOrEmpty(java.lang.String s)
s
- the string to check
public static java.lang.String quoteRemarkSQL(java.lang.String sql)
sql
- the string
public static java.lang.String pad(java.lang.String string, int n, java.lang.String padding, boolean right)
string
- the original stringn
- the target lengthpadding
- the padding stringright
- true if the padding should be appended at the end
public static char[] cloneCharArray(char[] chars)
chars
- the char array (may be null)
public static java.lang.String trim(java.lang.String s, boolean leading, boolean trailing, java.lang.String sp)
s
- the stringleading
- if leading characters should be removedtrailing
- if trailing characters should be removedsp
- what to remove (only the first character is used)
or null for a space
public static boolean isNumber(java.lang.String s)
s
- the string
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |