Class 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
    • 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 array
      int getSize()
      Return document size
      void 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
    • 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.
    • Constructor Detail

      • AbstractDocument

        public AbstractDocument()
    • 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.
        Specified by:
        load in interface Document
        Parameters:
        file - File.
        Throws:
        java.io.FileNotFoundException
        java.io.IOException
      • load

        public void load​(java.io.InputStream inputStream)
                  throws java.io.IOException
        Description copied from interface: Document
        Load document from an InputStream.
        Specified by:
        load in interface Document
        Throws:
        java.io.IOException
      • write

        public void write​(java.io.File file)
                   throws java.io.IOException
        Description copied from interface: Document
        Write document to a File.
        Specified by:
        write in interface Document
        Parameters:
        file - File.
        Throws:
        java.io.IOException
      • write

        public void write​(java.io.OutputStream outputStream)
                   throws java.io.IOException
        Description copied from interface: Document
        Write document to an OutputStream
        Specified by:
        write in interface Document
        Throws:
        java.io.IOException
      • getSize

        public int getSize()
        Description copied from interface: Document
        Return document size
        Specified by:
        getSize in interface Document
        Returns:
        Document size in bytes.
      • getContent

        public byte[] getContent()
        Description copied from interface: Document
        Return document content as a byte array
        Specified by:
        getContent in interface Document
        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 index
        end - Range end index
        Throws:
        DocumentException