|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.jface.resource.StringConverter
Helper class for converting various data types to and from strings. Supported types include:
boolean
int
long
float
double
org.eclipse.swt.graphics.Point
org.eclipse.swt.graphics.Rectangle
org.eclipse.swt.graphics.RGB
org.eclipse.swt.graphics.FontData
All methods declared on this class are static. This class cannot be instantiated.
Method Summary | |
static String[] |
asArray(String value)
Breaks out space-separated words into an array of words. |
static String[] |
asArray(String value,
String[] dflt)
/** Breaks out space-separated words into an array of words. |
static boolean |
asBoolean(String value)
Converts the given value into a boolean. |
static boolean |
asBoolean(String value,
boolean dflt)
Converts the given value into a boolean. |
static String |
asDisplayableString(FontData value)
Converts a font data object to a string representation for display. |
static double |
asDouble(String value)
Converts the given value into a double. |
static double |
asDouble(String value,
double dflt)
Converts the given value into a double. |
static float |
asFloat(String value)
Converts the given value into a float. |
static float |
asFloat(String value,
float dflt)
Converts the given value into a float. |
static FontData |
asFontData(String value)
Converts the given value into an SWT font data object. |
static FontData |
asFontData(String value,
FontData dflt)
Converts the given value into an SWT font data object. |
static int |
asInt(String value)
Converts the given value into an int. |
static int |
asInt(String value,
int dflt)
Converts the given value into an int. |
static long |
asLong(String value)
Converts the given value into a long. |
static long |
asLong(String value,
long dflt)
Converts the given value into a long. |
static Point |
asPoint(String value)
Converts the given value into an SWT point. |
static Point |
asPoint(String value,
Point dflt)
Converts the given value into an SWT point. |
static Rectangle |
asRectangle(String value)
Converts the given value into an SWT rectangle. |
static Rectangle |
asRectangle(String value,
Rectangle dflt)
Converts the given value into an SWT rectangle. |
static RGB |
asRGB(String value)
Converts the given value into an SWT RGB color value. |
static RGB |
asRGB(String value,
RGB dflt)
Converts the given value into an SWT RGB color value. |
static String |
asString(boolean value)
Converts the given boolean value to a string. |
static String |
asString(Boolean value)
Converts the given boolean object to a string. |
static String |
asString(double value)
Converts the given double value to a string. |
static String |
asString(Double value)
Converts the given double object to a string. |
static String |
asString(float value)
Converts the given float value to a string. |
static String |
asString(Float value)
Converts the given float object to a string. |
static String |
asString(FontData value)
Converts a font data object to a string. |
static String |
asString(int value)
Converts the given int value to a string. |
static String |
asString(Integer value)
Converts the given integer object to a string. |
static String |
asString(long value)
Converts the given long value to a string. |
static String |
asString(Long value)
Converts the given long object to a string. |
static String |
asString(Point value)
Converts the given SWT point object to a string. |
static String |
asString(Rectangle value)
Converts the given SWT rectangle object to a string. |
static String |
asString(RGB value)
Converts the given SWT RGB color value object to a string. |
static String |
removeWhiteSpaces(String s)
Returns the given string with all whitespace characters removed. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static String[] asArray(String value) throws DataFormatException
"no comment"
into an array
a[0]="no"
and a[1]= "comment"
.
value
- the string to be converted
DataFormatException
public static String[] asArray(String value, String[] dflt)
"no comment"
into an array
a[0]="no"
and a[1]= "comment"
.
Returns the given default value if the value cannot be parsed.
value
- the string to be converteddflt
- the default value
public static boolean asBoolean(String value) throws DataFormatException
Valid representations of true
include the strings
"t
", "true
", or equivalent in mixed
or upper case.
Similarly, valid representations of false
include the strings
"f
", "false
", or equivalent in mixed
or upper case.
value
- the value to be converted
DataFormatException
- if the given value does not represent
a booleanpublic static boolean asBoolean(String value, boolean dflt)
value
- the value to be converteddflt
- the default value
public static double asDouble(String value) throws DataFormatException
value
- the value to be converted
DataFormatException
- if the given value does not represent
a doublepublic static double asDouble(String value, double dflt)
value
- the value to be converteddflt
- the default value
public static float asFloat(String value) throws DataFormatException
value
- the value to be converted
DataFormatException
- if the given value does not represent
a floatpublic static float asFloat(String value, float dflt)
value
- the value to be converteddflt
- the default value
public static FontData asFontData(String value) throws DataFormatException
A valid font data representation is a string of the form
where
is the name of a font,
is a font style (one of
"regular"
, "bold"
,
"italic"
, or "bold italic"
)
and
is an integer representing the
font height. Example: Times New Roman-bold-36
.
value
- the value to be converted
DataFormatException
- if the given value does not represent
font datapublic static FontData asFontData(String value, FontData dflt)
value
- the value to be converteddflt
- the default value
public static int asInt(String value) throws DataFormatException
value
- the value to be converted
DataFormatException
- if the given value does not represent
an intpublic static int asInt(String value, int dflt)
value
- the value to be converteddflt
- the default value
public static long asLong(String value) throws DataFormatException
value
- the value to be converted
DataFormatException
- if the given value does not represent
a longpublic static long asLong(String value, long dflt)
value
- the value to be converteddflt
- the default value
public static Point asPoint(String value) throws DataFormatException
A valid point representation is a string of the form
where
and
are valid ints.
value
- the value to be converted
DataFormatException
- if the given value does not represent
a pointpublic static Point asPoint(String value, Point dflt)
value
- the value to be converteddflt
- the default value
public static Rectangle asRectangle(String value) throws DataFormatException
A valid rectangle representation is a string of the form
where
,
,
, and
are valid ints.
value
- the value to be converted
DataFormatException
- if the given value does not represent
a rectanglepublic static Rectangle asRectangle(String value, Rectangle dflt)
value
- the value to be converteddflt
- the default value
public static RGB asRGB(String value) throws DataFormatException
A valid RGB color value representation is a string of the form
,
,
are valid ints.
value
- the value to be converted
DataFormatException
- if the given value does not represent
an RGB color valuepublic static RGB asRGB(String value, RGB dflt)
value
- the value to be converteddflt
- the default value
public static String asString(double value)
String.valueOf(value)
.
value
- the double value
public static String asString(float value)
String.valueOf(value)
.
value
- the float value
public static String asString(int value)
String.valueOf(value)
.
value
- the int value
public static String asString(long value)
String.valueOf(value)
.
value
- the long value
public static String asString(Boolean value)
String.valueOf(value.booleanValue())
.
value
- the boolean object
public static String asString(Double value)
String.valueOf(value.doubleValue())
.
value
- the double object
public static String asString(Float value)
String.valueOf(value.floatValue())
.
value
- the float object
public static String asString(Integer value)
String.valueOf(value.intValue())
.
value
- the integer object
public static String asString(Long value)
String.valueOf(value.longValue())
.
value
- the long object
public static String asString(FontData value)
value
- The font data.
public static String asString(Point value)
The string representation of a point has the form
where
and
are string representations of integers.
value
- the point object
public static String asString(Rectangle value)
The string representation of a rectangle has the form
where
,
,
, and
are string representations of integers.
value
- the rectangle object
public static String asString(RGB value)
The string representation of an RGB color value has the form
,
,
are string representations of integers.
value
- the RGB color value object
public static String asString(boolean value)
String.valueOf(value)
.
value
- the boolean value
public static String removeWhiteSpaces(String s)
All characters that have codes less than or equal to '\u0020'
(the space character) are considered to be a white space.
s
- the source string
public static String asDisplayableString(FontData value)
value
- The font data.
|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |