|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectwicket.util.string.StringValue
Holds an immutable String value and optionally a Locale, with methods to convert to various types. Also provides some handy parsing methods and a variety of static factory methods.
Objects can be constructed directly from Strings or by using the valueOf() static factory methods. The repeat() static factory methods provide a way of generating a String value that repeats a given char or String a number of times.
Conversions to a wide variety of types can be found in the to*() methods. A generic conversion can be achieved with to(Class).
The beforeFirst(), afterFirst(), beforeLast() and afterLast() methods are handy for parsing things like paths and filenames.
| Constructor Summary | |
protected |
StringValue(java.lang.String text)
Private constructor to force use of static factory methods. |
protected |
StringValue(java.lang.String text,
java.util.Locale locale)
Private constructor to force use of static factory methods. |
| Method Summary | |
java.lang.String |
afterFirst(char c)
Gets the substring after the first occurence given char. |
java.lang.String |
afterLast(char c)
Gets the substring after the last occurence given char. |
java.lang.String |
beforeFirst(char c)
Gets the substring before the first occurence given char. |
java.lang.String |
beforeLast(char c)
Gets the substring before the last occurence given char. |
static StringValue |
repeat(int times,
char c)
|
static StringValue |
repeat(int times,
java.lang.String s)
|
java.lang.String |
replaceAll(java.lang.String searchFor,
java.lang.String replaceWith)
Replaces on this text. |
java.lang.Object |
to(java.lang.Class type)
Converts this StringValue to a given type. |
boolean |
toBoolean()
Convert this text to a boolean. |
boolean |
toBoolean(boolean defaultValue)
Convert to primitive types, returning default value if text is null. |
java.lang.Boolean |
toBooleanObject()
Convert this text to a boolean and convert unchecked NumberFormatExceptions to checked. |
char |
toChar()
Convert this text to a char. |
char |
toChar(char defaultValue)
Convert to primitive types, returning default value if text is null. |
java.lang.Character |
toCharacter()
Convert this text to a Character and convert unchecked NumberFormatExceptions to checked. |
double |
toDouble()
Convert this text to a double and convert unchecked NumberFormatExceptions to checked. |
double |
toDouble(double defaultValue)
Convert to primitive types, returning default value if text is null. |
java.lang.Double |
toDoubleObject()
Convert this text to a Double and convert unchecked NumberFormatExceptions to checked. |
Duration |
toDuration()
Convert this text to a Duration instance and convert unchecked NumberFormatExceptions to checked. |
Duration |
toDuration(Duration defaultValue)
Convert to primitive types, returning default value if text is null. |
int |
toInt()
Convert this text to an int and convert unchecked NumberFormatExceptions to checked. |
int |
toInt(int defaultValue)
Convert to primitive types, returning default value if text is null. |
java.lang.Integer |
toInteger()
Convert this text to an Integer and convert unchecked NumberFormatExceptions to checked. |
long |
toLong()
Convert this text to a long and convert unchecked NumberFormatExceptions to checked. |
long |
toLong(long defaultValue)
Convert to primitive types, returning default value if text is null. |
java.lang.Long |
toLongObject()
Convert this text to a Long and convert unchecked NumberFormatExceptions to checked. |
java.lang.Boolean |
toOptionalBoolean()
Convert to object types, returning null if text is null. |
java.lang.Character |
toOptionalCharacter()
Convert to object types, returning null if text is null. |
java.lang.Double |
toOptionalDouble()
Convert to object types, returning null if text is null. |
Duration |
toOptionalDuration()
Convert to object types, returning null if text is null. |
java.lang.Integer |
toOptionalInteger()
Convert to object types, returning null if text is null. |
java.lang.Long |
toOptionalLong()
Convert to object types, returning null if text is null. |
java.lang.String |
toOptionalString()
Convert to object types, returning null if text is null. |
Time |
toOptionalTime()
Convert to object types, returning null if text is null. |
java.lang.String |
toString()
|
java.lang.String |
toString(java.lang.String defaultValue)
Convert to primitive types, returning default value if text is null. |
Time |
toTime()
Convert this text to a time instance and convert unchecked NumberFormatExceptions to checked. |
Time |
toTime(Time defaultValue)
Convert to primitive types, returning default value if text is null. |
static StringValue |
valueOf(double value)
Converts the given input to an instance of StringValue. |
static StringValue |
valueOf(double value,
int places,
java.util.Locale locale)
Converts the given input to an instance of StringValue. |
static StringValue |
valueOf(double value,
java.util.Locale locale)
Converts the given input to an instance of StringValue. |
static StringValue |
valueOf(java.lang.Object object)
Converts the given input to an instance of StringValue. |
static StringValue |
valueOf(java.lang.Object object,
java.util.Locale locale)
Converts the given input to an instance of StringValue. |
static StringValue |
valueOf(java.lang.String string)
Converts the given input to an instance of StringValue. |
static StringValue |
valueOf(java.lang.StringBuffer buffer)
Converts the given input to an instance of StringValue. |
static StringValue |
valueOf(java.lang.String string,
java.util.Locale locale)
Converts the given input to an instance of StringValue. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
protected StringValue(java.lang.String text)
text - The text for this string value
protected StringValue(java.lang.String text,
java.util.Locale locale)
text - The text for this string valuelocale - the locale for formatting and parsing| Method Detail |
public static StringValue repeat(int times,
char c)
times - Number of times to repeat characterc - Character to repeat
public static StringValue repeat(int times,
java.lang.String s)
times - Number of times to repeat strings - String to repeat
public static StringValue valueOf(double value)
value - Double precision value
public static StringValue valueOf(double value,
int places,
java.util.Locale locale)
value - Double precision valueplaces - Number of places after decimallocale - Locale to be used for formatting
public static StringValue valueOf(double value,
java.util.Locale locale)
value - Double precision valuelocale - Locale to be used for formatting
public static StringValue valueOf(java.lang.Object object)
object - An object
public static StringValue valueOf(java.lang.Object object,
java.util.Locale locale)
object - An objectlocale - Locale to be used for formatting
public static StringValue valueOf(java.lang.String string)
string - A string
public static StringValue valueOf(java.lang.String string,
java.util.Locale locale)
string - A stringlocale - Locale to be used for formatting
public static StringValue valueOf(java.lang.StringBuffer buffer)
buffer - A string buffer
public final java.lang.String afterFirst(char c)
c - char to scan for
public final java.lang.String afterLast(char c)
c - char to scan for
public final java.lang.String beforeFirst(char c)
c - char to scan for
public final java.lang.String beforeLast(char c)
c - char to scan for
public final java.lang.String replaceAll(java.lang.String searchFor,
java.lang.String replaceWith)
searchFor - What to search forreplaceWith - What to replace with
public final java.lang.Object to(java.lang.Class type)
throws StringValueConversionException
type - The type to convert to
StringValueConversionException
public final boolean toBoolean()
throws StringValueConversionException
StringValueConversionException
public final boolean toBoolean(boolean defaultValue)
throws StringValueConversionException
defaultValue - the default value to return of text is null
StringValueConversionException
public final java.lang.Boolean toBooleanObject()
throws StringValueConversionException
StringValueConversionException
public final char toChar()
throws StringValueConversionException
StringValueConversionException
public final char toChar(char defaultValue)
throws StringValueConversionException
defaultValue - the default value to return of text is null
StringValueConversionException
public final java.lang.Character toCharacter()
throws StringValueConversionException
StringValueConversionException
public final double toDouble()
throws StringValueConversionException
StringValueConversionException
public final double toDouble(double defaultValue)
throws StringValueConversionException
defaultValue - the default value to return of text is null
StringValueConversionException
public final java.lang.Double toDoubleObject()
throws StringValueConversionException
StringValueConversionException
public final Duration toDuration()
throws StringValueConversionException
StringValueConversionException
public final Duration toDuration(Duration defaultValue)
throws StringValueConversionException
defaultValue - the default value to return of text is null
StringValueConversionException
public final int toInt()
throws StringValueConversionException
StringValueConversionException
public final int toInt(int defaultValue)
throws StringValueConversionException
defaultValue - the default value to return of text is null
StringValueConversionException
public final java.lang.Integer toInteger()
throws StringValueConversionException
StringValueConversionException
public final long toLong()
throws StringValueConversionException
StringValueConversionException
public final long toLong(long defaultValue)
throws StringValueConversionException
defaultValue - the default value to return of text is null
StringValueConversionException
public final java.lang.Long toLongObject()
throws StringValueConversionException
StringValueConversionException
public final java.lang.Boolean toOptionalBoolean()
throws StringValueConversionException
StringValueConversionException
public final java.lang.Character toOptionalCharacter()
throws StringValueConversionException
StringValueConversionException
public final java.lang.Double toOptionalDouble()
throws StringValueConversionException
StringValueConversionException
public final Duration toOptionalDuration()
throws StringValueConversionException
StringValueConversionException
public final java.lang.Integer toOptionalInteger()
throws StringValueConversionException
StringValueConversionException
public final java.lang.Long toOptionalLong()
throws StringValueConversionException
StringValueConversionExceptionpublic final java.lang.String toOptionalString()
public final Time toOptionalTime()
throws StringValueConversionException
StringValueConversionExceptionpublic final java.lang.String toString()
public final java.lang.String toString(java.lang.String defaultValue)
defaultValue - the default value to return of text is null
public final Time toTime()
throws StringValueConversionException
StringValueConversionException
public final Time toTime(Time defaultValue)
throws StringValueConversionException
defaultValue - the default value to return of text is null
StringValueConversionException
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||