| java.lang.Object | |
| ↳ | com.google.gdata.util.common.base.StringUtil |
Some common string manipulation utilities.
| Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| String | EMPTY_STRING | ||||||||||
| String | LINE_BREAKS | ||||||||||
| String | WHITE_SPACES | ||||||||||
| Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| CJK_BLOCKS | Unicode code blocks containing CJK characters. | ||||||||||
| CONTROL_MATCHER | |||||||||||
| UNSAFE_TAGS | |||||||||||
| characterReferencePattern | |||||||||||
| dbSpecPattern | |||||||||||
| escapeStrings | |||||||||||
| hexChars | |||||||||||
| htmlTagPattern | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
This method is deprecated.
Please use
But note that
Join does not consider null elements to be
equivalent to the empty string, as this method does.
| |||||||||||
This method is deprecated.
Please use
But note that
Join does not consider null elements to be
equivalent to the empty string, as this method does.
| |||||||||||
Determines if a string contains only ascii characters
| |||||||||||
Returns a javascript representation of the character in a hex escaped
format.
| |||||||||||
Serializes a map
| |||||||||||
Convert a byte array to a hex-encoding string with the specified
delimiter: "a3<delimiter>3b<delimiter>ff..."
| |||||||||||
Convert a byte array to a hex-encoding string: "a33bff00..."
| |||||||||||
Convert a byte array to a String using Latin-1 (aka ISO-8859-1) encoding.
| |||||||||||
Convert an array of bytes into a List of Strings using UTF-8.
| |||||||||||
Convert a byte array to a String using UTF-8 encoding.
| |||||||||||
Returns a string that is equivalent to the specified string with its
first character converted to uppercase as by
toUpperCase(). | |||||||||||
Replaces any string of matched characters with the supplied string.
| |||||||||||
Replaces any string of adjacent whitespace characters with the whitespace
character " ".
| |||||||||||
Determines if a string contains what looks like an html character
reference.
| |||||||||||
This method is deprecated.
Please inline this method.
| |||||||||||
Converts any instances of "\r" or "\r\n" style EOLs into "\n" (Line Feed).
| |||||||||||
Copy all data from in to out in 4096 byte chunks.
| |||||||||||
This removes characters between maching charLimit chars.
| |||||||||||
The old interface to cropBetween - using a single char limit
| |||||||||||
Returns the approximate display width of the character, measured
in units of ascii characters.
| |||||||||||
Returns the approximate display width of the string, measured in units of
ascii characters.
| |||||||||||
Convert a String to a byte array using the specified encoding.
| |||||||||||
Compares two strings, guarding against nulls If both Strings are null we
return true
| |||||||||||
Reformats the given string to a fixed width by inserting
carriage returns and trimming unnecessary whitespace.
| |||||||||||
Reformats the given array of lines to a fixed width by inserting
carriage returns and trimming unnecessary whitespace.
| |||||||||||
Convert a string of hex digits to a byte array, with the first
byte in the array being the MSB.
| |||||||||||
Escapes special characters (& < > ") from a string so it can safely be
included in an HTML document.
| |||||||||||
Indents the given String per line.
| |||||||||||
Like String.indexOf() except that it will look for any of the
characters in 'chars' (similar to C's strpbrk)
| |||||||||||
Like String.indexOf() except that it will look for any of the
characters in 'chars' (similar to C's strpbrk)
| |||||||||||
Inserts spaces every splitLen characters so that the string will wrap.
| |||||||||||
Determines if a character is a CJK ideograph or a character typically
used only in CJK text.
| |||||||||||
Determines if a character is a CJK ideograph or a character typically
used only in CJK text.
| |||||||||||
Determines if a string is a CJK word.
| |||||||||||
Helper function for null and empty string testing.
| |||||||||||
Helper function for null, empty, and whitespace string testing.
| |||||||||||
Determines if a string is a Hebrew word.
| |||||||||||
Determines if a character is a Hebrew character.
| |||||||||||
We escape some characters in s to be able to insert strings into Java code
| |||||||||||
Escape a string so that it can be safely placed as value of an
attribute.
| |||||||||||
We escape some characters in s to be able to insert strings into JavaScript
code.
| |||||||||||
We escape some characters in s to be able to insert strings into JavaScript
code.
| |||||||||||
Undo escaping as performed in javaScriptEscape(.)
Throws an IllegalArgumentException if the string contains
bad escaping.
| |||||||||||
Escapes the special characters from a string so it can be used as part of
a regex pattern.
| |||||||||||
This method is deprecated.
Please use
But note that
Join does not consider null elements to be
equivalent to the empty string, as this method does.
| |||||||||||
This method is deprecated.
Please use
But note that
Join does not consider null elements to be
equivalent to the empty string, as this method does.
| |||||||||||
Concatenates the given int[] array into one String, inserting a delimiter
between each pair of elements.
| |||||||||||
Concatenates the given long[] array into one String, inserting a delimiter
between each pair of elements.
| |||||||||||
Finds the last index in str of a character not in the characters
in 'chars' (similar to ANSI string.find_last_not_of).
| |||||||||||
Splits s with delimiters in delimiter and returns the last token
| |||||||||||
Convert a String to a byte array using Latin-1 (aka ISO-8859-1) encoding.
| |||||||||||
This method is deprecated.
Please use
But note that
Join does not consider null elements to be
equivalent to the empty string, as this method does.
| |||||||||||
Given a map, creates and returns a new map in which all keys are the
lower-cased version of each key.
| |||||||||||
This method is deprecated.
ensure the string is not null and use
CharMatcher.LEGACY_WHITESPACE.trimLeadingFrom(str); also consider whether you
really want the legacy whitespace definition, or something more
standard like WHITESPACE.
| |||||||||||
Helper function for making null strings safe for comparisons, etc.
| |||||||||||
This function concatenates the elements of a Map in a string with form
"
| |||||||||||
Returns a string consisting of "s", with each of the first "len" characters
replaced by "mask_ch" character.
| |||||||||||
Returns a string consisting of "s", with each of the last "len" characters
replaces by "mask_ch" character.
| |||||||||||
This method is deprecated.
ensure the string is not null and use
| |||||||||||
Counts the number of (not necessarily distinct) characters in the
string that also happen to be in 'chars'
| |||||||||||
Returns a string consisting of "s", plus enough copies of "pad_ch" on the
left hand side to make the length of "s" equal to or greater than len (if
"s" is already longer than "len", then "s" is returned).
| |||||||||||
Returns a string consisting of "s", plus enough copies of "pad_ch" on the
right hand side to make the length of "s" equal to or greater than len (if
"s" is already longer than "len", then "s" is returned).
| |||||||||||
Parse a list of substrings separated by a given delimiter.
| |||||||||||
We escape some characters in s to be able to make the string executable
from a python string
| |||||||||||
Escapes the special characters from a string so it can be used as part of
a regex pattern.
| |||||||||||
Escapes the '\' and '$' characters, which comprise the subset of regex
characters that has special meaning in methods such as:
java.util.regex.Matcher.appendReplacement(sb, replacement); java.lang.String.replaceAll(str, replacement);Note that this method is offered in java version 1.5 as the method java.util.regex.Matcher.quoteReplacement(String); | |||||||||||
Remove any occurrances of 'oldchars' in 'str'.
| |||||||||||
Returns sourceString concatenated together 'factor' times.
| |||||||||||
This method is deprecated.
Please use
replace(CharSequence, CharSequence).
| |||||||||||
Like String.replace() except that it accepts any number of old chars.
| |||||||||||
Replaces microsoft "smart quotes" (curly " and ') with their
ascii counterparts.
| |||||||||||
Removes all characters from 'str' that are not in 'retainChars'.
| |||||||||||
This method is deprecated.
ensure the string is not null and use
CharMatcher.LEGACY_WHITESPACE.trimTrailingFrom(str); also consider whether you
really want the legacy whitespace definition, or something more
standard like WHITESPACE.
| |||||||||||
Split "str" by run of delimiters and return.
| |||||||||||
Split "str" into tokens by delimiters and optionally remove white spaces
from the splitted tokens.
| |||||||||||
Short hand for
split(str, delims, true)
| |||||||||||
Parse comma-separated list of ints and return as array.
| |||||||||||
Parse comma-separated list of longs and return as array.
| |||||||||||
Read a String of up to maxLength bytes from an InputStream
| |||||||||||
Converts a delimited string to a collection of strings.
| |||||||||||
This converts a String to a list of strings by extracting the substrings
between delimiter
| |||||||||||
This converts a string to a Map.
| |||||||||||
This converts a String to a Set of strings by extracting the substrings
between delimiter
| |||||||||||
strip - strips both ways
| |||||||||||
Strip white spaces from both end, and collapse white spaces
in the middle.
| |||||||||||
Given a
String, returns an equivalent String with
all HTML tags stripped. | |||||||||||
Strips all non-digit characters from a string.
| |||||||||||
Give me a string and a potential prefix, and I return the string
following the prefix if the prefix matches, else null.
| |||||||||||
Case insensitive version of stripPrefix.
| |||||||||||
Helper function for making empty strings into a null.
| |||||||||||
Helper function for turning empty or whitespace strings into a null.
| |||||||||||
Returns the string, in single quotes, or "NULL".
| |||||||||||
Replacement for deprecated StringBufferInputStream().
| |||||||||||
Safely convert the string to uppercase.
| |||||||||||
Unescape any C escape sequences (\n, \r, \\, \ooo, etc) and return the
resulting string.
| |||||||||||
Replace all the occurences of HTML escape strings with the
respective characters.
| |||||||||||
Unescape any MySQL escape sequences.
| |||||||||||
Replaces each non-ascii character in s with its Unicode escape sequence
\\uxxxx where xxxx is a hex number.
| |||||||||||
Convert a String to a byte array using UTF-8 encoding.
| |||||||||||
Escape a string that is meant to be embedded in a CDATA section.
| |||||||||||
Escape a string for use inside as XML element content.
| |||||||||||
Returns a form of "s" appropriate for including in an XML document, after
escaping certain special characters (e.g.
| |||||||||||
Escape a string for use inside as XML single-quoted attributes.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
Unicode code blocks containing CJK characters.
This method is deprecated.
Please use
But note that Join does not consider null elements to be
equivalent to the empty string, as this method does.
This concatenates the elements of a collection in a string
| in | - the collection that has to be conatenated |
|---|---|
| separator | - a string to sepparate the elements from the list |
This method is deprecated.
Please use
But note that Join does not consider null elements to be
equivalent to the empty string, as this method does.
| it | |
|---|---|
| separator |
Determines if a string contains only ascii characters
| s |
|---|
Returns a javascript representation of the character in a hex escaped format. Although this is a rather specific method, it is made public because it is also used by the JSCompiler.
| sb | The buffer to which the hex representation should be appended. |
|---|---|
| c | The character to be appended. |
Serializes a map
| map | A map of String keys to arrays of String values |
|---|---|
| keyValueDelim | Delimiter between keys and values |
| entryDelim | Delimiter between entries |
Convert a byte array to a hex-encoding string with the specified delimiter: "a3<delimiter>3b<delimiter>ff..."
| bytes | |
|---|---|
| delimiter |
Convert a byte array to a hex-encoding string: "a33bff00..."
| bytes |
|---|
Convert a byte array to a String using Latin-1 (aka ISO-8859-1) encoding. Note: something is probably wrong if you're using this method. Either you're dealing with legacy code that doesn't support i18n or you're using a third-party library that only deals with Latin-1. New code should (almost) always uses UTF-8 encoding.
| ba |
|---|
Convert an array of bytes into a List of Strings using UTF-8. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed.
Can be used to parse the output of| bytes | The array to convert |
|---|
Convert a byte array to a String using UTF-8 encoding.
| ba |
|---|
Returns a string that is equivalent to the specified string with its
first character converted to uppercase as by toUpperCase().
The returned string will have the same value as the specified string if
its first character is non-alphabetic, if its first character is already
uppercase, or if the specified string is of length 0.
For example:
capitalize("foo bar").equals("Foo bar");
capitalize("2b or not 2b").equals("2b or not 2b")
capitalize("Foo bar").equals("Foo bar");
capitalize("").equals("");
| s | The string whose first character is to be uppercased |
|---|
| NullPointerException | if s is null |
|---|
Replaces any string of matched characters with the supplied string.
This is a more general version of collapseWhitespace.
E.g. collapse("hello world", " ", "::")
will return the following string: "hello::world"
| str | The string you want to munge |
|---|---|
| chars | All of the characters to be considered for munge |
| replacement | The replacement string |
Replaces any string of adjacent whitespace characters with the whitespace character " ".
| str | The string you want to munge |
|---|
Determines if a string contains what looks like an html character reference. Useful for deciding whether unescaping is necessary.
| s |
|---|
This method is deprecated.
Please inline this method.
| input |
|---|
Converts any instances of "\r" or "\r\n" style EOLs into "\n" (Line Feed).
| input |
|---|
Copy all data from in to out in 4096 byte chunks.
| in | |
|---|---|
| out |
| IOException |
|---|
This removes characters between maching charLimit chars. For example cropBetween("ab^cd^ef^gh^hi", '^') will return "abefhi" It will consider squences of 2 charLimit as one charLimit in the output
| in | - the string to process |
|---|---|
| limit | - the limit of the string(s) to remove |
The old interface to cropBetween - using a single char limit
| in | |
|---|---|
| limit |
Returns the approximate display width of the character, measured in units of ascii characters. This method should err on the side of caution. By default, characters are assumed to have width 2; this covers CJK ideographs, various symbols and miscellaneous weird scripts. Given below are some Unicode ranges for which it seems safe to assume that no character is substantially wider than an ascii character: - Latin, extended Latin, even more extended Latin. - Greek, extended Greek, Cyrillic. - Some symbols (including currency symbols) and punctuation. - Half-width Katakana and Hangul. - Hebrew - Thai Characters in these ranges are given a width of 1. IMPORTANT: this function has an analog in strutil.cc named UnicodeCharWidth, which needs to be updated if you change the implementation here.
| ch |
|---|
Returns the approximate display width of the string, measured in units of ascii characters.
| s |
|---|
Convert a String to a byte array using the specified encoding.
| str | |
|---|---|
| encoding | The encoding to use |
Compares two strings, guarding against nulls If both Strings are null we return true
| s1 | |
|---|---|
| s2 |
| dbSpecComponent | A single component of a DBDescriptor spec
(e.g. the host or database component). The expected format of the string is:
|
|---|
| IllegalArgumentException | if the string does not parse. |
|---|---|
| IllegalStateException |
Reformats the given string to a fixed width by inserting carriage returns and trimming unnecessary whitespace.
| str | The string to format |
|---|---|
| width | The fixed width (in characters) |
Reformats the given array of lines to a fixed width by inserting carriage returns and trimming unnecessary whitespace.
| lines | - array of lines to format |
|---|---|
| width | - the fixed width (in characters) |
Convert a string of hex digits to a byte array, with the first byte in the array being the MSB. The string passed in should be just the raw digits (upper or lower case), with no leading or trailing characters (like '0x' or 'h'). An odd number of characters is supported. If the string is empty, an empty array will be returned. This is significantly faster than using new BigInteger(str, 16).toByteArray(); especially with larger strings. Here are the results of some microbenchmarks done on a P4 2.8GHz 2GB RAM running linux 2.4.22-gg11 and JDK 1.5 with an optimized build: String length hexToBytes (usec) BigInteger ----------------------------------------------------- 16 0.570 1.43 256 8.21 44.4 1024 32.8 526 16384 546 121000
| str |
|---|
Escapes special characters (& < > ") from a string so it can safely be
included in an HTML document. (same as xmlEscape except that
htmlEscape does not escape the apostrophe character).
| s |
|---|
Indents the given String per line.
| iString | The string to indent. |
|---|---|
| iIndentDepth | The depth of the indentation. |
Like String.indexOf() except that it will look for any of the characters in 'chars' (similar to C's strpbrk)
| str | |
|---|---|
| chars | |
| fromIndex |
Like String.indexOf() except that it will look for any of the characters in 'chars' (similar to C's strpbrk)
| str | |
|---|---|
| chars |
Inserts spaces every splitLen characters so that the string will wrap.
| lineLen | The length of the substrings to separate with spaces. |
|---|---|
| original | The original String |
Determines if a character is a CJK ideograph or a character typically
used only in CJK text.
Note: This function cannot handle supplementary characters. To handle all
Unicode characters, including supplementary characters, use the function
isCjk(int).
| ch |
|---|
Determines if a character is a CJK ideograph or a character typically used only in CJK text.
| codePoint |
|---|
Determines if a string is a CJK word. A string is considered to be CJK
if isCjk(char) is true for any of its characters.
| s |
|---|
Helper function for null and empty string testing.
| s |
|---|
Helper function for null, empty, and whitespace string testing.
| s |
|---|
Determines if a string is a Hebrew word. A string is considered to be
a Hebrew word if isHebrew(int) is true for any of its characters.
| s |
|---|
Determines if a character is a Hebrew character.
| codePoint |
|---|
We escape some characters in s to be able to insert strings into Java code
| s |
|---|
Escape a string so that it can be safely placed as value of an attribute. This is essentially similar to the javaEscape(java.lang.String) except that it escapes double quote to the HTML literal ". This is to prevent the double quote from being interpreted as the character closing the attribute.
| s |
|---|
We escape some characters in s to be able to insert strings into JavaScript code. Also, make sure that we don't write out --> or
| s |
|---|
We escape some characters in s to be able to insert strings into JavaScript code. Also, make sure that we don't write out --> or </scrip, which may close a script tag. Turns all non-ascii characters into ASCII javascript escape sequences (eg ?)
| s |
|---|
Undo escaping as performed in javaScriptEscape(.) Throws an IllegalArgumentException if the string contains bad escaping.
| s |
|---|
Escapes the special characters from a string so it can be used as part of a regex pattern. This method is for use on regexes in the flavor of the java.util.regex package. This method should be removed when we move to the java version 1.5 (Tiger) release, since that release gives us a literal regex flag as well as a quote method to produce literal regexes.
| s |
|---|
This method is deprecated.
Please use
But note that Join does not consider null elements to be
equivalent to the empty string, as this method does.
Same as join(Object[], String), but takes a Collection
instead.
| tokens | |
|---|---|
| delimiter |
This method is deprecated.
Please use
But note that Join does not consider null elements to be
equivalent to the empty string, as this method does.
Concatenates the String representations of the elements of a String[] array into one String, and inserts a delimiter between each pair of elements.
This includes the String[] case, because if s is a String, then s.toString() returns s.
| tokens | |
|---|---|
| delimiter |
Concatenates the given int[] array into one String, inserting a delimiter between each pair of elements.
| tokens | |
|---|---|
| delimiter |
Concatenates the given long[] array into one String, inserting a delimiter between each pair of elements.
| tokens | |
|---|---|
| delimiter |
Finds the last index in str of a character not in the characters in 'chars' (similar to ANSI string.find_last_not_of). Returns -1 if no such character can be found.
| str | |
|---|---|
| chars | |
| fromIndex |
Splits s with delimiters in delimiter and returns the last token
| s | |
|---|---|
| delimiter |
Convert a String to a byte array using Latin-1 (aka ISO-8859-1) encoding. If any character in the String is not Latin-1 (meaning it's high 8 bits are not all zero), then the returned byte array will contain garbage. Therefore, only use this if you know all your characters are within Latin-1. Note: something is probably wrong if you're using this method. Either you're dealing with legacy code that doesn't support i18n or you're using a third-party library that only deals with Latin-1. New code should (almost) always uses UTF-8 encoding.
| str |
|---|
This method is deprecated.
Please use
But note that Join does not consider null elements to be
equivalent to the empty string, as this method does.
Lots of people called list2String when in fact it was implemented as Collection2String. I added Collection2String as a new function and am leaving the list2String function signature here so it can continue to be
| in | |
|---|---|
| separator |
Given a map, creates and returns a new map in which all keys are the lower-cased version of each key.
| map | A map containing String keys to be lowercased |
|---|
| IllegalArgumentException | if the map contains duplicate string keys after lower casing |
|---|
This method is deprecated.
ensure the string is not null and use CharMatcher.LEGACY_WHITESPACE.trimLeadingFrom(str); also consider whether you
really want the legacy whitespace definition, or something more
standard like WHITESPACE.
lstrip - strips spaces from left
| str | What to strip |
|---|
Helper function for making null strings safe for comparisons, etc.
| s |
|---|
This function concatenates the elements of a Map in a string with form
"
| in | - the map to be converted |
|---|---|
| sepKey | - the separator to put between key and value |
| sepEntry | - the separator to put between map entries |
Returns a string consisting of "s", with each of the first "len" characters replaced by "mask_ch" character.
| s | |
|---|---|
| len | |
| mask_ch |
Returns a string consisting of "s", with each of the last "len" characters replaces by "mask_ch" character.
| s | |
|---|---|
| len | |
| mask_ch |
This method is deprecated.
ensure the string is not null and use
CharMatcher.anyOf(what).trimFrom(str)
if left == true and right == true
CharMatcher.anyOf(what).trimLeadingFrom(str)
if left == true and right == false
CharMatcher.anyOf(what).trimTrailingFrom(str)
if left == false and right == true
This is a both way strip
| str | The string to strip |
|---|---|
| left | Strip from left |
| right | Strip from right |
| what | Character(s) to strip |
Counts the number of (not necessarily distinct) characters in the string that also happen to be in 'chars'
| str | |
|---|---|
| chars |
Returns a string consisting of "s", plus enough copies of "pad_ch" on the left hand side to make the length of "s" equal to or greater than len (if "s" is already longer than "len", then "s" is returned).
| s | |
|---|---|
| len | |
| pad_ch |
Returns a string consisting of "s", plus enough copies of "pad_ch" on the right hand side to make the length of "s" equal to or greater than len (if "s" is already longer than "len", then "s" is returned).
| s | |
|---|---|
| len | |
| pad_ch |
Parse a list of substrings separated by a given delimiter. The delimiter can also appear in substrings (just double them): parseDelimitedString("this|is", '|') returns ["this","is"] parseDelimitedString("this||is", '|') returns ["this|is"]
| list | String containing delimited substrings |
|---|---|
| delimiter | Delimiter (anything except ' ' is allowed) |
We escape some characters in s to be able to make the string executable from a python string
| s |
|---|
Escapes the special characters from a string so it can be used as part of a regex pattern. This method is for use on gnu.regexp style regular expressions.
| s |
|---|
Escapes the '\' and '$' characters, which comprise the subset of regex characters that has special meaning in methods such as:
java.util.regex.Matcher.appendReplacement(sb, replacement);
java.lang.String.replaceAll(str, replacement);Note that this method is offered in java version 1.5 as the method
java.util.regex.Matcher.quoteReplacement(String);
| s |
|---|
Remove any occurrances of 'oldchars' in 'str'. Example: removeChars("Hello, world!", ",!") returns "Hello world"
| str | |
|---|---|
| oldchars |
Returns sourceString concatenated together 'factor' times.
| sourceString | The string to repeat |
|---|---|
| factor | The number of times to repeat it. |
This method is deprecated.
Please use replace(CharSequence, CharSequence).
This replaces the occurances of 'what' in 'str' with 'with'
| str | - the string o process |
|---|---|
| what | - to replace |
| with | - replace with this |
Like String.replace() except that it accepts any number of old chars. Replaces any occurrances of 'oldchars' in 'str' with 'newchar'. Example: replaceChars("Hello, world!", "H,!", ' ') returns " ello world "
| str | |
|---|---|
| oldchars | |
| newchar |
Replaces microsoft "smart quotes" (curly " and ') with their ascii counterparts.
| str |
|---|
Removes all characters from 'str' that are not in 'retainChars'. Example: retainAllChars("Hello, world!", "lo") returns "llool"
| str | |
|---|---|
| retainChars |
This method is deprecated.
ensure the string is not null and use CharMatcher.LEGACY_WHITESPACE.trimTrailingFrom(str); also consider whether you
really want the legacy whitespace definition, or something more
standard like WHITESPACE.
rstrip - strips spaces from right
| str | What to strip |
|---|
Split "str" by run of delimiters and return.
| str | |
|---|---|
| delims |
Split "str" into tokens by delimiters and optionally remove white spaces from the splitted tokens.
| str | |
|---|---|
| delims | |
| trimTokens | If true, then trim the tokens |
Short hand for split(str, delims, true)
| str | |
|---|---|
| delims |
Parse comma-separated list of ints and return as array.
| str |
|---|
| IllegalArgumentException |
|---|
Parse comma-separated list of longs and return as array.
| str |
|---|
| IllegalArgumentException |
|---|
Read a String of up to maxLength bytes from an InputStream
| is | Input stream |
|---|---|
| maxLength | Max number of bytes to read from "is". If this is -1, we read everything. |
| IOException |
|---|
Converts a delimited string to a collection of strings. Substrings between delimiters are extracted from the string and added to a collection that is provided by the caller.
| in | The delimited input string to process |
|---|---|
| delimiter | The string delimiting entries in the input string. |
| doStrip | |
| collection | The collection to which the strings will be added. If
null, a new List will be created. |
This converts a String to a list of strings by extracting the substrings between delimiter
| in | - what to process |
|---|---|
| delimiter | - the delimiting string |
| doStrip | - to strip the substrings before adding to the list |
This converts a string to a Map. It will first split the string into entries using delimEntry. Then each entry is split into a key and a value using delimKey. By default we strip the keys. Use doStripEntry to strip also the entries
| in | - the string to be processed |
|---|---|
| delimEntry | - delimiter for the entries |
| delimKey | - delimiter between keys and values |
| doStripEntry | - strip entries before inserting in the map |
This converts a String to a Set of strings by extracting the substrings between delimiter
| in | - what to process |
|---|---|
| delimiter | - the delimiting string |
| doStrip | - to strip the substrings before adding to the list |
strip - strips both ways
| str | What to strip |
|---|
Strip white spaces from both end, and collapse white spaces in the middle.
| str | What to strip |
|---|
Given a String, returns an equivalent String with
all HTML tags stripped. Note that HTML entities, such as "&" will
still be preserved.
| string |
|---|
Strips all non-digit characters from a string. The resulting string will only contain characters for which isDigit() returns true.
| str | The string to strip |
|---|
Give me a string and a potential prefix, and I return the string following the prefix if the prefix matches, else null. Analogous to the c++ functions strprefix and var_strprefix.
| str | |
|---|---|
| prefix |
Case insensitive version of stripPrefix. Analogous to the c++ functions strcaseprefix and var_strcaseprefix.
| str | |
|---|---|
| prefix |
Helper function for making empty strings into a null.
| s |
|---|
Helper function for turning empty or whitespace strings into a null.
| s |
|---|
| iArray |
|---|
| iArray |
|---|
| iArray |
|---|
| iArray |
|---|
| obj |
|---|
Returns the string, in single quotes, or "NULL". Intended only for logging.
| s | - the string |
|---|
| iArray |
|---|
| iArray |
|---|
Replacement for deprecated StringBufferInputStream(). Instead of: InputStream is = new StringBuilderInputStream(str); do: InputStream is = StringUtil.toUTF8InputStream(str);
| str |
|---|
Safely convert the string to uppercase.
| src |
|---|
Unescape any C escape sequences (\n, \r, \\, \ooo, etc) and return the resulting string.
| s |
|---|
Replace all the occurences of HTML escape strings with the respective characters.
| s | A String value |
|---|
String value
Unescape any MySQL escape sequences. See MySQL language reference Chapter 6 at http://www.mysql.com/doc/. This function will not work for other SQL-like dialects.
| s | String to unescape, with the surrounding quotes. |
|---|
| IllegalArgumentException | if s is not a valid MySQL string. |
|---|
Replaces each non-ascii character in s with its Unicode escape sequence \\uxxxx where xxxx is a hex number. Existing escape sequences won't be affected.
| s |
|---|
Convert a String to a byte array using UTF-8 encoding.
| str |
|---|
Escape a string that is meant to be embedded in a CDATA section. The returned string is guaranteed to be valid CDATA content. The syntax of CDATA sections is the following:
<[!CDATA[...]]>
The only invalid character sequence in a CDATA tag is "]]>".
If this sequence is present in the input string, we replace
it by closing the current CDATA field, then write ']]>',
then reopen a new CDATA section.
| s |
|---|
Escape a string for use inside as XML element content. This escapes less-than and ampersand, only.
| s |
|---|
Returns a form of "s" appropriate for including in an XML document, after escaping certain special characters (e.g. '&' => '&', etc.)
| s |
|---|
Escape a string for use inside as XML single-quoted attributes. This escapes less-than, single-quote, ampersand, and (not strictly necessary) newlines.
| s |
|---|