From fbe13396231f42475418314a0768ddcfef515ab6 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 29 Jan 2013 14:17:11 -0800 Subject: [PATCH] Expose immutable List rather than array in GuacamoleInstruction. Bump version to 0.8.0. --- .../protocol/ConfiguredGuacamoleSocket.java | 24 +++++++++----- .../protocol/GuacamoleInstruction.java | 33 ++++++++++++++----- 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/guacamole-common/src/main/java/net/sourceforge/guacamole/protocol/ConfiguredGuacamoleSocket.java b/guacamole-common/src/main/java/net/sourceforge/guacamole/protocol/ConfiguredGuacamoleSocket.java index 0dd34abe8..4fafc54a2 100644 --- a/guacamole-common/src/main/java/net/sourceforge/guacamole/protocol/ConfiguredGuacamoleSocket.java +++ b/guacamole-common/src/main/java/net/sourceforge/guacamole/protocol/ConfiguredGuacamoleSocket.java @@ -37,6 +37,7 @@ package net.sourceforge.guacamole.protocol; * * ***** END LICENSE BLOCK ***** */ +import java.util.List; import net.sourceforge.guacamole.GuacamoleException; import net.sourceforge.guacamole.GuacamoleServerException; import net.sourceforge.guacamole.io.GuacamoleReader; @@ -117,16 +118,21 @@ public class ConfiguredGuacamoleSocket implements GuacamoleSocket { } while (!instruction.getOpcode().equals("args")); // Build args list off provided names and config - String[] args = new String[instruction.getArgs().length]; - for (int i=0; i arg_names = instruction.getArgs(); + String[] arg_values = new String[arg_names.size()]; + for (int i=0; i args; /** * Creates a new GuacamoleInstruction having the given Operation and @@ -58,7 +69,7 @@ public class GuacamoleInstruction { */ public GuacamoleInstruction(String opcode, String... args) { this.opcode = opcode; - this.args = args; + this.args = Collections.unmodifiableList(Arrays.asList(args)); } /** @@ -70,13 +81,14 @@ public class GuacamoleInstruction { } /** - * Returns an array of all argument values specified for this - * GuacamoleInstruction. + * Returns a List of all argument values specified for this + * GuacamoleInstruction. Note that the List returned is immutable. + * Attempts to modify the list will result in exceptions. * - * @return An array of all argument values specified for this + * @return A List of all argument values specified for this * GuacamoleInstruction. */ - public String[] getArgs() { + public List getArgs() { return args; } @@ -92,17 +104,20 @@ public class GuacamoleInstruction { StringBuilder buff = new StringBuilder(); + // Write opcode buff.append(opcode.length()); buff.append('.'); buff.append(opcode); - for (int i=0; i