org.appcelerator.kroll
Class KrollProxy

java.lang.Object
  extended by org.appcelerator.kroll.KrollProxy
All Implemented Interfaces:
android.os.Handler.Callback, KrollConvertable, OnEventListenerChange
Direct Known Subclasses:
ActivityProxy, IntentProxy, KrollModule, MenuItemProxy, MenuProxy, RProxy, ServiceProxy, Ti2DMatrix, TiAnimation, TiBlob, TiFile, TiViewProxy

@Kroll.proxy
public class KrollProxy
extends java.lang.Object
implements android.os.Handler.Callback, OnEventListenerChange, KrollConvertable


Nested Class Summary
 class KrollProxy.ThisMethod
           
 
Field Summary
protected  KrollProxyBinding binding
           
static java.lang.String BINDING_SUFFIX
           
protected  TiContext context
           
protected  KrollModule createdInModule
           
protected  TiContext creatingContext
           
protected  KrollDict creationDict
           
protected  KrollInvocation currentInvocation
           
protected  KrollEventManager eventManager
           
protected  KrollObject krollObject
           
protected  KrollProxyListener modelListener
           
protected static int MSG_LAST_ID
           
protected static int MSG_LISTENER_ADDED
           
protected static int MSG_LISTENER_REMOVED
           
protected static int MSG_MODEL_PROPERTIES_CHANGED
           
protected static int MSG_MODEL_PROPERTY_CHANGE
           
protected  KrollDict properties
           
static java.lang.String PROXY_ID_PREFIX
           
protected static java.util.HashMap<java.lang.Class<? extends KrollProxy>,KrollProxyBinding> proxyBindings
           
protected static java.util.concurrent.atomic.AtomicInteger proxyCounter
           
protected  java.lang.String proxyId
           
protected  android.os.Handler uiHandler
           
static java.lang.Object UNDEFINED
           
protected  java.util.concurrent.CountDownLatch waitForHandler
           
 
Constructor Summary
KrollProxy(TiContext context)
           
KrollProxy(TiContext context, boolean autoBind)
           
 
Method Summary
 int addEventListener(KrollInvocation invocation, java.lang.String eventName, java.lang.Object listener)
           
 void bindContextSpecific(KrollBridge bridge)
           
 java.lang.Object call(org.mozilla.javascript.Scriptable scope, java.lang.String name, java.lang.Object[] args)
           
protected  KrollDict createErrorResponse(int code, java.lang.String message)
           
 KrollInvocation createEventInvocation(java.lang.String eventName)
           
 void eventListenerAdded(java.lang.String eventName, int count, KrollProxy proxy)
           
 void eventListenerRemoved(java.lang.String eventName, int count, KrollProxy proxy)
           
 void extend(KrollDict options)
           
 boolean fireEvent(java.lang.String eventName, KrollDict data)
           
protected  void firePropertiesChanged(java.util.List<KrollPropertyChange> changes)
           
protected  void firePropertyChanged(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
           
 void fireSingleEvent(java.lang.String eventName, java.lang.Object listener, KrollDict data)
           
 java.lang.Object get(org.mozilla.javascript.Scriptable scope, java.lang.String name)
           
 java.lang.String getAPIName()
           
 KrollProxyBinding getBinding()
           
static KrollProxyBinding getBinding(java.lang.Class<? extends KrollProxy> proxyClass)
           
protected  java.lang.Object getBinding(java.lang.String name)
           
 KrollMethod getBoundMethod(java.lang.String name)
           
 KrollMethod getBoundMethodForThis(java.lang.String name)
           
 KrollProperty getBoundProperty(java.lang.String name)
           
 KrollModule getCreatedInModule()
           
 KrollDict getCreationDict()
           
 KrollInvocation getCurrentInvocation()
           
 java.lang.Object getDefaultValue(java.lang.Class<?> typeHint)
           
protected  java.lang.Object getDynamicProperty(org.mozilla.javascript.Scriptable scope, java.lang.String name, KrollProperty dynprop)
           
 java.lang.Object getJavascriptValue()
           
 KrollBridge getKrollBridge()
           
 KrollObject getKrollObject()
           
 java.lang.Object getNativeValue()
           
 KrollDict getProperties()
           
 java.lang.Object getProperty(java.lang.String name)
           
 java.lang.String getProxyId()
           
 java.lang.String getShortAPIName()
           
 TiContext getTiContext()
           
 android.os.Handler getUIHandler()
           
 void handleCreationArgs(KrollModule createdInModule, java.lang.Object[] args)
          Handle the arguments passed into the "create" method for this proxy.
 void handleCreationDict(KrollDict dict)
          Handle the creation KrollDict passed into the create method for this proxy.
 boolean handleMessage(android.os.Message msg)
           
 boolean has(org.mozilla.javascript.Scriptable scope, java.lang.String name)
           
protected  boolean hasBinding(java.lang.String name)
           
 boolean hasBoundMethod(java.lang.String methodName)
           
 boolean hasBoundProperty(java.lang.String propertyName)
           
 boolean hasListeners(java.lang.String eventName)
           
 boolean hasProperty(java.lang.String name)
           
 void removeEventListener(KrollInvocation invocation, java.lang.String eventName, java.lang.Object listener)
           
 void set(org.mozilla.javascript.Scriptable scope, java.lang.String name, java.lang.Object value)
           
protected  void setDynamicProperty(org.mozilla.javascript.Scriptable scope, java.lang.String name, KrollProperty dynprop, java.lang.Object value)
           
 void setModelListener(KrollProxyListener modelListener)
           
 void setProperty(java.lang.String name, java.lang.Object value)
           
 void setProperty(java.lang.String name, java.lang.Object value, boolean fireChange)
           
protected  boolean shouldFireChange(java.lang.Object oldValue, java.lang.Object newValue)
           
 TiContext switchContext(TiContext tiContext)
           
 void switchToCreatingContext()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MSG_MODEL_PROPERTY_CHANGE

protected static final int MSG_MODEL_PROPERTY_CHANGE
See Also:
Constant Field Values

MSG_LISTENER_ADDED

protected static final int MSG_LISTENER_ADDED
See Also:
Constant Field Values

MSG_LISTENER_REMOVED

protected static final int MSG_LISTENER_REMOVED
See Also:
Constant Field Values

MSG_MODEL_PROPERTIES_CHANGED

protected static final int MSG_MODEL_PROPERTIES_CHANGED
See Also:
Constant Field Values

MSG_LAST_ID

protected static final int MSG_LAST_ID
See Also:
Constant Field Values

proxyCounter

protected static java.util.concurrent.atomic.AtomicInteger proxyCounter

proxyBindings

protected static java.util.HashMap<java.lang.Class<? extends KrollProxy>,KrollProxyBinding> proxyBindings

PROXY_ID_PREFIX

public static final java.lang.String PROXY_ID_PREFIX
See Also:
Constant Field Values

BINDING_SUFFIX

public static final java.lang.String BINDING_SUFFIX
See Also:
Constant Field Values

UNDEFINED

public static final java.lang.Object UNDEFINED

properties

protected KrollDict properties

context

protected TiContext context

creatingContext

protected TiContext creatingContext

uiHandler

protected android.os.Handler uiHandler

waitForHandler

protected java.util.concurrent.CountDownLatch waitForHandler

proxyId

protected java.lang.String proxyId

modelListener

protected KrollProxyListener modelListener

eventManager

protected KrollEventManager eventManager

createdInModule

protected KrollModule createdInModule

binding

protected KrollProxyBinding binding

krollObject

protected KrollObject krollObject

currentInvocation

@Kroll.inject
protected KrollInvocation currentInvocation

creationDict

protected KrollDict creationDict
Constructor Detail

KrollProxy

public KrollProxy(TiContext context)

KrollProxy

public KrollProxy(TiContext context,
                  boolean autoBind)
Method Detail

getBinding

public static KrollProxyBinding getBinding(java.lang.Class<? extends KrollProxy> proxyClass)

getBinding

public KrollProxyBinding getBinding()

hasBinding

protected boolean hasBinding(java.lang.String name)

getBinding

protected java.lang.Object getBinding(java.lang.String name)

bindContextSpecific

public void bindContextSpecific(KrollBridge bridge)

getAPIName

public java.lang.String getAPIName()

getShortAPIName

public java.lang.String getShortAPIName()

getKrollObject

public KrollObject getKrollObject()

has

public boolean has(org.mozilla.javascript.Scriptable scope,
                   java.lang.String name)

get

public java.lang.Object get(org.mozilla.javascript.Scriptable scope,
                            java.lang.String name)
                     throws java.lang.NoSuchFieldException
Throws:
java.lang.NoSuchFieldException

set

public void set(org.mozilla.javascript.Scriptable scope,
                java.lang.String name,
                java.lang.Object value)
         throws java.lang.NoSuchFieldException
Throws:
java.lang.NoSuchFieldException

call

public java.lang.Object call(org.mozilla.javascript.Scriptable scope,
                             java.lang.String name,
                             java.lang.Object[] args)
                      throws java.lang.Exception
Throws:
java.lang.Exception

getDynamicProperty

protected java.lang.Object getDynamicProperty(org.mozilla.javascript.Scriptable scope,
                                              java.lang.String name,
                                              KrollProperty dynprop)
                                       throws java.lang.NoSuchFieldException
Throws:
java.lang.NoSuchFieldException

setDynamicProperty

protected void setDynamicProperty(org.mozilla.javascript.Scriptable scope,
                                  java.lang.String name,
                                  KrollProperty dynprop,
                                  java.lang.Object value)
                           throws java.lang.NoSuchFieldException
Throws:
java.lang.NoSuchFieldException

getProperties

public KrollDict getProperties()

hasProperty

public boolean hasProperty(java.lang.String name)

getProperty

public java.lang.Object getProperty(java.lang.String name)

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)

firePropertyChanged

protected void firePropertyChanged(java.lang.String name,
                                   java.lang.Object oldValue,
                                   java.lang.Object newValue)

shouldFireChange

protected boolean shouldFireChange(java.lang.Object oldValue,
                                   java.lang.Object newValue)

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value,
                        boolean fireChange)

extend

@Kroll.method
public void extend(KrollDict options)

firePropertiesChanged

protected void firePropertiesChanged(java.util.List<KrollPropertyChange> changes)

hasBoundMethod

public boolean hasBoundMethod(java.lang.String methodName)

hasBoundProperty

public boolean hasBoundProperty(java.lang.String propertyName)

getBoundMethod

public KrollMethod getBoundMethod(java.lang.String name)

getBoundMethodForThis

public KrollMethod getBoundMethodForThis(java.lang.String name)

getBoundProperty

public KrollProperty getBoundProperty(java.lang.String name)

handleCreationArgs

public void handleCreationArgs(KrollModule createdInModule,
                               java.lang.Object[] args)
Handle the arguments passed into the "create" method for this proxy. If your proxy simply needs to handle a KrollDict, see handleCreationDict(KrollDict)

Parameters:
args -

handleCreationDict

public void handleCreationDict(KrollDict dict)
Handle the creation KrollDict passed into the create method for this proxy. This is usually the first (and sometimes only) argument to the proxy's create method.

Parameters:
dict -

getCreationDict

public KrollDict getCreationDict()

getCreatedInModule

public KrollModule getCreatedInModule()

handleMessage

public boolean handleMessage(android.os.Message msg)
Specified by:
handleMessage in interface android.os.Handler.Callback

setModelListener

public void setModelListener(KrollProxyListener modelListener)

switchContext

public TiContext switchContext(TiContext tiContext)

switchToCreatingContext

public void switchToCreatingContext()

getUIHandler

public android.os.Handler getUIHandler()

getTiContext

public TiContext getTiContext()

getKrollBridge

public KrollBridge getKrollBridge()

getProxyId

public java.lang.String getProxyId()

addEventListener

@Kroll.method
public int addEventListener(KrollInvocation invocation,
                                         java.lang.String eventName,
                                         java.lang.Object listener)

removeEventListener

@Kroll.method
public void removeEventListener(KrollInvocation invocation,
                                             java.lang.String eventName,
                                             java.lang.Object listener)

eventListenerAdded

public void eventListenerAdded(java.lang.String eventName,
                               int count,
                               KrollProxy proxy)
Specified by:
eventListenerAdded in interface OnEventListenerChange

eventListenerRemoved

public void eventListenerRemoved(java.lang.String eventName,
                                 int count,
                                 KrollProxy proxy)
Specified by:
eventListenerRemoved in interface OnEventListenerChange

fireEvent

@Kroll.method
public boolean fireEvent(java.lang.String eventName,
                                      @Kroll.argument(optional=true)
                                      KrollDict data)

createEventInvocation

public KrollInvocation createEventInvocation(java.lang.String eventName)

fireSingleEvent

@Kroll.method
public void fireSingleEvent(java.lang.String eventName,
                                         java.lang.Object listener,
                                         KrollDict data)

hasListeners

public boolean hasListeners(java.lang.String eventName)

createErrorResponse

protected KrollDict createErrorResponse(int code,
                                        java.lang.String message)

getCurrentInvocation

public KrollInvocation getCurrentInvocation()

toString

@Kroll.method
public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getDefaultValue

public java.lang.Object getDefaultValue(java.lang.Class<?> typeHint)

getJavascriptValue

public java.lang.Object getJavascriptValue()
Specified by:
getJavascriptValue in interface KrollConvertable

getNativeValue

public java.lang.Object getNativeValue()
Specified by:
getNativeValue in interface KrollConvertable


Copyright © 2010 Appcelerator, Inc. Licensed under the Apache License 2.0