|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.zkoss.lang.Strings
public class Strings
String utilties and constants
| Nested Class Summary | |
|---|---|
static class |
Strings.Result
The result of substring(java.lang.String, int, char). |
| Constructor Summary | |
|---|---|
Strings()
|
|
| Method Summary | |
|---|---|
static int |
anyOf(java.lang.String src,
java.lang.String delimiters,
int from)
Returns the index that is one of delimiters, or the length if none of delimiter is found. |
static java.lang.StringBuffer |
appendEscape(java.lang.StringBuffer sb,
java.lang.String s,
java.lang.String specials)
Escapes (aka. quote) the special characters with backslash and appends it the specified string buffer. |
static java.lang.String |
encode(int val)
Returns an encoded string, faster and shorter than Long.toHexString. |
static java.lang.String |
encode(long val)
Returns an encoded string, faster and shorter than Long.toHexString. |
static java.lang.StringBuffer |
encode(java.lang.StringBuffer sb,
int val)
Returns an encoded string buffer, faster and shorter than Integer.toHexString. |
static java.lang.StringBuffer |
encode(java.lang.StringBuffer sb,
long val)
Returns an encoded string buffer, faster and shorter than Long.toHexString. |
static java.lang.String |
escape(java.lang.String s,
java.lang.String specials)
Escapes (aka, quote) the special characters with backslash. |
static boolean |
isBlank(java.lang.String s)
Returns true if the string is null or empty or pure blank. |
static boolean |
isEmpty(java.lang.String s)
Returns true if the string is null or empty. |
static int |
lastAnyOf(java.lang.String src,
java.lang.String delimiters,
int from)
The backward version of anyOf(java.lang.String, java.lang.String, int). |
static int |
nextSeparator(java.lang.String src,
int from,
char[] separators,
boolean escBackslash,
boolean escQuot,
boolean quotAsSeparator)
Returns the next seperator index in the src string. |
static Strings.Result |
nextToken(java.lang.String src,
int from,
char[] separators)
Returns the next token with unescape. |
static Strings.Result |
nextToken(java.lang.String src,
int from,
char[] separators,
boolean escBackslash,
boolean quotAsToken)
Returns the next token with unescape option. |
static int |
nextWhitespace(java.lang.CharSequence src,
int from)
Returns the next whitespace. |
static int |
skipWhitespaces(java.lang.CharSequence src,
int from)
Returns the next index after skipping whitespaces. |
static int |
skipWhitespacesBackward(java.lang.CharSequence src,
int from)
The backward version of skipWhitespaces(java.lang.CharSequence, int). |
static Strings.Result |
substring(java.lang.String src,
int from,
char until)
Returns the substring from the from index up to the
until character or end-of-string. |
static Strings.Result |
substring(java.lang.String src,
int from,
char until,
boolean escBackslash)
Returns the substring from the from index up to the
until character or end-of-string. |
static java.lang.String |
unescape(java.lang.String s)
Un-escape the quoted string. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Strings()
| Method Detail |
|---|
public static final boolean isEmpty(java.lang.String s)
public static final boolean isBlank(java.lang.String s)
public static final java.lang.StringBuffer encode(java.lang.StringBuffer sb,
int val)
It works even in system that is case-insensitive, such as IE.
It is useful to generate a string to represent a number.
public static final java.lang.StringBuffer encode(java.lang.StringBuffer sb,
long val)
It works even in system that is case-insensitive, such as IE.
It is useful to generate a string to represent a number.
public static final java.lang.String encode(int val)
public static final java.lang.String encode(long val)
public static final int anyOf(java.lang.String src,
java.lang.String delimiters,
int from)
Unlike String.indexOf(String, int), this method returns the first occurrence of any character in the delimiters.
This method is optimized to use String.indexOf(char, int) if it found the length of dilimiter is 1.
src - the source string to searchfrom - the index to start the search fromdelimiters - the set of characters to search for
lastAnyOf(java.lang.String, java.lang.String, int)
public static final int lastAnyOf(java.lang.String src,
java.lang.String delimiters,
int from)
anyOf(java.lang.String, java.lang.String, int).
This method is optimized to use String.indexOf(char, int) if it found the length of dilimiter is 1.
fromanyOf(java.lang.String, java.lang.String, int)
public static final int skipWhitespaces(java.lang.CharSequence src,
int from)
public static final int skipWhitespacesBackward(java.lang.CharSequence src,
int from)
skipWhitespaces(java.lang.CharSequence, int).
public static final int nextWhitespace(java.lang.CharSequence src,
int from)
public static final java.lang.String escape(java.lang.String s,
java.lang.String specials)
Note: specials usually contains '\\'.
For example, Maps.parse(java.util.Map, java.lang.String, char, char) will un-quote
backspace. Thus, if you want to preserve backslash, you have
invoke escape(s, "\\") before calling Maps.parse().
s - the string to process. If null, null is returned.specials - a string of characters that shall be escaped/quotedunescape(java.lang.String)
public static final java.lang.StringBuffer appendEscape(java.lang.StringBuffer sb,
java.lang.String s,
java.lang.String specials)
public static final java.lang.String unescape(java.lang.String s)
escape(java.lang.String, java.lang.String),
appendEscape(java.lang.StringBuffer, java.lang.String, java.lang.String)
public static final Strings.Result substring(java.lang.String src,
int from,
char until)
from index up to the
until character or end-of-string.
Unlike String.subsring, it converts \f, \n, \t and \r. It doesn't
handle u and x yet.
until character if found, or
a number larger than length() if no such character.
public static final Strings.Result substring(java.lang.String src,
int from,
char until,
boolean escBackslash)
from index up to the
until character or end-of-string.
escBackslash - whether to treat '\\' specially (as escape char)
It doesn't handle u and x yet.
until character if found, or
a number larger than length() if no such character.
You can tell which case it is by examining Strings.Result.separator.
public static final Strings.Result nextToken(java.lang.String src,
int from,
char[] separators)
throws IllegalSyntaxException
Strings.Result.separator.
IllegalSyntaxException - if the quoted string is unclosed.
public static final Strings.Result nextToken(java.lang.String src,
int from,
char[] separators,
boolean escBackslash,
boolean quotAsToken)
throws IllegalSyntaxException
Strings.Result.separator.
escBackslash - whether to treat '\\' specially (as escape char)
It doesn't handle u and x yet.quotAsToken - whether to treat characters inside '\'' or '"'
as a token
IllegalSyntaxException - if the quoted string is unclosed.
public static int nextSeparator(java.lang.String src,
int from,
char[] separators,
boolean escBackslash,
boolean escQuot,
boolean quotAsSeparator)
escQuot - whether to escape characters inside quotations
('\'' or '"'). In other words, ignore separators inside quotationsquotAsSeparator - whether to consider quotations as one of
the separators
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||