|
Brooklyn | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbrooklyn.util.text.Strings
public class Strings
Field Summary | |
---|---|
static CharMatcher |
IS_JAVA_IDENTIFIER_PART
A CharMatcher that matches valid Java identifier characters. |
static java.lang.String |
VALID_NON_ALPHANUM_FILE_CHARS
Valid non alphanumeric characters for filenames. |
Method Summary | |
---|---|
static void
|
checkNonEmpty(java.lang.CharSequence s)
throws IllegalArgument if string not empty; cf. guava Preconditions.checkXxxx |
static void
|
checkNonEmpty(java.lang.CharSequence s, java.lang.String message)
throws IllegalArgument if string not empty; cf. guava Preconditions.checkXxxx |
static java.lang.String[]
|
combineArrays(java.lang.String[]... arrays)
|
static boolean
|
containsLiteral(java.lang.CharSequence input, java.lang.CharSequence fragment)
|
static boolean
|
containsLiteralIgnoreCase(java.lang.CharSequence input, java.lang.CharSequence fragment)
|
static java.lang.String
|
getLastWord(java.lang.String s)
|
static boolean
|
isBlank(java.lang.CharSequence s)
Checks if the given string is empty or only consists of whitespace. |
static boolean
|
isEmpty(java.lang.CharSequence s)
Checks if the given string is null or is an empty string. |
static boolean
|
isLowerCase(java.lang.String s)
|
static boolean
|
isNonBlank(java.lang.CharSequence s)
The inverse of isBlank(CharSequence). |
static boolean
|
isNonEmpty(java.lang.CharSequence s)
The inverse of isEmpty(CharSequence). |
static java.lang.String
|
join(java.lang.Iterable list, java.lang.String seperator)
@deprecated use com.google.common.base.Joiner |
static java.lang.String
|
join(java.lang.Object[] list, java.lang.String seperator)
@deprecated use com.google.common.base.Joiner |
static java.lang.String[]
|
makeArray(java.lang.String prefix, int count)
returns e.g. { "prefix01", ..., "prefix96" }; see more functional NumericRangeGlobExpander for "prefix{01-96}" |
static java.lang.String
|
makePaddedString(java.lang.String base, int len, java.lang.String left_pad, java.lang.String right_pad)
pads the string with "pad" at the left up to len; no padding if base longer than len |
static java.lang.String
|
makeRandomId(int l)
@see Identifiers#makeRandomId(int)#makeRandomId(int) |
static java.lang.String
|
makeRealString(double x, int maxlen, int prec, int leftPadLen)
creates a string from a real number, with specified accuracy (more iff it comes for free, ie integer-part); switches to E notation if needed to fit within maxlen; can be padded left up too (not useful) |
static java.lang.String
|
makeRealString(double x, int maxlen, int prec, int leftPadLen, double skipDecimalThreshhold, boolean useEForSmallNumbers)
creates a string from a real number, with specified accuracy (more iff it comes for free, ie integer-part); switches to E notation if needed to fit within maxlen; can be padded left up too (not useful) |
static java.lang.String
|
makeRealStringNearZero(double x, int maxlen, int prec, int leftPadLen)
creates a string from a real number, with specified accuracy (more iff it comes for free, ie integer-part); switches to E notation if needed to fit within maxlen; can be padded left up too (not useful) |
static java.lang.String
|
makeRepeated(char c, int length)
|
static java.lang.String
|
makeSizeString(long sizeInBytes)
returns a size string using defaults from ByteSizeStrings, e.g. 23.5mb |
static java.lang.String
|
makeTimeString(long utcMillis)
|
static java.lang.String
|
makeValidFilename(java.lang.String s)
Returns a valid filename based on the input. |
static java.lang.String
|
makeValidJavaName(java.lang.String s)
Returns a valid Java identifier name based on the input. |
static java.lang.String
|
makeValidUniqueJavaName(java.lang.String s)
Returns a unique valid java identifier name based on the input. |
static java.lang.String
|
makeZeroPaddedString(int i, int len)
pads the string with 0's at the left up to len; no padding if i longer than len |
static java.lang.String
|
maxlen(java.lang.String s, int maxlen)
returns up to maxlen characters from the start of s |
static java.lang.String
|
removeAllFromEnd(java.lang.String string, java.lang.String... suffixes)
as removeFromEnd, but repeats until all such suffixes are gone |
static java.lang.String
|
removeAllFromStart(java.lang.String string, java.lang.String... prefixes)
as removeFromStart, but repeats until all such suffixes are gone |
static java.lang.String
|
removeFromEnd(java.lang.String string, java.lang.String... suffixes)
removes the first suffix in the list which is present at the end of string and returns that string; ignores subsequent suffixes if a matching one is found; returns the original string if no suffixes are at the end |
static java.lang.String
|
removeFromStart(java.lang.String string, java.lang.String... prefixes)
removes the first prefix in the list which is present at the start of string and returns that string; ignores subsequent prefixes if a matching one is found; returns the original string if no prefixes match |
static java.lang.String
|
replaceAll(java.lang.String source, java.util.Map replacements)
replaces all key->value entries from the replacement map in source (non-regex) |
static java.lang.String
|
replaceAll(java.lang.String source, java.lang.String pattern, java.lang.String replacement)
NON-REGEX replaceAll - replaces all instances in source, of the given pattern, with the given replacement (not interpreting any arguments as regular expressions) |
static java.lang.String
|
replaceAllNonRegex(java.lang.String source, java.lang.String pattern, java.lang.String replacement)
NON-REGEX replacement -- explicit method name for reabaility, doing same as Strings.replaceAll |
static java.lang.String
|
replaceAllRegex(java.lang.String source, java.lang.String pattern, java.lang.String replacement)
REGEX replacement -- explicit method name for reabaility, doing same as String.replaceAll |
static java.lang.String
|
reverse(java.lang.String name)
|
static StringShortener
|
shortener()
returns a configurable shortener |
static java.lang.String
|
toInitialCapOnly(java.lang.String value)
|
static java.lang.String
|
toString(java.lang.Object o)
returns toString of the object if it is not null, otherwise null |
static void
|
trimAll(java.lang.String[] s)
|
static java.lang.String
|
trimEnd(java.lang.String s)
|
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Field Detail |
---|
public static final CharMatcher IS_JAVA_IDENTIFIER_PART
public static final java.lang.String VALID_NON_ALPHANUM_FILE_CHARS
Method Detail |
---|
public static void checkNonEmpty(java.lang.CharSequence s)
public static void checkNonEmpty(java.lang.CharSequence s, java.lang.String message)
public static java.lang.String[] combineArrays(java.lang.String[]... arrays)
public static boolean containsLiteral(java.lang.CharSequence input, java.lang.CharSequence fragment)
public static boolean containsLiteralIgnoreCase(java.lang.CharSequence input, java.lang.CharSequence fragment)
public static java.lang.String getLastWord(java.lang.String s)
public static boolean isBlank(java.lang.CharSequence s)
s
- the String to check
public static boolean isEmpty(java.lang.CharSequence s)
s
- the String to check
public static boolean isLowerCase(java.lang.String s)
public static boolean isNonBlank(java.lang.CharSequence s)
s
- the String to check
public static boolean isNonEmpty(java.lang.CharSequence s)
s
- the String to check
ated public public static java.lang.String join(java.lang.Iterable list, java.lang.String seperator)
ated public public static java.lang.String join(java.lang.Object[] list, java.lang.String seperator)
public static java.lang.String[] makeArray(java.lang.String prefix, int count)
public static java.lang.String makePaddedString(java.lang.String base, int len, java.lang.String left_pad, java.lang.String right_pad)
public static java.lang.String makeRandomId(int l)
public static java.lang.String makeRealString(double x, int maxlen, int prec, int leftPadLen)
x
- number to usemaxlen
- maximum length for the numeric string, if possible (-1 to suppress)prec
- number of digits accuracy desired (more kept for integers)leftPadLen
- will add spaces at left if necessary to make string this long (-1 to suppress) [probably not usef]
public static java.lang.String makeRealString(double x, int maxlen, int prec, int leftPadLen, double skipDecimalThreshhold, boolean useEForSmallNumbers)
x
- number to usemaxlen
- maximum length for the numeric string, if possible (-1 to suppress)prec
- number of digits accuracy desired (more kept for integers)leftPadLen
- will add spaces at left if necessary to make string this long (-1 to suppress) [probably not usef]skipDecimalThreshhold
- if positive it will not add a decimal part if the fractional part is less than this threshhold
(but for a value 3.00001 it would show zeroes, e.g. with 3 precision and positive threshhold <= 0.00001 it would show 3.00);
if zero or negative then decimal digits are always shownuseEForSmallNumbers
- whether to use E notation for numbers near zero
public static java.lang.String makeRealStringNearZero(double x, int maxlen, int prec, int leftPadLen)
x
- number to usemaxlen
- maximum length for the numeric string, if possible (-1 to suppress)prec
- number of digits accuracy desired (more kept for integers)leftPadLen
- will add spaces at left if necessary to make string this long (-1 to suppress) [probably not usef]
public static java.lang.String makeRepeated(char c, int length)
public static java.lang.String makeSizeString(long sizeInBytes)
public static java.lang.String makeTimeString(long utcMillis)
public static java.lang.String makeValidFilename(java.lang.String s)
public static java.lang.String makeValidJavaName(java.lang.String s)
The result is usually unique to s, though this isn't guaranteed, for example if all characters are invalid. For a unique identifier use makeValidUniqueJavaName(String).
public static java.lang.String makeValidUniqueJavaName(java.lang.String s)
public static java.lang.String makeZeroPaddedString(int i, int len)
public static java.lang.String maxlen(java.lang.String s, int maxlen)
public static java.lang.String removeAllFromEnd(java.lang.String string, java.lang.String... suffixes)
public static java.lang.String removeAllFromStart(java.lang.String string, java.lang.String... prefixes)
public static java.lang.String removeFromEnd(java.lang.String string, java.lang.String... suffixes)
public static java.lang.String removeFromStart(java.lang.String string, java.lang.String... prefixes)
@SuppressWarnings("rawtypes") public static java.lang.String replaceAll(java.lang.String source, java.util.Map replacements)
public static java.lang.String replaceAll(java.lang.String source, java.lang.String pattern, java.lang.String replacement)
public static java.lang.String replaceAllNonRegex(java.lang.String source, java.lang.String pattern, java.lang.String replacement)
public static java.lang.String replaceAllRegex(java.lang.String source, java.lang.String pattern, java.lang.String replacement)
public static java.lang.String reverse(java.lang.String name)
public static StringShortener shortener()
public static java.lang.String toInitialCapOnly(java.lang.String value)
public static java.lang.String toString(java.lang.Object o)
public static void trimAll(java.lang.String[] s)
public static java.lang.String trimEnd(java.lang.String s)
Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.