Package com.aoindustries.io.stream
Class StreamableInput
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- java.io.DataInputStream
-
- com.aoindustries.io.stream.StreamableInput
-
- All Implemented Interfaces:
Closeable,DataInput,AutoCloseable
public class StreamableInput extends DataInputStream
Adds compressed data transfer to DataInputStream. This class is not thread safe.- Author:
- AO Industries, Inc.
-
-
Field Summary
-
Fields inherited from class java.io.FilterInputStream
in
-
-
Constructor Summary
Constructors Constructor Description StreamableInput(InputStream in)
-
Method Summary
-
Methods inherited from class java.io.DataInputStream
read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, readUTF, skipBytes
-
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skip
-
-
-
-
Constructor Detail
-
StreamableInput
public StreamableInput(InputStream in)
-
-
Method Detail
-
readCompressedInt
public static int readCompressedInt(InputStream in) throws IOException
Reads a compressed integer from the stream. The 31 bit pattern is as follows:5 bit - 000SXXXX 13 bit - 001SXXXX XXXXXXXX 22 bit - 01SXXXXX XXXXXXXX XXXXXXXX 31 bit - 1SXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
- Throws:
EOFException- if the end of file is reachedIOException
-
readCompressedInt
public int readCompressedInt() throws IOExceptionReads a compressed integer from the stream. The 31 bit pattern is as follows:5 bit - 000SXXXX 13 bit - 001SXXXX XXXXXXXX 22 bit - 01SXXXXX XXXXXXXX XXXXXXXX 31 bit - 1SXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
- Throws:
EOFException- if the end of file is reachedIOException
-
readCompressedUTF
public String readCompressedUTF() throws IOException
- Throws:
EOFException- if the end of file is reachedIOException
-
readNullUTF
public String readNullUTF() throws IOException
- Throws:
IOException
-
readLongUTF
public String readLongUTF() throws IOException
Reads a string of any length.- Throws:
IOException
-
readNullLongUTF
public String readNullLongUTF() throws IOException
Reads a string of any length, supportingnull.- Throws:
IOException
-
readNullByte
public Byte readNullByte() throws IOException
- Throws:
IOException
-
readNullShort
public Short readNullShort() throws IOException
- Throws:
IOException
-
readNullInteger
public Integer readNullInteger() throws IOException
- Throws:
IOException
-
readNullLong
public Long readNullLong() throws IOException
- Throws:
IOException
-
readEnum
public <T extends Enum<T>> T readEnum(Class<T> enumType) throws IOException
Reads anEnum, represented by itsEnum.name().- Throws:
IOException
-
readNullEnum
public <T extends Enum<T>> T readNullEnum(Class<T> enumType) throws IOException
- Throws:
IOException
-
readNullBoolean
public Boolean readNullBoolean() throws IOException
- Throws:
IOException
-
readTimestamp
public static Timestamp readTimestamp(DataInputStream in) throws IOException
Reads aTimestamp, maintaining the full nanosecond precision. Time zone offset is not maintained.See
StreamableOutput.writeTimestamp(java.sql.Timestamp, java.io.DataOutputStream)for wire protocol details.- Throws:
IOException
-
readTimestamp
public Timestamp readTimestamp() throws IOException
Reads aTimestamp.- Throws:
IOException- See Also:
readTimestamp(java.io.DataInputStream)
-
readNullTimestamp
public Timestamp readNullTimestamp() throws IOException
Reads a possibly-nullTimestamp.- Throws:
IOException- See Also:
readTimestamp()
-
readUnmodifiableTimestamp
public static UnmodifiableTimestamp readUnmodifiableTimestamp(DataInputStream in) throws IOException
Reads anUnmodifiableTimestamp, maintaining the full nanosecond precision. Time zone offset is not maintained.See
StreamableOutput.writeTimestamp(java.sql.Timestamp, java.io.DataOutputStream)for wire protocol details.- Throws:
IOException
-
readUnmodifiableTimestamp
public UnmodifiableTimestamp readUnmodifiableTimestamp() throws IOException
Reads anUnmodifiableTimestamp.- Throws:
IOException- See Also:
readUnmodifiableTimestamp(java.io.DataInputStream)
-
readNullUnmodifiableTimestamp
public UnmodifiableTimestamp readNullUnmodifiableTimestamp() throws IOException
Reads a possibly-nullUnmodifiableTimestamp.- Throws:
IOException- See Also:
readUnmodifiableTimestamp()
-
readIdentifier
public Identifier readIdentifier() throws IOException
Reads anIdentifier.- Throws:
IOException
-
readNullIdentifier
public Identifier readNullIdentifier() throws IOException
Reads a possibly-nullIdentifier.- Throws:
IOException
-
readSmallIdentifier
public SmallIdentifier readSmallIdentifier() throws IOException
Reads aSmallIdentifier.- Throws:
IOException
-
readNullSmallIdentifier
public SmallIdentifier readNullSmallIdentifier() throws IOException
Reads a possibly-nullIdentifier.- Throws:
IOException
-
-