com.qoppa.pdf.source
Class URLOnDemandPDFSource

java.lang.Object
  extended by com.qoppa.pdf.source.URLOnDemandPDFSource
All Implemented Interfaces:
PDFSource

public class URLOnDemandPDFSource
extends Object
implements PDFSource

Implementation of the PDFSource interface that will load sections of a PDF on demand. This This PDFSource can be used to display the first page of the PDF before the whole PDF is loaded. The source creates a local copy of the PDF either in a byte array or a local temp file and downloads sections of the PDF only when they are accessed.

Author:
Qoppa Software

Field Summary
static int STORE_BYTE_ARRAY
           
static int STORE_TEMP_FILE
           
 
Constructor Summary
URLOnDemandPDFSource(URL url, File tempFile)
          Create a PDFSource to read a PDF from a URL "on demand".
URLOnDemandPDFSource(URL url, int storeType)
          Create a PDFSource to read a PDF from a URL "on demand".
 
Method Summary
 boolean equals(PDFSource other)
          Compares this PDF source to anothe URLOnDemandPDFSource for equality.
 PDFContent getContent()
          Create an object to implement PDFContent.
 String getName()
          Gets the name of this PDF source.
 String getPath()
          Returns the URL path to the PDF document.
 int getSectorSize()
          Returns the current sector size.
 URL getURL()
          Returns the URL where the PDF came from.
 void setSectorSize(int sectorSize)
          Set the sector size to use when reading the PDF.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STORE_BYTE_ARRAY

public static final int STORE_BYTE_ARRAY
See Also:
Constant Field Values

STORE_TEMP_FILE

public static final int STORE_TEMP_FILE
See Also:
Constant Field Values
Constructor Detail

URLOnDemandPDFSource

public URLOnDemandPDFSource(URL url,
                            int storeType)
                     throws PDFException
Create a PDFSource to read a PDF from a URL "on demand". On demand means that the PDF is read one sector at a time, when the contents of that sector are needed to render the PDF content. This source depends on the HTTP server supporting the HTTP Range property.

Parameters:
url - The URL to the PDF document.
storeType - The type of local storage to use. This can be STORE_BYTE_ARRAY to keep local content in a byte array, or STORE_TEMP_FILE to store the contents in a temporary file.
Throws:
PDFException

URLOnDemandPDFSource

public URLOnDemandPDFSource(URL url,
                            File tempFile)
                     throws PDFException
Create a PDFSource to read a PDF from a URL "on demand". On demand means that the PDF is read one sector at a time, when the contents of that sector are needed to render the PDF content. This source depends on the HTTP server supporting the HTTP Range property.

Parameters:
url - The URL to the PDF document.
tempFile - A temporary file used to store the PDF content locally.
Throws:
PDFException
Method Detail

setSectorSize

public void setSectorSize(int sectorSize)
Set the sector size to use when reading the PDF. This value implies a compromise: with larger sector sizes, there is less HTTP requests, but more of the document is read at load time. The default sector size is set at 64 KB.

Parameters:
sectorSize -

getSectorSize

public int getSectorSize()
Returns the current sector size.

Returns:
The sector size.

equals

public boolean equals(PDFSource other)
Compares this PDF source to anothe URLOnDemandPDFSource for equality.

Specified by:
equals in interface PDFSource

getName

public String getName()
Gets the name of this PDF source.

Specified by:
getName in interface PDFSource

getPath

public String getPath()
Returns the URL path to the PDF document.

Specified by:
getPath in interface PDFSource

getURL

public URL getURL()
Returns the URL where the PDF came from.

Returns:
The URL location of the PDF document.

getContent

public PDFContent getContent()
                      throws IOException
Create an object to implement PDFContent.

Specified by:
getContent in interface PDFSource
Returns:
Returns an object that implements the PDFContent interface.
Throws:
IOException