Package one.nio.rpc.stream
Class RpcStreamImpl<S,R>
- java.lang.Object
-
- one.nio.rpc.stream.RpcStreamImpl<S,R>
-
- All Implemented Interfaces:
DataInput,DataOutput,ObjectInput,ObjectOutput,AutoCloseable,BaseStream,BidiStream<S,R>,ReceiveStream<R>,RpcStream,SendStream<S>
public class RpcStreamImpl<S,R> extends Object implements RpcStream, BidiStream<S,R>
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanerrorprotected ObjectInputChannelinprotected ObjectOutputChanneloutprotected Socketsocket
-
Constructor Summary
Constructors Constructor Description RpcStreamImpl(Socket socket)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()voidflush()longgetBytesRead()longgetBytesWritten()voidinvalidate()intread()intread(byte[] b)intread(byte[] b, int off, int len)voidread(ByteBuffer buf)booleanreadBoolean()bytereadByte()charreadChar()doublereadDouble()floatreadFloat()voidreadFully(byte[] b)voidreadFully(byte[] b, int off, int len)intreadInt()StringreadLine()longreadLong()ObjectreadObject()shortreadShort()intreadUnsignedByte()intreadUnsignedShort()StringreadUTF()Rreceive()voidsend(S object)RsendAndGet(S object)longskip(long n)intskipBytes(int n)Socketsocket()voidwrite(byte[] b)voidwrite(byte[] b, int off, int len)voidwrite(int b)voidwrite(ByteBuffer buf)voidwriteBoolean(boolean v)voidwriteByte(int v)voidwriteBytes(String s)voidwriteChar(int v)voidwriteChars(String s)voidwriteDouble(double v)voidwriteFloat(float v)voidwriteInt(int v)voidwriteLong(long v)voidwriteObject(Object obj)voidwriteShort(int v)voidwriteUTF(String s)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface one.nio.rpc.stream.BaseStream
getLocalAddress, getRemoteAddress
-
-
-
-
Field Detail
-
socket
protected final Socket socket
-
in
protected final ObjectInputChannel in
-
out
protected final ObjectOutputChannel out
-
error
protected boolean error
-
-
Constructor Detail
-
RpcStreamImpl
public RpcStreamImpl(Socket socket)
-
-
Method Detail
-
socket
public Socket socket()
- Specified by:
socketin interfaceBaseStream
-
getBytesRead
public long getBytesRead()
- Specified by:
getBytesReadin interfaceBaseStream
-
getBytesWritten
public long getBytesWritten()
- Specified by:
getBytesWrittenin interfaceBaseStream
-
invalidate
public void invalidate()
- Specified by:
invalidatein interfaceBaseStream
-
read
public void read(ByteBuffer buf) throws IOException
- Specified by:
readin interfaceRpcStream- Throws:
IOException
-
readObject
public Object readObject() throws IOException, ClassNotFoundException
- Specified by:
readObjectin interfaceObjectInput- Throws:
IOExceptionClassNotFoundException
-
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
-
skip
public long skip(long n) throws IOException- Specified by:
skipin interfaceObjectInput- Throws:
IOException
-
available
public int available()
- Specified by:
availablein interfaceObjectInput
-
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
-
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
-
write
public void write(ByteBuffer buf) throws IOException
- Specified by:
writein interfaceRpcStream- Throws:
IOException
-
writeObject
public void writeObject(Object obj) throws IOException
- Specified by:
writeObjectin interfaceObjectOutput- Throws:
IOException
-
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
-
flush
public void flush() throws IOException- Specified by:
flushin interfaceBidiStream<S,R>- Specified by:
flushin interfaceObjectOutput- Throws:
IOException
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceBaseStream- Specified by:
closein interfaceObjectInput- Specified by:
closein interfaceObjectOutput
-
receive
public R receive() throws IOException, ClassNotFoundException
- Specified by:
receivein interfaceReceiveStream<S>- Throws:
IOExceptionClassNotFoundException
-
send
public void send(S object) throws IOException
- Specified by:
sendin interfaceSendStream<S>- Throws:
IOException
-
sendAndGet
public R sendAndGet(S object) throws IOException, ClassNotFoundException
- Specified by:
sendAndGetin interfaceBidiStream<S,R>- Throws:
IOExceptionClassNotFoundException
-
-