public class DynamicRemoteConnection extends Object implements RemoteConnection
RemoteConnection
that wraps another RemoteConnection
that can change dynamically.Constructor and Description |
---|
DynamicRemoteConnection() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the connection.
|
void |
flushCommand()
Ends the command frame.
|
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.
|
List<Object> |
readParameters()
Reads the parameters of a command.
|
String |
readString()
Reads a string parameter.
|
void |
sendBoolean(boolean b)
Sends a boolean parameter.
|
void |
sendByteArray(byte[] a)
Sends a byte array parameter.
|
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 |
setConnection(RemoteConnection newConnection)
Set the underlying connection.
|
void |
skipParameters()
Skips the parameters of a command and get ready to read the following command.
|
void |
startCommand(String command)
Starts a command.
|
public void close()
RemoteConnection
close
in interface RemoteConnection
public void flushCommand()
CommandSender
flushCommand
in interface CommandSender
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 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.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 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 setConnection(RemoteConnection newConnection)
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.