public class ERXStringUtilities
extends java.lang.Object
String utilities. Contains
the base localization support.| Modifier and Type | Field and Description |
|---|---|
protected static double |
adjustement
holds the base adjustment for fuzzy matching
|
static char[] |
HEX_CHARS
Holds the chars for hex encoding
|
static NSDictionary<java.lang.String,java.lang.String> |
HTML_SAFE_UNESCAPES
Safe HTML entities to unescape (SYMBOL+ISO).
|
static NSDictionary<java.lang.String,java.lang.String> |
HTML_UNESCAPES
HTML entities to unescape (XML+SYMBOL+ISO).
|
static NSDictionary<java.lang.String,java.lang.String> |
ISO_UNESCAPES
ISO entities to unescape.
|
static NSArray |
SORT_ASCENDING
Holds the ascending
EOSortOrderings |
static NSArray |
SORT_DESCENDING
Holds the ascending
EOSortOrderings |
static java.lang.String |
SpecialRegexCharacters
Holds characters that have special meaning for regex
|
static NSDictionary<java.lang.String,java.lang.String> |
SYMBOL_UNESCAPES
Symbol entities to unescape.
|
static NSDictionary<java.lang.String,java.lang.String> |
XML_UNESCAPES
XML entities to unescape.
|
| Constructor and Description |
|---|
ERXStringUtilities() |
| Modifier and Type | Method and Description |
|---|---|
static void |
appendSeparatorIfLastNot(char separator,
char not,
java.lang.StringBuffer sb)
Utility method to append a character to a
StringBuffer if the last character is not
a certain character.
|
static void |
appendSeparatorIfLastNot(char separator,
char not,
java.lang.StringBuilder sb)
Utility method to append a character to a
StringBuilder if the last character is not
a certain character.
|
static java.lang.Object |
attributeCustomValueFromString(EOAttribute attr,
java.lang.String strVal,
java.lang.String encoding)
Attempts to convert string values for attributes into the appropriate
value class for the attribute.
|
static java.lang.Number |
attributeNumberValueFromString(EOAttribute attr,
java.lang.String strVal)
Attempts to convert string values for attributes into the appropriate
value class for the attribute.
|
static java.lang.Object |
attributeValueFromString(EOAttribute attr,
java.lang.String strVal,
java.lang.String encoding,
java.text.Format formatter)
Attempts to convert string values for attributes into the appropriate
value class for the attribute.
|
static java.lang.String |
byteArrayToHexString(byte[] block)
Converts a byte array to hex string.
|
static java.lang.String |
camelCaseToUnderscore(java.lang.String camelString,
boolean lowercase)
Converts a string in camel case to an underscore representation.
|
static java.lang.String |
capitalize(java.lang.String value)
Capitalizes a given string.
|
static java.lang.String |
capitalizeAllWords(java.lang.String value)
Capitalizes all the strings in a given string.
|
static boolean |
caseInsensitiveStartsWith(java.lang.String stringToSearch,
java.lang.String prefix)
Tests if the string starts with the specified prefix ignoring case.
|
static boolean |
caseInsensitiveStartsWith(java.lang.String stringToSearch,
java.lang.String prefix,
int toffset)
Tests if the string starts with the specified prefix starting at the specified index ignoring case.
|
static java.lang.String |
cleanString(java.lang.String newString,
NSArray<java.lang.String> toBeCleaneds)
Given an initial string and an array of substrings,
Removes any occurrences of any of the substrings
from the initial string.
|
static boolean |
containsAnyCharacter(java.lang.String source,
java.lang.String characters)
Checks if any of the characters specified in characters is contained in the string
specified by source.
|
static java.lang.String |
displayNameForKey(java.lang.String key)
Calculates a default display name for a given
key path.
|
static double |
distance(java.lang.String a,
java.lang.String b)
Deprecated.
Use
levenshteinDistance(String, String), which
correctly returns an int result |
static java.lang.String |
dumpObject(java.lang.Object object)
Creates a readable debug string for some data types (dicts, arrays, adaptorOperations, databaseOperations).
|
static java.lang.String |
emptyStringForNull(java.lang.String s)
Simple utility method that will return the
string "" if the string passed in is null
otherwise it will return the passed in
string.
|
static java.lang.String |
escape(char[] _escapeChars,
char _escapeWith,
java.lang.String _sourceString)
Escapes the given characters with the given escape character in _sourceString.
|
static java.lang.String |
escapeJavascriptApostrophes(java.lang.String sourceString)
Escapes the apostrophes in a Javascript string with a backslash.
|
static java.lang.String |
escapeNonBasicLatinChars(char c) |
static java.lang.String |
escapeNonBasicLatinChars(java.lang.String str) |
static java.lang.String |
escapeNonXMLChars(java.lang.String str) |
static java.lang.String |
escapePCData(java.lang.String pcdata)
Escapes the given PCDATA string as CDATA.
|
static java.lang.String |
escapeSpace(java.lang.String aString)
Deprecated.
use
removeSpaces(String) instead |
static java.lang.String |
excelSafeCsvString(java.lang.String s)
Removes line breaks and quotes the string if necessary
|
static java.lang.String |
firstPropertyKeyInKeyPath(java.lang.String keyPath) |
static java.lang.String |
fromBytes(byte[] bytes,
java.lang.String encoding)
Utility to convert from bytes without the try/catch.
|
static java.lang.String |
fromUTF8Bytes(byte[] bytes)
Utility to convert from UTF-8 bytes without the try/catch.
|
static NSArray |
fuzzyMatch(java.lang.String name,
java.lang.String entityName,
java.lang.String propertyKey,
java.lang.String synonymsKey,
EOEditingContext ec,
ERXFuzzyMatchCleaner cleaner,
NSArray sortOrderings)
Fuzzy matching is useful for catching user entered typos.
|
static NSArray |
fuzzyMatch(java.lang.String name,
java.lang.String entityName,
java.lang.String propertyKey,
java.lang.String synonymsKey,
EOEditingContext ec,
ERXFuzzyMatchCleaner cleaner,
java.lang.String comparisonString)
|
static java.lang.String |
getSimpleClassName(java.lang.Class clazz)
"Borrowed" from 1.5's Class.getSimpleClassName
|
static byte[] |
hexStringToByteArray(java.lang.String hexString)
Converts a even-length, hex-encoded String to a byte array.
|
static void |
indent(java.io.PrintWriter writer,
int level) |
static void |
indent(java.lang.StringBuffer sb,
int level) |
static int |
indexOfNumericInString(java.lang.String str)
Locate the the first numeric character in the given string.
|
static int |
indexOfNumericInString(java.lang.String str,
int fromIndex)
Locate the the first numeric character
after
fromIndex in the given string. |
static java.lang.String |
insertString(java.lang.String destinationString,
java.lang.String contentToInsert,
int insertOffset)
Inserts the a string into another string at a particular offset.
|
static java.lang.Integer |
integerWithString(java.lang.String s)
Calculates an Integer for a given string.
|
static boolean |
isBlank(java.lang.String value) |
static boolean |
isDigitsOnly(java.lang.String aString)
Deprecated.
use
StringUtils#isNumeric(String) instead |
static boolean |
isLettersOnly(java.lang.String aString)
Deprecated.
use
StringUtils#isAlpha(String) instead |
static boolean |
isNotBlank(java.lang.String value) |
static boolean |
isValueInRange(int value,
java.lang.String rangeString)
Returns whether the given value falls in a range defined by the given string, which is
in the format "1-5,100,500,800-1000".
|
static java.lang.String |
keyPathWithoutFirstProperty(java.lang.String keyPath) |
static java.lang.String |
keyPathWithoutLastProperty(java.lang.String keyPath) |
static java.lang.String |
lastPropertyKeyInKeyPath(java.lang.String keyPath) |
static java.lang.String |
leftPad(java.lang.String string,
char padChar,
int paddedLength)
Pads a string to the specified number of chars by adding the the given pad char on the left side.
|
static int |
levenshteinDistance(java.lang.String a,
java.lang.String b)
Deprecated.
use
StringUtils#getLevenshteinDistance(String, String) instead |
static java.lang.String |
localizedStringForKey(java.lang.String key)
Gets a localized string for a given key in the application's
Localizable strings file for the default language (English).
|
static java.lang.String |
localizedStringForKey(java.lang.String key,
java.lang.String framework)
Gets a localized string for a given key in a given framework's
Localizable strings file for the default language (English).
|
static java.lang.String |
localizedStringForKey(java.lang.String key,
java.lang.String framework,
NSArray languages)
Gets a localized string for a given key in a given framework's
Localizable strings file using the array of languages as the
search order for the key.
|
static java.lang.String |
localizedTemplateStringWithObjectForKey(java.lang.Object o,
java.lang.String key,
java.lang.String framework,
NSArray languages)
Uses the method
localizedStringForKey to retreive
a template that is then parsed using the passed in object to
produce a resulting string. |
static boolean |
luhnCheck(java.lang.String value)
A fast Luhn algorithm check.
|
static java.lang.String |
maskStringWithCharacter(java.lang.String arg,
char mask,
int beginIndex,
int endIndex)
Masks a given string with a single character in the substring specified by the
begin and end indexes.
|
static java.lang.String |
matchCase(java.lang.String originalString,
java.lang.String newString)
Returns a string case-matched against the original string.
|
static byte[] |
md5(java.lang.String str,
java.lang.String encoding)
Generate an MD5 hash from a String.
|
static java.lang.String |
md5Hex(java.lang.String str,
java.lang.String encoding)
Generate an MD5 hash as hex from a String.
|
static java.lang.String |
nullForEmptyString(java.lang.String s)
Simple utility method that will return null
if the string passed in is equal to ""
otherwise it will return the passed in
string.
|
static int |
numberOfOccurrencesOfCharInString(char c,
java.lang.String s)
Counts the number of occurrences of a particular
char in a given string. |
static boolean |
quicksilverContains(java.lang.String _str,
java.lang.String _searchString)
Matches strings like Quicksilver (NullPointerException is matched by "NPE").
|
static java.lang.String |
quote(java.lang.String s,
java.lang.String quoteSymbol)
Quote the given string with the provided quote symbols
|
static boolean |
regionMatches(java.lang.StringBuffer str,
int toffset,
java.lang.String other,
int ooffset,
int len)
It's ridiculous that StringBuffer doesn't have a .regionMatches like String.
|
static java.lang.String |
removeCharacters(java.lang.String source,
java.lang.String characters)
Removes any character which is in characters from the source string.
|
static java.lang.String |
removeExceptCharacters(java.lang.String source,
java.lang.String characters)
Removes any character which is not in characters from the source string.
|
static java.lang.String |
removeExtraDotsFromVersionString(java.lang.String version)
Cleans up the given version string by removing extra
dots(.), for example, 5.1.3 becomes 5.13, so that
the string can be converted to a double or BigDecimal
type easily.
|
static java.lang.String |
removeHTMLTagsFromString(java.lang.String s)
Removes all of the HTML tags from a given string.
|
static java.lang.String |
removeSpaces(java.lang.String aString)
Removes the spaces in a given string.
|
static java.lang.String |
replaceStringByStringInString(java.lang.String old,
java.lang.String newString,
java.lang.String buffer)
Deprecated.
use
StringUtils#replace(String, String, String) instead |
static java.lang.String |
rightPad(java.lang.String string,
char padChar,
int paddedLength)
Pads a string to the specified number of chars by adding the the given pad char on the right side.
|
static java.lang.String |
safeIdentifierName(java.lang.String source)
Convenience method to call safeIdentifierName(source, "_", '_')
|
static java.lang.String |
safeIdentifierName(java.lang.String source,
java.lang.String prefix)
Convenience method to call safeIdentifierName(source, prefix, '_')
|
static java.lang.String |
safeIdentifierName(java.lang.String source,
java.lang.String prefix,
char replacement)
Converts source to be suitable for use as an identifier in JavaScript.
|
static java.lang.Integer |
safeInteger(java.lang.String s)
Wrapper for
Integer.valueOf(String) that catches
the NumberFormatException. |
static java.lang.Long |
safeLong(java.lang.String s)
Wrapper for
Long.valueOf(String) that catches
the NumberFormatException. |
static void |
setAdjustement(double newAdjustement)
Sets the base adjustment used for fuzzy matching
|
static java.lang.String |
stringByAppendingCSSClass(java.lang.String originalString,
java.lang.String cssClass)
Appends a CSS class to an existing (possibly null) CSS class string.
|
static java.lang.String |
stringByReplacingFirstOccurrenceOfStringWithString(java.lang.String sourceString,
java.lang.String stringToReplace,
java.lang.String replacementString)
Deprecated.
use
StringUtils#replaceOnce(String, String, String) instead |
static java.lang.String |
stringByTruncatingStringToByteLengthInEncoding(java.lang.String inputString,
int byteLength,
java.lang.String encoding)
This method takes a string and returns a string which is the first string such that the
result byte length in the specified encoding does not exceed the byte limit.
|
static boolean |
stringContainsSpecialRegexCharacters(java.lang.String s)
checks if the String contains a character that has a special meaning
in regex.
|
static boolean |
stringEqualsString(java.lang.String s1,
java.lang.String s2) |
static java.lang.String |
stringFromDictionary(NSDictionary dict)
Same as NSPropertySerialization except it sorts on keys first.
|
static java.lang.String |
stringFromInputStream(java.io.InputStream in)
Returns a string from the input stream using the default
encoding.
|
static java.lang.String |
stringFromInputStream(java.io.InputStream in,
java.lang.String encoding)
Returns a string from the input stream using the default
encoding.
|
static java.lang.String |
stringFromResource(java.lang.String name,
java.lang.String extension,
NSBundle bundle)
Retrieves a given string for a given name, extension
and bundle.
|
static java.lang.String |
stringFromURL(java.net.URL url)
Returns a string from the contents of the given URL.
|
static java.lang.String |
stringFromURL(java.net.URL url,
java.lang.String encoding)
Returns a string from the contents of the given URL.
|
static boolean |
stringIsNullOrEmpty(java.lang.String s)
Simple test if the string is either null or
equal to "".
|
static boolean |
stringIsParseableInteger(java.lang.String s)
Tests if a given string object can be parsed into
an integer.
|
static java.lang.String |
stringWithContentsOfFile(java.io.File file)
Reads the contents of a file given by a path
into a string.
|
static java.lang.String |
stringWithContentsOfFile(java.lang.String path)
Reads the contents of a file given by a path
into a string.
|
static java.lang.String |
stringWithNtimesString(int n,
java.lang.String s)
String multiplication.
|
static java.lang.String |
stripHtml(java.lang.String str)
Deprecated.
|
static java.lang.String |
stripHtml(java.lang.String str,
boolean convertChars)
Removes HTML characters from the given string.
|
static java.lang.String |
strippedValue(java.lang.String value,
int length)
Returns the value stripped from HTML tags if escapeHTML is false.
|
static byte[] |
toBytes(java.lang.String string,
java.lang.String encoding)
Utility to convert to bytes without the try/catch.
|
static java.lang.String |
toHexString(char c) |
static java.lang.String |
toHexString(java.lang.String str) |
static java.lang.String |
toLowerCase(java.lang.String str)
This method runs about 20 times faster than
java.lang.String.toLowerCase (and doesn't waste any storage
when the result is equal to the input).
|
static java.lang.String |
toString(java.lang.Object[] array,
java.lang.String separator)
Returns a String by invoking toString() on each object from the array.
|
static byte[] |
toUTF8Bytes(java.lang.String string)
Utility to convert to UTF-8 bytes without the try/catch.
|
static java.lang.String |
trimString(java.lang.String s)
Null-safe wrapper for java.lang.String.trim
|
static java.lang.String |
trimZeroInFrontOfNumbers(java.lang.String str)
trim leading 0 from a (Number) String
|
static java.lang.String |
uncapitalize(java.lang.String value)
Uncapitalizes a given string.
|
static java.lang.String |
underscoreToCamelCase(java.lang.String underscoreString,
boolean capitalize)
Converts this_is_a_test to ThisIsATest
|
static java.lang.String |
unescapeEntities(java.lang.String string,
java.util.Map<java.lang.String,java.lang.String> map)
Util to unescape entities.
|
static java.lang.String |
unquote(java.lang.String s,
java.lang.String quoteSymbol)
Remove the quote symbols from the given string
|
static java.lang.String |
urlDecode(java.lang.String string)
Utility to decode an URL without the try/catch.
|
static java.lang.String |
urlEncode(java.lang.String string)
Utility to encode an URL without the try/catch.
|
static java.lang.String |
wordSafeTrimmedString(java.lang.String trimmingString,
int maxLenght)
Returns a string trimmed about at the max length you define without truncating the last word and adding "..." (if necessary)
|
public static final char[] HEX_CHARS
public static final NSArray SORT_ASCENDING
EOSortOrderingspublic static final NSArray SORT_DESCENDING
EOSortOrderingspublic static final java.lang.String SpecialRegexCharacters
protected static double adjustement
public static final NSDictionary<java.lang.String,java.lang.String> XML_UNESCAPES
public static final NSDictionary<java.lang.String,java.lang.String> ISO_UNESCAPES
public static final NSDictionary<java.lang.String,java.lang.String> SYMBOL_UNESCAPES
public static final NSDictionary<java.lang.String,java.lang.String> HTML_SAFE_UNESCAPES
public static final NSDictionary<java.lang.String,java.lang.String> HTML_UNESCAPES
@Deprecated
public static double distance(java.lang.String a,
java.lang.String b)
levenshteinDistance(String, String), which
correctly returns an int resulta and b as a double. (This
method is being retained for backwards compatibility, and will be removed
at some future point. New code should use
levenshteinDistance(String, String).)a - first stringb - second stringa and b@Deprecated
public static int levenshteinDistance(java.lang.String a,
java.lang.String b)
StringUtils#getLevenshteinDistance(String, String) insteada and b. This code is based on some Python code posted to a mailing list by Magnus L. Hetland
<mlh@idt.ntnu.no>, and assumed to be in the public domain.
def distance(a,b):
c = {}
n = len(a); m = len(b)
for i in range(0,n+1):
c[i,0] = i
for j in range(0,m+1):
c[0,j] = j
for i in range(1,n+1):
for j in range(1,m+1):
x = c[i-1,j]+1
y = c[i,j-1]+1
if a[i-1] == b[j-1]:
z = c[i-1,j-1]
else:
z = c[i-1,j-1]+1
c[i,j] = min(x,y,z)
return c[n,m]
It calculates the following: Given two strings, a and b,
and three operations, adding, subtracting and exchanging single
characters, what is the minimal number of steps needed to translate
a into b? The method is based on the following idea. We
want to find the distance between a[:x] and b[:y]. To do
this, we first calculate:
a[:x-1] and b[:y], adding the
cost of a subtract-operation, used to get from a[:x] to
a[:z-1];a[:x] and b[:y-1], adding the
cost of an addition-operation, used to get from b[:y-1] to
b[:y];a[:x-1] and b[:y-1], adding the
cost of a possible exchange of the letter b[y] (with
a[x]).a[x] and b[y] are
different, and 0 otherwise. After calculating these costs, we choose the
least one of them (since we want to use the best solution.)
Instead of doing this recursively, i.e. calculating ourselves "back" from
the final value, we build a cost-matrix c containing the optimal
costs, so we can reuse them when calculating the later values. The costs
c[i,0] (from string of length n to empty string) are all
i, and correspondingly all c[0,j] (from empty string to
string of length j) are j. Finally, the cost of
translating between the full strings a and b (
c[n,m]) is returned.
a - first stringb - second stringpublic static void setAdjustement(double newAdjustement)
newAdjustement - factor to be used.public static NSArray fuzzyMatch(java.lang.String name, java.lang.String entityName, java.lang.String propertyKey, java.lang.String synonymsKey, EOEditingContext ec, ERXFuzzyMatchCleaner cleaner, NSArray sortOrderings)
name - to be matched againstentityName - name of the entity to perform the match against.propertyKey - to be matched againstsynonymsKey - allows objects to have additional values to be matched
against in addition to just the value of the propertyKeyec - context to fetch data incleaner - object used to clean a string, for example the cleaner might
strip out the words 'The' and 'Inc.'sortOrderings - can be either SORT_ASCENDING or SORT_DESCENDING
to tell how the results should be sorted.@Deprecated public static NSArray fuzzyMatch(java.lang.String name, java.lang.String entityName, java.lang.String propertyKey, java.lang.String synonymsKey, EOEditingContext ec, ERXFuzzyMatchCleaner cleaner, java.lang.String comparisonString)
fuzzyMatch(String, String, String, String, EOEditingContext, ERXFuzzyMatchCleaner, NSArray)name - entityName - propertyKey - synonymsKey - ec - cleaner - comparisonString - public static java.lang.String localizedStringForKey(java.lang.String key)
key - to be lookup in the strings filepublic static java.lang.String localizedStringForKey(java.lang.String key,
java.lang.String framework)
key - to be lookup in the strings fileframework - name, specify app or null to perform the
lookup in the application's resources.public static java.lang.String localizedStringForKey(java.lang.String key,
java.lang.String framework,
NSArray languages)
key - to be lookup in the strings fileframework - name, specify app or null to perform the
lookup in the application's resources.languages - array to search for the key inpublic static java.lang.String localizedTemplateStringWithObjectForKey(java.lang.Object o,
java.lang.String key,
java.lang.String framework,
NSArray languages)
localizedStringForKey to retreive
a template that is then parsed using the passed in object to
produce a resulting string. The template parser used is
ERXSimpleTemplateParser.o - object used to resolve keys in the localized templatekey - to be lookup in the strings fileframework - name, specify app or null to perform the
lookup in the application's resources.languages - array to search for the key inpublic static java.lang.String stringWithContentsOfFile(java.io.File file)
file - path to the file in the file systempublic static java.lang.String stringWithContentsOfFile(java.lang.String path)
path - to the file in the file systempublic static java.lang.Integer integerWithString(java.lang.String s)
s - string to caclulate an Integer fromERXConstant.integerForString(String)public static boolean stringIsParseableInteger(java.lang.String s)
s - string to be parsedtrue if the string is not null
and can be parsed to an intpublic static java.lang.Integer safeInteger(java.lang.String s)
Integer.valueOf(String) that catches
the NumberFormatException.s - string to convert to an Integernull if the string could
not be parsedpublic static java.lang.Long safeLong(java.lang.String s)
Long.valueOf(String) that catches
the NumberFormatException.s - string to convert to a Longnull if the string could
not be parsedpublic static java.lang.String stringFromResource(java.lang.String name,
java.lang.String extension,
NSBundle bundle)
name - of the resourceextension - of the resource, example: txt or rtfbundle - to look for the resource inpublic static final java.lang.String firstPropertyKeyInKeyPath(java.lang.String keyPath)
public static final java.lang.String lastPropertyKeyInKeyPath(java.lang.String keyPath)
public static final java.lang.String keyPathWithoutLastProperty(java.lang.String keyPath)
public static final java.lang.String keyPathWithoutFirstProperty(java.lang.String keyPath)
public static java.lang.String displayNameForKey(java.lang.String key)
key - to calculate the display namepublic static int indexOfNumericInString(java.lang.String str)
str - string to scanpublic static int indexOfNumericInString(java.lang.String str,
int fromIndex)
fromIndex in the given string.str - string to scanfromIndex - index position from where to startpublic static void appendSeparatorIfLastNot(char separator,
char not,
java.lang.StringBuffer sb)
separator - character to potentially
add to the StringBuffer.not - character to test if the given
StringBuffer ends in it.sb - StringBuffer to test and potentially
append to.public static void appendSeparatorIfLastNot(char separator,
char not,
java.lang.StringBuilder sb)
separator - character to potentially
add to the StringBuilder.not - character to test if the given
StringBuilder ends in it.sb - StringBuilder to test and potentially
append to.@Deprecated
public static java.lang.String replaceStringByStringInString(java.lang.String old,
java.lang.String newString,
java.lang.String buffer)
StringUtils#replace(String, String, String) insteadold - string to be replacednewString - to be insertedbuffer - string to have the replacement done on it@Deprecated
public static java.lang.String stringByReplacingFirstOccurrenceOfStringWithString(java.lang.String sourceString,
java.lang.String stringToReplace,
java.lang.String replacementString)
StringUtils#replaceOnce(String, String, String) insteadsourceString - string to use on which to perform the replacementstringToReplace - string to replace in sourceString if it exists.replacementString - the string with which to replace stringToReplace.@Deprecated public static java.lang.String escapeSpace(java.lang.String aString)
removeSpaces(String) insteadaString - string to remove spaces frompublic static java.lang.String removeSpaces(java.lang.String aString)
aString - string to remove spaces frompublic static java.lang.String toLowerCase(java.lang.String str)
public static java.lang.String stringWithNtimesString(int n,
java.lang.String s)
n - the number of times to concatenate a given strings - string to be multipliedpublic static int numberOfOccurrencesOfCharInString(char c,
java.lang.String s)
char in a given string.c - char to count in strings - string to look for specified char in.public static boolean stringIsNullOrEmpty(java.lang.String s)
s - string to testpublic static java.lang.String nullForEmptyString(java.lang.String s)
s - string to testpublic static java.lang.String emptyStringForNull(java.lang.String s)
s - string to testpublic static java.lang.String escapeNonXMLChars(java.lang.String str)
public static java.lang.String unescapeEntities(java.lang.String string,
java.util.Map<java.lang.String,java.lang.String> map)
string - string to unescapemap - map of entitiespublic static java.lang.String escapePCData(java.lang.String pcdata)
pcdata - The string to escapepublic static java.lang.String escapeNonBasicLatinChars(char c)
public static java.lang.String escapeNonBasicLatinChars(java.lang.String str)
public static java.lang.String escapeJavascriptApostrophes(java.lang.String sourceString)
sourceString - the source string to escapepublic static java.lang.String escape(char[] _escapeChars,
char _escapeWith,
java.lang.String _sourceString)
_escapeChars - the list of characters to escape_escapeWith - the escape character to use_sourceString - the string to escape the characters in.public static java.lang.String toHexString(char c)
public static java.lang.String toHexString(java.lang.String str)
public static java.lang.String byteArrayToHexString(byte[] block)
block - byte arraypublic static byte[] hexStringToByteArray(java.lang.String hexString)
hexString - hex string to convertpublic static java.lang.String removeExtraDotsFromVersionString(java.lang.String version)
version - stringpublic static java.lang.String capitalize(java.lang.String value)
you have a dog", this method would
return "You have a dog".value - to be capitalizedpublic static java.lang.String uncapitalize(java.lang.String value)
value - to be uncapitalizedpublic static java.lang.String capitalizeAllWords(java.lang.String value)
you have a dog" (with two spaces between each word), this
method would return "You Have A Dog".value - to be capitalizedpublic static java.lang.String underscoreToCamelCase(java.lang.String underscoreString,
boolean capitalize)
underscoreString - the string_with_underscorescapitalize - if true, the first letter is capitalizedpublic static java.lang.String camelCaseToUnderscore(java.lang.String camelString,
boolean lowercase)
camelString - string to convertlowercase - if all uppercase characters should be converted to lowercasepublic static boolean stringEqualsString(java.lang.String s1,
java.lang.String s2)
public static boolean caseInsensitiveStartsWith(java.lang.String stringToSearch,
java.lang.String prefix)
stringToSearch - string to checkprefix - prefix to look forpublic static boolean caseInsensitiveStartsWith(java.lang.String stringToSearch,
java.lang.String prefix,
int toffset)
stringToSearch - string to checkprefix - prefix to look fortoffset - starting offset to perform the searchpublic static java.lang.String stringByTruncatingStringToByteLengthInEncoding(java.lang.String inputString,
int byteLength,
java.lang.String encoding)
This method is optimized for the UTF-8 case. If encoding is either "UTF-8" or "UTF8",
the optimized case will kick in.
inputString - string to truncatebyteLength - maximum byte lengthencoding - encoding to use@Deprecated public static boolean isDigitsOnly(java.lang.String aString)
StringUtils#isNumeric(String) insteadaString - the string to check@Deprecated public static boolean isLettersOnly(java.lang.String aString)
StringUtils#isAlpha(String) insteadaString - the string to checkpublic static boolean stringContainsSpecialRegexCharacters(java.lang.String s)
s - the string to checktrue if s contains one or multiple characters that have special
meanings in regex.public static java.lang.String stringFromURL(java.net.URL url)
throws java.io.IOException
url - the URL to read fromjava.io.IOException - if the connection failspublic static java.lang.String stringFromURL(java.net.URL url,
java.lang.String encoding)
throws java.io.IOException
url - the URL to read fromencoding - the string encoding to read withjava.io.IOException - if the connection failspublic static java.lang.String stringFromInputStream(java.io.InputStream in)
throws java.io.IOException
in - stream to readjava.io.IOException - if things go wrongpublic static java.lang.String stringFromInputStream(java.io.InputStream in,
java.lang.String encoding)
throws java.io.IOException
in - stream to readencoding - to be used, null will use the defaultjava.io.IOException - if things go wrongpublic static java.lang.String toString(java.lang.Object[] array,
java.lang.String separator)
array - an object array from which to get a nice String representationseparator - a separator which is displayed between the objects toString() valuepublic static java.lang.String dumpObject(java.lang.Object object)
object - the object to dumppublic static boolean containsAnyCharacter(java.lang.String source,
java.lang.String characters)
source - the String which might contain characterscharacters - the characters to checkpublic static java.lang.String removeExceptCharacters(java.lang.String source,
java.lang.String characters)
source - the string which will be modifiedcharacters - the characters that are allowed to be in sourcepublic static java.lang.String removeCharacters(java.lang.String source,
java.lang.String characters)
source - the string which will be modifiedcharacters - the characters that are not allowed to be in sourcepublic static boolean quicksilverContains(java.lang.String _str,
java.lang.String _searchString)
_str - the string to search in_searchString - the search string to look forpublic static byte[] md5(java.lang.String str,
java.lang.String encoding)
str - the string to hashencoding - MD5 operates on byte arrays, so we need to know the encoding to getBytes aspublic static java.lang.String md5Hex(java.lang.String str,
java.lang.String encoding)
str - the string to hashencoding - MD5 operates on byte arrays, so we need to know the encoding to getBytes aspublic static java.lang.String matchCase(java.lang.String originalString,
java.lang.String newString)
originalString - the original string to analyze the case ofnewString - the new stringpublic static void indent(java.io.PrintWriter writer,
int level)
public static void indent(java.lang.StringBuffer sb,
int level)
public static java.lang.String getSimpleClassName(java.lang.Class clazz)
public static java.lang.String stringFromDictionary(NSDictionary dict)
dict - public static boolean regionMatches(java.lang.StringBuffer str,
int toffset,
java.lang.String other,
int ooffset,
int len)
str - the StringBuffer to compare a region oftoffset - the starting offset of the sub-region in this string.other - the string argument.ooffset - the starting offset of the sub-region in the string argument.len - the number of characters to compare.true if the specified sub-region of this string
exactly matches the specified sub-region of the string argument;
false otherwise.public static java.lang.String safeIdentifierName(java.lang.String source,
java.lang.String prefix,
char replacement)
source - String to make into a identifier nameprefix - String to prefix source with to make it a valid identifier namereplacement - character to use to replace characters in source that are no allowed in an identifier nameCharacter.isJavaIdentifierStart(char),
Character.isJavaIdentifierPart(char)public static java.lang.String safeIdentifierName(java.lang.String source,
java.lang.String prefix)
source - String to make into a identifier nameprefix - String to prefix source with to make it a valid identifier namesafeIdentifierName(String, String, char)public static java.lang.String safeIdentifierName(java.lang.String source)
source - String to make into a identifier namesafeIdentifierName(String, String, char)public static java.lang.String urlEncode(java.lang.String string)
string - public static java.lang.String urlDecode(java.lang.String string)
string - public static byte[] toUTF8Bytes(java.lang.String string)
string - string to convertpublic static byte[] toBytes(java.lang.String string,
java.lang.String encoding)
string - string to convertencoding - public static java.lang.String fromUTF8Bytes(byte[] bytes)
bytes - string to convertpublic static java.lang.String fromBytes(byte[] bytes,
java.lang.String encoding)
bytes - string to convertencoding - public static java.lang.String rightPad(java.lang.String string,
char padChar,
int paddedLength)
string - the string to padpadChar - the character to pad withpaddedLength - the length to pad topublic static java.lang.String leftPad(java.lang.String string,
char padChar,
int paddedLength)
string - the string to padpadChar - the character to pad withpaddedLength - the length to pad topublic static java.lang.String insertString(java.lang.String destinationString,
java.lang.String contentToInsert,
int insertOffset)
destinationString - the string to insert intocontentToInsert - the string to insertinsertOffset - the offset in destinationString to insertpublic static java.lang.String trimString(java.lang.String s)
s - string to trimpublic static java.lang.String excelSafeCsvString(java.lang.String s)
s - public static java.lang.String unquote(java.lang.String s,
java.lang.String quoteSymbol)
s - quoteSymbol - public static java.lang.String quote(java.lang.String s,
java.lang.String quoteSymbol)
s - the string to quotequoteSymbol - - the quote symbolpublic static java.lang.String stringByAppendingCSSClass(java.lang.String originalString,
java.lang.String cssClass)
originalString - the original stringcssClass - the new CSS class to appendpublic static java.lang.String stripHtml(java.lang.String str,
boolean convertChars)
str - the string to remove HTML fromconvertChars - set to true if you want html special chars to be converted ( ex. © to (C) ), false otherwisepublic static java.lang.String removeHTMLTagsFromString(java.lang.String s)
ERXSimpleHTMLFormatters - html stringpublic static java.lang.String strippedValue(java.lang.String value,
int length)
@Deprecated public static java.lang.String stripHtml(java.lang.String str)
stripHtml(String, boolean)public static java.lang.Object attributeValueFromString(EOAttribute attr, java.lang.String strVal, java.lang.String encoding, java.text.Format formatter)
attr - The attribute for the value in question.strVal - The string value to be coerced.encoding - The encoding used if the attribute value class is custom
and the factory method does not accept a string.formatter - The formatter used if the value class is NSTimestamp.public static java.lang.Number attributeNumberValueFromString(EOAttribute attr, java.lang.String strVal)
attr - The attribute for the value in question.strVal - The string value to be coerced.public static java.lang.Object attributeCustomValueFromString(EOAttribute attr, java.lang.String strVal, java.lang.String encoding)
attr - The attribute for the value in question.strVal - The string value to be coerced.encoding - The encoding used if the attribute value class is custom
and the factory method does not accept a string.public static boolean isValueInRange(int value,
java.lang.String rangeString)
value - the value to check forrangeString - the range string to parsepublic static java.lang.String maskStringWithCharacter(java.lang.String arg,
char mask,
int beginIndex,
int endIndex)
maskStringWithCharacter("Visa 4111111111111111", '*', 5, -4); will
result in a string value of "Visa ************1111"arg - The string value to maskmask - The character maskbeginIndex - The string index where masking begins.
Negative numbers count down from the end of the string.endIndex - The index where masking ends.
Negative numbers count down from the end of the stringpublic static boolean luhnCheck(java.lang.String value)
value - A string value consisting of numeric digits between 0-9. If
the number contains hyphens, spaces, or anything other than a
string of digits between 0-9 the method returns false.public static java.lang.String wordSafeTrimmedString(java.lang.String trimmingString,
int maxLenght)
trimmingString - the string you would like to trimmaxLenght - the max length you needpublic static java.lang.String trimZeroInFrontOfNumbers(java.lang.String str)
str - - the Stringstr - - 処理対象の文字列public static java.lang.String cleanString(java.lang.String newString,
NSArray<java.lang.String> toBeCleaneds)
newString - initial string from which to remove other stringstoBeCleaneds - array of substrings to be removed from the initial string.public static boolean isBlank(java.lang.String value)
public static boolean isNotBlank(java.lang.String value)
Copyright © 2002 – 2022 Project Wonder.