Class StringConverter
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
Modifier and TypeMethodDescriptionstatic String[]
Breaks out space-separated words into an array of words.static String[]
/** Breaks out space-separated words into an array of words.static boolean
Converts the given value into a boolean.static boolean
Converts the given value into a boolean.static String
asDisplayableString
(FontData value) Deprecated.use asString(FontData)static double
Converts the given value into a double.static double
Converts the given value into a double.static float
Converts the given value into a float.static float
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 FontData[]
asFontDataArray
(String value) Convert the given value into an array of SWT font data objects.static int
Converts the given value into an int.static int
Converts the given value into an int.static long
Converts the given value into a long.static long
Converts the given value into a long.static Point
Converts the given value into an SWT point.static Point
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
Converts the given value into an SWT RGB color value.static RGB
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
(double value) Converts the given double value to a string.static String
asString
(float value) Converts the given float value to a string.static String
asString
(int value) Converts the given int value to a string.static String
asString
(long value) Converts the given long value to a string.static String
Converts the given boolean object to a string.static String
Converts the given double object to a string.static String
Converts the given float object to a string.static String
Converts the given integer object to a string.static String
Converts the given long object to a string.static String
Converts a font data object to a string.static String
Converts a font data array to a string.static String
Converts the given SWT point object to a string.static String
Converts the given SWT rectangle object to a string.static String
Converts the given SWT RGB color value object to a string.static String
Returns the given string with all whitespace characters removed.
-
Method Details
-
asArray
Breaks out space-separated words into an array of words. For example:"no comment"
into an arraya[0]="no"
anda[1]= "comment"
.- Parameters:
value
- the string to be converted- Returns:
- the list of words
- Throws:
DataFormatException
- thrown if request string could not seperated
-
asArray
/** Breaks out space-separated words into an array of words. For example:"no comment"
into an arraya[0]="no"
anda[1]= "comment"
. Returns the given default value if the value cannot be parsed.- Parameters:
value
- the string to be converteddflt
- the default value- Returns:
- the list of words, or the default value
-
asBoolean
Converts the given value into a boolean. This method fails if the value does not represent a boolean.Valid representations of
true
include the strings "t
", "true
", or equivalent in mixed or upper case. Similarly, valid representations offalse
include the strings "f
", "false
", or equivalent in mixed or upper case.- Parameters:
value
- the value to be converted- Returns:
- the value as a boolean
- Throws:
DataFormatException
- if the given value does not represent a boolean
-
asBoolean
Converts the given value into a boolean. Returns the given default value if the value does not represent a boolean.- Parameters:
value
- the value to be converteddflt
- the default value- Returns:
- the value as a boolean, or the default value
-
asDouble
Converts the given value into a double. This method fails if the value does not represent a double.- Parameters:
value
- the value to be converted- Returns:
- the value as a double
- Throws:
DataFormatException
- if the given value does not represent a double
-
asDouble
Converts the given value into a double. Returns the given default value if the value does not represent a double.- Parameters:
value
- the value to be converteddflt
- the default value- Returns:
- the value as a double, or the default value
-
asFloat
Converts the given value into a float. This method fails if the value does not represent a float.- Parameters:
value
- the value to be converted- Returns:
- the value as a float
- Throws:
DataFormatException
- if the given value does not represent a float
-
asFloat
Converts the given value into a float. Returns the given default value if the value does not represent a float.- Parameters:
value
- the value to be converteddflt
- the default value- Returns:
- the value as a float, or the default value
-
asFontData
Converts the given value into an SWT font data object. This method fails if the value does not represent font data.A valid font data representation is a string of the form
fontname-style-height
wherefontname
is the name of a font,style
is a font style (one of"regular"
,"bold"
,"italic"
, or"bold italic"
) andheight
is an integer representing the font height. Example:Times New Roman-bold-36
.- Parameters:
value
- the value to be converted- Returns:
- the value as font data
- Throws:
DataFormatException
- if the given value does not represent font data
-
asFontDataArray
Convert the given value into an array of SWT font data objects.- Parameters:
value
- the font list string- Returns:
- the value as a font list
- Since:
- 3.0
-
asFontData
Converts the given value into an SWT font data object. Returns the given default value if the value does not represent a font data object.- Parameters:
value
- the value to be converteddflt
- the default value- Returns:
- the value as a font data object, or the default value
-
asInt
Converts the given value into an int. This method fails if the value does not represent an int.- Parameters:
value
- the value to be converted- Returns:
- the value as an int
- Throws:
DataFormatException
- if the given value does not represent an int
-
asInt
Converts the given value into an int. Returns the given default value if the value does not represent an int.- Parameters:
value
- the value to be converteddflt
- the default value- Returns:
- the value as an int, or the default value
-
asLong
Converts the given value into a long. This method fails if the value does not represent a long.- Parameters:
value
- the value to be converted- Returns:
- the value as a long
- Throws:
DataFormatException
- if the given value does not represent a long
-
asLong
Converts the given value into a long. Returns the given default value if the value does not represent a long.- Parameters:
value
- the value to be converteddflt
- the default value- Returns:
- the value as a long, or the default value
-
asPoint
Converts the given value into an SWT point. This method fails if the value does not represent a point.A valid point representation is a string of the form
x,y
wherex
andy
are valid ints.- Parameters:
value
- the value to be converted- Returns:
- the value as a point
- Throws:
DataFormatException
- if the given value does not represent a point
-
asPoint
Converts the given value into an SWT point. Returns the given default value if the value does not represent a point.- Parameters:
value
- the value to be converteddflt
- the default value- Returns:
- the value as a point, or the default value
-
asRectangle
Converts the given value into an SWT rectangle. This method fails if the value does not represent a rectangle.A valid rectangle representation is a string of the form
x,y,width,height
wherex
,y
,width
, andheight
are valid ints.- Parameters:
value
- the value to be converted- Returns:
- the value as a rectangle
- Throws:
DataFormatException
- if the given value does not represent a rectangle
-
asRectangle
Converts the given value into an SWT rectangle. Returns the given default value if the value does not represent a rectangle.- Parameters:
value
- the value to be converteddflt
- the default value- Returns:
- the value as a rectangle, or the default value
-
asRGB
Converts the given value into an SWT RGB color value. This method fails if the value does not represent an RGB color value.A valid RGB color value representation is a string of the form
red,green,blue
wherered,green
andblue
are valid ints.- Parameters:
value
- the value to be converted- Returns:
- the value as an RGB color value
- Throws:
DataFormatException
- if the given value does not represent an RGB color value
-
asRGB
Converts the given value into an SWT RGB color value. Returns the given default value if the value does not represent an RGB color value.- Parameters:
value
- the value to be converteddflt
- the default value- Returns:
- the value as a RGB color value, or the default value
-
asString
Converts the given double value to a string. Equivalent toString.valueOf(value)
.- Parameters:
value
- the double value- Returns:
- the string representing the given double
-
asString
Converts the given float value to a string. Equivalent toString.valueOf(value)
.- Parameters:
value
- the float value- Returns:
- the string representing the given float
-
asString
Converts the given int value to a string. Equivalent toString.valueOf(value)
.- Parameters:
value
- the int value- Returns:
- the string representing the given int
-
asString
Converts the given long value to a string. Equivalent toString.valueOf(value)
.- Parameters:
value
- the long value- Returns:
- the string representing the given long
-
asString
Converts the given boolean object to a string. Equivalent toString.valueOf(value.booleanValue())
.- Parameters:
value
- the boolean object- Returns:
- the string representing the given boolean value
-
asString
Converts the given double object to a string. Equivalent toString.valueOf(value.doubleValue())
.- Parameters:
value
- the double object- Returns:
- the string representing the given double value
-
asString
Converts the given float object to a string. Equivalent toString.valueOf(value.floatValue())
.- Parameters:
value
- the float object- Returns:
- the string representing the given float value
-
asString
Converts the given integer object to a string. Equivalent toString.valueOf(value.intValue())
.- Parameters:
value
- the integer object- Returns:
- the string representing the given integer value
-
asString
Converts the given long object to a string. Equivalent toString.valueOf(value.longValue())
.- Parameters:
value
- the long object- Returns:
- the string representing the given long value
-
asString
Converts a font data array to a string. The string representation is that of asString(FontData) seperated by ';'- Parameters:
value
- The font data.- Returns:
- The string representation of the font data arra.
- Since:
- 3.0
-
asString
Converts a font data object to a string. The string representation is "font name-style-height" (for example "Times New Roman-bold-36").- Parameters:
value
- The font data.- Returns:
- The string representation of the font data object.
-
asString
Converts the given SWT point object to a string.The string representation of a point has the form
x,y
wherex
andy
are string representations of integers.- Parameters:
value
- the point object- Returns:
- the string representing the given point
-
asString
Converts the given SWT rectangle object to a string.The string representation of a rectangle has the form
x,y,width,height
wherex
,y
,width
, andheight
are string representations of integers.- Parameters:
value
- the rectangle object- Returns:
- the string representing the given rectangle
-
asString
Converts the given SWT RGB color value object to a string.The string representation of an RGB color value has the form
red,green,blue
wherered,green
andblue
are string representations of integers.- Parameters:
value
- the RGB color value object- Returns:
- the string representing the given RGB color value
-
asString
Converts the given boolean value to a string. Equivalent toString.valueOf(value)
.- Parameters:
value
- the boolean value- Returns:
- the string representing the given boolean
-
removeWhiteSpaces
Returns the given string with all whitespace characters removed.All characters that have codes less than or equal to
'\u0020'
(the space character) are considered to be a white space.- Parameters:
s
- the source string- Returns:
- the string with all whitespace characters removed
-
asDisplayableString
Deprecated.use asString(FontData)Converts a font data object to a string representation for display. The string representation is "font name-style-height" (for example "Times New Roman-bold-36").- Parameters:
value
- The font data.- Returns:
- The string representation of the font data object.
-