From: <ha...@us...> - 2007-02-27 13:41:11
|
Revision: 6967 http://svn.sourceforge.net/jmol/?rev=6967&view=rev Author: hansonr Date: 2007-02-27 05:41:06 -0800 (Tue, 27 Feb 2007) Log Message: ----------- compiler cleanup Modified Paths: -------------- trunk/Jmol/src/org/jmol/viewer/Compiler.java trunk/Jmol/src/org/jmol/viewer/Eval.java Modified: trunk/Jmol/src/org/jmol/viewer/Compiler.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Compiler.java 2007-02-27 13:36:31 UTC (rev 6966) +++ trunk/Jmol/src/org/jmol/viewer/Compiler.java 2007-02-27 13:41:06 UTC (rev 6967) @@ -453,6 +453,10 @@ return (ch == ';' || ch == '\r' || ch == '\n'); } + static boolean isOneOf(String key, String semiList) { + return (';' + semiList + ';').indexOf(';' + key + ';') >= 0; + } + private boolean lookingAtLeadingWhitespace() { //log("lookingAtLeadingWhitespace"); int ichT = ichToken; @@ -1337,7 +1341,7 @@ //distance was specified, but to what? getToken(); key = ((String) theValue).toLowerCase(); - if (";plane;hkl;coord;".indexOf(";" + key + ";") >= 0) { + if (isOneOf(key, "plane;hkl;coord")) { addTokenToPostfix(new Token(Token.string, key)); } else { returnToken(); @@ -1347,7 +1351,7 @@ } } } - if (";plane;hkl;coord;".indexOf(";" + key + ";") >= 0) + if (isOneOf(key, "plane;hkl;coord")) isCoordOrPlane = true; addNextTokenIf(Token.comma); if (isCoordOrPlane) { Modified: trunk/Jmol/src/org/jmol/viewer/Eval.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Eval.java 2007-02-27 13:36:31 UTC (rev 6966) +++ trunk/Jmol/src/org/jmol/viewer/Eval.java 2007-02-27 13:41:06 UTC (rev 6967) @@ -6490,8 +6490,8 @@ else type = "XYZ"; } - boolean isImage = isOneOf(type, "JPEG;JPG64;JPG;PPM;PNG"); - if (!isImage && !isOneOf(type, "SPT;HIS;MO;ISO;VAR;XYZ;MOL;PDB")) + boolean isImage = Compiler.isOneOf(type, "JPEG;JPG64;JPG;PPM;PNG"); + if (!isImage && !Compiler.isOneOf(type, "SPT;HIS;MO;ISO;VAR;XYZ;MOL;PDB")) evalError(GT._("write what? {0} or {1} \"filename\"", new Object[] { "STATE|HISTORY|IMAGE|ISOSURFACE|MO CLIPBOARD|VAR x|DATA", "JPG|JPG64|PNG|PPM|SPT|JVXL|XYZ|MOL|PDB" })); @@ -8715,14 +8715,14 @@ float distance = 0; boolean isSequence = false; if (withinSpec instanceof String) - isSequence = !isOneOf(withinStr, "element;site;group;chain;molecule;model"); + isSequence = !Compiler.isOneOf(withinStr, "element;site;group;chain;molecule;model"); else if (withinSpec instanceof Float) distance = Token.fValue(args[0]); else return false; if (args.length == 3) { withinStr = Token.sValue(args[1]); - if (!isOneOf(withinStr,"plane;hkl;coord")) + if (!Compiler.isOneOf(withinStr,"plane;hkl;coord")) return false; } if (isSyntaxCheck) @@ -9090,9 +9090,4 @@ } } - - static boolean isOneOf(String key, String semiList) { - return (";" + semiList + ";").indexOf(";" + key + ";") >= 0; - } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |