public abstract class NSObject
extends java.lang.Object
Every Property List contains one or more NSObject
s.
Every different extension holds a certain kind of value,
for example the NSString
holds a String
and the NSDate
holds a Date
.
Some NSObject
s can hold other NSObject
s, 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) |
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() |
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<NSObject> |
toList()
Try to retrieve the list contained in this
NSObject . |
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.lang.Number |
toNumber()
Return the value as a number.
|
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.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
String
representation for this objectObject.toString()
public java.io.ByteArrayInputStream toStream()
ByteArrayInputStream
in which encapsulates the result of toBytes()
.ByteArrayInputStream
public java.util.List<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.TRUE
NSString
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 elementsNSDate
NSData
with a length greater than 0public final java.lang.Boolean toBoolean()
isTrue()
public 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.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()
;NullPointerException
s.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.