mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-267: Avoid unnecessarily rebuilding the Guacamole protocol form of a GuacamoleInstruction.
This commit is contained in:
@@ -33,12 +33,18 @@ public class GuacamoleInstruction {
|
|||||||
/**
|
/**
|
||||||
* The opcode of this instruction.
|
* The opcode of this instruction.
|
||||||
*/
|
*/
|
||||||
private String opcode;
|
private final String opcode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All arguments of this instruction, in order.
|
* All arguments of this instruction, in order.
|
||||||
*/
|
*/
|
||||||
private List<String> args;
|
private final List<String> args;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The cached result of converting this GuacamoleInstruction to the format
|
||||||
|
* used by the Guacamole protocol.
|
||||||
|
*/
|
||||||
|
private String protocolForm = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new GuacamoleInstruction having the given Operation and
|
* Creates a new GuacamoleInstruction having the given Operation and
|
||||||
@@ -91,12 +97,17 @@ public class GuacamoleInstruction {
|
|||||||
* Returns this GuacamoleInstruction in the form it would be sent over the
|
* Returns this GuacamoleInstruction in the form it would be sent over the
|
||||||
* Guacamole protocol.
|
* Guacamole protocol.
|
||||||
*
|
*
|
||||||
* @return This GuacamoleInstruction in the form it would be sent over the
|
* @return
|
||||||
|
* This GuacamoleInstruction in the form it would be sent over the
|
||||||
* Guacamole protocol.
|
* Guacamole protocol.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
||||||
|
// Avoid rebuilding Guacamole protocol form of instruction if already
|
||||||
|
// known
|
||||||
|
if (protocolForm == null) {
|
||||||
|
|
||||||
StringBuilder buff = new StringBuilder();
|
StringBuilder buff = new StringBuilder();
|
||||||
|
|
||||||
// Write opcode
|
// Write opcode
|
||||||
@@ -115,7 +126,12 @@ public class GuacamoleInstruction {
|
|||||||
// Write terminator
|
// Write terminator
|
||||||
buff.append(';');
|
buff.append(';');
|
||||||
|
|
||||||
return buff.toString();
|
// Cache result for future calls
|
||||||
|
protocolForm = buff.toString();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return protocolForm;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user