Package com.aparapi.internal.reader
Class ByteReader
- java.lang.Object
-
- com.aparapi.internal.reader.ByteReader
-
public class ByteReader extends java.lang.Object
Primarily used to parse various ClassFile structures. This class provides low level access to sequential bytes in a stream given stream.Basically wraps a
ByteBuffer
and keeps track of the current offset. All requests on thisByteReader
will be delegated to wrappedByteBuffer
.- See Also:
ByteBuffer
-
-
Field Summary
Fields Modifier and Type Field Description private ByteBuffer
byteBuffer
private int
offset
-
Constructor Summary
Constructors Constructor Description ByteReader(byte[] _bytes)
Construct form an array of bytes.ByteReader(ByteBuffer _byteBuffer)
Construct form a given ByteBuffer.ByteReader(java.io.InputStream _inputStream)
Construct form an input stream (say a ClassFile).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
bytes(int _length)
double
d8()
float
f4()
int
getOffset()
boolean
hasMore()
int
peekU2()
int
s2()
int
s4()
void
setOffset(int _offset)
void
skip(int _length)
int
u1()
int
u2()
int
u4()
long
u8()
java.lang.String
utf8()
-
-
-
Field Detail
-
byteBuffer
private final ByteBuffer byteBuffer
-
offset
private int offset
-
-
Constructor Detail
-
ByteReader
public ByteReader(ByteBuffer _byteBuffer)
Construct form a given ByteBuffer.- Parameters:
_byteBuffer
- an existingByteBuffer
-
ByteReader
public ByteReader(byte[] _bytes)
Construct form an array of bytes.- Parameters:
_bytes
- an existing byte array
-
ByteReader
public ByteReader(java.io.InputStream _inputStream)
Construct form an input stream (say a ClassFile).- Parameters:
_inputStream
- a stream of bytes
-
-
Method Detail
-
u1
public int u1()
-
u2
public int u2()
-
s2
public int s2()
-
peekU2
public int peekU2()
-
u4
public int u4()
-
s4
public int s4()
-
u8
public long u8()
-
f4
public float f4()
-
d8
public double d8()
-
utf8
public java.lang.String utf8()
-
bytes
public byte[] bytes(int _length)
-
skip
public void skip(int _length)
-
getOffset
public int getOffset()
-
setOffset
public void setOffset(int _offset)
-
hasMore
public boolean hasMore()
-
-