|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.lang3.StringUtils
com.silverpeas.util.StringUtil
public class StringUtil
Field Summary | |
---|---|
static String |
newline
|
Fields inherited from class org.apache.commons.lang3.StringUtils |
---|
EMPTY, INDEX_NOT_FOUND |
Method Summary | |
---|---|
static boolean |
areStringEquals(String s1,
String s2)
Indicates if two Strings are equals, managing null. |
static String |
asBase64(byte[] binaryData)
Encodes the specified binary data into a text of Base64 characters. |
static String |
asHex(byte[] binaryData)
Encodes the specified binary data into a String representing the hexadecimal values of each byte in order. |
static float |
convertFloat(String value)
|
static String |
convertToEncoding(String toConvert,
String encoding)
|
static String |
defaultStringIfNotDefined(String string)
Returns either the passed in String, or if the String is not defined , an empty String (""). |
static String |
defaultStringIfNotDefined(String string,
String defaultString)
Returns either the passed in String, or if the String is not defined , the value of defaultString . |
static String |
detectEncoding(byte[] data,
String declaredEncoding)
Method for trying to detect encoding |
static Set<String> |
detectMaybeEncoding(byte[] data,
String declaredEncoding)
Method for trying to detect encoding |
static String |
detectStringEncoding(byte[] data,
String declaredEncoding)
Method for trying to detect encoding |
static String |
escapeQuote(String text)
|
static float |
floatValue(String value)
Parse a String into a float using the default locale. |
static float |
floatValue(String value,
String language)
Parse a String into a float using the specified locale. |
static String |
format(String label,
Map<String,?> values)
Format a string by extending the principle of the the method format() of the class java.text.MessageFormat to string arguments. |
static byte[] |
fromBase64(String base64Text)
Decodes the specified text with Base64 characters in binary. |
static byte[] |
fromHex(String hexText)
Decodes the specified text with hexadecimal values in bytes of those same values. |
static boolean |
getBooleanValue(String expression)
Evaluate the expression and return true if expression equals "true", "yes", "y", "1" or "oui". |
static boolean |
isDefined(String parameter)
|
static boolean |
isFloat(String id)
|
static boolean |
isInteger(String id)
|
static boolean |
isLong(String id)
|
static boolean |
isNotDefined(String parameter)
|
static boolean |
isValidEmailAddress(String aEmailAddress)
Validate the form of an email address. |
static boolean |
isValidHour(String time)
|
static String |
regexReplace(String source,
String regex,
String replacement)
Replace parts of a text by an one replacement string. |
static Iterable<String> |
splitString(String str)
Splits the provided text into an array, using whitespace as the separator. |
static Iterable<String> |
splitString(String str,
char separatorChar)
Splits the provided text into an array, separator specified. |
static String |
toAcceptableFilename(String name)
Replaces |
static String |
truncate(String text,
int maxLength)
|
Methods inherited from class org.apache.commons.lang3.StringUtils |
---|
abbreviate, abbreviate, abbreviateMiddle, capitalize, center, center, center, chomp, chomp, chop, contains, contains, containsAny, containsAny, containsIgnoreCase, containsNone, containsNone, containsOnly, containsOnly, containsWhitespace, countMatches, defaultIfBlank, defaultIfEmpty, defaultString, defaultString, deleteWhitespace, difference, endsWith, endsWithAny, endsWithIgnoreCase, equals, equalsIgnoreCase, getCommonPrefix, getLevenshteinDistance, getLevenshteinDistance, indexOf, indexOf, indexOf, indexOf, indexOfAny, indexOfAny, indexOfAny, indexOfAnyBut, indexOfAnyBut, indexOfDifference, indexOfDifference, indexOfIgnoreCase, indexOfIgnoreCase, isAllLowerCase, isAllUpperCase, isAlpha, isAlphanumeric, isAlphanumericSpace, isAlphaSpace, isAsciiPrintable, isBlank, isEmpty, isNotBlank, isNotEmpty, isNumeric, isNumericSpace, isWhitespace, join, join, join, join, join, join, join, join, join, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOfAny, lastIndexOfIgnoreCase, lastIndexOfIgnoreCase, lastOrdinalIndexOf, left, leftPad, leftPad, leftPad, length, lowerCase, lowerCase, mid, normalizeSpace, ordinalIndexOf, overlay, remove, remove, removeEnd, removeEndIgnoreCase, removeStart, removeStartIgnoreCase, repeat, repeat, repeat, replace, replace, replaceChars, replaceChars, replaceEach, replaceEachRepeatedly, replaceOnce, reverse, reverseDelimited, right, rightPad, rightPad, rightPad, split, split, split, split, splitByCharacterType, splitByCharacterTypeCamelCase, splitByWholeSeparator, splitByWholeSeparator, splitByWholeSeparatorPreserveAllTokens, splitByWholeSeparatorPreserveAllTokens, splitPreserveAllTokens, splitPreserveAllTokens, splitPreserveAllTokens, splitPreserveAllTokens, startsWith, startsWithAny, startsWithIgnoreCase, strip, strip, stripAccents, stripAll, stripAll, stripEnd, stripStart, stripToEmpty, stripToNull, substring, substring, substringAfter, substringAfterLast, substringBefore, substringBeforeLast, substringBetween, substringBetween, substringsBetween, swapCase, toString, trim, trimToEmpty, trimToNull, uncapitalize, upperCase, upperCase |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static String newline
Method Detail |
---|
public static boolean isDefined(String parameter)
public static boolean isNotDefined(String parameter)
public static String defaultStringIfNotDefined(String string)
Returns either the passed in String, or if the String is
not defined
, an empty String ("").
StringUtil.defaultStringIfNotDefined(null) = "" StringUtil.defaultStringIfNotDefined("") = "" StringUtil.defaultStringIfNotDefined(" ") = "" StringUtil.defaultStringIfNotDefined("bat") = "bat"
string
- the String to check, may be null, blank or filled by spaces
if the input is not defined
, may be null, blank or filled by spaces
null
isNotDefined(String)
,
StringUtils.defaultString(String, String)
public static String defaultStringIfNotDefined(String string, String defaultString)
Returns either the passed in String, or if the String is
not defined
, the value of defaultString
.
StringUtil.defaultStringIfNotDefined(null, "NULL") = "NULL" StringUtil.defaultStringIfNotDefined("", "NULL") = "NULL" StringUtil.defaultStringIfNotDefined(" ", "NULL") = "NULL" StringUtil.defaultStringIfNotDefined("bat", "NULL") = "bat"
string
- the String to check, may be null, blank or filled by spacesdefaultString
- the default String to return
if the input is not defined
, may be null, blank or filled by spaces
null
isNotDefined(String)
,
StringUtils.defaultString(String, String)
public static boolean isInteger(String id)
public static boolean isLong(String id)
public static float convertFloat(String value)
public static boolean isFloat(String id)
public static String escapeQuote(String text)
text
-
public static String toAcceptableFilename(String name)
name
-
public static String format(String label, Map<String,?> values)
label
- The string to formatvalues
- The values to insert into the string
public static String truncate(String text, int maxLength)
text
- The string to truncate if its size is greater than the maximum length given as
parameter.maxLength
- The maximum length required.
public static String regexReplace(String source, String regex, String replacement)
source
- the original textregex
- the regex that permits to identify parts of text to replacereplacement
- the replacement text
public static boolean isValidEmailAddress(String aEmailAddress)
Return true only if
InternetAddress
aEmailAddress
- the address to be validated
public static boolean isValidHour(String time)
public static String convertToEncoding(String toConvert, String encoding)
public static boolean getBooleanValue(String expression)
expression
- the expression to be evaluated
public static String detectEncoding(byte[] data, String declaredEncoding)
data
- some data to try to detect the encoding.declaredEncoding
- expected encoding.
public static String detectStringEncoding(byte[] data, String declaredEncoding) throws UnsupportedEncodingException
data
- some data to try to detect the encoding.declaredEncoding
- expected encoding.
UnsupportedEncodingException
public static Set<String> detectMaybeEncoding(byte[] data, String declaredEncoding)
data
- some data to try to detect the encoding.declaredEncoding
- expected encoding.
public static boolean areStringEquals(String s1, String s2)
s1
- the first String.s2
- the second String.
public static float floatValue(String value) throws ParseException
value
- the string to be parsed into a float.
ParseException
public static float floatValue(String value, String language) throws ParseException
value
- the string to be parsed into a floatlanguage
- the language for defining the locale
ParseException
public static String asBase64(byte[] binaryData)
binaryData
- the binary data to convert in Base64-based String.
public static byte[] fromBase64(String base64Text)
base64Text
- the text in Base64.
public static String asHex(byte[] binaryData)
binaryData
- the binary data to concert in hexadecimal-based String.
public static byte[] fromHex(String hexText) throws ParseException
hexText
- the text with hexadecimal-based characters.
ParseException
- if an odd number or illegal of characters is supplied.public static Iterable<String> splitString(String str)
Splits the provided text into an array, using whitespace as the separator. Whitespace is
defined by Character.isWhitespace(char)
.
The separator is not included in the returned String array. Adjacent separators are treated as one separator. For more control over the split use the StrTokenizer class.
A null
input String returns null
.
StringUtils.split(null) = null StringUtils.split("") = empty list StringUtils.split("abc def") = ["abc", "def"] StringUtils.split("abc def") = ["abc", "def"] StringUtils.split(" abc ") = ["abc"]
str
- the String to parse, may be null
null
if null String inputpublic static Iterable<String> splitString(String str, char separatorChar)
Splits the provided text into an array, separator specified. This is an alternative to using StringTokenizer.
The separator is not included in the returned String array. Adjacent separators are treated as one separator. For more control over the split use the StrTokenizer class.
A null
input String returns null
.
StringUtils.split(null, *) = null StringUtils.split("", *) = empty list StringUtils.split("a.b.c", '.') = ["a", "b", "c"] StringUtils.split("a..b.c", '.') = ["a", "b", "c"] StringUtils.split("a:b:c", '.') = ["a:b:c"] StringUtils.split("a b c", ' ') = ["a", "b", "c"]
str
- the String to parse, may be nullseparatorChar
- the character used as the delimiter
null
if null String input
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |