public class Proxy extends java.lang.Object implements Peerable
The following snippet is taken from a unit test, to give you an idea of how to use the Proxy class to wrap an Objective-C object.
The NSRange object is a structure that we define in Java to correspond with the NSRange objective-c structure according to JNA conventions. It's implementation (for your reference) was:
Constructor and Description |
---|
Proxy()
Creates a proxy for a Null pointer.
|
Proxy(Client client)
Creates a proxy for a Null pointer using the specified Client object.
|
Proxy(Client client,
com.sun.jna.Pointer peer)
Creates a proxy for the specified peer Objective-C object, using
the specified client to send messages to the peer.
|
Proxy(com.sun.jna.Pointer peer)
Creates a proxy for the specified peer Objective-C object.
|
Modifier and Type | Method and Description |
---|---|
Proxy |
chain(Message... msgs)
Deprecated.
|
Proxy |
chain(com.sun.jna.Pointer selector,
java.lang.Object... args)
Deprecated.
|
Proxy |
chain(java.lang.String selector,
java.lang.Object... args)
Deprecated.
|
void |
dispose(boolean sendDeallocMessage)
Removes the proxy from the proxy cache, and optionally sends a dealloc message
to the peer.
|
boolean |
equals(java.lang.Object o)
Compares this object to another Peerable object.
|
java.lang.Object |
get(java.lang.String key)
Wrapper for key-value coding.
|
boolean |
getBoolean(java.lang.String key)
Returns the KVC coded value for the specified key as a boolean.
|
Client |
getClient()
Returns the client that is used by this Proxy object.
|
double |
getDouble(java.lang.String key)
Returns the KVC coded value for the specified key as a double.
|
int |
getInt(java.lang.String key)
Returns the KVC coded value for the specified key as an int.
|
com.sun.jna.Pointer |
getPeer()
Returns the Pointer to the native peer object.
|
com.sun.jna.Pointer |
getPointer(java.lang.String key)
Returns the KVC coded value for the specified key as a Pointer.
|
Proxy |
getProxy(java.lang.String key)
Returns the KVC coded value for the specified key as a Proxy.
|
int |
hashCode() |
static Proxy |
load(com.sun.jna.Pointer peer)
Loads a proxy object for the specified pointer to an objective-c object.
|
java.lang.Object |
send(Message... msgs)
Sends a message to the peer.
|
java.lang.Object |
send(com.sun.jna.Pointer selector,
java.lang.Object... args)
Sends a message to the peer.
|
java.lang.Object |
send(java.lang.String selector,
java.lang.Object... args)
Sends a message to the peer.
|
boolean |
sendBoolean(com.sun.jna.Pointer selector,
java.lang.Object... args)
A wrapper for the send() method, that returns a boolean.
|
boolean |
sendBoolean(java.lang.String selector,
java.lang.Object... args)
A wrapper for the send() method, that returns a boolean.
|
double |
sendDouble(com.sun.jna.Pointer selector,
java.lang.Object... args)
A wrapper for the send() method, that returns a double.
|
double |
sendDouble(java.lang.String selector,
java.lang.Object... args)
A wrapper for the send() method, that returns a double.
|
int |
sendInt(com.sun.jna.Pointer selector,
java.lang.Object... args)
A wrapper for the send() method, that returns an int.
|
int |
sendInt(java.lang.String selector,
java.lang.Object... args)
A wrapper for the send() method, that returns an int.
|
com.sun.jna.Pointer |
sendPointer(com.sun.jna.Pointer selector,
java.lang.Object... args)
A wrapper for the send() method, that returns a Pointer.
|
com.sun.jna.Pointer |
sendPointer(java.lang.String selector,
java.lang.Object... args)
A wrapper for the send() method, that returns a Pointer.
|
Proxy |
sendProxy(com.sun.jna.Pointer selector,
java.lang.Object... args)
A wrapper for the send() method, that returns a Pointer.
|
Proxy |
sendProxy(java.lang.String selector,
java.lang.Object... args)
A wrapper for the send() method, that returns a Pointer.
|
java.lang.Object |
sendRaw(Message... msgs)
Sends a message to the peer without performing any type coercion to
the inputs or outputs.
|
java.lang.Object |
sendRaw(com.sun.jna.Pointer selector,
java.lang.Object... args)
Sends a message to the peer.
|
java.lang.Object |
sendRaw(java.lang.String selector,
java.lang.Object... args)
Sends a message to the peer without performing any type coercion to
the inputs or outputs.
|
java.lang.String |
sendString(com.sun.jna.Pointer selector,
java.lang.Object... args) |
java.lang.String |
sendString(java.lang.String selector,
java.lang.Object... args) |
void |
set(java.lang.String key,
java.lang.Object value)
Wrapper for Key-Value coding.
|
Proxy |
setClient(Client client)
Sets the client that should be used for sending messages to the
peer object.
|
void |
setPeer(com.sun.jna.Pointer peer)
Sets the pointer to the native peer object.
|
java.lang.String |
toString()
Outputs the object as a string.
|
public Proxy()
public Proxy(Client client)
client
- public Proxy(Client client, com.sun.jna.Pointer peer)
client
- peer
- public Proxy(com.sun.jna.Pointer peer)
peer
- public static Proxy load(com.sun.jna.Pointer peer)
peer
- The objective-c peer object.public void dispose(boolean sendDeallocMessage)
sendDeallocMessage
- IF true, then this will also send a dealloc message
to the peer. If false, then it will simply remove from the Proxy cache, but
leave the Objective-C object intact.public com.sun.jna.Pointer sendPointer(com.sun.jna.Pointer selector, java.lang.Object... args)
selector
- The selector to call on the peer.args
- Variable argument list.public com.sun.jna.Pointer sendPointer(java.lang.String selector, java.lang.Object... args)
selector
- The selector to call on the peer.args
- Variable argument list.public Proxy sendProxy(java.lang.String selector, java.lang.Object... args)
selector
- The selector to call on the peer.args
- Variable argument list.public Proxy sendProxy(com.sun.jna.Pointer selector, java.lang.Object... args)
selector
- The selector to call on the peer.args
- Variable argument list.public java.lang.String sendString(com.sun.jna.Pointer selector, java.lang.Object... args)
public java.lang.String sendString(java.lang.String selector, java.lang.Object... args)
public int sendInt(com.sun.jna.Pointer selector, java.lang.Object... args)
selector
- The selector to call on the peer.args
- Variable argument list.public int sendInt(java.lang.String selector, java.lang.Object... args)
selector
- The selector to call on the peer.args
- Variable argument list.public double sendDouble(com.sun.jna.Pointer selector, java.lang.Object... args)
selector
- The selector to call on the peer.args
- Variable argument list.public double sendDouble(java.lang.String selector, java.lang.Object... args)
selector
- The selector to call on the peer.args
- Variable argument list.public boolean sendBoolean(com.sun.jna.Pointer selector, java.lang.Object... args)
selector
- The selector to call on the peer.args
- Variable argument list.public boolean sendBoolean(java.lang.String selector, java.lang.Object... args)
selector
- The selector to call on the peer.args
- Variable argument list.public java.lang.Object send(com.sun.jna.Pointer selector, java.lang.Object... args)
selector
- The selector to send to.args
- Variable argument list.public java.lang.Object send(java.lang.String selector, java.lang.Object... args)
selector
- The selector to send to.args
- Variable argument list.public java.lang.Object send(Message... msgs)
selector
- The selector to send to.args
- Variable argument list.public java.lang.Object sendRaw(com.sun.jna.Pointer selector, java.lang.Object... args)
selector
- The selector to send to.args
- Variable argument list.public java.lang.Object sendRaw(java.lang.String selector, java.lang.Object... args)
selector
- The selector to send to.args
- Variable argument list.public java.lang.Object sendRaw(Message... msgs)
selector
- The selector to send to.args
- Variable argument list.public Proxy chain(com.sun.jna.Pointer selector, java.lang.Object... args)
selector
- args
- public Proxy chain(java.lang.String selector, java.lang.Object... args)
selector
- args
- public Client getClient()
public Proxy setClient(Client client)
client
- public com.sun.jna.Pointer getPeer()
public void setPeer(com.sun.jna.Pointer peer)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- public int hashCode()
hashCode
in class java.lang.Object
public void set(java.lang.String key, java.lang.Object value)
key
- value
- public java.lang.Object get(java.lang.String key)
key
- public int getInt(java.lang.String key)
key
- public boolean getBoolean(java.lang.String key)
key
- public Proxy getProxy(java.lang.String key)
key
- public double getDouble(java.lang.String key)
key
- public com.sun.jna.Pointer getPointer(java.lang.String key)
key
-