From 55022c858882bcabf92ad7bba05c41b5a221625c Mon Sep 17 00:00:00 2001 From: jprocter Date: Mon, 29 Aug 2011 13:48:41 +0100 Subject: [PATCH] JAL-633, JAL-591 - refactored ArgumentI.getValue from jabaws .getDefaultValue --- src/jalview/ws/jws2/dm/JabaOption.java | 4 +-- src/jalview/ws/jws2/dm/JabaValueConstrain.java | 11 +++++-- src/jalview/ws/params/ArgumentI.java | 18 ++++++++--- .../ws/params/InvalidArgumentException.java | 33 ++++++++++++++++++++ src/jalview/ws/params/ValueConstrainI.java | 8 +++-- 5 files changed, 63 insertions(+), 11 deletions(-) create mode 100644 src/jalview/ws/params/InvalidArgumentException.java diff --git a/src/jalview/ws/jws2/dm/JabaOption.java b/src/jalview/ws/jws2/dm/JabaOption.java index be4912b..6a139b0 100644 --- a/src/jalview/ws/jws2/dm/JabaOption.java +++ b/src/jalview/ws/jws2/dm/JabaOption.java @@ -35,7 +35,7 @@ public class JabaOption implements jalview.ws.params.OptionI Option opt; @Override - public String getDefaultValue() + public String getValue() { return opt.getDefaultValue(); } @@ -72,7 +72,7 @@ public class JabaOption implements jalview.ws.params.OptionI } @Override - public void setDefaultValue(String selectedItem) + public void setValue(String selectedItem) { try { diff --git a/src/jalview/ws/jws2/dm/JabaValueConstrain.java b/src/jalview/ws/jws2/dm/JabaValueConstrain.java index f3e3930..611aa59 100644 --- a/src/jalview/ws/jws2/dm/JabaValueConstrain.java +++ b/src/jalview/ws/jws2/dm/JabaValueConstrain.java @@ -33,10 +33,15 @@ public class JabaValueConstrain implements ValueConstrainI } @Override - public Type getType() + public ValueType getType() { - // TODO: refactor to local Jalview parameter type system. - return vc.getType(); + if (vc.getType()==ValueConstrain.Type.Float) { + return ValueType.Float; + } + if (vc.getType()==ValueConstrain.Type.Integer) { + return ValueType.Integer; + } + throw new Error("IMPLEMENTATION ERROR: jalview.ws.params.ValueConstrainI.ValueType does not support the JABAWS type :"+vc.toString()); } @Override diff --git a/src/jalview/ws/params/ArgumentI.java b/src/jalview/ws/params/ArgumentI.java index 2f42838..b464daa 100644 --- a/src/jalview/ws/params/ArgumentI.java +++ b/src/jalview/ws/params/ArgumentI.java @@ -19,12 +19,22 @@ package jalview.ws.params; public interface ArgumentI { + /** + * + * @return name for this argument + */ String getName(); - // TODO: rename setDefaultValue to setValue - to make it more semantically - // obvious what it means! - String getDefaultValue(); + /** + * + * @return current value for the argument (may equal the name) + */ + String getValue(); - void setDefaultValue(String selectedItem); + /** + * set the current value for the argument. + * @param selectedItem + */ + void setValue(String selectedItem); } diff --git a/src/jalview/ws/params/InvalidArgumentException.java b/src/jalview/ws/params/InvalidArgumentException.java new file mode 100644 index 0000000..978f756 --- /dev/null +++ b/src/jalview/ws/params/InvalidArgumentException.java @@ -0,0 +1,33 @@ +/** + * + */ +package jalview.ws.params; + +/** + * Raised if an object configured by an instance of jalview.ws.params.ArgumentI + * is given an instance which it does not support. + */ +public class InvalidArgumentException extends Exception +{ + + public InvalidArgumentException() + { + super(); + } + + public InvalidArgumentException(String message, Throwable cause) + { + super(message, cause); + } + + public InvalidArgumentException(String message) + { + super(message); + } + + public InvalidArgumentException(Throwable cause) + { + super(cause); + } + +} diff --git a/src/jalview/ws/params/ValueConstrainI.java b/src/jalview/ws/params/ValueConstrainI.java index fa24ba0..6941d48 100644 --- a/src/jalview/ws/params/ValueConstrainI.java +++ b/src/jalview/ws/params/ValueConstrainI.java @@ -26,8 +26,12 @@ import compbio.metadata.ValueConstrain.Type; public interface ValueConstrainI { - // TODO: remove dependence on ValueConstraint.Type - Type getType(); + public enum ValueType { + Integer, + Float, + String + }; + ValueType getType(); Number getMax(); -- 1.7.10.2