Class StringConverter
booleanintlongfloatdoubleorg.eclipse.swt.graphics.Pointorg.eclipse.swt.graphics.Rectangleorg.eclipse.swt.graphics.RGBorg.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 booleanConverts the given value into a boolean.static booleanConverts the given value into a boolean.static StringasDisplayableString(FontData value) Deprecated.use asString(FontData)static doubleConverts the given value into a double.static doubleConverts the given value into a double.static floatConverts the given value into a float.static floatConverts the given value into a float.static FontDataasFontData(String value) Converts the given value into an SWT font data object.static FontDataasFontData(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 intConverts the given value into an int.static intConverts the given value into an int.static longConverts the given value into a long.static longConverts the given value into a long.static PointConverts the given value into an SWT point.static PointConverts the given value into an SWT point.static RectangleasRectangle(String value) Converts the given value into an SWT rectangle.static RectangleasRectangle(String value, Rectangle dflt) Converts the given value into an SWT rectangle.static RGBConverts the given value into an SWT RGB color value.static RGBConverts the given value into an SWT RGB color value.static StringasString(boolean value) Converts the given boolean value to a string.static StringasString(double value) Converts the given double value to a string.static StringasString(float value) Converts the given float value to a string.static StringasString(int value) Converts the given int value to a string.static StringasString(long value) Converts the given long value to a string.static StringConverts the given boolean object to a string.static StringConverts the given double object to a string.static StringConverts the given float object to a string.static StringConverts the given integer object to a string.static StringConverts the given long object to a string.static StringConverts a font data object to a string.static StringConverts a font data array to a string.static StringConverts the given SWT point object to a string.static StringConverts the given SWT rectangle object to a string.static StringConverts the given SWT RGB color value object to a string.static StringReturns 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
trueinclude the strings "t", "true", or equivalent in mixed or upper case. Similarly, valid representations offalseinclude 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-heightwherefontnameis the name of a font,styleis a font style (one of"regular","bold","italic", or"bold italic") andheightis 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,ywherexandyare 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,heightwherex,y,width, andheightare 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,bluewherered,greenandblueare 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,ywherexandyare 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,heightwherex,y,width, andheightare 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,bluewherered,greenandblueare 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.
-