|
fop 1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.fop.pdf.PDFObject
public abstract class PDFObject
generic PDF object. A PDF Document is essentially a collection of these objects. A PDF Object has a number and a generation (although the generation will always be 0 in new documents).
Field Summary | |
---|---|
protected static org.apache.commons.logging.Log |
log
logger for all PDFObjects (and descendants) |
Constructor Summary | |
---|---|
PDFObject()
Default constructor. |
|
PDFObject(PDFObject parent)
Constructor for direct objects. |
Method Summary | |
---|---|
protected boolean |
contentEquals(PDFObject o)
Check if the other PDFObject has the same content as the current object. |
static byte[] |
encode(java.lang.String text)
Converts text to a byte array for writing to a PDF file. |
protected void |
encodeBinaryToHexString(byte[] data,
java.io.OutputStream out)
Encodes binary data as hexadecimal string object. |
protected byte[] |
encodeString(java.lang.String string)
Encodes a String (3.2.3 in PDF 1.4 specs) |
protected byte[] |
encodeText(java.lang.String text)
Encodes a Text String (3.8.1 in PDF 1.4 specs) |
protected void |
formatObject(java.lang.Object obj,
java.io.OutputStream out,
java.lang.StringBuilder textBuffer)
Formats an object for serialization to PDF. |
PDFDocument |
getDocument()
Returns the parent PDFDocument if assigned. |
PDFDocument |
getDocumentSafely()
Returns the parent PDFDocument, but unlike getDocument()
it throws an informative Exception if the parent document is unavailable
instead of having a NullPointerException somewhere without a message. |
int |
getGeneration()
Returns this object's generation. |
java.lang.String |
getObjectID()
Returns the PDF representation of the Object ID. |
int |
getObjectNumber()
Returns the object's number. |
PDFObject |
getParent()
Returns this objects's parent. |
boolean |
hasObjectNumber()
Indicates whether this PDFObject has already been assigned an object number. |
PDFReference |
makeReference()
Creates and returns a reference to this object. |
int |
output(java.io.OutputStream stream)
Write the PDF represention of this object |
void |
outputInline(java.io.OutputStream out,
java.lang.StringBuilder textBuffer)
Writes a "direct object" (inline object) representation to the stream. |
java.lang.String |
referencePDF()
Returns the PDF representation of a reference to this object. |
void |
setDocument(PDFDocument doc)
Sets the parent PDFDocument. |
void |
setObjectNumber(int objnum)
Sets the object number |
void |
setParent(PDFObject parent)
Sets the direct parent object. |
protected byte[] |
toPDF()
Encodes the object as a byte array for output to a PDF file. |
protected java.lang.String |
toPDFString()
This method returns a String representation of the PDF object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final org.apache.commons.logging.Log log
Constructor Detail |
---|
public PDFObject()
public PDFObject(PDFObject parent)
parent
- the containing PDFObject instanceMethod Detail |
---|
public int getObjectNumber()
public boolean hasObjectNumber()
public void setObjectNumber(int objnum)
objnum
- the object numberpublic int getGeneration()
public final PDFDocument getDocument()
public final PDFDocument getDocumentSafely()
getDocument()
it throws an informative Exception if the parent document is unavailable
instead of having a NullPointerException somewhere without a message.
public void setDocument(PDFDocument doc)
doc
- the PDFDocument.public PDFObject getParent()
public void setParent(PDFObject parent)
parent
- the direct parentpublic java.lang.String getObjectID()
public java.lang.String referencePDF()
public PDFReference makeReference()
public int output(java.io.OutputStream stream) throws java.io.IOException
stream
- the stream to write the PDF to
java.io.IOException
- if there is an error writing to the streampublic void outputInline(java.io.OutputStream out, java.lang.StringBuilder textBuffer) throws java.io.IOException
IMPORTANT: If you need to write out binary output, call
PDFDocument.flushTextBuffer(StringBuilder, OutputStream)
before writing any content
to the OutputStream
!
outputInline
in interface PDFWritable
out
- the OutputStream (for binary content)textBuffer
- the text buffer for text content
java.io.IOException
- if an I/O error occursprotected byte[] toPDF()
protected java.lang.String toPDFString()
public static final byte[] encode(java.lang.String text)
text
- text to convert/encode
protected byte[] encodeText(java.lang.String text)
text
- the text to encode
protected byte[] encodeString(java.lang.String string)
string
- the string to encode
protected void encodeBinaryToHexString(byte[] data, java.io.OutputStream out) throws java.io.IOException
data
- the binary dataout
- the OutputStream to write the encoded object to
java.io.IOException
- if an I/O error occursprotected void formatObject(java.lang.Object obj, java.io.OutputStream out, java.lang.StringBuilder textBuffer) throws java.io.IOException
IMPORTANT: If you need to write out binary output, call
PDFDocument.flushTextBuffer(StringBuilder, OutputStream)
before writing any content
to the OutputStream
!
obj
- the objectout
- the OutputStream to write totextBuffer
- a text buffer for text output
java.io.IOException
- If an I/O error occursprotected boolean contentEquals(PDFObject o)
Note: This function has a contract which is less binding than
Object.equals(Object)
. Whereas equals would require all values to be
identical, this method is not required to check everything. In the case
of PDFObjects, this means that the overriding function does not have to
check for getObjectID()
.
o
- object to compare to.
|
fop 1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |