public abstract class NSObject
extends java.lang.Object
Every Property List contains one or more NSObjects.
Every different extension holds a certain kind of value,
for example the NSString holds a String and the NSDate holds a Date.
Some NSObjects can hold other NSObjects, thus making a tree.
Those are NSDictionary and NSArray.
The value of this object can be requested through the getValue() method.
The hashCode(), equals(Object) and toString() methods are overridden to use the respective functions of the value object.
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object obj) |
static NSObject |
fromObject(java.lang.Object object)
Convert a Object to NSObject.
|
abstract java.lang.Object |
getValue()
Get the unmodifiable value of this object.
|
int |
hashCode() |
abstract boolean |
isTrue()
Return whether or not the value evaluates to true.
|
java.lang.Boolean |
toBoolean() |
abstract byte[] |
toBytes()
Get the raw data of the value.
|
java.util.Date |
toDate()
Get the value as a date.
|
abstract double |
toDouble()
Return the value as a double.
|
int |
toInteger()
Return the value as an int.
|
java.util.List<? extends NSObject> |
toList()
Try to retrieve the list contained in this
NSObject. |
java.util.List<?> |
toListObject()
Convenience function to avoid casting.
|
abstract long |
toLong()
Return the value as a long.
|
java.util.SortedMap<java.lang.String,NSObject> |
toMap()
Try to retrieve the
SortedMap contained in this NSObject. |
java.util.SortedMap<java.lang.String,?> |
toMapObject()
Convenience function to avoid casting.
|
java.lang.Number |
toNumber()
Return the value as a number.
|
java.lang.Object |
toObject()
Converts this NSObject to a normal Java object.
|
java.io.ByteArrayInputStream |
toStream()
Get a
ByteArrayInputStream in which encapsulates the result of toBytes(). |
java.lang.String |
toString()
Get the String representation of this objects value.
|
public abstract java.lang.Object getValue()
public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.ObjectString representation for this objectObject.toString()public java.io.ByteArrayInputStream toStream()
ByteArrayInputStream in which encapsulates the result of toBytes().ByteArrayInputStreampublic java.util.List<? extends NSObject> toList()
NSObject.
This method will return the list if the object is a NSArray
and will return a list containing all the values (but without the keys)
if this object is a NSDictionary. Otherwise an empty list is returned.public abstract boolean isTrue()
Return whether or not the value evaluates to true.
A value returns to true if and only if
NSBoolean type NSBoolean.TRUENSString which has a length greater than zero and does not equal "NO" or "False" (case insensitive)NSNumber greater than 0NSCollection which contains more than zero elementsNSDateNSData with a length greater than 0public final java.lang.Boolean toBoolean()
isTrue()public abstract byte[] toBytes()
public java.util.Date toDate()
NSDate,
otherwise the current date is returned.public java.util.SortedMap<java.lang.String,NSObject> toMap()
SortedMap contained in this NSObject.
This method will return the SortedMap if the object is a NSDictionary
and will return a SortedMap containing incremental keys and all the values
if this object is a NSArray. Otherwise an empty list is returned.public java.lang.Object toObject()
fromObject(Object) which will convert the object back to an NSObject.
Note: This method will NOT convert NSUID objects,
because there is no Java equivalent for those.public final java.util.SortedMap<java.lang.String,?> toMapObject()
public final java.util.List<?> toListObject()
public java.lang.Number toNumber()
Return the value as a number.
If this is not a NSNumber
the number is derived from the value.
The number is derived in the following way
NSNumber: the actual number valueNSCollection: the amount of childrenNSData: the length in bytesNSBoolean: always byte; 0 for false, 1 for trueNSString: If the String is numeric, return the number in the string. Otherwise return 0*If you need to be sure about the result (e.g. you need to know if the result is user intended or a guess) you should do instanceof checks yourself.
*This behaviour is exactly as the library works and even though one could argue that the method should return null instead of 0, the method returns 0 and will never return null. There are a couple reasons for this:
toLong() and toDouble() use toNumber();NullPointerExceptions.toNumber() on any NSObject is dirty anyway.NSObject is an NSNumber.public abstract long toLong()
NSInteger
the long value is derived from the actual value.public final int toInteger()
toLong().public abstract double toDouble()
NSReal
the double value is derived from the actual value.public static NSObject fromObject(java.lang.Object object)
object - to convert to NSObjectjava.io.InvalidObjectException - if the Object cannot be converted