|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.openxava.util.Strings
public class Strings
Utilities to work with String.
| Constructor Summary | |
|---|---|
Strings()
|
|
| Method Summary | |
|---|---|
static java.lang.String |
change(java.lang.String string,
java.util.Map toChange)
In the sent string changes the strings in toChange map for its values. |
static java.lang.String |
change(java.lang.String string,
java.lang.String original,
java.lang.String newString)
Change in string |
static java.lang.String |
changeSeparatorsBySpaces(java.lang.String string)
Changes \n, \r and \t by space. |
static java.lang.String |
firstLower(java.lang.String s)
Returns a string like the sent one but with the first letter in lowercase. |
static java.lang.String |
firstToken(java.lang.String string,
java.lang.String delim)
|
static java.lang.String |
firstUpper(java.lang.String s)
Returns a string like the sent one but with the first letter in uppercase. |
static java.lang.String |
fix(java.lang.String string,
int length,
Align align)
Fix the length of the string filling with spaces if needed. |
static java.lang.String |
fix(java.lang.String string,
int length,
Align align,
char fillCharacter)
Fix the length of the string filling with the specified character if needed. |
static java.lang.String |
javaIdentifierToNaturalLabel(java.lang.String name)
Convert a string with a Java identifier in label natural for a human. |
static java.lang.String |
lastToken(java.lang.String string)
|
static java.lang.String |
lastToken(java.lang.String string,
java.lang.String delim)
|
static java.lang.String |
noFirstToken(java.lang.String string,
java.lang.String delim)
All string but without first token. |
static java.lang.String |
noLastToken(java.lang.String string)
All string but without last token. |
static java.lang.String |
noLastToken(java.lang.String string,
java.lang.String delim)
All string but without last token. |
static java.lang.String |
noLastTokenWithoutLastDelim(java.lang.String string,
java.lang.String delim)
All string but without last token. |
static java.lang.String |
removeAccents(java.lang.String value)
Change from a vowel with an accent, to vowel with no accent If you send "Camión" it returns "Camion" |
static java.lang.Object |
removeXSS(java.lang.Object notSafeValue)
|
static java.lang.String |
removeXSS(java.lang.String notSafeValue)
A key function of any application filtering process will be the removal of possible dangerous special characters. |
static java.lang.String |
repeat(int count,
java.lang.String string)
Creates a string from repeating another string. |
static java.lang.String |
spaces(int count)
Creates a string with the specified blank spaces. |
static java.lang.String[] |
toArray(java.lang.String list)
Converts a list of comma separated elements in a string array. |
static java.lang.String[] |
toArray(java.lang.String list,
java.lang.String separator)
Converts a list of elements separated by a arbitrary character in a string array. |
static java.lang.String |
toCharSet(java.lang.String original,
java.lang.String charSet)
Translate to the charset specified. |
static java.util.Collection<java.lang.String> |
toCollection(java.lang.String list)
Converts a list of comma separated elements in a string collection. |
static java.util.Collection<java.lang.String> |
toCollection(java.lang.String list,
java.lang.String separator)
Converts a list of elements separated by a arbitrary character in a string collection. |
static java.util.List<java.lang.String> |
toList(java.lang.String list)
Converts a list of comma separated elements in a string List. |
static java.util.List<java.lang.String> |
toList(java.lang.String list,
java.lang.String separator)
Converts a list of elements separated by a arbitrary character in a string List. |
static java.lang.Object |
toObject(java.lang.Class type,
java.lang.String string)
Converts a string a object of the specified type. |
static java.util.Set<java.lang.String> |
toSet(java.lang.String list)
Converts a list of comma separated elements in a string set. |
static java.util.Set<java.lang.String> |
toSet(java.lang.String list,
java.lang.String separator)
Converts a list of elements separated by a arbitrary character in a string set. |
static java.util.Set<java.lang.String> |
toSetNullByPass(java.lang.String list)
Converts a list of comma separated elements in a string set. |
static java.lang.String |
toString(java.util.Collection collection)
Converts a collection of objects in a string of comma separated elements. |
static java.lang.String |
toString(java.util.Collection collection,
java.lang.String separator)
Converts a collection of objects in string of elements separated by a arbitrary character . |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Strings()
| Method Detail |
|---|
public static java.lang.String changeSeparatorsBySpaces(java.lang.String string)
string - Not null
public static java.lang.String toCharSet(java.lang.String original,
java.lang.String charSet)
throws java.io.UnsupportedEncodingException
original - Original stringcharSet - Charset to traslate to, for example, UTF-8, or ISO-8859-1
java.io.UnsupportedEncodingException - If charset is not supportedpublic static java.lang.String spaces(int count)
count - Quantity of spaces
public static java.lang.String fix(java.lang.String string,
int length,
Align align)
Returns the sent string but with the specified length.
It fills or cuts as it needs.
string - Can be null, in which case empty string is assumedlength - Character count of result stringalign - Not null
public static java.lang.String fix(java.lang.String string,
int length,
Align align,
char fillCharacter)
Returns the sent string but with the specified length.
It fills or cuts as it needs.
string - Can be null, in which case empty string is assumedlength - Character count of result stringalign - Not nullfillCharacter - Character used to fill
public static java.lang.String repeat(int count,
java.lang.String string)
count - Times to repeatstring - String to repeat
public static final java.lang.String[] toArray(java.lang.String list)
For example, the list Angel, Manolo, Antonia is converted to
a array of 3 elements with this 3 names without comman nor spaces.
list - String with the list. If null return a empty string
public static final java.lang.String[] toArray(java.lang.String list,
java.lang.String separator)
For example, the list Angel : Manolo : Antonia is converted to
a array of 3 elements with this 3 names without colon (for example) nor spaces.
list - String with the list. If null return a empty stringseparator - The character used as separator.
public static final java.util.Collection<java.lang.String> toCollection(java.lang.String list)
For example, the list Angel, Manolo, Antonia is converted to
a collection of 3 elements with this 3 names without comman nor spaces.
list - String with the list. If null return a empty string
public static final java.util.Collection<java.lang.String> toCollection(java.lang.String list,
java.lang.String separator)
For example, the list Angel : Manolo : Antonia is converted to
a collection of 3 elements with this 3 names without colon (for example) nor spaces.
list - String with the list. If null return a empty stringseparator - The character used as separator.
public static final java.util.List<java.lang.String> toList(java.lang.String list)
For example, the list Angel, Manolo, Antonia is converted to
a List of 3 elements with this 3 names without comma nor spaces.
list - String with the list. If null return a empty string
public static final java.util.List<java.lang.String> toList(java.lang.String list,
java.lang.String separator)
For example, the list Angel : Manolo : Antonia is converted to
a List of 3 elements with this 3 names without colon (for example) nor spaces.
list - String with the list. If null return a empty stringseparator - The character used as separator.
public static final java.util.Set<java.lang.String> toSet(java.lang.String list)
For example, the list Angel, Manolo, Antonia is converted to
a set of 3 elements with this 3 names without comman nor spaces.
list - String with the list. If null return a empty string
public static final java.util.Set<java.lang.String> toSetNullByPass(java.lang.String list)
For example, the list Angel, Manolo, Antonia is converted to
a set of 3 elements with this 3 names without comman nor spaces.
list - String with the list. If null return a empty string
public static final java.util.Set<java.lang.String> toSet(java.lang.String list,
java.lang.String separator)
For example, the list Angel : Manolo : Antonia is converted to
a set of 3 elements with this 3 names without colon (for example) nor spaces.
list - String with the list. If null return a empty stringseparator - The character used as separator.
public static final java.lang.String toString(java.util.Collection collection)
For example, a collection of 3 elements with 3 names
is converted to the string Angel, Manolo, Antonia
collection - Collection with the elements. If null return a empty string
public static final java.lang.String toString(java.util.Collection collection,
java.lang.String separator)
For example, a collection of 3 elements with this 3 names
is converted to a string of 3 elements with this 3 names and colon (for example).
collection - A collection of objects. If null return a empty stringseparator - The character used as separator.
public static final java.lang.Object toObject(java.lang.Class type,
java.lang.String string)
Supports all primitive type plus its wrappers except char and void.
Support String and BigDecimal too.
If there is conversion error or is a type not supporte return null or the default value for the type (zero for numeric).
type - The type of returned object (can be a primitive type
in this case return its wrapper). Not nullstring - String with data to convert. Can be null, in this case
return a default value.public static java.lang.String firstUpper(java.lang.String s)
If null is sent null is returned.
public static java.lang.String firstLower(java.lang.String s)
If null is sent null is returned.
public static java.lang.String change(java.lang.String string,
java.util.Map toChange)
string - Not nulltoChagne - Not null
public static java.lang.String change(java.lang.String string,
java.lang.String original,
java.lang.String newString)
string original by newString.
- Parameters:
string - String in which we make the changes. Can be nulloriginal - String to search. Not nullnewString - New value to put in place of original. Not null
- Returns:
- The changed string, if the sent string is null a null is returned
public static java.lang.String lastToken(java.lang.String string)
public static java.lang.String lastToken(java.lang.String string,
java.lang.String delim)
public static java.lang.String noLastToken(java.lang.String string)
A trim is applied to the result.
public static java.lang.String noLastToken(java.lang.String string,
java.lang.String delim)
Includes the last delim.
public static java.lang.String noFirstToken(java.lang.String string,
java.lang.String delim)
Includes the delim.
public static java.lang.String noLastTokenWithoutLastDelim(java.lang.String string,
java.lang.String delim)
It does not include the last delim.
public static java.lang.String firstToken(java.lang.String string,
java.lang.String delim)
public static java.lang.String removeXSS(java.lang.String notSafeValue)
public static java.lang.Object removeXSS(java.lang.Object notSafeValue)
notSafeValue -
public static java.lang.String javaIdentifierToNaturalLabel(java.lang.String name)
If you send "firstName" it returns "First name".
If you send "CustomerOrder" it returns "Customer order".
public static java.lang.String removeAccents(java.lang.String value)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||