Message info
 
To:cytoscape-cvs@googlegroups.com From:cytoscape-noreply54@cytoscape.org Subject:r29134 - in core3/impl/trunk/command-executor-impl/src/main/java/org/cytoscape/command/internal: . tunables Date:Mon, 7 May 2012 13:54:08 -0700
 

Author: mes
Date: 2012-05-07 13:54:07 -0700 (Mon, 07 May 2012)
New Revision: 29134

Modified:
core3/impl/trunk/command-executor-impl/src/main/java/org/cytoscape/command/internal/CommandExecutorImpl.java
core3/impl/trunk/command-executor-impl/src/main/java/org/cytoscape/command/internal/tunables/AbstractStringTunableHandler.java
Log:
added support for parsing quoted strings

Modified: core3/impl/trunk/command-executor-impl/src/main/java/org/cytoscape/command/internal/CommandExecutorImpl.java
===================================================================
--- core3/impl/trunk/command-executor-impl/src/main/java/org/cytoscape/command/internal/CommandExecutorImpl.java 2012-05-07 20:00:35 UTC (rev 29133)
+++ core3/impl/trunk/command-executor-impl/src/main/java/org/cytoscape/command/internal/CommandExecutorImpl.java 2012-05-07 20:54:07 UTC (rev 29134)
@@ -107,21 +107,6 @@
}
}

- // If the key matches the first chars of the line, then
- // return the remainder of the line. Otherwise return null.
- private String peel(String line, String key) {
- if ( line.length() < key.length() ) {
- return null;
- }
- final String match = line.substring(0,key.length());
- final String remainder = line.substring(key.length(),line.length()).trim();
- if ( match.equals(key) ) {
- return remainder;
- } else {
- return null;
- }
- }
-
public void executeList(List<String> commandLines, TaskMonitor tm) throws Exception {

double size = (double)commandLines.size();

Modified: core3/impl/trunk/command-executor-impl/src/main/java/org/cytoscape/command/internal/tunables/AbstractStringTunableHandler.java
===================================================================
--- core3/impl/trunk/command-executor-impl/src/main/java/org/cytoscape/command/internal/tunables/AbstractStringTunableHandler.java 2012-05-07 20:00:35 UTC (rev 29133)
+++ core3/impl/trunk/command-executor-impl/src/main/java/org/cytoscape/command/internal/tunables/AbstractStringTunableHandler.java 2012-05-07 20:54:07 UTC (rev 29134)
@@ -16,6 +16,9 @@
public abstract class AbstractStringTunableHandler extends AbstractTunableHandler implements StringTunableHandler {

private static final Logger logger = LoggerFactory.getLogger(IntTunableHandler.class);
+ private static final String SPACE = " ";
+ private static final String EQUALS = "=";
+ private static final String QUOTE = "\"";

public AbstractStringTunableHandler(Field f, Object o, Tunable t) {
super(f,o,t);
@@ -31,12 +34,16 @@
if ( s == null )
return;

- String[] args = s.split("\s+");
+ String[] args = s.split(SPACE);

- for ( String arg : args ) {
+ for ( int i = 0; i < args.length; i++ ) {
+ String arg = args[i];

- String[] keyValue = arg.split("=");
+ if ( arg.isEmpty() )
+ continue;

+ String[] keyValue = arg.split(EQUALS);
+
if ( keyValue.length != 2 ) {
logger.warn("couldn't parse 'key=value' string from arg: '" + arg +"'");
continue;
@@ -45,6 +52,18 @@
String key = keyValue[0];
String value = keyValue[1];

+ // process any quote marks
+ if ( value.startsWith(QUOTE) ) {
+
+ // get additional strings from args that are part of this value
+ while ( value.startsWith(QUOTE) && !value.endsWith(QUOTE)) {
+ value = value + SPACE + args[++i];
+ }
+
+ // strip off quote marks
+ value = value.substring(1,value.length()-1);
+ }
+
if ( key.equals(getName()) ) {
Object result;
try {

--
You received this message because you are subscribed to the Google Groups "cytoscape-cvs" group.
To post to this group, send email to cytoscape-cvs@googlegroups.com.
To unsubscribe from this group, send email to cytoscape-cvs+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cytoscape-cvs?hl=en.