|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.Number
org.pfsw.text.NaturalNumber
public class NaturalNumber
A natural number is an abstraction of the two types Integer and Long.
It allows to treat such values in a more neutral way without being fixed on a specific
java standard type.
| Constructor Summary | |
|---|---|
NaturalNumber(int value)
|
|
NaturalNumber(long value)
|
|
NaturalNumber(java.lang.String value)
Parses the string argument as a signed decimal long. |
|
| Method Summary | |
|---|---|
java.lang.Integer |
asInteger()
|
java.lang.Long |
asLong()
|
java.lang.String |
asString()
|
int |
compareTo(NaturalNumber other)
Compares two NaturalNumber objects numerically. |
double |
doubleValue()
|
boolean |
equals(java.lang.Object obj)
|
float |
floatValue()
|
protected java.lang.Long |
getNumberValue()
|
int |
hashCode()
|
int |
intValue()
|
boolean |
isNegative()
Returns true if this number is less than 0. |
boolean |
isPositive()
Returns true if this number is greater than 0. |
long |
longValue()
|
static NaturalNumber |
parse(java.lang.String value)
Parses the string argument as a signed decimal long. |
java.lang.String |
toString()
|
static NaturalNumber |
valueOf(int value)
|
static NaturalNumber |
valueOf(long value)
|
| Methods inherited from class java.lang.Number |
|---|
byteValue, shortValue |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public NaturalNumber(long value)
public NaturalNumber(int value)
public NaturalNumber(java.lang.String value)
long. The characters in the string must all be
decimal digits, except that the first character may be an ASCII
minus sign '-' (\u002D') to
indicate a negative value.
Note that neither the character L
('\u004C') nor l
('\u006C') is permitted to appear at the end
of the string as a type indicator, as would be permitted in
Java programming language source code.
value - a String containing the long
representation to be parsed
java.lang.NumberFormatException - if the string does not contain a
parsable long.| Method Detail |
|---|
public static NaturalNumber valueOf(long value)
public static NaturalNumber valueOf(int value)
public static NaturalNumber parse(java.lang.String value)
long. The characters in the string must all be
decimal digits, except that the first character may be an ASCII
minus sign '-' (\u002D') to
indicate a negative value.
Note that neither the character L
('\u004C') nor l
('\u006C') is permitted to appear at the end
of the string as a type indicator, as would be permitted in
Java programming language source code.
value - a String containing the long
representation to be parsed
long represented by the argument in
decimal.
java.lang.NumberFormatException - if the string does not contain a
parsable long.public double doubleValue()
doubleValue in class java.lang.Numberpublic float floatValue()
floatValue in class java.lang.Numberpublic int intValue()
intValue in class java.lang.Numberpublic long longValue()
longValue in class java.lang.Numberpublic java.lang.String asString()
asString in interface org.pfsw.bif.text.IStringRepresentationpublic java.lang.Long asLong()
asLong in interface org.pfsw.bif.conversion.ILongRepresentationpublic java.lang.Integer asInteger()
asInteger in interface org.pfsw.bif.conversion.IIntegerRepresentationpublic boolean isPositive()
public boolean isNegative()
public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int compareTo(NaturalNumber other)
NaturalNumber objects numerically.
compareTo in interface java.lang.Comparable<NaturalNumber>other - the NaturalNumber to be compared.
0 if this NaturalNumber is
equal to the argument NaturalNumber; a value less than
0 if this NaturalNumber is numerically less
than the argument NaturalNumber; and a value greater
than 0 if this NaturalNumber is numerically
greater than the argument NaturalNumber (signed
comparison).public java.lang.String toString()
toString in class java.lang.Objectprotected java.lang.Long getNumberValue()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||