001: /*
002: Copyright © 2006,2007 Stefano Chizzolini. http://clown.stefanochizzolini.it
003:
004: Contributors:
005: * Stefano Chizzolini (original code developer, http://www.stefanochizzolini.it):
006: contributed code is Copyright © 2006,2007 by Stefano Chizzolini.
007:
008: This file should be part of the source code distribution of "PDF Clown library"
009: (the Program): see the accompanying README files for more info.
010:
011: This Program is free software; you can redistribute it and/or modify it under
012: the terms of the GNU General Public License as published by the Free Software
013: Foundation; either version 2 of the License, or (at your option) any later version.
014:
015: This Program is distributed in the hope that it will be useful, but WITHOUT ANY
016: WARRANTY, either expressed or implied; without even the implied warranty of
017: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more details.
018:
019: You should have received a copy of the GNU General Public License along with this
020: Program (see README files); if not, go to the GNU website (http://www.gnu.org/).
021:
022: Redistribution and use, with or without modification, are permitted provided that such
023: redistributions retain the above copyright notice, license and disclaimer, along with
024: this list of conditions.
025: */
026:
027: package it.stefanochizzolini.clown.bytes;
028:
029: import java.io.EOFException;
030: import java.nio.ByteOrder;
031:
032: /**
033: Input stream.
034: <p>Its pivotal concept is the access pointer.</p>
035: @version 0.0.4
036: */
037: public interface IInputStream {
038: /**
039: Gets the byte order.
040: */
041: ByteOrder getByteOrder();
042:
043: /**
044: Gets the used buffer size.
045: */
046: long getLength();
047:
048: /**
049: Gets the pointer position.
050: */
051: long getPosition();
052:
053: /**
054: Gets the hash representation of the sequence.
055: */
056: int hashCode();
057:
058: /**
059: Reads a sequence of bytes from the stream and advances the position within the stream.
060: @param data Target byte array.
061: */
062: void read(byte[] data) throws EOFException;
063:
064: /**
065: Reads a sequence of bytes from the stream and advances the position within the stream.
066: @param data Target byte array.
067: @param offset Location in the byte array at which storing begins.
068: @param length Number of bytes to copy.
069: */
070: void read(byte[] data, int offset, int length) throws EOFException;
071:
072: /**
073: Reads a byte from the stream and advances the position within the stream.
074: @return Byte from the stream.
075: */
076: byte readByte() throws EOFException;
077:
078: /**
079: Reads an integer from the stream and advances the position within the stream.
080: @return Integer from the stream.
081: */
082: int readInt() throws EOFException;
083:
084: /**
085: Reads the next line of text.
086: @return String from the stream.
087: */
088: String readLine() throws EOFException;
089:
090: /**
091: Reads a short integer from the stream and advances the position within the stream.
092: @return Short integer from the stream.
093: */
094: short readShort() throws EOFException;
095:
096: /**
097: Reads a string from the stream and advances the position within the stream.
098: @param length Number of bytes to read.
099: @return String from the stream.
100: */
101: String readString(int length) throws EOFException;
102:
103: /**
104: Reads an unsigned byte integer from the stream and advances the position within the stream.
105: @return Unsigned byte integer from the stream.
106: */
107: int readUnsignedByte() throws EOFException;
108:
109: /**
110: Reads an unsigned short integer from the stream and advances the position within the stream.
111: @return Unsigned short integer from the stream.
112: */
113: int readUnsignedShort() throws EOFException;
114:
115: /**
116: Sets the pointer absolute position.
117: */
118: void seek(long position);
119:
120: /**
121: Sets the byte order.
122: */
123: void setByteOrder(ByteOrder value);
124:
125: /**
126: Sets the pointer position.
127: */
128: void setPosition(long value);
129:
130: /**
131: Sets the pointer relative position.
132: */
133: void skip(long offset);
134:
135: /**
136: Gets the buffer data copied to a newly-allocated byte array.
137: */
138: byte[] toByteArray();
139: }
|