com.sun.pdfview
public class PDFObject extends Object
A PDF object can be a simple type, like a Boolean, a Number, a String, or the Null value. It can also be a NAME, which looks like a string, but is a special type in PDF files, like "/Name".
A PDF object can also be complex types, including Array; Dictionary; Stream, which is a Dictionary plus an array of bytes; or Indirect, which is a reference to some other PDF object. Indirect references will always be dereferenced by the time any data is returned from one of the methods in this class.
Field Summary | |
---|---|
static int | ARRAY an array of PDFObjects |
static int | BOOLEAN a Boolean |
static int | DICTIONARY a Hashmap that maps String names to PDFObjects |
static int | INDIRECT an indirect reference |
static int | KEYWORD a special PDF bare word, like R, obj, true, false, etc |
static PDFObject | nullObj the NULL PDFObject |
static int | NAME a special string, seen in PDF files as /Name |
static int | NULL the NULL object (there is only one) |
static int | NUMBER a Number, represented as a double |
static int | STREAM a Stream: a Hashmap with a byte array |
static int | STRING a String |
Constructor Summary | |
---|---|
PDFObject(PDFFile owner, int type, Object value)
create a new simple PDFObject with a type and a value | |
PDFObject(Object obj)
create a new PDFObject that is the closest match to a
given Java object. | |
PDFObject(PDFFile owner, PDFXref xref)
create a new PDFObject based on a PDFXref |
Method Summary | |
---|---|
PDFObject | dereference()
Make sure that this object is dereferenced. |
PDFObject[] | getArray()
get the value as a PDFObject[]. |
PDFObject | getAt(int idx)
if this object is an ARRAY, get the PDFObject at some
position in the array. |
boolean | getBooleanValue()
get the value as a boolean. |
Object | getCache()
get the value in the cache. |
HashMap | getDictionary()
get the dictionary as a HashMap. |
Iterator | getDictKeys()
get an Iterator over all the keys in the dictionary. |
PDFObject | getDictRef(String key)
get the value associated with a particular key in the
dictionary. |
double | getDoubleValue()
get the value as a double. |
float | getFloatValue()
get the value as a float. |
int | getIntValue()
get the value as an int. |
byte[] | getStream()
get the stream from this object. |
ByteBuffer | getStreamBuffer()
get the stream from this object as a byte buffer. |
String | getStringValue()
get the value as a String. |
int | getType()
get the type of this object. |
boolean | isDictType(String match)
returns true only if this object is a DICTIONARY or a
STREAM, and the "Type" entry in the dictionary matches a
given value. |
void | setCache(Object obj)
set the cached value. |
void | setStream(ByteBuffer data)
set the stream of this object. |
Parameters: owner the PDFFile in which this object resides, used for dereferencing. This may be null. type the type of object value the value. For DICTIONARY, this is a HashMap. for ARRAY it's an ArrayList. For NUMBER, it's a Double. for BOOLEAN, it's Boolean.TRUE or Boolean.FALSE. For everything else, it's a String.
Parameters: obj the sample Java object to convert to a PDFObject.
Throws: PDFParseException if the object isn't one of the above examples, and can't be turned into a PDFObject.
Parameters: owner the PDFFile from which the PDFXref was drawn xref the PDFXref to turn into a PDFObject
Returns: the cached value, or null if the value has been garbage collected.
Returns: the stream, or null, if this isn't a STREAM.
Returns: the buffer, or null, if this isn't a STREAM.
Returns: the type of the object
Parameters: match the expected value for the "Type" key in the dictionary
Returns: whether the dictionary is of the expected type
Parameters: obj the object to be cached
Parameters: data the data, as a ByteBuffer.