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[]contentContent of the document.static intREAD_BUFFER_SIZEBuffer size used while reading (loading) document content.private static longserialVersionUIDSerial 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 voidappend(Document document)Append pages of another document to the current document.protected voidassertValidPageIndex(int index)Assert the given page index is valid for the current document.protected voidassertValidPageRange(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 arrayintgetSize()Return document sizevoidload(java.io.File file)Load document from a File.voidload(java.io.InputStream inputStream)Load document from an InputStream.voidwrite(java.io.File file)Write document to a File.voidwrite(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.IOExceptionDescription copied from interface:DocumentLoad document from a File.
-
load
public void load(java.io.InputStream inputStream) throws java.io.IOExceptionDescription copied from interface:DocumentLoad document from an InputStream.
-
write
public void write(java.io.File file) throws java.io.IOExceptionDescription copied from interface:DocumentWrite document to a File.
-
write
public void write(java.io.OutputStream outputStream) throws java.io.IOExceptionDescription copied from interface:DocumentWrite document to an OutputStream
-
getSize
public int getSize()
Description copied from interface:DocumentReturn document size
-
getContent
public byte[] getContent()
Description copied from interface:DocumentReturn document content as a byte array- Specified by:
getContentin interfaceDocument- Returns:
- Byte array
-
assertValidPageIndex
protected void assertValidPageIndex(int index) throws DocumentExceptionAssert 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 DocumentExceptionAssert 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:DocumentAppend pages of another document to the current document.- Specified by:
appendin interfaceDocument- Parameters:
document- Document ot append- Throws:
DocumentException
-
explode
public java.util.List<Document> explode() throws DocumentException
Description copied from interface:DocumentSeparate each pages to a new document.- Specified by:
explodein interfaceDocument- Returns:
- A list of Document.
- Throws:
DocumentException
-
-