@Override
    public GuacamoleInstruction next() {

        // No instruction to return if not yet complete
        if (state != State.COMPLETE)
            return null;
        
        // Reset for next instruction.
        state = State.PARSING_LENGTH;
        elementCount = 0;
        elementLength = 0;
        
        return parsedInstruction;

    }
Appends data from the given buffer to the current instruction.

@param chunk The data to append.
@return 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.
guacamole-common/src/main/java/org/apache/guacamole/protocol/GuacamoleParser.java