org.apache.fop.pdf
public abstract class PDFObject extends java.lang.Object implements PDFWritable
Modifier and Type | Field and Description |
---|---|
protected static java.text.SimpleDateFormat |
DATE_FORMAT
Formatting pattern for PDF date
|
protected static org.apache.commons.logging.Log |
log
logger for all PDFObjects (and descendants)
|
Constructor and Description |
---|
PDFObject()
Default constructor.
|
PDFObject(PDFObject parent)
Constructor for direct objects.
|
Modifier and Type | Method and Description |
---|---|
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 java.lang.String |
formatDateTime(java.util.Date time)
Formats a date/time according to the PDF specification.
|
protected java.lang.String |
formatDateTime(java.util.Date time,
java.util.TimeZone tz)
Formats a date/time according to the PDF specification
(D:YYYYMMDDHHmmSSOHH'mm').
|
protected void |
formatObject(java.lang.Object obj,
java.io.OutputStream out,
java.io.Writer writer)
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 the 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.
|
protected int |
output(java.io.OutputStream stream)
Write the PDF represention of this object
|
void |
outputInline(java.io.OutputStream out,
java.io.Writer writer)
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.
|
protected static org.apache.commons.logging.Log log
protected static final java.text.SimpleDateFormat DATE_FORMAT
public PDFObject()
public PDFObject(PDFObject parent)
parent
- the containing PDFObject instancepublic 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()
protected int output(java.io.OutputStream stream) throws java.io.IOException
stream
- the stream to write the PDF tojava.io.IOException
- if there is an error writing to the streampublic void outputInline(java.io.OutputStream out, java.io.Writer writer) throws java.io.IOException
flush()
is called before any direct calls to out
are made.outputInline
in interface PDFWritable
out
- the OutputStream (for binary content)writer
- the Writer (for text content, wraps the above OutputStream)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/encodeprotected byte[] encodeText(java.lang.String text)
text
- the text to encodeprotected byte[] encodeString(java.lang.String string)
string
- the string to encodeprotected void encodeBinaryToHexString(byte[] data, java.io.OutputStream out) throws java.io.IOException
data
- the binary dataout
- the OutputStream to write the encoded object tojava.io.IOException
- if an I/O error occursprotected void formatObject(java.lang.Object obj, java.io.OutputStream out, java.io.Writer writer) throws java.io.IOException
obj
- the objectout
- the OutputStream to write towriter
- a Writer for text content (will always be a wrapper around the above
OutputStream. Make sure flush
is called when mixing calls)java.io.IOException
- If an I/O error occursprotected java.lang.String formatDateTime(java.util.Date time, java.util.TimeZone tz)
time
- date/time value to formattz
- the time zoneprotected java.lang.String formatDateTime(java.util.Date time)
time
- date/time value to formatCopyright 1999-2008 The Apache Software Foundation. All Rights Reserved.