public class NSNumber extends NSObject implements Comparable<Object>
Modifier and Type | Field and Description |
---|---|
static int |
BOOLEAN
Indicates that the number's value is boolean.
|
static int |
INTEGER
Indicates that the number's value is an integer.
|
static int |
REAL
Indicates that the number's value is a real number.
|
Constructor and Description |
---|
NSNumber(boolean b)
Creates a new NSNumber instance with the specified value.
|
NSNumber(byte[] bytes,
int type)
Creates a new NSNumber instance from its binary representation.
|
NSNumber(byte[] bytes,
int startIndex,
int endIndex,
int type)
Creates a new NSNumber instance from its binary representation.
|
NSNumber(double d)
Creates a new NSNumber instance with the specified value.
|
NSNumber(int i)
Creates a new NSNumber instance with the specified value.
|
NSNumber(long l)
Creates a new NSNumber instance with the specified value.
|
NSNumber(String text)
Create a NSNumber instance from its textual representation.
|
Modifier and Type | Method and Description |
---|---|
boolean |
boolValue()
Gets this instance's boolean value.
|
NSNumber |
clone()
Creates and returns a deep copy of this instance.
|
int |
compareTo(Object o) |
double |
doubleValue()
Gets this instance's
double value. |
boolean |
equals(Object obj)
Checks whether the other object is a NSNumber of the same value.
|
float |
floatValue()
Gets this instance's
float value. |
int |
hashCode() |
int |
intValue()
Gets this instance's integer value.
|
boolean |
isBoolean()
Gets a value indicating whether the value of this NSNumber is a boolean.
|
boolean |
isInteger()
Gets a value indicating whether the value of this NSNumber is an integer.
|
boolean |
isReal()
Gets a value indicating whether the value of this NSNumber is a real number.
|
long |
longValue()
Gets this instance's long integer value.
|
String |
stringValue()
Gets this instance's value expressed as a human-readable string.
|
protected void |
toASCII(StringBuilder ascii,
int level)
Generates the ASCII representation of this object.
|
protected void |
toASCIIGnuStep(StringBuilder ascii,
int level)
Generates the ASCII representation of this object in the GnuStep format.
|
String |
toString() |
int |
type()
Gets the type of this instance's value.
|
fromJavaObject, toJavaObject, toJavaObject, toXMLPropertyList
public static final int INTEGER
long
.
Its original value could have been char, short, int, long or even long long.public static final int REAL
double
.
Its original value could have been float or double.public static final int BOOLEAN
public NSNumber(byte[] bytes, int type)
public NSNumber(byte[] bytes, int startIndex, int endIndex, int type)
public NSNumber(String text)
text
- The textual representation of the number.IllegalArgumentException
- If the text does not represent an integer, real number or boolean value.Boolean.parseBoolean(java.lang.String)
,
Long.parseLong(java.lang.String)
,
Double.parseDouble(java.lang.String)
public NSNumber(int i)
i
- The integer value.public NSNumber(long l)
l
- The long integer value.public NSNumber(double d)
d
- The real value.public NSNumber(boolean b)
b
- The boolean value.public int type()
public boolean isBoolean()
public boolean isInteger()
public boolean isReal()
public boolean boolValue()
true
if the value is true or non-zero, false
otherwise.public long longValue()
long
.public int intValue()
int
.public double doubleValue()
double
value.double
.public float floatValue()
float
value.
WARNING: Possible loss of precision if the value is outside the float range.float
.public String stringValue()
public boolean equals(Object obj)
public NSNumber clone()
NSObject
protected void toASCII(StringBuilder ascii, int level)
NSObject
toASCII
in class NSObject
ascii
- The StringBuilder
onto which the ASCII representation is appended.level
- The indentation level of the object.protected void toASCIIGnuStep(StringBuilder ascii, int level)
NSObject
toASCIIGnuStep
in class NSObject
ascii
- The StringBuilder
onto which the ASCII representation is appended.level
- The indentation level of the object.public int compareTo(Object o)
compareTo
in interface Comparable<Object>
Copyright © 2018. All rights reserved.