org.rococoa
Class Foundation

java.lang.Object
  extended by org.rococoa.Foundation

public abstract class Foundation
extends java.lang.Object

The core of Rococoa - statics to handle selectors and messaging at a function call level. Marshalling of Java types to C types is handled by JNA. Marshalling of Java type to Objective-C types is handled by RococoaTypeMapper. Not to be confused with the Mac Foundation or Core Foundation frameworks, most users shouldn't need to access this class directly.

Author:
duncan

Constructor Summary
Foundation()
           
 
Method Summary
static
<T> T
callOnMainThread(java.util.concurrent.Callable<T> callable)
          Return the result of calling callable on the main Cococoa thread.
static int cfGetRetainCount(ID cfTypeRef)
           
static void cfRelease(ID id)
          Release the NSObject with id
static ID cfRetain(ID id)
          Retain the NSObject with id
static ID cfString(java.lang.String s)
          Return a CFString as an ID, toll-free bridged to NSString.
static ID getClass(java.lang.String className)
          Get the ID of the NSClass with className
static boolean isMainThread()
           
static ID newOCProxy(OCInvocationCallbacks callbacks)
          Create an Objective-C object which delegates to callbacks when methods are invoked on it.
static void nsLog(java.lang.String format, java.lang.Object thing)
           
static void runOnMainThread(java.lang.Runnable runnable)
          Run runnable on the main Cococoa thread, waiting for completion.
static void runOnMainThread(java.lang.Runnable runnable, boolean waitUntilDone)
          Run runnable on the main Cococoa thread, optionally waiting for completion.
static Selector selector(java.lang.String selectorName)
           
static boolean selectorNameMeansWeOwnReturnedObject(java.lang.String selectorName)
           
static
<T> T
send(ID receiver, Selector selector, java.lang.Class<T> returnType, java.lang.Object... args)
          Send message with selector to receiver, passing args, expecting returnType.
static
<T> T
send(ID receiver, java.lang.String selectorName, java.lang.Class<T> returnType, java.lang.Object... args)
          Send message with selectorName to receiver, passing args, expecting returnType.
static ID sendReturnsID(ID receiver, java.lang.String selectorName, java.lang.Object... args)
          Convenience as this happens a lot in tests.
static void sendReturnsVoid(ID receiver, java.lang.String selectorName, java.lang.Object... args)
          Convenience as this happens a lot in tests.
static java.lang.String toString(ID cfString)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Foundation

public Foundation()
Method Detail

nsLog

public static void nsLog(java.lang.String format,
                         java.lang.Object thing)

cfString

public static ID cfString(java.lang.String s)
Return a CFString as an ID, toll-free bridged to NSString. Note that the returned string must be freed with cfRelease(ID).


cfRetain

public static ID cfRetain(ID id)
Retain the NSObject with id


cfRelease

public static void cfRelease(ID id)
Release the NSObject with id


cfGetRetainCount

public static int cfGetRetainCount(ID cfTypeRef)

toString

public static java.lang.String toString(ID cfString)

getClass

public static ID getClass(java.lang.String className)
Get the ID of the NSClass with className


selector

public static Selector selector(java.lang.String selectorName)

send

public static <T> T send(ID receiver,
                         java.lang.String selectorName,
                         java.lang.Class<T> returnType,
                         java.lang.Object... args)
Send message with selectorName to receiver, passing args, expecting returnType. Note that you are responsible for memory management if returnType is ID.


send

public static <T> T send(ID receiver,
                         Selector selector,
                         java.lang.Class<T> returnType,
                         java.lang.Object... args)
Send message with selector to receiver, passing args, expecting returnType. Note that you are responsible for memory management if returnType is ID.


sendReturnsID

public static ID sendReturnsID(ID receiver,
                               java.lang.String selectorName,
                               java.lang.Object... args)
Convenience as this happens a lot in tests. Note that you are responsible for memory management for the returned ID


sendReturnsVoid

public static void sendReturnsVoid(ID receiver,
                                   java.lang.String selectorName,
                                   java.lang.Object... args)
Convenience as this happens a lot in tests.


isMainThread

public static boolean isMainThread()

callOnMainThread

public static <T> T callOnMainThread(java.util.concurrent.Callable<T> callable)
Return the result of calling callable on the main Cococoa thread.


runOnMainThread

public static void runOnMainThread(java.lang.Runnable runnable)
Run runnable on the main Cococoa thread, waiting for completion.


runOnMainThread

public static void runOnMainThread(java.lang.Runnable runnable,
                                   boolean waitUntilDone)
Run runnable on the main Cococoa thread, optionally waiting for completion.


newOCProxy

public static ID newOCProxy(OCInvocationCallbacks callbacks)
Create an Objective-C object which delegates to callbacks when methods are invoked on it. Object is created with alloc, so is owned by the caller.


selectorNameMeansWeOwnReturnedObject

public static boolean selectorNameMeansWeOwnReturnedObject(java.lang.String selectorName)


Copyright © 2009. All Rights Reserved.