intarsys PDF library API

de.intarsys.pdf.writer
Class COSWriter

java.lang.Object
  extended by de.intarsys.pdf.writer.COSWriter
All Implemented Interfaces:
ICOSObjectVisitor, ICOSProxyVisitor

public class COSWriter
extends Object
implements ICOSObjectVisitor, ICOSProxyVisitor

A writer for PDF related data structures.


Field Summary
static byte[] ARRAY_CLOSE
           
static byte[] ARRAY_OPEN
           
static byte[] COMMENT
           
static byte[] CRLF
          To be used when 2 byte sequence is enforced.
static byte[] DICT_CLOSE
           
static byte[] DICT_OPEN
           
static byte[] ENDOBJ
           
static byte[] ENDSTREAM
           
static byte[] EOF
           
static byte[] EOL
          standard line separator on this platform
static byte[] FALSE
           
static byte[] GARBAGE
           
static byte[] LF
          Line feed character.
static byte[] LITERAL_ESCAPED_BS
           
static byte[] LITERAL_ESCAPED_CR
           
static byte[] LITERAL_ESCAPED_FF
           
static byte[] LITERAL_ESCAPED_HT
           
static byte[] LITERAL_ESCAPED_LF
           
static byte[] NAME_ESCAPE
           
static byte[] NAME_PREFIX
           
static byte[] NULL
           
static byte[] OBJ
           
static byte[] PDF_ESCAPE
           
static byte[] REFERENCE
           
static byte[] SPACE
           
static byte[] STREAM
           
static byte[] STRING_CLOSE
           
static byte[] STRING_HEX_CLOSE
           
static byte[] STRING_HEX_OPEN
           
static byte[] STRING_OPEN
           
static byte[] TRAILER
           
static byte[] TRUE
           
 
Constructor Summary
COSWriter(IRandomAccess randomAccess, ISystemSecurityHandler securityHandler)
           
 
Method Summary
static void basicWriteFixed(IRandomAccess randomAccess, float value, int precision)
           
static void basicWriteInteger(IRandomAccess randomAccess, int value)
           
static void basicWriteName(IRandomAccess randomAccess, byte[] name)
          create the byte stream for the representation of a name
static void basicWriteStringHex(IRandomAccess randomAccess, byte[] string)
          create a hex encoded byte stream representation of string
static void basicWriteStringLiteral(IRandomAccess randomAccess, byte[] string)
          create the literal byte stream representation of string
 List getProxies()
          The collection of proxies to COSObjects visited by the writer.
 IRandomAccess getRandomAccess()
           
 boolean isIncremental()
           
 void seekToEnd()
           
 void setIncremental(boolean incremental)
           
static byte[] toByteArray(COSObject object)
          Create a byte array representation from a COSObject.
 Object visitFromArray(COSArray obj)
          visitFromArray.
 Object visitFromBoolean(COSBoolean obj)
          visitFromBoolean.
 Object visitFromDictionary(COSDictionary obj)
          visitFromDictionary.
 Object visitFromFixed(COSFixed obj)
          visitFromFixed.
 Object visitFromIndirectObject(COSIndirectObject obj)
          This will write an indirect object reference
 Object visitFromInteger(COSInteger obj)
          visitFromInteger.
 Object visitFromName(COSName obj)
          visitFromName.
 Object visitFromNull(COSNull obj)
          visitFromNull.
 Object visitFromProxy(COSObjectProxy obj)
          Notification of visit to COSObjectProxy object.
 Object visitFromStream(COSStream obj)
          visitFromStream.
 Object visitFromString(COSString obj)
          visitFromString.
 void write(byte[] b)
          This will write some byte to the stream.
 void write(byte[] b, int off, int len)
          This will write some byte to the stream.
 void write(int b)
          This will write a single byte to the stream.
 void writeContentStream(CSContent contentStream)
           
 void writeDocument(STDocument doc)
           
 void writeEOL()
          This will write an EOL to the stream.
 void writeIndirectObject(COSIndirectObject object)
           
 void writeObject(COSObject object)
          This will write a cos object to the stream
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ARRAY_CLOSE

public static final byte[] ARRAY_CLOSE

ARRAY_OPEN

public static final byte[] ARRAY_OPEN

COMMENT

public static final byte[] COMMENT

CRLF

public static final byte[] CRLF
To be used when 2 byte sequence is enforced.


