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 boolean number.
|
NSNumber(byte[] bytes,
int type)
Parses integers and real numbers from their binary representation.
|
NSNumber(double d)
Creates a real number.
|
NSNumber(int i)
Creates an integer number.
|
NSNumber(long l)
Creates an integer number.
|
NSNumber(String text)
Creates a number from its textual representation.
|
Modifier and Type | Method and Description |
---|---|
boolean |
boolValue()
The number's boolean value.
|
int |
compareTo(Object o) |
double |
doubleValue()
The number's double value.
|
boolean |
equals(Object obj)
Checks whether the other object is a NSNumber of the same value.
|
float |
floatValue()
The number's float value.
|
int |
hashCode() |
int |
intValue()
The number's int value.
|
boolean |
isBoolean()
Checks whether the value of this NSNumber is a boolean.
|
boolean |
isInteger()
Checks whether the value of this NSNumber is an integer.
|
boolean |
isReal()
Checks whether the value of this NSNumber is a real number.
|
long |
longValue()
The number's long value.
|
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 number's value.
|
toJavaObject, toXMLPropertyList, wrap, wrap, wrap, wrap, wrap, wrap, wrap, wrap, wrapSerialized
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(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()
public int intValue()
public double doubleValue()
public float floatValue()
public boolean equals(Object obj)
protected void toASCII(StringBuilder ascii, int level)
NSObject
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 © 2014. All Rights Reserved.