Errai 3.0.1-SNAPSHOT

org.jboss.errai.jpa.client.local
Class JsonUtil

java.lang.Object
  extended by org.jboss.errai.jpa.client.local.JsonUtil

public class JsonUtil
extends Object

JSON-related operations required by Errai JPA.

Author:
Jonathan Fuerth

Constructor Summary
JsonUtil()
           
 
Method Summary
static
<Y> Y
basicValueFromJson(com.google.gwt.json.client.JSONValue jsonValue, Class<Y> expectedType)
          Converts the given JSONValue to the Java value of the given type.
static com.google.gwt.json.client.JSONValue basicValueToJson(Object value)
          Returns a JSONValue that represents the given value, which must be one of the JPA2 basic types.
static boolean equals(com.google.gwt.json.client.JSONValue v1, com.google.gwt.json.client.JSONValue v2)
          Compares two JSON values for equality by value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsonUtil

public JsonUtil()
Method Detail

basicValueToJson

public static com.google.gwt.json.client.JSONValue basicValueToJson(Object value)
Returns a JSONValue that represents the given value, which must be one of the JPA2 basic types. JPA2 basic types are Java primitive types, wrappers of the primitive types, java.lang.String, java.math.BigInteger, java.math.BigDecimal, java.util.Date, java.sql.Date, java.sql.Time, java.sql.Timestamp, byte[], Byte[], char[], Character[], and enums. Note that JPA2 also specifies java.util.Calendar and all serializable types as basic types, but these are not supported because they are not GWT-compatible.

Parameters:
value - The value to convert to JSON. Must be a JPA2 basic type. Null is permitted.
Returns:
The JSON representation of value. Never null (but might be an instance of JSONNull).

basicValueFromJson

public static <Y> Y basicValueFromJson(com.google.gwt.json.client.JSONValue jsonValue,
                                       Class<Y> expectedType)
Converts the given JSONValue to the Java value of the given type. No type coercion is performed; the given JSONValue and Class must correspond with what would have been produced by basicValueToJson(Object).

Parameters:
jsonValue - The value to convert from JSON. Not null.
expectedType - The Java type to convert to. Not null.
Returns:
The JSON representation of value. Will be null if the given JSONValue is a JSONNull.

equals

public static boolean equals(com.google.gwt.json.client.JSONValue v1,
                             com.google.gwt.json.client.JSONValue v2)
Compares two JSON values for equality by value.

If the actual type of v1 and v2 differs, the values are considered unequal (that is, type coercion is never performed when doing a comparison).

This method returns true under the following conditions:

Parameters:
v1 - One of the values to compare. Must not be null (but JSONNull is permitted).
v2 - The other value to compare. Must not be null (but JSONNull is permitted).
Returns:
true if v1 and v2 have identical values according to the above criteria.

Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.