| java.lang.Object com.sun.pdfview.PDFObject
PDFObject | public class PDFObject (Code) | | a class encapsulating all the possibilities of content for
an object in a PDF file.
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.
author: Mike Wessler |
Constructor Summary | |
public | PDFObject(PDFFile owner, int type, Object value) create a new simple PDFObject with a type and a value
Parameters: owner - the PDFFile in which this object resides, usedfor dereferencing. | public | PDFObject(Object obj) create a new PDFObject that is the closest match to a
given Java object. | public | PDFObject(PDFFile owner, PDFXref xref) |
ARRAY | final public static int ARRAY(Code) | | an array of PDFObjects
|
BOOLEAN | final public static int BOOLEAN(Code) | | a Boolean
|
DICTIONARY | final public static int DICTIONARY(Code) | | a Hashmap that maps String names to PDFObjects
|
INDIRECT | final public static int INDIRECT(Code) | | an indirect reference
|
KEYWORD | final public static int KEYWORD(Code) | | a special PDF bare word, like R, obj, true, false, etc
|
NAME | final public static int NAME(Code) | | a special string, seen in PDF files as /Name
|
NULL | final public static int NULL(Code) | | the NULL object (there is only one)
|
NUMBER | final public static int NUMBER(Code) | | a Number, represented as a double
|
STREAM | final public static int STREAM(Code) | | a Stream: a Hashmap with a byte array
|
STRING | final public static int STRING(Code) | | a String
|
PDFObject | public PDFObject(PDFFile owner, int type, Object value)(Code) | | create a new simple PDFObject with a type and a value
Parameters: owner - the PDFFile in which this object resides, usedfor dereferencing. This may be null. Parameters: type - the type of object Parameters: 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. Foreverything else, it's a String. |
PDFObject | public PDFObject(Object obj) throws PDFParseException(Code) | | create a new PDFObject that is the closest match to a
given Java object. Possibilities include Double, String,
PDFObject[], HashMap, Boolean, or PDFParser.Tok,
which should be "true" or "false" to turn into a BOOLEAN.
Parameters: obj - the sample Java object to convert to a PDFObject. throws: PDFParseException - if the object isn't one of theabove examples, and can't be turned into a PDFObject. |
PDFObject | public PDFObject(PDFFile owner, PDFXref xref)(Code) | | create a new PDFObject based on a PDFXref
Parameters: owner - the PDFFile from which the PDFXref was drawn Parameters: xref - the PDFXref to turn into a PDFObject |
dereference | public PDFObject dereference() throws IOException(Code) | | Make sure that this object is dereferenced. Use the cache of
an indirect object to cache the dereferenced value, if possible.
|
equals | public boolean equals(Object o)(Code) | | Test whether two PDFObject are equal. Objects are equal IFF they
are the same reference OR they are both indirect objects with the
same id and generation number in their xref
|
getArray | public PDFObject[] getArray() throws IOException(Code) | | get the value as a PDFObject[]. If this object is an ARRAY,
will return the array. Otherwise, will return an array
of one element with this object as the element.
|
getAt | public PDFObject getAt(int idx) throws IOException(Code) | | if this object is an ARRAY, get the PDFObject at some
position in the array. If this is not an ARRAY, returns
null.
|
getBooleanValue | public boolean getBooleanValue() throws IOException(Code) | | get the value as a boolean. Will return false if this
object is not a BOOLEAN
|
getCache | public Object getCache() throws IOException(Code) | | get the value in the cache. May become null at any time.
the cached value, or null if the value has beengarbage collected. |
getDictKeys | public Iterator getDictKeys() throws IOException(Code) | | get an Iterator over all the keys in the dictionary. If
this object is not a DICTIONARY or a STREAM, returns an
Iterator over the empty list.
|
getDictRef | public PDFObject getDictRef(String key) throws IOException(Code) | | get the value associated with a particular key in the
dictionary. If this isn't a DICTIONARY or a STREAM,
or there is no such key, returns null.
|
getDictionary | public HashMap getDictionary() throws IOException(Code) | | get the dictionary as a HashMap. If this isn't a DICTIONARY
or a STREAM, returns null
|
getDoubleValue | public double getDoubleValue() throws IOException(Code) | | get the value as a double. Will return 0 if this object
isn't a NUMBER.
|
getFloatValue | public float getFloatValue() throws IOException(Code) | | get the value as a float. Will return 0 if this object
isn't a NUMBER
|
getIntValue | public int getIntValue() throws IOException(Code) | | get the value as an int. Will return 0 if this object
isn't a NUMBER.
|
getStream | public byte[] getStream() throws IOException(Code) | | get the stream from this object. Will return null if this
object isn't a STREAM.
the stream, or null, if this isn't a STREAM. |
getStreamBuffer | public ByteBuffer getStreamBuffer() throws IOException(Code) | | get the stream from this object as a byte buffer. Will return null if
this object isn't a STREAM.
the buffer, or null, if this isn't a STREAM. |
getStringValue | public String getStringValue() throws IOException(Code) | | get the value as a String. Will return null if the object
isn't a STRING, NAME, or KEYWORD. This method will NOT
convert a NUMBER to a String.
|
getType | public int getType() throws IOException(Code) | | get the type of this object. The object will be
dereferenced, so INDIRECT will never be returned.
the type of the object |
isDictType | public boolean isDictType(String match) throws IOException(Code) | | returns true only if this object is a DICTIONARY or a
STREAM, and the "Type" entry in the dictionary matches a
given value.
Parameters: match - the expected value for the "Type" key in thedictionary whether the dictionary is of the expected type |
setCache | public void setCache(Object obj) throws IOException(Code) | | set the cached value. The object may be garbage collected
if no other reference exists to it.
Parameters: obj - the object to be cached |
setStream | public void setStream(ByteBuffer data)(Code) | | set the stream of this object. It should have been
a DICTIONARY before the call.
Parameters: data - the data, as a ByteBuffer. |
toString | public String toString()(Code) | | return a representation of this PDFObject as a String.
Does NOT dereference anything: this is the only method
that allows you to distinguish an INDIRECT PDFObject.
|
|
|