DICT_CLOSE

public static final byte[] DICT_CLOSE

DICT_OPEN

public static final byte[] DICT_OPEN

ENDOBJ

public static final byte[] ENDOBJ

ENDSTREAM

public static final byte[] ENDSTREAM

EOF

public static final byte[] EOF

EOL

public static final byte[] EOL
standard line separator on this platform


FALSE

public static final byte[] FALSE

GARBAGE

public static final byte[] GARBAGE

LF

public static final byte[] LF
Line feed character.


LITERAL_ESCAPED_BS

public static final byte[] LITERAL_ESCAPED_BS

LITERAL_ESCAPED_CR

public static final byte[] LITERAL_ESCAPED_CR

LITERAL_ESCAPED_FF

public static final byte[] LITERAL_ESCAPED_FF

LITERAL_ESCAPED_HT

public static final byte[] LITERAL_ESCAPED_HT

LITERAL_ESCAPED_LF

public static final byte[] LITERAL_ESCAPED_LF

NAME_ESCAPE

public static final byte[] NAME_ESCAPE

NAME_PREFIX

public static final byte[] NAME_PREFIX

NULL

public static final byte[] NULL

OBJ

public static final byte[] OBJ

PDF_ESCAPE

public static final byte[] PDF_ESCAPE

REFERENCE

public static final byte[] REFERENCE

SPACE

public static final byte[] SPACE

STREAM

public static final byte[] STREAM

STRING_CLOSE

public static final byte[] STRING_CLOSE

STRING_HEX_CLOSE

public static final byte[] STRING_HEX_CLOSE

STRING_HEX_OPEN

public static final byte[] STRING_HEX_OPEN

STRING_OPEN

public static final byte[] STRING_OPEN

TRAILER

public static final byte[] TRAILER

TRUE

public static final byte[] TRUE
Constructor Detail

COSWriter

public COSWriter(IRandomAccess randomAccess,
                 ISystemSecurityHandler securityHandler)
Method Detail

basicWriteFixed

public static void basicWriteFixed(IRandomAccess randomAccess,
                                   float value,
                                   int precision)
                            throws IOException
Throws:
IOException

basicWriteInteger

public static void basicWriteInteger(IRandomAccess randomAccess,
                                     int value)
                              throws IOException
Throws:
IOException

basicWriteName

public static void basicWriteName(IRandomAccess randomAccess,
                                  byte[] name)
                           throws IOException
create the byte stream for the representation of a name

Parameters:
randomAccess - the randomAccessData to write to
name - the names byte stream
Throws:
IOException

basicWriteStringHex

public static void basicWriteStringHex(IRandomAccess randomAccess,
                                       byte[] string)
                                throws IOException
create a hex encoded byte stream representation of string

Parameters:
randomAccess - the randomAccessData to write to
string - the string to write
Throws:
IOException

basicWriteStringLiteral

public static void basicWriteStringLiteral(IRandomAccess randomAccess,
                                           byte[] string)
                                    throws IOException
create the literal byte stream representation of string

Parameters:
randomAccess - the randomAccessData to write to
string - the string to write
Throws:
IOException

toByteArray

public static final byte[] toByteArray(COSObject object)
Create a byte array representation from a COSObject.

Parameters:
object - The object to be serialized.
Returns:
A byte array representation from a COSObject.

getProxies

public List getProxies()
The collection of proxies to COSObjects visited by the writer.

Returns:
The collection of proxies to COSObjects visited by the writer.

getRandomAccess

public IRandomAccess getRandomAccess()

isIncremental

public boolean isIncremental()

seekToEnd

public void seekToEnd()
               throws IOException
Throws:
IOException

setIncremental

public void setIncremental(boolean incremental)

visitFromArray

public Object visitFromArray(COSArray obj)
                      throws COSVisitorException
visitFromArray.

Specified by:
visitFromArray in interface ICOSObjectVisitor
Parameters:
obj - The object that is being visited.
Returns:
unused
Throws:
COSVisitorException - If there is an exception while visiting this object.

visitFromBoolean

public Object visitFromBoolean(COSBoolean obj)
                        throws COSVisitorException
visitFromBoolean.

Specified by:
visitFromBoolean in interface ICOSObjectVisitor
Parameters:
obj - The object that is being visited.
Returns:
unused
Throws:
COSVisitorException - If there is an exception while visiting this object.

visitFromDictionary

