org.cruxframework.crux.core.client.utils
Class JsUtils

java.lang.Object
  extended by org.cruxframework.crux.core.client.utils.JsUtils

public class JsUtils
extends Object

Author:
Thiago da Rosa de Bustamante

Constructor Summary
JsUtils()
           
 
Method Summary
static void copyValues(com.google.gwt.core.client.JsArrayMixed input, com.google.gwt.core.client.JsArrayMixed output)
          Append all values contained in input array into the output array
static String escape(String input)
           
static com.google.gwt.core.client.JavaScriptObject fromJSONValue(com.google.gwt.json.client.JSONValue jsonValue)
          Extract the associated native javascript object from the given json object
static
<T extends com.google.gwt.core.client.JavaScriptObject>
T
fromJSONValue(String encodedObject)
          Extract the associated native javascript object from the given json string
static
<T extends com.google.gwt.core.client.JavaScriptObject>
T
fromString(String encodedObject)
          Extract the associated native javascript object from the given json string
static boolean hasPropertyValue(com.google.gwt.core.client.JavaScriptObject object, String property)
          Return true if given object has a property with specified name.
static boolean isArray(com.google.gwt.core.client.JavaScriptObject obj)
          Check if the given native object represents an array
static boolean readBooleanPropertyValue(com.google.gwt.core.client.JavaScriptObject object, String property)
          Read properties from native javascript objects.
static double readDoublePropertyValue(com.google.gwt.core.client.JavaScriptObject object, String property)
          Read properties from native javascript objects.
static int readIntPropertyValue(com.google.gwt.core.client.JavaScriptObject object, String property)
          Read properties from native javascript objects.
static com.google.gwt.core.client.JavaScriptObject readObjectPropertyValue(com.google.gwt.core.client.JavaScriptObject object, String property)
          Read properties from native javascript objects.
static void readPropertyValue(com.google.gwt.core.client.JavaScriptObject object, String property, com.google.gwt.core.client.JsArrayMixed output)
          Read properties from native javascript objects.
static void readPropertyValue(com.google.gwt.core.client.JavaScriptObject object, String property, com.google.gwt.core.client.JsArrayMixed output, boolean includeNull)
          Read properties from native javascript objects.
static String readStringPropertyValue(com.google.gwt.core.client.JavaScriptObject object, String property)
          Read properties from native javascript objects.
static String[] toArray(com.google.gwt.core.client.JsArrayString jSArray)
           
static FastList<String> toFastList(com.google.gwt.core.client.JsArrayString jSArray)
           
static com.google.gwt.core.client.JsArrayString toJsArray(List<String> list)
           
static com.google.gwt.core.client.JsArrayString toJsArray(String[] args)
           
static com.google.gwt.json.client.JSONValue toJSONValue(com.google.gwt.core.client.JavaScriptObject object)
          Create a JSONValue Object from a native javascript object
static List<String> toList(com.google.gwt.core.client.JsArrayString jSArray)
           
static String unescape(String input)
           
static void writePropertyValue(com.google.gwt.core.client.JavaScriptObject object, String property, boolean input)
          Write property to native javascript objects.
static void writePropertyValue(com.google.gwt.core.client.JavaScriptObject object, String property, double input)
          Write property to native javascript objects.
static void writePropertyValue(com.google.gwt.core.client.JavaScriptObject object, String property, com.google.gwt.core.client.JavaScriptObject input)
          Write property to native javascript objects.
static void writePropertyValue(com.google.gwt.core.client.JavaScriptObject object, String property, com.google.gwt.core.client.JsArrayMixed input, boolean extractArrayContent)
          Write property to native javascript objects.
static void writePropertyValue(com.google.gwt.core.client.JavaScriptObject object, String property, String input)
          Write property to native javascript objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsUtils

public JsUtils()
Method Detail

copyValues

public static void copyValues(com.google.gwt.core.client.JsArrayMixed input,
                              com.google.gwt.core.client.JsArrayMixed output)
Append all values contained in input array into the output array

Parameters:
in -
out -

toJSONValue

public static com.google.gwt.json.client.JSONValue toJSONValue(com.google.gwt.core.client.JavaScriptObject object)
Create a JSONValue Object from a native javascript object

Parameters:
object -
Returns:

fromString

public static <T extends com.google.gwt.core.client.JavaScriptObject> T fromString(String encodedObject)
Extract the associated native javascript object from the given json string

Parameters:
jsonValue -
Returns:

fromJSONValue

public static <T extends com.google.gwt.core.client.JavaScriptObject> T fromJSONValue(String encodedObject)
Extract the associated native javascript object from the given json string

Parameters:
jsonValue -
Returns:

fromJSONValue

public static com.google.gwt.core.client.JavaScriptObject fromJSONValue(com.google.gwt.json.client.JSONValue jsonValue)
Extract the associated native javascript object from the given json object

Parameters:
jsonValue -
Returns:

isArray

public static boolean isArray(com.google.gwt.core.client.JavaScriptObject obj)
Check if the given native object represents an array

Parameters:
obj -
Returns:

hasPropertyValue

public static boolean hasPropertyValue(com.google.gwt.core.client.JavaScriptObject object,
                                       String property)
Return true if given object has a property with specified name.

Parameters:
object - the Object where the property will be read from.
property - the name of the property. You can pass inner properties using dot notation (prop1.prop2)

readPropertyValue

public static void readPropertyValue(com.google.gwt.core.client.JavaScriptObject object,
                                     String property,
                                     com.google.gwt.core.client.JsArrayMixed output)
Read properties from native javascript objects.

Parameters:
object - the Object where the property will be read from.
property - the name of the property. You can pass inner properties using dot notation (prop1.prop2)
output - an array where the output will be written

readPropertyValue

public static void readPropertyValue(com.google.gwt.core.client.JavaScriptObject object,
                                     String property,
                                     com.google.gwt.core.client.JsArrayMixed output,
                                     boolean includeNull)
Read properties from native javascript objects.

Parameters:
object - the Object where the property will be read from.
property - the name of the property. You can pass inner properties using dot notation (prop1.prop2)
output - an array where the output will be written
includeNull - if true, includes null values on output array

readStringPropertyValue

public static String readStringPropertyValue(com.google.gwt.core.client.JavaScriptObject object,
                                             String property)
Read properties from native javascript objects.

Parameters:
object - the Object where the property will be read from.
property - the name of the property. You can pass inner properties using dot notation (prop1.prop2)

readIntPropertyValue

public static int readIntPropertyValue(com.google.gwt.core.client.JavaScriptObject object,
                                       String property)
Read properties from native javascript objects.

Parameters:
object - the Object where the property will be read from.
property - the name of the property. You can pass inner properties using dot notation (prop1.prop2)

readDoublePropertyValue

public static double readDoublePropertyValue(com.google.gwt.core.client.JavaScriptObject object,
                                             String property)
Read properties from native javascript objects.

Parameters:
object - the Object where the property will be read from.
property - the name of the property. You can pass inner properties using dot notation (prop1.prop2)

readBooleanPropertyValue

public static boolean readBooleanPropertyValue(com.google.gwt.core.client.JavaScriptObject object,
                                               String property)
Read properties from native javascript objects.

Parameters:
object - the Object where the property will be read from.
property - the name of the property. You can pass inner properties using dot notation (prop1.prop2)

readObjectPropertyValue

public static com.google.gwt.core.client.JavaScriptObject readObjectPropertyValue(com.google.gwt.core.client.JavaScriptObject object,
                                                                                  String property)
Read properties from native javascript objects.

Parameters:
object - the Object where the property will be read from.
property - the name of the property. You can pass inner properties using dot notation (prop1.prop2)

writePropertyValue

public static void writePropertyValue(com.google.gwt.core.client.JavaScriptObject object,
                                      String property,
                                      com.google.gwt.core.client.JsArrayMixed input,
                                      boolean extractArrayContent)
Write property to native javascript objects.

Parameters:
object - the Object where the property will be written.
property - the name of the property. You can pass inner properties using dot notation (prop1.prop2)
input - an array containing the property value.
extractArrayContent - It true, the first element from input array is used as property value.

writePropertyValue

public static void writePropertyValue(com.google.gwt.core.client.JavaScriptObject object,
                                      String property,
                                      String input)
Write property to native javascript objects.

Parameters:
object - the Object where the property will be written.
property - the name of the property. You can pass inner properties using dot notation (prop1.prop2)
input - the property value.

writePropertyValue

public static void writePropertyValue(com.google.gwt.core.client.JavaScriptObject object,
                                      String property,
                                      double input)
Write property to native javascript objects.

Parameters:
object - the Object where the property will be written.
property - the name of the property. You can pass inner properties using dot notation (prop1.prop2)
input - the property value.

writePropertyValue

public static void writePropertyValue(com.google.gwt.core.client.JavaScriptObject object,
                                      String property,
                                      boolean input)
Write property to native javascript objects.

Parameters:
object - the Object where the property will be written.
property - the name of the property. You can pass inner properties using dot notation (prop1.prop2)
input - the property value.

writePropertyValue

public static void writePropertyValue(com.google.gwt.core.client.JavaScriptObject object,
                                      String property,
                                      com.google.gwt.core.client.JavaScriptObject input)
Write property to native javascript objects.

Parameters:
object - the Object where the property will be written.
property - the name of the property. You can pass inner properties using dot notation (prop1.prop2)
input - the property value.

toArray

public static String[] toArray(com.google.gwt.core.client.JsArrayString jSArray)

toList

public static List<String> toList(com.google.gwt.core.client.JsArrayString jSArray)

toFastList

public static FastList<String> toFastList(com.google.gwt.core.client.JsArrayString jSArray)

toJsArray

public static com.google.gwt.core.client.JsArrayString toJsArray(List<String> list)

toJsArray

public static com.google.gwt.core.client.JsArrayString toJsArray(String[] args)

escape

public static String escape(String input)

unescape

public static String unescape(String input)


Copyright © 2014. All rights reserved.