at.gv.egiz.pdfas.io
Class ByteArrayDataSink

java.lang.Object
  extended byat.gv.egiz.pdfas.io.ByteArrayDataSink
All Implemented Interfaces:
DataSink

public class ByteArrayDataSink
extends Object
implements DataSink

Author:
wprinz

Field Summary
protected  String characterEncoding
          The character encoding.
protected  String mimeType
          The mime type.
 
Constructor Summary
ByteArrayDataSink()
           
 
Method Summary
 OutputStream createOutputStream(String mimeType)
          Creates an OutputStream for binary data.
 OutputStream createOutputStream(String mimeType, String characterEncoding)
          Creates an OutputStream for character data.
 String getCharacterEncoding()
          Returns the character encoding of the data stream.
 byte[] getData()
          Returns the byte data, or null if none available.
 String getMimeType()
          Returns the mime type of the data stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mimeType

protected String mimeType
The mime type.


characterEncoding

protected String characterEncoding
The character encoding.

Constructor Detail

ByteArrayDataSink

public ByteArrayDataSink()
Method Detail

createOutputStream

public OutputStream createOutputStream(String mimeType)
                                throws IOException
Description copied from interface: DataSink
Creates an OutputStream for binary data.

Note that the stream may be written only once. Creating another stream overwrites the existing one.

Specified by:
createOutputStream in interface DataSink
Parameters:
mimeType - The mime type of the output data.
Returns:
Returns the created output stream.
Throws:
IOException - Thrown if the stream cannot be created.
See Also:
DataSink.createOutputStream(java.lang.String)

createOutputStream

public OutputStream createOutputStream(String mimeType,
                                       String characterEncoding)
                                throws IOException
Description copied from interface: DataSink
Creates an OutputStream for character data.

This is basically the same as DataSink.createOutputStream(String), but allows to specify the character encoding.

Specified by:
createOutputStream in interface DataSink
Parameters:
mimeType - The mime type of the output data.
characterEncoding - The character encoding of the data.
Returns:
Returns the created output stream.
Throws:
IOException - Thrown if the stream cannot be created.
See Also:
DataSink.createOutputStream(java.lang.String, java.lang.String)

getMimeType

public String getMimeType()
Description copied from interface: DataSink
Returns the mime type of the data stream.

This is only valid after a stream has been created.

Specified by:
getMimeType in interface DataSink
Returns:
Returns the mime type of the data stream.
See Also:
DataSink.getMimeType()

getCharacterEncoding

public String getCharacterEncoding()
Description copied from interface: DataSink
Returns the character encoding of the data stream.

This is only valid after a stream has been created. Null means that no character encoding was specified for the data (e.g. if the data is binary).

Specified by:
getCharacterEncoding in interface DataSink
Returns:
Returns the character encoding of the data stream.
See Also:
DataSink.getCharacterEncoding()

getData

public byte[] getData()
Returns the byte data, or null if none available.

Note that internally, this just calls the ByteArrayOutputStream.toByteArray() method.

Returns:
Returns the byte data, or null if none available.


Copyright © 2006-2010. All Rights Reserved.