gnu.gnustep.base
Class NSObject

java.lang.Object
  |
  +--gnu.gnustep.base.NSObject
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
GSSAXHandler, GSXMLDocument, GSXMLNamespace, GSXMLNode, GSXMLParser, NSArray, NSBundle, NSData, NSDate, NSDictionary, NSEnumerator, NSNotification, NSNotificationCenter, NSNull, NSPort, NSProcessInfo, NSPropertyListSerialization, NSRunLoop, NSSet, NSTask, NSTimer, NSTimeZone, NSUserDefaults

public class NSObject
extends java.lang.Object
implements java.lang.Cloneable

This class wraps the Objective-C root class NSObject. All GNUstep Objective-C classes exposed to Java inherit from this class.


Constructor Summary
NSObject()
           
 
Method Summary
 java.lang.Object clone()
           
 java.lang.String description()
           
 boolean equals(java.lang.Object anObject)
           
 int hashCode()
           
 java.lang.Object mutableClone()
           
static void releaseObject(java.lang.Object object)
          See documentation on retainObject for more information.
static void retainObject(java.lang.Object object)
          retainObject and releaseObject are used to deal transparently with weak references passed to Objective-C methods.
 void takeValueForKey(java.lang.Object value, java.lang.String keyName)
           
 java.lang.String toString()
           
 java.lang.Object valueForKey(java.lang.String keyName)
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NSObject

public NSObject()
Method Detail

equals

public boolean equals(java.lang.Object anObject)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException

mutableClone

public java.lang.Object mutableClone()

toString

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

description

public java.lang.String description()

valueForKey

public java.lang.Object valueForKey(java.lang.String keyName)

takeValueForKey

public void takeValueForKey(java.lang.Object value,
                            java.lang.String keyName)

retainObject

public static void retainObject(java.lang.Object object)
retainObject and releaseObject are used to deal transparently with weak references passed to Objective-C methods. For example, if you want to set your java object 'javaDelegate' as delegate of the objective-C object 'objcObject', do as follows:
   NSObject.retainObject (javaDelegate);
   objcObject.setDelegate (javaDelegate);
 
If you don't do this (or don't retain in some other way javaDelegate on the objective-C side before passing it to setDelegate), your program will segfault. This is not a bug in the JIGS: it can't be otherwise.

Warning: you need to 'retain' javaDelegate _before_ passing it through the JIGS. But you don't need to retain javaDelegate if it already passed through the JIGS and some objective-C object is already keeping a reference to it.

After you are done with the object (for example, when you set a different delegate), you should `release' it, as in the following example which changes the delegate of objcObject:

   NSObject.retainObject (newJavaDelegate);
   objcObject.setDelegate (newJavaDelegate);
   NSObject.releaseObject (javaDelegate);
 
The rule is: you 'retain' the object before setting it as delegate, and 'release' it after having set another delegate.

Normally, you don't need these methods, they are needed only when calling Objective-C methods which store a reference to the argument without retaining it, such 'setDelegate:' and 'setTarget:'.


releaseObject

public static void releaseObject(java.lang.Object object)
See documentation on retainObject for more information.