|
LEONARDI Application Composer - 8.9.0.40 by W4 S.A. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectleon.misc.LyTools
public class LyTools
This class implements some basic conversion and utilities methods. Part of them are toString methods that convert objects to their string representation and fromString methods that build objects from a given string.
Field Summary | |
---|---|
static java.lang.String |
__VERSION
|
static char |
ARRAY_SEP
Separator used for Arrays. |
static char |
BITSET_SEP
Separator used for BitSets. |
static char |
CLASS_SEP
Separator used between class name and id. |
static char |
OBJECT_SEP
Separator used for applicative objects. |
static char |
PIPE_SEP
Separator used for strings in web. |
static char |
VALUE_SEP
Separator used between values of applicative objects. |
static char |
VECTOR_SEP
Separator used for Vectors. |
Constructor Summary | |
---|---|
LyTools()
|
Method Summary | |
---|---|
static java.lang.Object[] |
ArrayFromString(java.lang.String value,
java.lang.Class<?> classRef)
Converts a string to an Array of objects. |
static java.util.BitSet |
BitSetFromString(java.lang.String value)
Converts a string to a BitSet. |
static boolean |
booleanFromString(java.lang.String value)
Converts a string to a boolean. |
static java.lang.Boolean |
BooleanFromString(java.lang.String value)
Converts a string to a Boolean. |
static java.lang.String |
breakString(java.lang.String label,
int maxChars)
Break the line in label that exceed maxChars number. |
static byte |
byteFromString(java.lang.String value)
Converts a string to a byte. |
static java.lang.Byte |
ByteFromString(java.lang.String value)
Converts a string to a Byte. |
static java.lang.Character |
CharacterFromString(java.lang.String value)
Converts a string to a Character. |
static char |
charFromString(java.lang.String value)
Converts a string to a char. |
static double |
checkDecimals(double value,
int decimals)
Checks the number of decimals of the given double. |
static java.lang.String |
checkDecimals(java.lang.String value,
int decimals)
Checks the number of decimals of the given string representation of a number. |
static java.util.Date |
DateFromString(java.lang.String value)
Converts a string to a Date. |
static double |
doubleFromString(java.lang.String value)
Converts a string to a double. |
static java.lang.Double |
DoubleFromString(java.lang.String value)
Converts a string to a Double. |
static double |
doubleFromString(java.lang.String value,
double defaultValue)
Converts a string to a double. |
static java.lang.String |
encodeXmlTags(java.lang.String value)
Encode Xml tags from a string to display it as Html. |
static float |
floatFromString(java.lang.String value)
Converts a string to a float. |
static java.lang.Float |
FloatFromString(java.lang.String value)
Converts a string to a Float. |
static java.lang.String |
formatToHTML(java.lang.String tip,
int maxCharPerLine)
Used in swing component to replace multilined String by its equivalent in HTML. |
static java.lang.String |
getIndentString()
|
static int |
getNextIdentifier()
Gets next identifier and increments internal counter. |
static double |
getPitch(double pitch,
int decimals)
Calculate a pitch according to a given number of decimals. |
static char |
getSeparator(java.lang.Object object)
Gets a separator depending on object type. |
static java.lang.Integer |
IntegerFromString(java.lang.String value)
Converts a string to an Integer. |
static int |
intFromString(java.lang.String value)
Converts a string to an int. |
static boolean |
isDouble(java.lang.String str)
Check if the given string can be parse as float or double |
static long |
longFromString(java.lang.String value)
Converts a string to a long. |
static java.lang.Long |
LongFromString(java.lang.String value)
Converts a string to a Long. |
static double |
nextDouble()
Gets the next random value as a double. |
static float |
nextFloat()
Gets the next random value as a float. |
static int |
nextInt()
Gets the next random value as an int. |
static long |
nextLong()
Gets next counter value and increments internal counter. |
static short |
nextShort()
Gets the next random value as a short. |
static java.lang.String |
removeAccents(java.lang.String s)
Removes accents from given string. |
static java.lang.String |
removeChar(java.lang.String str,
char character)
Remove all occurrence of a specific character in a string |
static java.lang.String |
removeExponent(java.lang.String value)
Removes exponent from the given string representation of a double. |
static java.lang.String |
removeHtmlTags(java.lang.String value)
Remove tags from a string. |
static short |
shortFromString(java.lang.String value)
Converts a string to a short. |
static java.lang.Short |
ShortFromString(java.lang.String value)
Converts a string to a Short. |
static java.lang.String |
toString(java.util.BitSet bs)
Converts a BitSet to a string. |
static java.lang.String |
toString(char c)
Converts a character to a string. |
static java.lang.String |
toString(java.util.Date date)
Convert a date to a string. |
static java.lang.String |
toString(java.lang.Object[] a)
Returns a string representation of the contents of the specified array. |
static java.util.Vector<java.lang.Object> |
VectorFromString(java.lang.String value,
java.lang.Class<?> classRef)
Converts a string to a vector. |
static java.util.Vector<java.lang.Object> |
VectorFromString(java.lang.String value,
java.lang.Class<?> classRef,
char SEP)
Converts a string to a vector. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String __VERSION
public static final char OBJECT_SEP
public static final char VALUE_SEP
public static final char VECTOR_SEP
public static final char ARRAY_SEP
public static final char BITSET_SEP
public static final char CLASS_SEP
public static final char PIPE_SEP
Constructor Detail |
---|
public LyTools()
Method Detail |
---|
public static java.lang.String toString(char c)
c
- the character to convert
Character.toString(char)
public static java.lang.String toString(java.util.Date date)
LyDateFormatter.format(date, "dd/MM/yyyy HH:mm:ss")
date
- The date that must be converted.
public static java.lang.String toString(java.util.BitSet bs)
bs
- The BitSet that must be converted.
public static int intFromString(java.lang.String value)
value
- The string that must be parsed.
public static java.lang.Integer IntegerFromString(java.lang.String value)
value
- The string that must be parsed.
public static float floatFromString(java.lang.String value)
value
- The string that must be parsed.
public static java.lang.Float FloatFromString(java.lang.String value)
value
- The string that must be parsed.
public static double doubleFromString(java.lang.String value)
doubleFromString(value, 0.0)
value
- The string that must be parsed.
doubleFromString(String, double)
public static double doubleFromString(java.lang.String value, double defaultValue)
value
- The string that must be parsed.defaultValue
- The default value if it is not a double value.
DoubleFromString(String)
public static java.lang.Double DoubleFromString(java.lang.String value)
value
- The string that must be parsed.
public static short shortFromString(java.lang.String value)
value
- The string that must be parsed.
public static java.lang.Short ShortFromString(java.lang.String value)
value
- The string that must be parsed.
public static long longFromString(java.lang.String value)
value
- The string that must be parsed.
public static java.lang.Long LongFromString(java.lang.String value)
value
- The string that must be parsed.
public static byte byteFromString(java.lang.String value)
value
- The string that must be parsed.
public static java.lang.Byte ByteFromString(java.lang.String value)
value
- The string that must be parsed.
public static boolean booleanFromString(java.lang.String value)
value
- The string that must be parsed.
BooleanFromString(String)
public static java.lang.Boolean BooleanFromString(java.lang.String value)
value
- The string that must be parsed.
public static char charFromString(java.lang.String value)
value
- The string that must be parsed.
public static java.lang.Character CharacterFromString(java.lang.String value)
value
- The string that must be parsed.
public static java.util.Date DateFromString(java.lang.String value)
value
- The string that must be parsed. It must respect the date format 'dd/MM/yyyy
HH:mm:ss'.
LyDateFormatter.parse(String, String)
public static java.lang.Object[] ArrayFromString(java.lang.String value, java.lang.Class<?> classRef)
value
- The string that must be converted.classRef
- The class of the objects to create.
VectorFromString(String, Class, char)
public static java.util.Vector<java.lang.Object> VectorFromString(java.lang.String value, java.lang.Class<?> classRef)
#VectorFromString(value, classRef, VECTOR_SEP)
value
- The string that must be converted.classRef
- The class of the objects to create.
public static java.util.Vector<java.lang.Object> VectorFromString(java.lang.String value, java.lang.Class<?> classRef, char SEP)
value
- The string that must be converted.classRef
- The class of the objects to create.SEP
- the separator between values.
public static java.util.BitSet BitSetFromString(java.lang.String value)
value
- The string that must be parsed.
public static int getNextIdentifier()
public static long nextLong()
public static int nextInt()
Random.nextInt()
public static short nextShort()
_random.nextInt(Short.MAX_VALUE)
Random.nextInt(int)
public static float nextFloat()
Random.nextFloat()
public static double nextDouble()
Random.nextDouble()
public static double checkDecimals(double value, int decimals)
value
- the double value to checkdecimals
- The number of decimals allowed. A negative value means no limit on number of
decimals.
public static java.lang.String checkDecimals(java.lang.String value, int decimals)
value
- the string representation of the number to checkdecimals
- The number of decimals. A negative value means no limit on number of
decimals.
public static java.lang.String removeChar(java.lang.String str, char character)
str
- the source stringcharacter
- the character to remove
public static java.lang.String removeExponent(java.lang.String value)
value
- Initial value result of Double.toString
public static double getPitch(double pitch, int decimals)
pitch
- The desired pitch.decimals
- The maximum number of decimals. For example the result of getPitch(0.04, 1)
will be 0.1.
public static char getSeparator(java.lang.Object object)
object
- The object whose type we want to retrieve separator.
public static java.lang.String formatToHTML(java.lang.String tip, int maxCharPerLine)
tip
- the original String to replace.maxCharPerLine
- maximum number of character in a line
public static java.lang.String breakString(java.lang.String label, int maxChars)
label
- the label that must not exceed maxChar lengthmaxChars
- the maximum number of characters of the label
public static java.lang.String toString(java.lang.Object[] a)
a
- the array whose string representation to return
public static java.lang.String removeAccents(java.lang.String s)
str
- Initial string.
public static java.lang.String getIndentString()
public static java.lang.String encodeXmlTags(java.lang.String value)
value
- the string that must be parsed
public static java.lang.String removeHtmlTags(java.lang.String value)
value
- the string that must be parsed
public static boolean isDouble(java.lang.String str)
str
- the string to check
|
(c) January 2013 - W4 S.A. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |