Package org.apache.guacamole.protocol
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 Summary
Fields Modifier and Type Field Description static int
INSTRUCTION_MAX_DIGITS
The maximum number of digits to allow per length prefix.static int
INSTRUCTION_MAX_ELEMENTS
The maximum number of elements per instruction, including the opcode.static int
INSTRUCTION_MAX_LENGTH
The maximum number of characters per instruction.
-
Constructor Summary
Constructors Constructor Description GuacamoleParser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
append(char[] chunk)
Appends data from the given buffer to the current instruction.int
append(char[] chunk, int offset, int length)
Appends data from the given buffer to the current instruction.boolean
hasNext()
GuacamoleInstruction
next()
void
remove()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Field Detail
-
INSTRUCTION_MAX_LENGTH
public static final int INSTRUCTION_MAX_LENGTH
The maximum number of characters per instruction.- See Also:
- Constant Field Values
-
INSTRUCTION_MAX_DIGITS
public static final int INSTRUCTION_MAX_DIGITS
The maximum number of digits to allow per length prefix.- See Also:
- Constant Field Values
-
INSTRUCTION_MAX_ELEMENTS
public static final int INSTRUCTION_MAX_ELEMENTS
The maximum number of elements per instruction, including the opcode.- See Also:
- Constant Field Values
-
-
Method Detail
-
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 interfaceIterator<GuacamoleInstruction>
-
next
public GuacamoleInstruction next()
- Specified by:
next
in interfaceIterator<GuacamoleInstruction>
-
remove
public void remove()
- Specified by:
remove
in interfaceIterator<GuacamoleInstruction>
-
-