|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.varienaja.util.StringUtil
public final class StringUtil
Miscellaneous string utility methods. Copied from Subsonic.
Field Summary | |
---|---|
static java.lang.String |
ENCODING_LATIN
|
static java.lang.String |
ENCODING_UTF8
|
Method Summary | |
---|---|
static java.lang.String |
capitalize(java.lang.String word)
Changes the first letter into a capital. |
static boolean |
contains(java.util.List<java.lang.String> items,
java.lang.String query)
Scans (case insensitive) if a String is present in the List of Strings. |
static java.lang.String |
formatBytes(long byteCount)
Converts a byte-count to a formatted string suitable for display to the user. |
static java.util.List<java.lang.String> |
getIndividualWords(java.lang.String words)
Parses the String of comma separated words and returns a list of the word strings. |
static java.lang.String |
getMimeType(java.lang.String suffix)
Returns the proper MIME type for the given suffix. |
static java.lang.String |
getSuffix(java.lang.String s)
Returns the suffix (the substring after the last dot) of the given string. |
static boolean |
isEqual(java.lang.Object a,
java.lang.Object b)
Determines whether a is equal to b, taking null into account. |
static java.util.Locale |
parseLocale(java.lang.String s)
Parses a locale from the given string. |
static java.lang.String[] |
readLines(java.io.InputStream in)
Reads lines from the given input stream. |
static java.lang.String |
removeSuffix(java.lang.String s)
Removes the suffix (the substring after the last dot) of the given string. |
static java.lang.String[] |
split(java.lang.String input)
Splits the input string. |
static java.lang.String |
toHtml(java.lang.String s)
Returns the specified string converted to a format suitable for HTML. |
static java.lang.String |
toHttpUrl(java.lang.String url,
int port)
Change protocol from "https" to "http" for the given URL. |
static java.lang.String |
utf8HexDecode(java.lang.String s)
Decodes the given string by using the hexadecimal representation of its UTF-8 bytes. |
static java.lang.String |
utf8HexEncode(java.lang.String s)
Encodes the given string by using the hexadecimal representation of its UTF-8 bytes. |
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 ENCODING_LATIN
public static final java.lang.String ENCODING_UTF8
Method Detail |
---|
public static java.lang.String toHtml(java.lang.String s)
s
- the string to convert
public static java.lang.String getSuffix(java.lang.String s)
s
- The string in question.
public static java.lang.String removeSuffix(java.lang.String s)
s
- The string in question, e.g., "foo.mp3".
public static java.lang.String getMimeType(java.lang.String suffix)
suffix
- The suffix, e.g., "mp3" or ".mp3".
application/octet-stream
is returned.public static java.lang.String formatBytes(long byteCount)
format(918)
returns "918 B".format(98765)
returns "96 KB".format(1238476)
returns "1.2 MB".
byteCount
- The number of bytes.
public static java.lang.String[] split(java.lang.String input)
"u2 rem "greatest hits""
will return an array with
three elements: {"u2", "rem", "greatest hits"}
input
- The input string.
public static java.lang.String[] readLines(java.io.InputStream in) throws java.io.IOException
in
- The input stream to read from.
java.io.IOException
- If an I/O error occurs.public static java.lang.String toHttpUrl(java.lang.String url, int port) throws java.net.MalformedURLException
url
- The original URL.port
- The port number to use, for instance 443.
java.net.MalformedURLException
- If the original URL is invalid.public static boolean isEqual(java.lang.Object a, java.lang.Object b)
public static java.util.Locale parseLocale(java.lang.String s)
s
- The locale string. Should be formatted as per the documentation in Locale.toString()
.
public static java.lang.String utf8HexEncode(java.lang.String s) throws java.lang.Exception
s
- The string to encode.
java.lang.Exception
- If an error occurs.public static java.lang.String utf8HexDecode(java.lang.String s) throws java.lang.Exception
s
- The string to decode.
java.lang.Exception
- If an error occurs.public static java.util.List<java.lang.String> getIndividualWords(java.lang.String words)
words
- The string of comma separated words.
public static java.lang.String capitalize(java.lang.String word)
word
- The word to capitalize.
public static boolean contains(java.util.List<java.lang.String> items, java.lang.String query)
items
- The itemsquery
- The query
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |