]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/util/binary/BinaryReadable.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / util / binary / BinaryReadable.java
1 /*******************************************************************************\r
2  *  Copyright (c) 2010 Association for Decentralized Information Management in\r
3  *  Industry THTH ry.\r
4  *  All rights reserved. This program and the accompanying materials\r
5  *  are made available under the terms of the Eclipse Public License v1.0\r
6  *  which accompanies this distribution, and is available at\r
7  *  http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  *  Contributors:\r
10  *      VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.databoard.util.binary;
13
14 import java.io.DataInput;\r
15 import java.io.EOFException;\r
16 import java.io.IOException;\r
17 import java.nio.ByteBuffer;\r
18
19 /**
20  * BinaryReadable is a readable stream of bytes.
21  * 
22  * Common interface for ByteBuffer, byte[], InputStream, RandomAccessFile.
23  * 
24  * @see ByteBufferReadable
25  * @see InputStreamReadable
26  * @author Toni Kalajainen (toni.kalajainen@vtt.fi)
27  */
28 public interface BinaryReadable extends DataInput {
29 \r
30         long skipBytes(long bytes) throws IOException;\r
31     
32     /**\r
33      * Read buf fully\r
34      * \r
35      * @param buf\r
36      * @throws EOFException if this stream reaches the end before reading all\r
37      *         the bytes.\r
38      * @throws IOException if an I/O error occurs.\r
39      */
40     void readFully(ByteBuffer buf)
41     throws IOException;
42     
43     /**
44      * Read fully length bytes
45      * 
46      * @param buf
47      * @param length
48      * @throws EOFException  if this stream reaches the end before reading\r
49      *               all the bytes.\r
50      * @throws IOException   if an I/O error occurs.\r
51      */
52     void readFully(ByteBuffer buf, int length)
53     throws IOException;
54         
55         long length() throws IOException;
56     
57         long position() throws IOException;
58                 
59 }
60