public class StreamRemoteConnection extends Object implements RemoteConnection
Constructor and Description |
---|
StreamRemoteConnection(InputStream is,
OutputStream os) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the connection.
|
void |
flushCommand()
Ends the command frame.
|
InputStream |
getInputStream()
Get the InputStream used by the instance.
|
OutputStream |
getOutputStream()
Get the OuputStream used by the instance.
|
boolean |
readBoolean()
Reads a boolean parameter.
|
byte[] |
readByteArray()
Reads a byte array parameter.
|
InputStream |
readByteArrayAsInputStream()
Reads a byte array using an input stream.
|
String |
readCommand()
Reads a command.
|
double |
readDouble()
Reads a double parameter.
|
float |
readFloat()
Reads a float parameter.
|
InputStream |
readInputStream()
Reads an input stream.
|
int |
readInt()
Reads an integer parameter.
|
long |
readLong()
Reads a long parameter.
|
Object |
readObject()
Reads a parameter, whatever it's type.
|
List<Object> |
readParameters()
Reads the parameters of a command.
|
String |
readString()
Reads a string parameter.
|
protected void |
releaseLock() |
void |
sendBoolean(boolean b)
Sends a boolean parameter.
|
void |
sendByteArray(byte[] a)
Sends a byte array parameter.
|
void |
sendByteArray(byte[] buffer,
int offset,
int length)
Sends a byte array parameter with offset and length.
|
void |
sendByteArrayAsInputStream(InputStream is)
Sends a byte array parameter using an input stream.
|
void |
sendDouble(double d)
Sends a double parameter.
|
void |
sendFloat(float f)
Sends a float parameter.
|
void |
sendInputStream(InputStream is)
Sends an input stream.
|
void |
sendInt(int i)
Sends an integer parameter.
|
void |
sendLong(long l)
Sends a long parameter.
|
void |
sendParams(List<Object> params)
Sends the given parameters.
|
void |
sendString(String s)
Sends a string parameter.
|
void |
skipParameters()
Skips the parameters of a command and get ready to read the following
command.
|
void |
startCommand(String command)
Starts a command.
|
protected void |
takeLock() |
public StreamRemoteConnection(InputStream is, OutputStream os)
public void close()
RemoteConnection
close
in interface RemoteConnection
public void flushCommand()
CommandSender
flushCommand
in interface CommandSender
@Nullable public InputStream getInputStream()
CommandSender
getInputStream
in interface CommandSender
null
if this command sender is not ready to send a
command.@Nullable public OutputStream getOutputStream()
CommandSender
getOutputStream
in interface CommandSender
null
if this command sender is not ready to send a
command.public boolean readBoolean() throws IOException
CommandReader
readBoolean
in interface CommandReader
IOException
- the stream has been closed and the contained input stream does not support reading after close, or
another I/O error occurs.public byte[] readByteArray() throws IOException
CommandReader
readByteArray
in interface CommandReader
IOException
- the stream has been closed and the contained input stream does not support reading after close, or
another I/O error occurs.public InputStream readByteArrayAsInputStream() throws IOException
CommandReader
The returned input stream must be fully read before returning the method.
readByteArrayAsInputStream
in interface CommandReader
IOException
- the stream has been closed and the contained input stream does not support reading after close, or
another I/O error occurs.public String readCommand() throws IOException
CommandReader
readCommand
in interface CommandReader
IOException
- the stream has been closed and the contained input stream does not support reading after close, or
another I/O error occurs.public double readDouble() throws IOException
CommandReader
readDouble
in interface CommandReader
IOException
- the stream has been closed and the contained input stream does not support reading after close, or
another I/O error occurs.public float readFloat() throws IOException
CommandReader
readFloat
in interface CommandReader
IOException
- the stream has been closed and the contained input stream does not support reading after close, or
another I/O error occurs.public InputStream readInputStream() throws IOException
CommandReader
The returned input stream must be fully read before returning the method.
readInputStream
in interface CommandReader
IOException
- the stream has been closed and the contained input stream does not support reading after close, or
another I/O error occurs.public int readInt() throws IOException
CommandReader
readInt
in interface CommandReader
IOException
- the stream has been closed and the contained input stream does not support reading after close, or
another I/O error occurs.public long readLong() throws IOException
CommandReader
readLong
in interface CommandReader
IOException
- the stream has been closed and the contained input stream does not support reading after close, or
another I/O error occurs.public Object readObject() throws IOException
CommandReader
readObject
in interface CommandReader
IOException
- the stream has been closed and the contained input stream does
not support reading after close, or another I/O error occurs.public List<Object> readParameters() throws IOException
RemoteConnection
Method CommandReader.skipParameters()
must be called after to be ready to read the following command.
readParameters
in interface RemoteConnection
IOException
public String readString() throws IOException
CommandReader
readString
in interface CommandReader
IOException
- the stream has been closed and the contained input stream does not support reading after close, or
another I/O error occurs.protected void releaseLock()
public void sendBoolean(boolean b)
CommandSender
sendBoolean
in interface CommandSender
b
- the boolean to send.public void sendByteArray(byte[] a)
CommandSender
sendByteArray
in interface CommandSender
a
- the byte array to send.public void sendByteArray(byte[] buffer, int offset, int length)
CommandSender
sendByteArray
in interface CommandSender
buffer
- the byte array to send.offset
- offset in the byte array.length
- data length to send.public void sendByteArrayAsInputStream(InputStream is)
CommandSender
The given input stream is fully read.
sendByteArrayAsInputStream
in interface CommandSender
is
- the input stream to send.public void sendDouble(double d)
CommandSender
sendDouble
in interface CommandSender
d
- the double to send.public void sendFloat(float f)
CommandSender
sendFloat
in interface CommandSender
f
- the float to send.public void sendInputStream(InputStream is)
CommandSender
sendInputStream
in interface CommandSender
is
- the input stream to send.public void sendInt(int i)
CommandSender
sendInt
in interface CommandSender
i
- the integer to send.public void sendLong(long l)
CommandSender
sendLong
in interface CommandSender
l
- the long to send.public void sendParams(List<Object> params)
RemoteConnection
sendParams
in interface RemoteConnection
params
- the list of parameters to send.public void sendString(String s)
CommandSender
sendString
in interface CommandSender
s
- the string to send.public void skipParameters() throws IOException
CommandReader
skipParameters
in interface CommandReader
IOException
public void startCommand(String command)
CommandSender
A command can be followed by arguments.
startCommand
in interface CommandSender
command
- the command name.protected void takeLock()