|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.gdata.util.common.base.StringUtil
public class StringUtil
Some common string manipulation utilities.
Field Summary | |
---|---|
static java.lang.String |
EMPTY_STRING
|
static java.lang.String |
LINE_BREAKS
|
static java.lang.String |
WHITE_SPACES
|
Method Summary | ||
---|---|---|
static boolean |
allAscii(java.lang.String s)
Determines if a string contains only ascii characters |
|
static void |
appendHexJavaScriptRepresentation(java.lang.StringBuilder sb,
char c)
Returns a javascript representation of the character in a hex escaped format. |
|
static java.lang.String |
arrayMap2String(java.util.Map<java.lang.String,java.lang.String[]> map,
java.lang.String keyValueDelim,
java.lang.String entryDelim)
Serializes a map |
|
static java.lang.String |
bytesToHexString(byte[] bytes)
Convert a byte array to a hex-encoding string: "a33bff00..." |
|
static java.lang.String |
bytesToHexString(byte[] bytes,
java.lang.Character delimiter)
Convert a byte array to a hex-encoding string with the specified delimiter: "a3<delimiter>3b<delimiter>ff..." |
|
static java.lang.String |
bytesToLatin1(byte[] ba)
Convert a byte array to a String using Latin-1 (aka ISO-8859-1) encoding. |
|
static java.util.List<java.lang.String> |
bytesToStringList(byte[] bytes)
Convert an array of bytes into a List of Strings using UTF-8. |
|
static java.lang.String |
bytesToUtf8(byte[] ba)
Convert a byte array to a String using UTF-8 encoding. |
|
static java.lang.String |
capitalize(java.lang.String s)
Returns a string that is equivalent to the specified string with its first character converted to uppercase as by String.toUpperCase(java.util.Locale) . |
|
static java.lang.String |
collapse(java.lang.String str,
java.lang.String chars,
java.lang.String replacement)
Replaces any string of matched characters with the supplied string. |
|
static java.lang.String |
collapseWhitespace(java.lang.String str)
Replaces any string of adjacent whitespace characters with the whitespace character " ". |
|
static java.lang.String |
Collection2String(java.util.Collection<?> in,
java.lang.String separator)
Deprecated. Please use But note that Join does not consider null elements to be
equivalent to the empty string, as this method does. |
|
static boolean |
containsCharRef(java.lang.String s)
Determines if a string contains what looks like an html character reference. |
|
static java.lang.String |
convertEOLToCRLF(java.lang.String input)
Deprecated. Please inline this method. |
|
static java.lang.String |
convertEOLToLF(java.lang.String input)
Converts any instances of "\r" or "\r\n" style EOLs into "\n" (Line Feed). |
|
static void |
copyStreams(java.io.InputStream in,
java.io.OutputStream out)
Copy all data from in to out in 4096 byte chunks. |
|
static java.lang.String |
cropBetween(java.lang.String in,
char limit)
The old interface to cropBetween - using a single char limit |
|
static java.lang.String |
cropBetween(java.lang.String in,
java.lang.String limit)
This removes characters between maching charLimit chars. |
|
static int |
displayWidth(char ch)
Returns the approximate display width of the character, measured in units of ascii characters. |
|
static int |
displayWidth(java.lang.String s)
Returns the approximate display width of the string, measured in units of ascii characters. |
|
static byte[] |
encodingToBytes(java.lang.String str,
java.lang.String encoding)
Convert a String to a byte array using the specified encoding. |
|
static boolean |
equals(java.lang.String s1,
java.lang.String s2)
Compares two strings, guarding against nulls If both Strings are null we return true |
|
static java.lang.String |
expandShardNames(java.lang.String dbSpecComponent)
|
|
static java.lang.String |
fixedWidth(java.lang.String[] lines,
int width)
Reformats the given array of lines to a fixed width by inserting carriage returns and trimming unnecessary whitespace. |
|
static java.lang.String |
fixedWidth(java.lang.String str,
int width)
Reformats the given string to a fixed width by inserting carriage returns and trimming unnecessary whitespace. |
|
static byte[] |
hexToBytes(java.lang.String str)
Convert a string of hex digits to a byte array, with the first byte in the array being the MSB. |
|
static java.lang.String |
htmlEscape(java.lang.String s)
Escapes special characters (& < > ") from a string so it can safely be included in an HTML document. |
|
static java.lang.String |
indent(java.lang.String iString,
int iIndentDepth)
Indents the given String per line. |
|
static int |
indexOfChars(java.lang.String str,
java.lang.String chars)
Like String.indexOf() except that it will look for any of the characters in 'chars' (similar to C's strpbrk) |
|
static int |
indexOfChars(java.lang.String str,
java.lang.String chars,
int fromIndex)
Like String.indexOf() except that it will look for any of the characters in 'chars' (similar to C's strpbrk) |
|
static java.lang.String |
insertBreakingWhitespace(int lineLen,
java.lang.String original)
Inserts spaces every splitLen characters so that the string will wrap. |
|
static boolean |
isCjk(char ch)
Determines if a character is a CJK ideograph or a character typically used only in CJK text. |
|
static boolean |
isCjk(int codePoint)
Determines if a character is a CJK ideograph or a character typically used only in CJK text. |
|
static boolean |
isCjk(java.lang.String s)
Determines if a string is a CJK word. |
|
static boolean |
isEmpty(java.lang.String s)
Helper function for null and empty string testing. |
|
static boolean |
isEmptyOrWhitespace(java.lang.String s)
Helper function for null, empty, and whitespace string testing. |
|
static boolean |
isHebrew(int codePoint)
Determines if a character is a Hebrew character. |
|
static boolean |
isHebrew(java.lang.String s)
Determines if a string is a Hebrew word. |
|
static java.lang.String |
Iterator2String(java.util.Iterator<?> it,
java.lang.String separator)
Deprecated. Please use But note that Join does not consider null elements to be
equivalent to the empty string, as this method does. |
|
static java.lang.String |
javaEscape(java.lang.String s)
We escape some characters in s to be able to insert strings into Java code |
|
static java.lang.String |
javaEscapeWithinAttribute(java.lang.String s)
Escape a string so that it can be safely placed as value of an attribute. |
|
static java.lang.String |
javaScriptEscape(java.lang.String s)
We escape some characters in s to be able to insert strings into JavaScript code. |
|
static java.lang.String |
javaScriptEscapeToAscii(java.lang.String s)
We escape some characters in s to be able to insert strings into JavaScript code. |
|
static java.lang.String |
javaScriptUnescape(java.lang.String s)
Undo escaping as performed in javaScriptEscape(.) Throws an IllegalArgumentException if the string contains bad escaping. |
|
static java.lang.String |
javaUtilRegexEscape(java.lang.String s)
Escapes the special characters from a string so it can be used as part of a regex pattern. |
|
static java.lang.String |
join(java.util.Collection tokens,
java.lang.String delimiter)
Deprecated. Please use But note that Join does not consider null elements to be
equivalent to the empty string, as this method does. |
|
static java.lang.String |
join(java.lang.Object[] tokens,
java.lang.String delimiter)
Deprecated. Please use But note that Join does not consider null elements to be
equivalent to the empty string, as this method does. |
|
static java.lang.String |
joinInts(int[] tokens,
java.lang.String delimiter)
Concatenates the given int[] array into one String, inserting a delimiter between each pair of elements. |
|
static java.lang.String |
joinLongs(long[] tokens,
java.lang.String delimiter)
Concatenates the given long[] array into one String, inserting a delimiter between each pair of elements. |
|
static int |
lastIndexNotOf(java.lang.String str,
java.lang.String chars,
int fromIndex)
Finds the last index in str of a character not in the characters in 'chars' (similar to ANSI string.find_last_not_of). |
|
static java.lang.String |
lastToken(java.lang.String s,
java.lang.String delimiter)
Splits s with delimiters in delimiter and returns the last token |
|
static byte[] |
latin1ToBytes(java.lang.String str)
Convert a String to a byte array using Latin-1 (aka ISO-8859-1) encoding. |
|
static java.lang.String |
list2String(java.util.Collection<?> in,
java.lang.String separator)
Deprecated. Please use But note that Join does not consider null elements to be
equivalent to the empty string, as this method does. |
|
static
|
lowercaseKeys(java.util.Map<java.lang.String,V> map)
Given a map, creates and returns a new map in which all keys are the lower-cased version of each key. |
|
static java.lang.String |
lstrip(java.lang.String str)
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 CharMatcher.WHITESPACE . |
|
static java.lang.String |
makeSafe(java.lang.String s)
Helper function for making null strings safe for comparisons, etc. |
|
static
|
map2String(java.util.Map<K,V> in,
java.lang.String sepKey,
java.lang.String sepEntry)
This function concatenates the elements of a Map in a string with form " |
|
static java.lang.String |
maskLeft(java.lang.String s,
int len,
char mask_ch)
Returns a string consisting of "s", with each of the first "len" characters replaced by "mask_ch" character. |
|
static java.lang.String |
maskRight(java.lang.String s,
int len,
char mask_ch)
Returns a string consisting of "s", with each of the last "len" characters replaces by "mask_ch" character. |
|
static java.lang.String |
megastrip(java.lang.String str,
boolean left,
boolean right,
java.lang.String what)
Deprecated. ensure the string is not null and use
|
|
static int |
numSharedChars(java.lang.String str,
java.lang.String chars)
Counts the number of (not necessarily distinct) characters in the string that also happen to be in 'chars' |
|
static java.lang.String |
padLeft(java.lang.String s,
int len,
char pad_ch)
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). |
|
static java.lang.String |
padRight(java.lang.String s,
int len,
char 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). |
|
static java.lang.String[] |
parseDelimitedList(java.lang.String list,
char delimiter)
Parse a list of substrings separated by a given delimiter. |
|
static java.lang.String |
pythonEscape(java.lang.String s)
We escape some characters in s to be able to make the string executable from a python string |
|
static java.lang.String |
regexEscape(java.lang.String s)
Escapes the special characters from a string so it can be used as part of a regex pattern. |
|
static java.lang.String |
regexReplacementEscape(java.lang.String s)
Escapes the '\' and '$' characters, which comprise the subset of regex characters that has special meaning in methods such as: |
|
static java.lang.String |
removeChars(java.lang.String str,
java.lang.String oldchars)
Remove any occurrances of 'oldchars' in 'str'. |
|
static java.lang.String |
repeat(java.lang.String sourceString,
int factor)
Returns sourceString concatenated together 'factor' times. |
|
static java.lang.String |
replace(java.lang.String str,
java.lang.String what,
java.lang.String with)
Deprecated. Please use String.replace(CharSequence, CharSequence) . |
|
static java.lang.String |
replaceChars(java.lang.String str,
java.lang.String oldchars,
char newchar)
Like String.replace() except that it accepts any number of old chars. |
|
static java.lang.String |
replaceSmartQuotes(java.lang.String str)
Replaces microsoft "smart quotes" (curly " and ') with their ascii counterparts. |
|
static java.lang.String |
retainAllChars(java.lang.String str,
java.lang.String retainChars)
Removes all characters from 'str' that are not in 'retainChars'. |
|
static java.lang.String |
rstrip(java.lang.String str)
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 CharMatcher.WHITESPACE . |
|
static java.lang.String[] |
split(java.lang.String str,
java.lang.String delims)
Split "str" by run of delimiters and return. |
|
static java.lang.String[] |
split(java.lang.String str,
java.lang.String delims,
boolean trimTokens)
Split "str" into tokens by delimiters and optionally remove white spaces from the splitted tokens. |
|
static java.lang.String[] |
splitAndTrim(java.lang.String str,
java.lang.String delims)
Short hand for split(str, delims, true) |
|
static int[] |
splitInts(java.lang.String str)
Parse comma-separated list of ints and return as array. |
|
static long[] |
splitLongs(java.lang.String str)
Parse comma-separated list of longs and return as array. |
|
static java.lang.String |
stream2String(java.io.InputStream is,
int maxLength)
Read a String of up to maxLength bytes from an InputStream |
|
static java.util.Collection<java.lang.String> |
string2Collection(java.lang.String in,
java.lang.String delimiter,
boolean doStrip,
java.util.Collection<java.lang.String> collection)
Converts a delimited string to a collection of strings. |
|
static java.util.LinkedList<java.lang.String> |
string2List(java.lang.String in,
java.lang.String delimiter,
boolean doStrip)
This converts a String to a list of strings by extracting the substrings between delimiter |
|
static java.util.HashMap<java.lang.String,java.lang.String> |
string2Map(java.lang.String in,
java.lang.String delimEntry,
java.lang.String delimKey,
boolean doStripEntry)
This converts a string to a Map. |
|
static java.util.Set |
string2Set(java.lang.String in,
java.lang.String delimiter,
boolean doStrip)
This converts a String to a Set of strings by extracting the substrings between delimiter |
|
static java.lang.String |
strip(java.lang.String str)
strip - strips both ways |
|
static java.lang.String |
stripAndCollapse(java.lang.String str)
Strip white spaces from both end, and collapse white spaces in the middle. |
|
static java.lang.String |
stripHtmlTags(java.lang.String string)
Given a String , returns an equivalent String with
all HTML tags stripped. |
|
static java.lang.String |
stripNonDigits(java.lang.String str)
Strips all non-digit characters from a string. |
|
static java.lang.String |
stripPrefix(java.lang.String str,
java.lang.String prefix)
Give me a string and a potential prefix, and I return the string following the prefix if the prefix matches, else null. |
|
static java.lang.String |
stripPrefixIgnoreCase(java.lang.String str,
java.lang.String prefix)
Case insensitive version of stripPrefix. |
|
static java.lang.String |
toNullIfEmpty(java.lang.String s)
Helper function for making empty strings into a null. |
|
static java.lang.String |
toNullIfEmptyOrWhitespace(java.lang.String s)
Helper function for turning empty or whitespace strings into a null. |
|
static java.lang.String |
toString(float[] iArray)
|
|
static java.lang.String |
toString(int[] iArray)
|
|
static java.lang.String |
toString(int[][] iArray)
|
|
static java.lang.String |
toString(long[] iArray)
|
|
static java.lang.String |
toString(long[][] iArray)
|
|
static java.lang.String |
toString(java.lang.Object[] obj)
|
|
static java.lang.String |
toString(java.lang.String s)
Returns the string, in single quotes, or "NULL". |
|
static java.lang.String |
toString(java.lang.String[] iArray)
|
|
static java.lang.String |
toUpperCase(java.lang.String src)
Safely convert the string to uppercase. |
|
static java.io.InputStream |
toUTF8InputStream(java.lang.String str)
Replacement for deprecated StringBufferInputStream(). |
|
static java.lang.String |
unescapeCString(java.lang.String s)
Unescape any C escape sequences (\n, \r, \\, \ooo, etc) and return the resulting string. |
|
static java.lang.String |
unescapeHTML(java.lang.String s)
Replace all the occurences of HTML escape strings with the respective characters. |
|
static java.lang.String |
unescapeMySQLString(java.lang.String s)
Unescape any MySQL escape sequences. |
|
static java.lang.String |
unicodeEscape(java.lang.String s)
Replaces each non-ascii character in s with its Unicode escape sequence \\uxxxx where xxxx is a hex number. |
|
static byte[] |
utf8ToBytes(java.lang.String str)
Convert a String to a byte array using UTF-8 encoding. |
|
static java.lang.String |
xmlCDataEscape(java.lang.String s)
Escape a string that is meant to be embedded in a CDATA section. |
|
static java.lang.String |
xmlContentEscape(java.lang.String s)
Escape a string for use inside as XML element content. |
|
static java.lang.String |
xmlEscape(java.lang.String s)
Returns a form of "s" appropriate for including in an XML document, after escaping certain special characters (e.g. |
|
static java.lang.String |
xmlSingleQuotedEscape(java.lang.String s)
Escape a string for use inside as XML single-quoted attributes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String EMPTY_STRING
public static final java.lang.String WHITE_SPACES
public static final java.lang.String LINE_BREAKS
Method Detail |
---|
public static java.lang.String[] split(java.lang.String str, java.lang.String delims)
public static java.lang.String[] split(java.lang.String str, java.lang.String delims, boolean trimTokens)
trimTokens
- if true, then trim the tokenspublic static java.lang.String[] splitAndTrim(java.lang.String str, java.lang.String delims)
split(str, delims, true)
public static int[] splitInts(java.lang.String str) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public static long[] splitLongs(java.lang.String str) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public static java.lang.String joinInts(int[] tokens, java.lang.String delimiter)
public static java.lang.String joinLongs(long[] tokens, java.lang.String delimiter)
@Deprecated public static java.lang.String join(java.lang.Object[] tokens, java.lang.String delimiter)
Join
does not consider null elements to be
equivalent to the empty string, as this method does.
This includes the String[] case, because if s is a String, then s.toString() returns s.
@Deprecated public static java.lang.String join(java.util.Collection tokens, java.lang.String delimiter)
Join
does not consider null elements to be
equivalent to the empty string, as this method does.
join(Object[],String)
, but takes a Collection
instead.
@Deprecated public static java.lang.String replace(java.lang.String str, java.lang.String what, java.lang.String with)
String.replace(CharSequence, CharSequence)
.
str
- - the string o processwhat
- - to replacewith
- - replace with this
public static java.lang.String fixedWidth(java.lang.String str, int width)
str
- the string to formatwidth
- the fixed width (in characters)public static java.lang.String fixedWidth(java.lang.String[] lines, int width)
lines
- - array of lines to formatwidth
- - the fixed width (in characters)public static java.lang.String insertBreakingWhitespace(int lineLen, java.lang.String original)
lineLen
- the length of the substrings to separate with spaces.original
- the original String
public static java.lang.String indent(java.lang.String iString, int iIndentDepth)
iString
- The string to indent.iIndentDepth
- The depth of the indentation.
@Deprecated public static java.lang.String megastrip(java.lang.String str, boolean left, boolean right, java.lang.String what)
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
str
- the string to stripleft
- strip from leftright
- strip from rightwhat
- character(s) to strip
@Deprecated public static java.lang.String lstrip(java.lang.String str)
CharMatcher.LEGACY_WHITESPACE.trimLeadingFrom(str)
; also consider whether you
really want the legacy whitespace definition, or something more
standard like CharMatcher.WHITESPACE
.
str
- what to strip
@Deprecated public static java.lang.String rstrip(java.lang.String str)
CharMatcher.LEGACY_WHITESPACE.trimTrailingFrom(str)
; also consider whether you
really want the legacy whitespace definition, or something more
standard like CharMatcher.WHITESPACE
.
str
- what to strip
public static java.lang.String strip(java.lang.String str)
str
- what to strip
public static java.lang.String stripAndCollapse(java.lang.String str)
str
- what to strip
public static java.lang.String stripPrefix(java.lang.String str, java.lang.String prefix)
public static java.lang.String stripPrefixIgnoreCase(java.lang.String str, java.lang.String prefix)
public static java.lang.String stripNonDigits(java.lang.String str)
str
- the string to strip
public static int numSharedChars(java.lang.String str, java.lang.String chars)
public static int indexOfChars(java.lang.String str, java.lang.String chars, int fromIndex)
public static int indexOfChars(java.lang.String str, java.lang.String chars)
public static int lastIndexNotOf(java.lang.String str, java.lang.String chars, int fromIndex)
public static java.lang.String replaceChars(java.lang.String str, java.lang.String oldchars, char newchar)
public static java.lang.String removeChars(java.lang.String str, java.lang.String oldchars)
public static java.lang.String retainAllChars(java.lang.String str, java.lang.String retainChars)
public static java.lang.String replaceSmartQuotes(java.lang.String str)
public static byte[] hexToBytes(java.lang.String str)
public static java.lang.String convertEOLToLF(java.lang.String input)
@Deprecated public static java.lang.String convertEOLToCRLF(java.lang.String input)
public static java.lang.String padLeft(java.lang.String s, int len, char pad_ch)
public static java.lang.String padRight(java.lang.String s, int len, char pad_ch)
public static java.lang.String maskLeft(java.lang.String s, int len, char mask_ch)
public static java.lang.String maskRight(java.lang.String s, int len, char mask_ch)
public static java.lang.String unescapeCString(java.lang.String s)
public static java.lang.String unescapeMySQLString(java.lang.String s) throws java.lang.IllegalArgumentException
s
- string to unescape, with the surrounding quotes.
java.lang.IllegalArgumentException
- if s is not a valid MySQL string.public static final java.lang.String unescapeHTML(java.lang.String s)
s
- a String
value
String
valuepublic static java.lang.String stripHtmlTags(java.lang.String string)
String
, returns an equivalent String
with
all HTML tags stripped. Note that HTML entities, such as "&" will
still be preserved.
public static java.lang.String pythonEscape(java.lang.String s)
public static java.lang.String javaScriptEscape(java.lang.String s)
public static java.lang.String javaScriptEscapeToAscii(java.lang.String s)
public static void appendHexJavaScriptRepresentation(java.lang.StringBuilder sb, char c)
sb
- The buffer to which the hex representation should be appended.c
- The character to be appended.public static java.lang.String javaScriptUnescape(java.lang.String s)
public static java.lang.String xmlContentEscape(java.lang.String s)
public static java.lang.String xmlSingleQuotedEscape(java.lang.String s)
public static java.lang.String xmlCDataEscape(java.lang.String s)
<[!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.
public static java.lang.String javaEscape(java.lang.String s)
public static java.lang.String javaEscapeWithinAttribute(java.lang.String s)
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.
public static java.lang.String xmlEscape(java.lang.String s)
public static java.lang.String htmlEscape(java.lang.String s)
xmlEscape
except that
htmlEscape
does not escape the apostrophe character).
public static java.lang.String regexEscape(java.lang.String s)
public static java.lang.String javaUtilRegexEscape(java.lang.String s)
public static java.lang.String regexReplacementEscape(java.lang.String s)
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);
public static java.lang.String cropBetween(java.lang.String in, char limit)
public static java.lang.String cropBetween(java.lang.String in, java.lang.String limit)
in
- - the string to processlimit
- - the limit of the string(s) to remove
public static java.util.LinkedList<java.lang.String> string2List(java.lang.String in, java.lang.String delimiter, boolean doStrip)
in
- - what to processdelimiter
- - the delimiting stringdoStrip
- - to strip the substrings before adding to the list
public static java.util.Set string2Set(java.lang.String in, java.lang.String delimiter, boolean doStrip)
in
- - what to processdelimiter
- - the delimiting stringdoStrip
- - to strip the substrings before adding to the list
public static java.util.Collection<java.lang.String> string2Collection(java.lang.String in, java.lang.String delimiter, boolean doStrip, java.util.Collection<java.lang.String> collection)
in
- The delimited input string to processdelimiter
- The string delimiting entries in the input string.doString
- Whether to strip the substrings before adding to the
collectioncollection
- The collection to which the strings will be added. If
null
, a new List
will be created.
@Deprecated public static java.lang.String list2String(java.util.Collection<?> in, java.lang.String separator)
Join
does not consider null elements to be
equivalent to the empty string, as this method does.
@Deprecated public static java.lang.String Collection2String(java.util.Collection<?> in, java.lang.String separator)
Join
does not consider null elements to be
equivalent to the empty string, as this method does.
in
- - the collection that has to be conatenatedseparator
- - a string to sepparate the elements from the list
@Deprecated public static java.lang.String Iterator2String(java.util.Iterator<?> it, java.lang.String separator)
Join
does not consider null elements to be
equivalent to the empty string, as this method does.
public static java.util.HashMap<java.lang.String,java.lang.String> string2Map(java.lang.String in, java.lang.String delimEntry, java.lang.String delimKey, boolean doStripEntry)
in
- - the string to be processeddelimEntry
- - delimiter for the entriesdelimKey
- - delimiter between keys and valuesdoStripEntry
- - strip entries before inserting in the map
public static <K,V> java.lang.String map2String(java.util.Map<K,V> in, java.lang.String sepKey, java.lang.String sepEntry)
in
- - the map to be convertedsepKey
- - the separator to put between key and valuesepEntry
- - the separator to put between map entries
public static <V> java.util.Map lowercaseKeys(java.util.Map<java.lang.String,V> map)
map
- A map containing String keys to be lowercased
java.lang.IllegalArgumentException
- if the map contains duplicate string keys
after lower casingpublic static java.lang.String collapseWhitespace(java.lang.String str)
str
- the string you want to munge
collapse
public static java.lang.String collapse(java.lang.String str, java.lang.String chars, java.lang.String replacement)
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 mungechars
- all of the characters to be considered for mungereplacement
- the replacement string
public static java.lang.String stream2String(java.io.InputStream is, int maxLength) throws java.io.IOException
is
- input streammaxLength
- max number of bytes to read from "is". If this is -1, we
read everything.
java.io.IOException
public static java.lang.String[] parseDelimitedList(java.lang.String list, char delimiter)
list
- String containing delimited substringsdelimiter
- Delimiter (anything except ' ' is allowed)
public static boolean isEmpty(java.lang.String s)
public static boolean isEmptyOrWhitespace(java.lang.String s)
public static java.lang.String makeSafe(java.lang.String s)
public static java.lang.String toNullIfEmpty(java.lang.String s)
public static java.lang.String toNullIfEmptyOrWhitespace(java.lang.String s)
public static java.lang.String arrayMap2String(java.util.Map<java.lang.String,java.lang.String[]> map, java.lang.String keyValueDelim, java.lang.String entryDelim)
map
- A map of String keys to arrays of String valueskeyValueDelim
- Delimiter between keys and valuesentryDelim
- Delimiter between entries
public static boolean equals(java.lang.String s1, java.lang.String s2)
public static java.lang.String lastToken(java.lang.String s, java.lang.String delimiter)
public static boolean allAscii(java.lang.String s)
public static boolean containsCharRef(java.lang.String s)
public static boolean isHebrew(java.lang.String s)
isHebrew(int)
is true for any of its characters.
public static boolean isHebrew(int codePoint)
public static boolean isCjk(java.lang.String s)
isCjk(char)
is true for any of its characters.
public static boolean isCjk(char ch)
isCjk(int)
.
public static boolean isCjk(int codePoint)
public static java.lang.String unicodeEscape(java.lang.String s)
public static int displayWidth(java.lang.String s)
displayWidth(char)
public static int displayWidth(char ch)
public static java.lang.String toString(float[] iArray)
public static java.lang.String toString(long[] iArray)
public static java.lang.String toString(int[] iArray)
public static java.lang.String toString(java.lang.String[] iArray)
public static java.lang.String toString(java.lang.String s)
s
- - the string
public static java.lang.String toString(int[][] iArray)
public static java.lang.String toString(long[][] iArray)
public static java.lang.String toString(java.lang.Object[] obj)
public static java.io.InputStream toUTF8InputStream(java.lang.String str)
public static void copyStreams(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
java.io.IOException
public static java.lang.String bytesToLatin1(byte[] ba)
public static java.lang.String bytesToHexString(byte[] bytes)
public static java.lang.String bytesToHexString(byte[] bytes, java.lang.Character delimiter)
public static byte[] latin1ToBytes(java.lang.String str)
public static java.lang.String bytesToUtf8(byte[] ba)
public static byte[] utf8ToBytes(java.lang.String str)
public static byte[] encodingToBytes(java.lang.String str, java.lang.String encoding)
encoding
- the encoding to use
public static java.util.List<java.lang.String> bytesToStringList(byte[] bytes)
bytes
- the array to convert
public static java.lang.String toUpperCase(java.lang.String src)
public static java.lang.String expandShardNames(java.lang.String dbSpecComponent) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
dbSpecComponent
- a single component of a DBDescriptor spec
(e.g. the host or database component). The expected format of the string is:
java.lang.IllegalArgumentException
- if the string does not parse.
java.lang.IllegalStateException
public static java.lang.String repeat(java.lang.String sourceString, int factor)
sourceString
- The string to repeatfactor
- The number of times to repeat it.public static java.lang.String capitalize(java.lang.String s)
String.toUpperCase(java.util.Locale)
.
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
java.lang.NullPointerException
- if s is null
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |