Class JsHelper
- java.lang.Object
- 
- org.pepstock.charba.client.commons.JsHelper
 
- 
 public final class JsHelper extends Object This is a singleton wrapper for Java native object which is wrapping a CHARBA java script object implementation with some utilities to act on java script objects.- Author:
- Andrea "Stock" Stocchero
 
- 
- 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Tcast(Object object)Performs unchecked cast to a type.
 Using this method can have an incorrect type of the object to the rest of the system which will result in hard to debug problems.MutationObserverInitcreateMutationObserverInit()Creates new instance of observer initialization options.static JsHelperget()Singleton object to get the helper instancebooleangetBooleanProperty(Key key, NativeObject nativeObject)Returns the property value from java script object, when it is stored as boolean.intgetIntegerProperty(Key key, NativeObject nativeObject)Returns the property value from java script object, when it is stored as integer.StringgetStringProperty(Key key, NativeObject nativeObject)Returns the property value from java script object, when the ID is stored as string.booleanhas(Object object, String key)Returns a boolean indicating whether the object has the specified property as its own property.booleanisCanvas(NativeObjectContainer object, Key key)Returnstrueif the object is aCanvas.booleanisCanvasGradient(Object object)Returnstrueif the object is aCanvasGradientItem.booleanisCanvasPattern(Object object)Returnstrueif the object is aCanvasPatternItem.booleanisImage(NativeObjectContainer object, Key key)Returnstrueif the object is aImg.<T> CallbackProxy<T>newCallbackProxy()Creates new proxy for callback which will passthisenvironment of java script as first argument of callback method.ObjectTypetypeOf(Object object)Returns the java script object type of object.ObjectTypetypeOf(Object object, String key)Returns the java script object type of a property.
 
- 
- 
- 
Method Detail- 
getpublic static JsHelper get() Singleton object to get the helper instance- Returns:
- helper instance.
 
 - 
castpublic <T> T cast(Object object) Performs unchecked cast to a type.
 Using this method can have an incorrect type of the object to the rest of the system which will result in hard to debug problems.- Type Parameters:
- T- type of the result
- Parameters:
- object- object which must be cast
- Returns:
- the object cast to another type
 
 - 
createMutationObserverInitpublic MutationObserverInit createMutationObserverInit() Creates new instance of observer initialization options.- Returns:
- new instance of observer initialization options
 
 - 
haspublic boolean has(Object object, String key) Returns a boolean indicating whether the object has the specified property as its own property.- Parameters:
- object- the object on which to search the property.
- key- the string name of the property to test.
- Returns:
- boolean indicating whether or not the object has the specified property as own property.
 
 - 
typeOfpublic ObjectType typeOf(Object object) Returns the java script object type of object.- Parameters:
- object- the object to get type.
- Returns:
- the object type
 
 - 
typeOfpublic ObjectType typeOf(Object object, String key) Returns the java script object type of a property.- Parameters:
- object- the object on which to search the property.
- key- the string name of the property to test.
- Returns:
- the object type
 
 - 
newCallbackProxypublic <T> CallbackProxy<T> newCallbackProxy() Creates new proxy for callback which will passthisenvironment of java script as first argument of callback method.- Type Parameters:
- T- type of callback wrapped by proxy
- Returns:
- new proxy for callback.
 
 - 
isCanvasPatternpublic boolean isCanvasPattern(Object object) Returnstrueif the object is aCanvasPatternItem.- Parameters:
- object- the object instance on which to check
- Returns:
- trueif the object is a- CanvasPatternItem
 
 - 
isCanvasGradientpublic boolean isCanvasGradient(Object object) Returnstrueif the object is aCanvasGradientItem.- Parameters:
- object- the object instance on which to check
- Returns:
- trueif the object is a- CanvasGradientItem
 
 - 
isCanvaspublic boolean isCanvas(NativeObjectContainer object, Key key) Returnstrueif the object is aCanvas.- Parameters:
- object- the object instance on which to check
- key- the string name of the property to test.
- Returns:
- trueif the object is a- Canvas
 
 - 
isImagepublic boolean isImage(NativeObjectContainer object, Key key) Returnstrueif the object is aImg.- Parameters:
- object- the object instance on which to check
- key- the string name of the property to test.
- Returns:
- trueif the object is a- Img
 
 - 
getIntegerPropertypublic int getIntegerProperty(Key key, NativeObject nativeObject) Returns the property value from java script object, when it is stored as integer.- Parameters:
- key- the key to search inside the object
- nativeObject- java script object
- Returns:
- the property value or Undefined.INTEGERif not exist
 
 - 
getBooleanPropertypublic boolean getBooleanProperty(Key key, NativeObject nativeObject) Returns the property value from java script object, when it is stored as boolean.- Parameters:
- key- the key to search inside the object
- nativeObject- java script object
- Returns:
- the property value or Undefined.BOOLEANif not exist
 
 - 
getStringPropertypublic String getStringProperty(Key key, NativeObject nativeObject) Returns the property value from java script object, when the ID is stored as string.- Parameters:
- key- the key to search inside the object
- nativeObject- java script object
- Returns:
- the property value or Undefined.STRINGif not exist
 
 
- 
 
-