|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.nuiton.util.StringUtil
public class StringUtil
Classe contenant un ensemle de methode static utiles pour la manipulation des chaine de caractere mais qui ne sont pas defini dans la classe String de Java.
| Nested Class Summary | |
|---|---|
static interface |
StringUtil.ToString<O>
Contract to use in join(Iterable , ToString, String, boolean)
method. |
| Field Summary | |
|---|---|
static String[] |
EMPTY_STRING_ARRAY
|
protected static double[] |
memoryFactors
|
protected static String[] |
memoryUnites
|
protected static double[] |
timeFactors
|
protected static String[] |
timeUnites
|
| Constructor Summary | |
|---|---|
protected |
StringUtil()
Constructor for the StringUtil object |
| Method Summary | ||
|---|---|---|
static String |
asHex(byte[] hash)
Turns array of bytes into string representing each byte as unsigned hex number. |
|
static boolean |
checkEnclosure(String txt,
char opener,
char closer)
Vérifie q'une chaine de caractère est valid pour les bloc openner closer, ie. |
|
static String |
convert(long value,
double[] factors,
String[] unites)
Note: this method use the current locale (the Locale.getDefault()) in the method
MessageFormat.MessageFormat(String). |
|
static String |
convertMemory(long value)
Converts an memory measure into a human readable format. |
|
static String |
convertTime(long value)
Converts an time delay into a human readable format. |
|
static String |
convertTime(long value,
long value2)
Converts an time period into a human readable format. |
|
static String |
convertToConstantName(String name)
Convertir un nom en une constante Java Les seuls caractères autorisés sont les alpha numériques, ains que l'underscore. tous les autres caractères seront ignorés. |
|
static String |
encodeMD5(String toEncode)
Convert a String to MD5. |
|
static String |
encodeSHA1(String toEncode)
Convert a String to SHA1. |
|
static boolean |
isEmail(String str)
Know if a string is a valid e-mail. |
|
static String |
join(Iterable<?> iterable,
String separator,
boolean trim)
Used to concat an iterable of Object separated
by separator using the toString() method of each object. |
|
static
|
join(Iterable<O> iterable,
StringUtil.ToString<O> ts,
String separator,
boolean trim)
Used to concat an iterable of object <O> separated by
separator. |
|
static String[] |
split(Character[] openingChars,
Character[] closingChars,
String args,
String separator)
Split string use 'separator' as separator. |
|
static String[] |
split(String stringList)
Use to split string array representation in array according with swixat seperator list |
|
static String[] |
split(String args,
String separator)
Split string use 'separator' as separator. |
|
static String |
substring(String s,
int begin)
substring from begin to end of s example: substring("tatetitotu", -4) => totu |
|
static String |
substring(String s,
int begin,
int end)
substring from begin to end of s example: substring("tatetitotu", -4, -2) => to |
|
static boolean[] |
toArrayBoolean(String... s)
|
|
static byte[] |
toArrayByte(String... s)
|
|
static char[] |
toArrayChar(String... s)
|
|
static double[] |
toArrayDouble(String... s)
|
|
static float[] |
toArrayFloat(String... s)
|
|
static int[] |
toArrayInt(String... s)
|
|
static long[] |
toArrayLong(String... s)
|
|
static short[] |
toArrayShort(String... s)
|
|
static boolean |
toBoolean(String s)
|
|
static byte |
toByte(String s)
|
|
static char |
toChar(String s)
|
|
static Color |
toColor(String s)
Essai de convertir une chaine de caractere en une couleur si possible si ce n'est pas possible retourne null. |
|
static Date |
toDate(String s)
|
|
static double |
toDouble(String s)
|
|
static float |
toFloat(String s)
|
|
static int |
toInt(String s)
|
|
static long |
toLong(String s)
|
|
static short |
toShort(String s)
|
|
static String |
unaccent(String s)
Cette methode retire les accents. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String[] EMPTY_STRING_ARRAY
protected static final double[] timeFactors
protected static final String[] timeUnites
protected static final double[] memoryFactors
protected static final String[] memoryUnites
| Constructor Detail |
|---|
protected StringUtil()
| Method Detail |
|---|
public static String unaccent(String s)
s - la chaine a unaccentuer
public static boolean isEmail(String str)
str - a string
str is syntactically a valid e-mail address
public static String join(Iterable<?> iterable,
String separator,
boolean trim)
iterable of Object separated
by separator using the toString() method of each object.
You can specify if the string must be trimmed or not.
iterable - Iterable with objects to treateseparator - to usedtrim - if each string must be trim
public static <O> String join(Iterable<O> iterable,
StringUtil.ToString<O> ts,
String separator,
boolean trim)
throws NullPointerException
iterable of object <O> separated by
separator. This method need a ts contract to
call on each object. The ToString can be null to use directly the
toString() method on the object. The trim boolean is used
to specify if each string object has to be trimmed. The null elements
in the list will be ignored.
O - type of object in the listiterable - Iterable with objects to treatets - used to specify how the object is converted in Stringseparator - to used between each object stringtrim - if trim() method need to by apply on each object string
NullPointerException - if iterable is null.
public static String substring(String s,
int begin)
s - begin - if begin < 0 then begin start at end of string - begin
public static String substring(String s,
int begin,
int end)
s - begin - if begin < 0 then begin start at end of string - beginend - if end < 0 then end start at end of string - end
public static String[] split(String args,
String separator)
args - string to splitseparator - separator use to split string
public static String[] split(String stringList)
stringList - string that represent array
public static String[] split(Character[] openingChars,
Character[] closingChars,
String args,
String separator)
openingChar closingChars
this method count the number of open char end close char to split
correctly argument
openingChars - list of opening caracteresclosingChars - list of closing caracteresargs - string to splitseparator - separator use to split string
public static boolean toBoolean(String s)
public static byte toByte(String s)
public static double toDouble(String s)
public static float toFloat(String s)
public static long toLong(String s)
public static short toShort(String s)
public static int toInt(String s)
public static char toChar(String s)
public static boolean[] toArrayBoolean(String... s)
public static byte[] toArrayByte(String... s)
public static double[] toArrayDouble(String... s)
public static float[] toArrayFloat(String... s)
public static long[] toArrayLong(String... s)
public static short[] toArrayShort(String... s)
public static int[] toArrayInt(String... s)
public static char[] toArrayChar(String... s)
public static String asHex(byte[] hash)
hash - Array of bytes to convert to hex-string
public static Color toColor(String s)
throws StringUtilException
s - la couleur sous la forme de string, par exemple "red",
"yellow" ou bien en RGB "#FFAA99", et avec un canal alpha
"#FFAA3366"
IllegalArgumentException
StringUtilException - if any problem while conversion
public static Date toDate(String s)
throws ParseException
ParseExceptionpublic static String convertTime(long value)
value - the delay to convert
convert(long, double[], String[])
public static String convertTime(long value,
long value2)
value - the begin timevalue2 - the end time
convert(long, double[], String[])public static String convertMemory(long value)
value - the memory measure to convert
convert(long, double[], String[])
public static String convert(long value,
double[] factors,
String[] unites)
Locale.getDefault()) in the method
MessageFormat.MessageFormat(String).
value - value to convertfactors - facotrs used form conversionunites - libelle of unites to use
public static boolean checkEnclosure(String txt,
char opener,
char closer)
txt - txte a verifieropener - le caractère ouvrantcloser - le caractère fermant
true is la chaine est validepublic static String convertToConstantName(String name)
name - le nom à convertir
public static String encodeMD5(String toEncode)
toEncode - string concerned
IllegalStateException - if could not found algorithm MD5public static String encodeSHA1(String toEncode)
toEncode - string to encode
IllegalStateException - if could not found algorithm SHA1
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||