JWS-17: fix problem with undefined URL for the furtherDetails tag
[jabaws.git] / datamodel / compbio / metadata / Option.java
index 3f47bb0..93361dd 100644 (file)
@@ -18,6 +18,7 @@
 \r
 package compbio.metadata;\r
 \r
+import java.net.MalformedURLException;\r
 import java.net.URL;\r
 import java.util.ArrayList;\r
 import java.util.HashSet;\r
@@ -30,6 +31,7 @@ import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;\r
 import javax.xml.bind.annotation.XmlAttribute;\r
 import javax.xml.bind.annotation.XmlElement;\r
+import javax.xml.bind.annotation.XmlTransient;\r
 \r
 import compbio.util.SysPrefs;\r
 import compbio.util.Util;\r
@@ -59,15 +61,17 @@ public class Option<T> implements Argument<T> {
        @XmlAttribute\r
        protected boolean isRequired;\r
        @XmlElement\r
-       protected URL furtherDetails;\r
+       protected String furtherDetails;\r
        @XmlElement\r
        protected String defaultValue;\r
+       @XmlTransient\r
+       private URL basicURL;\r
 \r
        Option() {\r
                // Has to have no arg constructor for JAXB\r
        }\r
 \r
-       public Option(String name, String description) {\r
+       public Option(String name, String description) throws MalformedURLException {\r
                this.name = name;\r
                this.description = description;\r
        }\r
@@ -83,6 +87,16 @@ public class Option<T> implements Argument<T> {
                this.name = name;\r
        }\r
 \r
+       public void setBasicURL(URL url) {\r
+               this.basicURL = url;\r
+       }\r
+       public URL getBasicURL() throws MalformedURLException {\r
+               URL out = new URL ("http://unknown.jabaws.server.ac.uk");\r
+               if (null != basicURL) {\r
+                       out = basicURL;\r
+               }\r
+               return out;\r
+       }       \r
        /**\r
         * A long description of the Option\r
         */\r
@@ -96,12 +110,13 @@ public class Option<T> implements Argument<T> {
 \r
        /**\r
         * The URL where further details about the option can be found\r
+        * @throws MalformedURLException \r
         */\r
-       public URL getFurtherDetails() {\r
+       public String getFurtherDetails() {\r
                return furtherDetails;\r
        }\r
 \r
-       public void setFurtherDetails(URL furtherDetails) {\r
+       public void setFurtherDetails(String furtherDetails) {\r
                this.furtherDetails = furtherDetails;\r
        }\r
 \r
@@ -190,17 +205,23 @@ public class Option<T> implements Argument<T> {
                String value = "Option name: " + this.name + SysPrefs.newlinechar;\r
                value += "Description: " + this.description + SysPrefs.newlinechar;\r
                if (!Util.isEmpty(defaultValue)) {\r
-                       value += "Default value: " + this.defaultValue\r
-                                       + SysPrefs.newlinechar;\r
+                       value += "Default value: " + this.defaultValue + SysPrefs.newlinechar;\r
+               }\r
+               if (null != this.furtherDetails) {\r
+                       value += "URL: " + this.basicURL + this.furtherDetails + SysPrefs.newlinechar;\r
+               } else {\r
+                       value += "URL: unknown URL" + SysPrefs.newlinechar;\r
                }\r
-               value += "URL: " + this.furtherDetails + SysPrefs.newlinechar;\r
                value += "Is required: " + this.isRequired + SysPrefs.newlinechar;\r
                if (!this.optionNames.isEmpty()) {\r
                        Set<String> sortedPosval = new TreeSet<String>(this.optionNames);\r
-                       value += "Option Names: " + SysPrefs.newlinechar;\r
+                       value += "Option(s): ";\r
+                       String delim = "";\r
                        for (String val : sortedPosval) {\r
-                               value += val + SysPrefs.newlinechar;\r
+                               value += delim + val;\r
+                               delim = ", ";\r
                        }\r
+                       value += SysPrefs.newlinechar;\r
                }\r
                return value;\r
        }\r