Home » pdfbox-1.1.0-src » org.apache.pdfbox.io » [javadoc | source]

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   package org.apache.pdfbox.io;
   18   
   19   import java.io.IOException;
   20   
   21   /**
   22    * An interface to allow PDF files to be stored completely in memory or
   23    * to use a scratch file on the disk.
   24    *
   25    * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
   26    * @version $Revision: 1.2 $
   27    */
   28   public interface RandomAccess
   29   {
   30   
   31       /**
   32        * Release resources that are being held.
   33        *
   34        * @throws IOException If there is an error closing this resource.
   35        */
   36       public void close() throws IOException;
   37   
   38       /**
   39        * Seek to a position in the data.
   40        *
   41        * @param position The position to seek to.
   42        * @throws IOException If there is an error while seeking.
   43        */
   44       public void seek(long position) throws IOException;
   45   
   46       /**
   47        * Read a single byte of data.
   48        *
   49        * @return The byte of data that is being read.
   50        *
   51        * @throws IOException If there is an error while reading the data.
   52        */
   53       public int read() throws IOException;
   54   
   55       /**
   56        * Read a buffer of data.
   57        *
   58        * @param b The buffer to write the data to.
   59        * @param offset Offset into the buffer to start writing.
   60        * @param length The amount of data to attempt to read.
   61        * @return The number of bytes that were actually read.
   62        * @throws IOException If there was an error while reading the data.
   63        */
   64       public int read(byte[] b, int offset, int length) throws IOException;
   65   
   66       /**
   67        * The total number of bytes that are available.
   68        *
   69        * @return The number of bytes available.
   70        *
   71        * @throws IOException If there is an IO error while determining the
   72        * length of the data stream.
   73        */
   74       public long length() throws IOException;
   75   
   76       /**
   77        * Write a byte to the stream.
   78        *
   79        * @param b The byte to write.
   80        * @throws IOException If there is an IO error while writing.
   81        */
   82       public void write(int b) throws IOException;
   83   
   84       /**
   85        * Write a buffer of data to the stream.
   86        *
   87        * @param b The buffer to get the data from.
   88        * @param offset An offset into the buffer to get the data from.
   89        * @param length The length of data to write.
   90        * @throws IOException If there is an error while writing the data.
   91        */
   92       public void write(byte[] b, int offset, int length) throws IOException;
   93   
   94   }

Home » pdfbox-1.1.0-src » org.apache.pdfbox.io » [javadoc | source]