Class DynamicRemoteConnection

    • Constructor Detail

      • DynamicRemoteConnection

        public DynamicRemoteConnection()
    • Method Detail

      • setConnection

        public void setConnection​(@Nullable
                                  RemoteConnection newConnection)
        Set the underlying connection. If defined, previous connection is closed.
        Given newConnection can be null.
      • readCommand

        public String readCommand()
                           throws IOException
        Description copied from interface: CommandReader
        Reads a command.
        Specified by:
        readCommand in interface CommandReader
        Returns:
        the command name.
        Throws:
        IOException - the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
      • readString

        public String readString()
                          throws IOException
        Description copied from interface: CommandReader
        Reads a string parameter.
        Specified by:
        readString in interface CommandReader
        Returns:
        the read string.
        Throws:
        IOException - the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
      • readLong

        public long readLong()
                      throws IOException
        Description copied from interface: CommandReader
        Reads a long parameter.
        Specified by:
        readLong in interface CommandReader
        Returns:
        the read long.
        Throws:
        IOException - the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
      • readByteArray

        public byte[] readByteArray()
                             throws IOException
        Description copied from interface: CommandReader
        Reads a byte array parameter.
        Specified by:
        readByteArray in interface CommandReader
        Returns:
        the read byte array.
        Throws:
        IOException - the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
      • readByteArrayAsInputStream

        public InputStream readByteArrayAsInputStream()
                                               throws IOException
        Description copied from interface: CommandReader
        Reads a byte array using an input stream.

        The returned input stream must be fully read before returning the method.

        Specified by:
        readByteArrayAsInputStream in interface CommandReader
        Returns:
        an inputStream that reads the underlying byte array.
        Throws:
        IOException - the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
      • readObject

        public Object readObject()
                          throws IOException
        Description copied from interface: CommandReader
        Reads a parameter, whatever it's type. Note that if the parameter is a byte array, it will be returned as an InputStream that must be completely consumed before reading the next parameter.
        Specified by:
        readObject in interface CommandReader
        Returns:
        an object reflecting the read parameter.
        Throws:
        IOException - the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
      • startCommand

        public void startCommand​(String command)
        Description copied from interface: CommandSender
        Starts a command.

        A command can be followed by arguments.

        Specified by:
        startCommand in interface CommandSender
        Parameters:
        command - the command name.
      • sendString

        public void sendString​(String s)
        Description copied from interface: CommandSender
        Sends a string parameter.
        Specified by:
        sendString in interface CommandSender
        Parameters:
        s - the string to send.
      • sendLong

        public void sendLong​(long l)
        Description copied from interface: CommandSender
        Sends a long parameter.
        Specified by:
        sendLong in interface CommandSender
        Parameters:
        l - the long to send.
      • sendByteArray

        public void sendByteArray​(byte[] a)
        Description copied from interface: CommandSender
        Sends a byte array parameter.
        Specified by:
        sendByteArray in interface CommandSender
        Parameters:
        a - the byte array to send.
      • sendByteArray

        public void sendByteArray​(byte[] buffer,
                                  int offset,
                                  int length)
        Description copied from interface: CommandSender
        Sends a byte array parameter with offset and length.
        Specified by:
        sendByteArray in interface CommandSender
        Parameters:
        buffer - the byte array to send.
        offset - offset in the byte array.
        length - data length to send.
      • sendByteArrayAsInputStream

        public void sendByteArrayAsInputStream​(InputStream is)
        Description copied from interface: CommandSender
        Sends a byte array parameter using an input stream.

        The given input stream is fully read.

        Specified by:
        sendByteArrayAsInputStream in interface CommandSender
        Parameters:
        is - the input stream to send.
      • sendInt

        public void sendInt​(int i)
        Description copied from interface: CommandSender
        Sends an integer parameter.
        Specified by:
        sendInt in interface CommandSender
        Parameters:
        i - the integer to send.
      • sendFloat

        public void sendFloat​(float f)
        Description copied from interface: CommandSender
        Sends a float parameter.
        Specified by:
        sendFloat in interface CommandSender
        Parameters:
        f - the float to send.
      • sendDouble

        public void sendDouble​(double d)
        Description copied from interface: CommandSender
        Sends a double parameter.
        Specified by:
        sendDouble in interface CommandSender
        Parameters:
        d - the double to send.
      • sendBoolean

        public void sendBoolean​(boolean b)
        Description copied from interface: CommandSender
        Sends a boolean parameter.
        Specified by:
        sendBoolean in interface CommandSender
        Parameters:
        b - the boolean to send.
      • readInt

        public int readInt()
                    throws IOException
        Description copied from interface: CommandReader
        Reads an integer parameter.
        Specified by:
        readInt in interface CommandReader
        Returns:
        the read integer.
        Throws:
        IOException - the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
      • readFloat

        public float readFloat()
                        throws IOException
        Description copied from interface: CommandReader
        Reads a float parameter.
        Specified by:
        readFloat in interface CommandReader
        Returns:
        the read float.
        Throws:
        IOException - the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
      • readDouble

        public double readDouble()
                          throws IOException
        Description copied from interface: CommandReader
        Reads a double parameter.
        Specified by:
        readDouble in interface CommandReader
        Returns:
        the read double.
        Throws:
        IOException - the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
      • readBoolean

        public boolean readBoolean()
                            throws IOException
        Description copied from interface: CommandReader
        Reads a boolean parameter.
        Specified by:
        readBoolean in interface CommandReader
        Returns:
        the read boolean.
        Throws:
        IOException - the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
      • readInputStream

        public InputStream readInputStream()
                                    throws IOException
        Description copied from interface: CommandReader
        Reads an input stream.

        The returned input stream must be fully read before returning the method.

        Specified by:
        readInputStream in interface CommandReader
        Returns:
        an inputStream.
        Throws:
        IOException - the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
      • getOutputStream

        @Nullable
        public OutputStream getOutputStream()
        Description copied from interface: CommandSender
        Get the OuputStream used by the instance.
        Specified by:
        getOutputStream in interface CommandSender
        Returns:
        the OuputStream used by the instance, or null if this command sender is not ready to send a command.
      • getInputStream

        @Nullable
        public InputStream getInputStream()
        Description copied from interface: CommandSender
        Get the InputStream used by the instance.
        Specified by:
        getInputStream in interface CommandSender
        Returns:
        the InputStream used by the instance, or null if this command sender is not ready to send a command.