]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/util/binary/BinaryReadable.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / util / binary / BinaryReadable.java
1 /*******************************************************************************
2  *  Copyright (c) 2010 Association for Decentralized Information Management in
3  *  Industry THTH ry.
4  *  All rights reserved. This program and the accompanying materials
5  *  are made available under the terms of the Eclipse Public License v1.0
6  *  which accompanies this distribution, and is available at
7  *  http://www.eclipse.org/legal/epl-v10.html
8  *
9  *  Contributors:
10  *      VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.databoard.util.binary;
13
14 import java.io.DataInput;
15 import java.io.EOFException;
16 import java.io.IOException;
17 import java.nio.ByteBuffer;
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
30         long skipBytes(long bytes) throws IOException;
31     
32     /**
33      * Read buf fully
34      * 
35      * @param buf
36      * @throws EOFException if this stream reaches the end before reading all
37      *         the bytes.
38      * @throws IOException if an I/O error occurs.
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
49      *               all the bytes.
50      * @throws IOException   if an I/O error occurs.
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