Package one.nio.serial
Class DataStream
- java.lang.Object
-
- one.nio.serial.DataStream
-
- All Implemented Interfaces:
DataInput,DataOutput,ObjectInput,ObjectOutput,AutoCloseable
- Direct Known Subclasses:
DeserializeStream,ObjectInputChannel,ObjectOutputChannel,SerializerCollector,SerializeStream
public class DataStream extends Object implements ObjectInput, ObjectOutput
-
-
Field Summary
Fields Modifier and Type Field Description protected longaddressprotected byte[]arrayprotected static byteFIRST_BOOT_UIDprotected longlimitprotected longoffsetprotected static byteREF_EMBEDDEDprotected static byteREF_NULLprotected static byteREF_RECURSIVEprotected static byteREF_RECURSIVE2
-
Constructor Summary
Constructors Modifier Constructor Description DataStream(byte[] array)protectedDataStream(byte[] array, long address, long length)DataStream(int capacity)DataStream(long address, long length)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longaddress()protected longalloc(int size)byte[]array()intavailable()ByteBufferbyteBuffer(int len)voidclose()intcount()voidflush()CloseablenewScope()intread()intread(byte[] b)intread(byte[] b, int off, int len)voidread(ByteBuffer dst)booleanreadBoolean()bytereadByte()charreadChar()doublereadDouble()floatreadFloat()voidreadFully(byte[] b)voidreadFully(byte[] b, int off, int len)intreadInt()StringreadLine()longreadLong()ObjectreadObject()protected ObjectreadRef(byte tag)shortreadShort()voidreadTo(long address, int len)intreadUnsignedByte()intreadUnsignedShort()StringreadUTF()voidregister(Object obj)longskip(long n)intskipBytes(int n)voidwrite(byte[] b)voidwrite(byte[] b, int off, int len)voidwrite(int b)voidwrite(ByteBuffer src)voidwriteBoolean(boolean v)voidwriteByte(int v)voidwriteBytes(String s)voidwriteChar(int v)voidwriteChars(String s)voidwriteDouble(double v)voidwriteFloat(float v)voidwriteFrom(long address, int len)voidwriteInt(int v)voidwriteLong(long v)voidwriteObject(Object obj)voidwriteShort(int v)voidwriteUTF(String s)
-
-
-
Field Detail
-
REF_NULL
protected static final byte REF_NULL
- See Also:
- Constant Field Values
-
REF_RECURSIVE
protected static final byte REF_RECURSIVE
- See Also:
- Constant Field Values
-
REF_RECURSIVE2
protected static final byte REF_RECURSIVE2
- See Also:
- Constant Field Values
-
REF_EMBEDDED
protected static final byte REF_EMBEDDED
- See Also:
- Constant Field Values
-
FIRST_BOOT_UID
protected static final byte FIRST_BOOT_UID
- See Also:
- Constant Field Values
-
array
protected byte[] array
-
address
protected long address
-
limit
protected long limit
-
offset
protected long offset
-
-
Method Detail
-
array
public byte[] array()
-
address
public long address()
-
count
public int count()
-
write
public void write(int b) throws IOException- Specified by:
writein interfaceDataOutput- Specified by:
writein interfaceObjectOutput- Throws:
IOException
-
write
public void write(byte[] b) throws IOException- Specified by:
writein interfaceDataOutput- Specified by:
writein interfaceObjectOutput- Throws:
IOException
-
write
public void write(byte[] b, int off, int len) throws IOException- Specified by:
writein interfaceDataOutput- Specified by:
writein interfaceObjectOutput- Throws:
IOException
-
writeBoolean
public void writeBoolean(boolean v) throws IOException- Specified by:
writeBooleanin interfaceDataOutput- Throws:
IOException
-
writeByte
public void writeByte(int v) throws IOException- Specified by:
writeBytein interfaceDataOutput- Throws:
IOException
-
writeShort
public void writeShort(int v) throws IOException- Specified by:
writeShortin interfaceDataOutput- Throws:
IOException
-
writeChar
public void writeChar(int v) throws IOException- Specified by:
writeCharin interfaceDataOutput- Throws:
IOException
-
writeInt
public void writeInt(int v) throws IOException- Specified by:
writeIntin interfaceDataOutput- Throws:
IOException
-
writeLong
public void writeLong(long v) throws IOException- Specified by:
writeLongin interfaceDataOutput- Throws:
IOException
-
writeFloat
public void writeFloat(float v) throws IOException- Specified by:
writeFloatin interfaceDataOutput- Throws:
IOException
-
writeDouble
public void writeDouble(double v) throws IOException- Specified by:
writeDoublein interfaceDataOutput- Throws:
IOException
-
writeBytes
public void writeBytes(String s) throws IOException
- Specified by:
writeBytesin interfaceDataOutput- Throws:
IOException
-
writeChars
public void writeChars(String s) throws IOException
- Specified by:
writeCharsin interfaceDataOutput- Throws:
IOException
-
writeUTF
public void writeUTF(String s) throws IOException
- Specified by:
writeUTFin interfaceDataOutput- Throws:
IOException
-
writeObject
public void writeObject(Object obj) throws IOException
- Specified by:
writeObjectin interfaceObjectOutput- Throws:
IOException
-
write
public void write(ByteBuffer src) throws IOException
- Throws:
IOException
-
writeFrom
public void writeFrom(long address, int len) throws IOException- Throws:
IOException
-
read
public int read() throws IOException- Specified by:
readin interfaceObjectInput- Throws:
IOException
-
read
public int read(byte[] b) throws IOException- Specified by:
readin interfaceObjectInput- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOException- Specified by:
readin interfaceObjectInput- Throws:
IOException
-
readFully
public void readFully(byte[] b) throws IOException- Specified by:
readFullyin interfaceDataInput- Throws:
IOException
-
readFully
public void readFully(byte[] b, int off, int len) throws IOException- Specified by:
readFullyin interfaceDataInput- Throws:
IOException
-
skip
public long skip(long n) throws IOException- Specified by:
skipin interfaceObjectInput- Throws:
IOException
-
skipBytes
public int skipBytes(int n) throws IOException- Specified by:
skipBytesin interfaceDataInput- Throws:
IOException
-
readBoolean
public boolean readBoolean() throws IOException- Specified by:
readBooleanin interfaceDataInput- Throws:
IOException
-
readByte
public byte readByte() throws IOException- Specified by:
readBytein interfaceDataInput- Throws:
IOException
-
readUnsignedByte
public int readUnsignedByte() throws IOException- Specified by:
readUnsignedBytein interfaceDataInput- Throws:
IOException
-
readShort
public short readShort() throws IOException- Specified by:
readShortin interfaceDataInput- Throws:
IOException
-
readUnsignedShort
public int readUnsignedShort() throws IOException- Specified by:
readUnsignedShortin interfaceDataInput- Throws:
IOException
-
readChar
public char readChar() throws IOException- Specified by:
readCharin interfaceDataInput- Throws:
IOException
-
readInt
public int readInt() throws IOException- Specified by:
readIntin interfaceDataInput- Throws:
IOException
-
readLong
public long readLong() throws IOException- Specified by:
readLongin interfaceDataInput- Throws:
IOException
-
readFloat
public float readFloat() throws IOException- Specified by:
readFloatin interfaceDataInput- Throws:
IOException
-
readDouble
public double readDouble() throws IOException- Specified by:
readDoublein interfaceDataInput- Throws:
IOException
-
readLine
public String readLine() throws IOException
- Specified by:
readLinein interfaceDataInput- Throws:
IOException
-
readUTF
public String readUTF() throws IOException
- Specified by:
readUTFin interfaceDataInput- Throws:
IOException
-
readObject
public Object readObject() throws IOException, ClassNotFoundException
- Specified by:
readObjectin interfaceObjectInput- Throws:
IOExceptionClassNotFoundException
-
readRef
protected Object readRef(byte tag) throws IOException, ClassNotFoundException
- Throws:
IOExceptionClassNotFoundException
-
read
public void read(ByteBuffer dst) throws IOException
- Throws:
IOException
-
readTo
public void readTo(long address, int len) throws IOException- Throws:
IOException
-
byteBuffer
public ByteBuffer byteBuffer(int len) throws IOException
- Throws:
IOException
-
available
public int available()
- Specified by:
availablein interfaceObjectInput
-
flush
public void flush() throws IOException- Specified by:
flushin interfaceObjectOutput- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceObjectInput- Specified by:
closein interfaceObjectOutput- Throws:
IOException
-
register
public void register(Object obj)
-
newScope
public Closeable newScope()
-
alloc
protected long alloc(int size) throws IOException- Throws:
IOException
-
-