git://source.jalview.org
/
jalview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
JAL-4265 Added saveState and restoreState to interface with no-op methods in abstract...
[jalview.git]
/
src
/
jalview
/
ws
/
rest
/
InputType.java
diff --git
a/src/jalview/ws/rest/InputType.java
b/src/jalview/ws/rest/InputType.java
index
91fce18
..
6ac720a
100644
(file)
--- a/
src/jalview/ws/rest/InputType.java
+++ b/
src/jalview/ws/rest/InputType.java
@@
-20,6
+20,8
@@
*/
package jalview.ws.rest;
*/
package jalview.ws.rest;
+import java.util.Locale;
+
import jalview.ws.params.ArgumentI;
import jalview.ws.params.InvalidArgumentException;
import jalview.ws.params.OptionI;
import jalview.ws.params.ArgumentI;
import jalview.ws.params.InvalidArgumentException;
import jalview.ws.params.OptionI;
@@
-46,6
+48,9
@@
import org.apache.http.entity.mime.content.StringBody;
*/
public abstract class InputType
{
*/
public abstract class InputType
{
+ private static final Pattern URL_PATTERN = Pattern
+ .compile("^([^=]+)=?'?([^']*)?'?");
+
/**
* not used yet
*/
/**
* not used yet
*/
@@
-127,17
+132,17
@@
public abstract class InputType
{
if (type == null)
{
{
if (type == null)
{
- return new StringBody(utf8.encode(content).asCharBuffer()
- .toString());
+ return new StringBody(
+ utf8.encode(content).asCharBuffer().toString());
}
else
{
}
else
{
- return new StringBody(utf8.encode(content).asCharBuffer()
- .toString(), type, utf8);
+ return new StringBody(
+ utf8.encode(content).asCharBuffer().toString(), type, utf8);
}
} catch (Exception ex)
{
}
} catch (Exception ex)
{
- System.err.println("Couldn't transform string\n" + content
+ jalview.bin.Console.errPrintln("Couldn't transform string\n" + content
+ "\nException was :");
ex.printStackTrace(System.err);
}
+ "\nException was :");
ex.printStackTrace(System.err);
}
@@
-209,7
+214,7
@@
public abstract class InputType
boolean valid = true;
for (String tok : tokenstring)
{
boolean valid = true;
for (String tok : tokenstring)
{
- Matcher mtch = Pattern.compile("^([^=]+)=?'?([^']*)?'?").matcher(tok);
+ Matcher mtch = URL_PATTERN.matcher(tok);
if (mtch.find())
{
try
if (mtch.find())
{
try
@@
-229,8
+234,8
@@
public abstract class InputType
{
valid = false;
warnings.append("Invalid value for parameter "
{
valid = false;
warnings.append("Invalid value for parameter "
- + mtch.group(1).toLowerCase() + " '" + mtch.group(2)
- + "' (expected an integer)\n");
+ + mtch.group(1).toLowerCase(Locale.ROOT) + " '"
+ + mtch.group(2) + "' (expected an integer)\n");
}
if (!configureProperty(mtch.group(1), mtch.group(2), warnings))
}
if (!configureProperty(mtch.group(1), mtch.group(2), warnings))
@@
-304,9
+309,10
@@
public abstract class InputType
{
// TODO: revise architecture - this is counter intuitive - options with
// different values to their names are actually parameters
{
// TODO: revise architecture - this is counter intuitive - options with
// different values to their names are actually parameters
- rg = (arg.getValue().length() > 0) ? (arg.getValue().equals(
- arg.getName()) ? arg.getName() : arg.getName() + "='"
- + arg.getValue() + "'") : arg.getName();
+ rg = (arg.getValue().length() > 0)
+ ? (arg.getValue().equals(arg.getName()) ? arg.getName()
+ : arg.getName() + "='" + arg.getValue() + "'")
+ : arg.getName();
}
if (rg.length() > 0)
{
}
if (rg.length() > 0)
{
@@
-314,7
+320,8
@@
public abstract class InputType
}
}
StringBuffer warnings;
}
}
StringBuffer warnings;
- if (!configureFromURLtokenString(urltoks, warnings = new StringBuffer()))
+ if (!configureFromURLtokenString(urltoks,
+ warnings = new StringBuffer()))
{
throw new InvalidArgumentException(warnings.toString());
}
{
throw new InvalidArgumentException(warnings.toString());
}
@@
-323,8
+330,8
@@
public abstract class InputType
protected OptionI createMolTypeOption(String name, String descr,
boolean req, molType curType, molType defType)
{
protected OptionI createMolTypeOption(String name, String descr,
boolean req, molType curType, molType defType)
{
- return new Option(name, descr, req, defType == null ? ""
- : defType.toString(),
+ return new Option(name, descr, req,
+ defType == null ? "" : defType.toString(),
curType == null ? "" : curType.toString(),
molType.toStringValues(), null);
}
curType == null ? "" : curType.toString(),
molType.toStringValues(), null);
}