org.apache.pdfbox.pdmodel.common
Class PDTextStream

java.lang.Object
  extended by org.apache.pdfbox.pdmodel.common.PDTextStream
All Implemented Interfaces:
COSObjectable

public class PDTextStream
extends Object
implements COSObjectable

A PDTextStream class is used when the PDF specification supports either a string or a stream for the value of an object. This is usually when a value could be large or small, for example a JavaScript method. This class will help abstract that and give a single unified interface to those types of fields.

Version:
$Revision: 1.3 $
Author:
Ben Litchfield

Constructor Summary
PDTextStream(COSStream str)
          Constructor.
PDTextStream(COSString str)
          Constructor.
PDTextStream(String str)
          Constructor.
 
Method Summary
static PDTextStream createTextStream(COSBase base)
          This will create the text stream object.
 InputStream getAsStream()
          This is the preferred way of getting data with this class as it uses a stream object.
 String getAsString()
          This will get this value as a string.
 COSBase getCOSObject()
          Convert this standard java object to a COS object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PDTextStream

public PDTextStream(COSString str)
Constructor.

Parameters:
str - The string parameter.

PDTextStream

public PDTextStream(String str)
Constructor.

Parameters:
str - The string parameter.

PDTextStream

public PDTextStream(COSStream str)
Constructor.

Parameters:
str - The stream parameter.
Method Detail

createTextStream

public static PDTextStream createTextStream(COSBase base)
This will create the text stream object. base must either be a string or a stream.

Parameters:
base - The COS text stream object.
Returns:
A PDTextStream that wraps the base object.

getCOSObject

public COSBase getCOSObject()
Convert this standard java object to a COS object.

Specified by:
getCOSObject in interface COSObjectable
Returns:
The cos object that matches this Java object.

getAsString

public String getAsString()
                   throws IOException
This will get this value as a string. If this is a stream then it will load the entire stream into memory, so you should only do this when the stream is a manageable size.

Returns:
This value as a string.
Throws:
IOException - If an IO error occurs while accessing the stream.

getAsStream

public InputStream getAsStream()
                        throws IOException
This is the preferred way of getting data with this class as it uses a stream object.

Returns:
The stream object.
Throws:
IOException - If an IO error occurs while accessing the stream.


Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.