org.apache.pdfbox.cos
abstract public class: COSNumber [javadoc |
source]
java.lang.Object
org.apache.pdfbox.cos.COSBase
org.apache.pdfbox.cos.COSNumber
All Implemented Interfaces:
COSObjectable
Direct Known Subclasses:
COSFloat, COSInteger
This class represents an abstract number in a PDF document.
Field Summary |
---|
public static final COSInteger | ZERO | |
public static final COSInteger | ONE | |
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from org.apache.pdfbox.cos.COSNumber Detail: |
abstract public double doubleValue()
This will get the double value of this number. |
abstract public float floatValue()
This will get the float value of this number. |
public static COSNumber get(String number) throws IOException {
if (number.length() == 1) {
char digit = number.charAt(0);
if ('0' < = digit && digit < = '9') {
return COSInteger.get(digit - '0');
} else {
throw new IOException("Not a number: " + number);
}
} else if (number.indexOf('.') == -1) {
try
{
return COSInteger.get( Long.parseLong( number ) );
}
catch( NumberFormatException e )
{
throw new IOException( "Value is not an integer: " + number );
}
} else {
return new COSFloat(number);
}
}
This factory method will get the appropriate number object. |
abstract public int intValue()
This will get the integer value of this number. |
abstract public long longValue()
This will get the long value of this number. |