public Object visitFromDictionary(COSDictionary obj)
                           throws COSVisitorException
visitFromDictionary.

Specified by:
visitFromDictionary in interface ICOSObjectVisitor
Parameters:
obj - The object that is being visited.
Returns:
unused
Throws:
COSVisitorException - If there is an exception while visiting this object.

visitFromFixed

public Object visitFromFixed(COSFixed obj)
                      throws COSVisitorException
visitFromFixed.

Specified by:
visitFromFixed in interface ICOSObjectVisitor
Parameters:
obj - The object that is being visited.
Returns:
unused
Throws:
COSVisitorException - If there is an exception while visiting this object.

visitFromIndirectObject

public Object visitFromIndirectObject(COSIndirectObject obj)
                               throws COSVisitorException
This will write an indirect object reference

Specified by:
visitFromIndirectObject in interface ICOSObjectVisitor
Parameters:
obj - The indirect object to write.
Returns:
any Object depending on the visitor implementation, or null
Throws:
COSVisitorException - If there is an exception while visiting this object.

visitFromInteger

public Object visitFromInteger(COSInteger obj)
                        throws COSVisitorException
visitFromInteger.

Specified by:
visitFromInteger in interface ICOSObjectVisitor
Parameters:
obj - The object that is being visited.
Returns:
unused
Throws:
COSVisitorException - If there is an exception while visiting this object.

visitFromName

public Object visitFromName(COSName obj)
                     throws COSVisitorException
visitFromName.

Specified by:
visitFromName in interface ICOSObjectVisitor
Parameters:
obj - The object that is being visited.
Returns:
unused
Throws:
COSVisitorException - If there is an exception while visiting this object.

visitFromNull

public Object visitFromNull(COSNull obj)
                     throws COSVisitorException
visitFromNull.

Specified by:
visitFromNull in interface ICOSObjectVisitor
Parameters:
obj - The object that is being visited.
Returns:
unused
Throws:
COSVisitorException - If there is an exception while visiting this object.

visitFromProxy

public Object visitFromProxy(COSObjectProxy obj)
                      throws COSVisitorException
Description copied from interface: ICOSProxyVisitor
Notification of visit to COSObjectProxy object.

Specified by:
visitFromProxy in interface ICOSProxyVisitor
Parameters:
obj - The Object that is being visited.
Returns:
any Object depending on the visitor implementation, or null
Throws:
COSVisitorException - If there is an error while visiting this object.

visitFromStream

public Object visitFromStream(COSStream obj)
                       throws COSVisitorException
visitFromStream.

Specified by:
visitFromStream in interface ICOSObjectVisitor
Parameters:
obj - The object that is being visited.
Returns:
unused
Throws:
COSVisitorException - If there is an exception while visiting this object.

visitFromString

public Object visitFromString(COSString obj)
                       throws COSVisitorException
visitFromString.

Specified by:
visitFromString in interface ICOSObjectVisitor
Parameters:
obj - The object that is being visited.
Returns:
unused
Throws:
COSVisitorException - If there is an exception while visiting this object.

write

public void write(byte[] b)
           throws IOException
This will write some byte to the stream.

Parameters:
b - The source byte array.
Throws:
IOException - If the underlying stream throws an exception.

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
This will write some byte to the stream.

Parameters:
b - The source byte array.
off - The offset into the array to start writing.
len - The number of bytes to write.
Throws:
IOException - If the underlying stream throws an exception.

write

public void write(int b)
           throws IOException
This will write a single byte to the stream.

Parameters:
b - The byte to write to the stream.
Throws:
IOException - If there is an error writing to the underlying stream.

writeContentStream

public void writeContentStream(CSContent contentStream)
                        throws IOException
Throws:
IOException

writeDocument

public void writeDocument(STDocument doc)
                   throws IOException
Throws:
IOException

writeEOL

public void writeEOL()
              throws IOException
This will write an EOL to the stream.

Throws:
IOException - If there is an error writing to the stream

writeIndirectObject

public void writeIndirectObject(COSIndirectObject object)
                         throws IOException
Throws:
IOException

writeObject

public void writeObject(COSObject object)
                 throws IOException
This will write a cos object to the stream

Parameters:
object - the object to write
Throws:
IOException - If an error occurs while generating the data.

intarsys PDF library API

Copyright © 2006 intarsys consulting GmbH. All Rights Reserved.