|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.pdfview.PDFObject
public class PDFObject
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.
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 int |
NAME
a special string, seen in PDF files as /Name |
static int |
NULL
the NULL object (there is only one) |
static PDFObject |
nullObj
the NULL PDFObject |
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(java.lang.Object obj)
create a new PDFObject that is the closest match to a given Java object. |
|
PDFObject(PDFFile owner,
int type,
java.lang.Object value)
create a new simple PDFObject with a type and a value |
|
PDFObject(PDFFile owner,
PDFXref xref)
create a new PDFObject based on a PDFXref |
Method Summary | |
---|---|
PDFObject |
dereference()
Make sure that this object is dereferenced. |
boolean |
equals(java.lang.Object o)
Test whether two PDFObject are equal. |
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. |
java.lang.Object |
getCache()
get the value in the cache. |
java.util.HashMap |
getDictionary()
get the dictionary as a HashMap. |
java.util.Iterator |
getDictKeys()
get an Iterator over all the keys in the dictionary. |
PDFObject |
getDictRef(java.lang.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. |
java.nio.ByteBuffer |
getStreamBuffer()
get the stream from this object as a byte buffer. |
java.lang.String |
getStringValue()
get the value as a String. |
int |
getType()
get the type of this object. |
boolean |
isDictType(java.lang.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(java.lang.Object obj)
set the cached value. |
void |
setStream(java.nio.ByteBuffer data)
set the stream of this object. |
java.lang.String |
toString()
return a representation of this PDFObject as a String. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int INDIRECT
public static final int BOOLEAN
public static final int NUMBER
public static final int STRING
public static final int NAME
public static final int ARRAY
public static final int DICTIONARY
public static final int STREAM
public static final int NULL
public static final int KEYWORD
public static final PDFObject nullObj
Constructor Detail |
---|
public PDFObject(PDFFile owner, int type, java.lang.Object value)
owner
- the PDFFile in which this object resides, used
for dereferencing. This may be null.type
- the type of objectvalue
- 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.public PDFObject(java.lang.Object obj) throws PDFParseException
obj
- the sample Java object to convert to a PDFObject.
PDFParseException
- if the object isn't one of the
above examples, and can't be turned into a PDFObject.public PDFObject(PDFFile owner, PDFXref xref)
owner
- the PDFFile from which the PDFXref was drawnxref
- the PDFXref to turn into a PDFObjectMethod Detail |
---|
public int getType() throws java.io.IOException
java.io.IOException
public void setStream(java.nio.ByteBuffer data)
data
- the data, as a ByteBuffer.public java.lang.Object getCache() throws java.io.IOException
java.io.IOException
public void setCache(java.lang.Object obj) throws java.io.IOException
obj
- the object to be cached
java.io.IOException
public byte[] getStream() throws java.io.IOException
java.io.IOException
public java.nio.ByteBuffer getStreamBuffer() throws java.io.IOException
java.io.IOException
public int getIntValue() throws java.io.IOException
java.io.IOException
public float getFloatValue() throws java.io.IOException
java.io.IOException
public double getDoubleValue() throws java.io.IOException
java.io.IOException
public java.lang.String getStringValue() throws java.io.IOException
java.io.IOException
public PDFObject[] getArray() throws java.io.IOException
java.io.IOException
public boolean getBooleanValue() throws java.io.IOException
java.io.IOException
public PDFObject getAt(int idx) throws java.io.IOException
java.io.IOException
public java.util.Iterator getDictKeys() throws java.io.IOException
java.io.IOException
public java.util.HashMap getDictionary() throws java.io.IOException
java.io.IOException
public PDFObject getDictRef(java.lang.String key) throws java.io.IOException
java.io.IOException
public boolean isDictType(java.lang.String match) throws java.io.IOException
match
- the expected value for the "Type" key in the
dictionary
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
public PDFObject dereference() throws java.io.IOException
java.io.IOException
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |