Package org.ghost4j.document
Class AbstractDocument
- java.lang.Object
-
- org.ghost4j.document.AbstractDocument
-
- All Implemented Interfaces:
java.io.Serializable
,Document
- Direct Known Subclasses:
PDFDocument
,PSDocument
public abstract class AbstractDocument extends java.lang.Object implements Document, java.io.Serializable
Abstract document implementation. Contains methods that are common to the different document types- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]
content
Content of the document.static int
READ_BUFFER_SIZE
Buffer size used while reading (loading) document content.private static long
serialVersionUID
Serial version UID.-
Fields inherited from interface org.ghost4j.document.Document
TYPE_PDF, TYPE_POSTSCRIPT
-
-
Constructor Summary
Constructors Constructor Description AbstractDocument()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
append(Document document)
Append pages of another document to the current document.protected void
assertValidPageIndex(int index)
Assert the given page index is valid for the current document.protected void
assertValidPageRange(int begin, int end)
Assert the given page range is valid for the current document.java.util.List<Document>
explode()
Separate each pages to a new document.byte[]
getContent()
Return document content as a byte arrayint
getSize()
Return document sizevoid
load(java.io.File file)
Load document from a File.void
load(java.io.InputStream inputStream)
Load document from an InputStream.void
write(java.io.File file)
Write document to a File.void
write(java.io.OutputStream outputStream)
Write document to an OutputStream-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.ghost4j.document.Document
extract, getPageCount, getType
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
Serial version UID.- See Also:
- Constant Field Values
-
READ_BUFFER_SIZE
public static final int READ_BUFFER_SIZE
Buffer size used while reading (loading) document content.- See Also:
- Constant Field Values
-
content
protected byte[] content
Content of the document.
-
-
Method Detail
-
load
public void load(java.io.File file) throws java.io.FileNotFoundException, java.io.IOException
Description copied from interface:Document
Load document from a File.
-
load
public void load(java.io.InputStream inputStream) throws java.io.IOException
Description copied from interface:Document
Load document from an InputStream.
-
write
public void write(java.io.File file) throws java.io.IOException
Description copied from interface:Document
Write document to a File.
-
write
public void write(java.io.OutputStream outputStream) throws java.io.IOException
Description copied from interface:Document
Write document to an OutputStream
-
getSize
public int getSize()
Description copied from interface:Document
Return document size
-
getContent
public byte[] getContent()
Description copied from interface:Document
Return document content as a byte array- Specified by:
getContent
in interfaceDocument
- Returns:
- Byte array
-
assertValidPageIndex
protected void assertValidPageIndex(int index) throws DocumentException
Assert the given page index is valid for the current document.- Parameters:
index
- Index to check- Throws:
DocumentException
- Thrown if index is not valid
-
assertValidPageRange
protected void assertValidPageRange(int begin, int end) throws DocumentException
Assert the given page range is valid for the current document.- Parameters:
begin
- Range begin indexend
- Range end index- Throws:
DocumentException
-
append
public void append(Document document) throws DocumentException
Description copied from interface:Document
Append pages of another document to the current document.- Specified by:
append
in interfaceDocument
- Parameters:
document
- Document ot append- Throws:
DocumentException
-
explode
public java.util.List<Document> explode() throws DocumentException
Description copied from interface:Document
Separate each pages to a new document.- Specified by:
explode
in interfaceDocument
- Returns:
- A list of Document.
- Throws:
DocumentException
-
-