Package org.eclipse.rap.rwt.remote
Class JsonMapping
java.lang.Object
org.eclipse.rap.rwt.remote.JsonMapping
Provides utility methods that map common SWT types to their JSON representations used in the RAP
protocol and back.
- Since:
- 2.3
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic Point
Returns an instance of Point for the given JSON representation.static Rectangle
readRectangle
(JsonValue value) Returns an instance of Rectangle for the given JSON representation.static RGB
Returns an instance of RGB for the given JSON representation.static JsonValue
Returns the JSON representation for the given Color.static JsonValue
Returns the JSON representation for the given Color with an additional alpha (opacity) value.static JsonValue
Returns the JSON representation for the given Cursor.static JsonValue
Returns the JSON representation for the given Font.static JsonValue
Returns the JSON representation for the given FontData.static JsonValue
Returns the JSON representation for the given Image.static JsonValue
Returns the JSON representation for the given Point.static JsonValue
Returns the JSON representation for the given array Point.static JsonValue
Returns the JSON representation for the given Rectangle.static JsonValue
Returns the JSON representation for the given RGB.static JsonValue
Returns the JSON representation for the given RGB with an additional alpha (opacity) value.static JsonValue
Returns the JSON representation for the given Widget.static JsonValue
Returns the JSON representation for the given array of widgets.
-
Method Details
-
toJson
Returns the JSON representation for the given Widget. This method acceptsnull
, which will be mapped toJsonValue.NULL
. Disposed widgets cannot be mapped to JSON.- Parameters:
widget
- the widget to encode ornull
, must not be disposed- Returns:
- a JSON value that represents the given widget
-
toJson
Returns the JSON representation for the given array of widgets. The array must not contain disposed widgets, as those cannot be mapped to JSON.- Parameters:
widgets
- the array of widgets to encode, must not benull
- Returns:
- a JSON value that represents the given widget array
- Since:
- 3.1
-
toJson
Returns the JSON representation for the given Point. This method acceptsnull
, which will be mapped toJsonValue.NULL
.- Parameters:
point
- the Point to encode ornull
- Returns:
- a JSON value that represents the given point
-
toJson
Returns the JSON representation for the given array Point. This method acceptsnull
, which will be mapped toJsonValue.NULL
.- Parameters:
points
- the array Point to encode ornull
- Returns:
- a JSON value that represents the given point
- Since:
- 3.13
-
toJson
Returns the JSON representation for the given Rectangle. This method acceptsnull
, which will be mapped toJsonValue.NULL
.- Parameters:
rect
- the Rectangle to encode ornull
- Returns:
- a JSON value that represents the given rectangle
-
toJson
Returns the JSON representation for the given Color. This method acceptsnull
, which will be mapped toJsonValue.NULL
. Disposed colors cannot be mapped to JSON.- Parameters:
color
- the Color to encode ornull
, must not be disposed- Returns:
- a JSON value that represents the given color
-
toJson
Returns the JSON representation for the given Color with an additional alpha (opacity) value. This method acceptsnull
, which will be mapped toJsonValue.NULL
regardless of the given alpha value. Disposed colors cannot be mapped to JSON.- Parameters:
color
- the Color to encode ornull
, must not be disposedalpha
- a value in the range of 0 (transparent) to 255 (opaque)- Returns:
- a JSON value that represents the given color
-
toJson
Returns the JSON representation for the given RGB. This method acceptsnull
, which will be mapped toJsonValue.NULL
.- Parameters:
rgb
- the Color to encode ornull
- Returns:
- a JSON value that represents the given color
-
toJson
Returns the JSON representation for the given RGB with an additional alpha (opacity) value. This method acceptsnull
, which will be mapped toJsonValue.NULL
regardless of the given alpha value.- Parameters:
rgb
- the RGB to encode ornull
alpha
- a value in the range of 0 (transparent) to 255 (opaque)- Returns:
- a JSON value that represents the given rgb
-
toJson
Returns the JSON representation for the given Image. This method acceptsnull
, which will be mapped toJsonValue.NULL
. Disposed images cannot be mapped to JSON.- Parameters:
image
- the Image to encode ornull
, must not be disposed- Returns:
- a JSON value that represents the given rgb
-
toJson
Returns the JSON representation for the given Font. This method acceptsnull
, which will be mapped toJsonValue.NULL
. Disposed fonts cannot be mapped to JSON.- Parameters:
font
- the Font to encode ornull
, must not be disposed- Returns:
- a JSON value that represents the given font
-
toJson
Returns the JSON representation for the given FontData. This method acceptsnull
, which will be mapped toJsonValue.NULL
.- Parameters:
fontData
- the FontData to encode ornull
- Returns:
- a JSON value that represents the given font data
-
toJson
Returns the JSON representation for the given Cursor. This method acceptsnull
, which will be mapped toJsonValue.NULL
.- Parameters:
cursor
- the Cursor to encode ornull
- Returns:
- a JSON value that represents the given cursor
- Since:
- 3.1
-
readPoint
Returns an instance of Point for the given JSON representation. This method returnsnull
if the given JSON value isJsonValue.NULL
.- Parameters:
value
- a JsonValue that represents a point orJsonValue.NULL
- Returns:
- a Point that corresponds to the given JSON value or
null
-
readRectangle
Returns an instance of Rectangle for the given JSON representation. This method returnsnull
if the given JSON value isJsonValue.NULL
.- Parameters:
value
- a JsonValue that represents a rectangle orJsonValue.NULL
- Returns:
- a Rectangle that corresponds to the given JSON value or
null
-
readRGB
Returns an instance of RGB for the given JSON representation. This method returnsnull
if the given JSON value isJsonValue.NULL
.- Parameters:
value
- a JsonValue that represents a color orJsonValue.NULL
- Returns:
- an RGB that corresponds to the given JSON value or
null
-