Package com.itextpdf.kernel.pdf
Class PdfNumber
- java.lang.Object
-
- com.itextpdf.kernel.pdf.PdfObject
-
- com.itextpdf.kernel.pdf.PdfPrimitiveObject
-
- com.itextpdf.kernel.pdf.PdfNumber
-
public class PdfNumber extends PdfPrimitiveObject
APdfNumber
-class is the PDF-equivalent of aDouble
-object.PDF provides two types of numeric objects: integer and real. Integer objects represent mathematical integers. Real objects represent mathematical real numbers. The range and precision of numbers may be limited by the internal representations used in the computer on which the PDF processor is running. An integer shall be written as one or more decimal digits optionally preceded by a sign. The value shall be interpreted as a signed decimal integer and shall be converted to an integer object. A real value shall be written as one or more decimal digits with an optional sign and a leading, trailing, or embedded period (decimal point).
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
isDouble
private double
value
-
Fields inherited from class com.itextpdf.kernel.pdf.PdfPrimitiveObject
content, directOnly
-
Fields inherited from class com.itextpdf.kernel.pdf.PdfObject
ARRAY, BOOLEAN, DICTIONARY, FLUSHED, FORBID_RELEASE, FREE, INDIRECT_REFERENCE, indirectReference, LITERAL, MODIFIED, MUST_BE_FLUSHED, MUST_BE_INDIRECT, NAME, NULL, NUMBER, ORIGINAL_OBJECT_STREAM, READ_ONLY, READING, STREAM, STRING, UNENCRYPTED
-
-
Constructor Summary
Constructors Modifier Constructor Description private
PdfNumber()
PdfNumber(byte[] content)
Creates an instance ofPdfNumber
with provided content.PdfNumber(double value)
Creates an instance ofPdfNumber
and sets value.PdfNumber(int value)
Creates an instance ofPdfNumber
and sets value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
copyContent(PdfObject from, PdfDocument document, ICopyFilter copyFilter)
Copies object content from object 'from'.void
decrement()
Decrements current value.double
doubleValue()
Returns double value of current instance ofPdfNumber
.boolean
equals(java.lang.Object o)
float
floatValue()
Returns value and converts it to float.protected void
generateContent()
protected void
generateValue()
byte
getType()
Gets object type.double
getValue()
Returns value of current instance ofPdfNumber
.boolean
hasDecimalPoint()
Checks if string representation of the value contains decimal point.int
hashCode()
void
increment()
Increments current value.int
intValue()
Returns value and converts it to an int.protected boolean
isDoubleNumber()
long
longValue()
Returns value and converts it to long.protected PdfObject
newInstance()
Creates new instance of object.void
setValue(double value)
Sets value.void
setValue(int value)
Sets value and convert it to double.java.lang.String
toString()
-
Methods inherited from class com.itextpdf.kernel.pdf.PdfPrimitiveObject
compareContent, getInternalContent, hasContent, makeIndirect, setIndirectReference
-
Methods inherited from class com.itextpdf.kernel.pdf.PdfObject
checkState, clearState, clone, clone, copyContent, copyTo, copyTo, copyTo, copyTo, equalContent, flush, flush, getIndirectReference, isArray, isBoolean, isDictionary, isFlushed, isIndirect, isIndirectReference, isLiteral, isModified, isName, isNull, isNumber, isReleaseForbidden, isStream, isString, makeIndirect, processCopying, processCopying, release, setModified, setState
-
-
-
-
Constructor Detail
-
PdfNumber
public PdfNumber(double value)
Creates an instance ofPdfNumber
and sets value.- Parameters:
value
- double value to set
-
PdfNumber
public PdfNumber(int value)
Creates an instance ofPdfNumber
and sets value.- Parameters:
value
- int value to set
-
PdfNumber
public PdfNumber(byte[] content)
Creates an instance ofPdfNumber
with provided content.- Parameters:
content
- byte array content to set
-
PdfNumber
private PdfNumber()
-
-
Method Detail
-
getType
public byte getType()
Description copied from class:PdfObject
Gets object type.
-
getValue
public double getValue()
Returns value of current instance ofPdfNumber
.- Returns:
- value of
PdfNumber
instance
-
doubleValue
public double doubleValue()
Returns double value of current instance ofPdfNumber
.- Returns:
- double value of
PdfNumber
instance
-
floatValue
public float floatValue()
Returns value and converts it to float.- Returns:
- value converted to float
-
longValue
public long longValue()
Returns value and converts it to long.- Returns:
- value converted to long
-
intValue
public int intValue()
Returns value and converts it to an int. If value surpassesInteger.MAX_VALUE
,Integer.MAX_VALUE
would be return.- Returns:
- value converted to int
-
setValue
public void setValue(int value)
Sets value and convert it to double.- Parameters:
value
- to set
-
setValue
public void setValue(double value)
Sets value.- Parameters:
value
- to set
-
increment
public void increment()
Increments current value.
-
decrement
public void decrement()
Decrements current value.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hasDecimalPoint
public boolean hasDecimalPoint()
Checks if string representation of the value contains decimal point.- Returns:
- true if contains so the number must be real not integer
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
newInstance
protected PdfObject newInstance()
Description copied from class:PdfObject
Creates new instance of object.- Specified by:
newInstance
in classPdfObject
- Returns:
- new instance of object.
-
isDoubleNumber
protected boolean isDoubleNumber()
-
generateContent
protected void generateContent()
- Specified by:
generateContent
in classPdfPrimitiveObject
-
generateValue
protected void generateValue()
-
copyContent
protected void copyContent(PdfObject from, PdfDocument document, ICopyFilter copyFilter)
Description copied from class:PdfObject
Copies object content from object 'from'.- Overrides:
copyContent
in classPdfPrimitiveObject
- Parameters:
from
- object to copy content from.document
- document to copy object to.copyFilter
-ICopyFilter
a filter that will apply on dictionaries and array UseNullCopyFilter
for no filtering
-
-