Modifier and Type | Field and Description |
---|---|
static NSBoolean |
FALSE
Represents
Boolean.FALSE |
static NSBoolean |
TRUE
Represents
Boolean.TRUE |
Constructor and Description |
---|
NSBoolean(boolean theBoolean)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
bool()
Get the boolean represented by this object.
|
java.lang.Boolean |
getValue()
Get the unmodifiable value of this object.
|
boolean |
isTrue()
Return whether or not the value evaluates to true.
|
byte[] |
toBytes()
Get the raw data of the value.
|
double |
toDouble()
Return the value as a double.
|
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.lang.String |
toString()
Get the String representation of this objects value.
|
public static final NSBoolean TRUE
Boolean.TRUE
public static final NSBoolean FALSE
Boolean.FALSE
public NSBoolean(boolean theBoolean)
theBoolean
- value of the new objectpublic java.lang.Boolean getValue()
public boolean isTrue()
NSObject
Return whether or not the value evaluates to true.
A value returns to true if and only if
public boolean bool()
public byte[] toBytes()
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:
NSObject.toLong()
and NSObject.toDouble()
use NSObject.toNumber()
;NullPointerException
s.NSObject.toNumber()
on any NSObject
is dirty anyway.NSObject
is an NSNumber
.public long toLong()
NSInteger
the long value is derived from the actual value.public double toDouble()
NSReal
the double value is derived from the actual value.