Class GuacamoleParser

java.lang.Object
org.apache.guacamole.protocol.GuacamoleParser
All Implemented Interfaces:
Iterator<GuacamoleInstruction>

public class GuacamoleParser extends Object implements Iterator<GuacamoleInstruction>
Parser for the Guacamole protocol. Arbitrary instruction data is appended, and instructions are returned as a result. Invalid instructions result in exceptions.
  • Field Details

    • INSTRUCTION_MAX_LENGTH

      public static final int INSTRUCTION_MAX_LENGTH
      The maximum number of characters per instruction.
      See Also:
    • INSTRUCTION_MAX_DIGITS

      public static final int INSTRUCTION_MAX_DIGITS
      The maximum number of digits to allow per length prefix.
      See Also:
    • INSTRUCTION_MAX_ELEMENTS

      public static final int INSTRUCTION_MAX_ELEMENTS
      The maximum number of elements per instruction, including the opcode.
      See Also:
  • Constructor Details

    • GuacamoleParser

      public GuacamoleParser()
  • Method Details

    • append

      public int append(char[] chunk, int offset, int length) throws GuacamoleException
      Appends data from the given buffer to the current instruction.
      Parameters:
      chunk - The buffer containing the data to append.
      offset - The offset within the buffer where the data begins.
      length - The length of the data to append.
      Returns:
      The number of characters appended, or 0 if complete instructions have already been parsed and must be read via next() before more data can be appended.
      Throws:
      GuacamoleException - If an error occurs while parsing the new data.
    • append

      public int append(char[] chunk) throws GuacamoleException
      Appends data from the given buffer to the current instruction.
      Parameters:
      chunk - The data to append.
      Returns:
      The number of characters appended, or 0 if complete instructions have already been parsed and must be read via next() before more data can be appended.
      Throws:
      GuacamoleException - If an error occurs while parsing the new data.
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<GuacamoleInstruction>
    • next

      public GuacamoleInstruction next()
      Specified by:
      next in interface Iterator<GuacamoleInstruction>
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<GuacamoleInstruction>