geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r411615 - in /geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell: builtins/SetCommand.java builtins/UnsetCommand.java command/VariablesImpl.java
Date Sun, 04 Jun 2006 22:41:37 GMT
Author: jdillon
Date: Sun Jun  4 15:41:36 2006
New Revision: 411615

URL: http://svn.apache.org/viewvc?rev=411615&view=rev
Log:
unset needs an identifer for name too

Modified:
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/SetCommand.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/UnsetCommand.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/VariablesImpl.java

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/SetCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/SetCommand.java?rev=411615&r1=411614&r2=411615&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/SetCommand.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/SetCommand.java
Sun Jun  4 15:41:36 2006
@@ -27,6 +27,7 @@
 import org.apache.geronimo.gshell.command.CommandSupport;
 import org.apache.geronimo.gshell.command.Variables;
 import org.apache.geronimo.gshell.command.MessageSource;
+import org.apache.geronimo.gshell.command.VariablesImpl;
 import org.apache.geronimo.gshell.console.IO;
 
 import java.util.Iterator;
@@ -176,28 +177,8 @@
         return nv;
     }
 
-    private boolean isIdentifier(final String name) {
-        if (name == null || name.length() == 0) {
-            return false;
-        }
-
-        char[] chars = name.toCharArray();
-
-        if (!Character.isJavaIdentifierStart(chars[0])) {
-            return false;
-        }
-
-        for (int i=1; i<chars.length; i++) {
-            if (!Character.isJavaIdentifierPart(chars[i])) {
-                return false;
-            }
-        }
-
-        return true;
-    }
-
     private void ensureIsIdentifier(final String name) {
-        if (!isIdentifier(name)) {
+        if (!VariablesImpl.isIdentifier(name)) {
             throw new RuntimeException("Invalid identifer name: " + name);
         }
     }
@@ -208,7 +189,7 @@
         log.info("Setting system property: " + nv.name + "=" + nv.value);
 
         ensureIsIdentifier(nv.name);
-        
+
         System.setProperty(nv.name, nv.value);
     }
 

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/UnsetCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/UnsetCommand.java?rev=411615&r1=411614&r2=411615&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/UnsetCommand.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/UnsetCommand.java
Sun Jun  4 15:41:36 2006
@@ -25,6 +25,7 @@
 import org.apache.geronimo.gshell.command.Command;
 import org.apache.geronimo.gshell.command.CommandSupport;
 import org.apache.geronimo.gshell.command.Variables;
+import org.apache.geronimo.gshell.command.VariablesImpl;
 import org.apache.geronimo.gshell.console.IO;
 
 /**
@@ -120,14 +121,25 @@
         return Command.SUCCESS;
     }
 
+    private void ensureIsIdentifier(final String name) {
+        if (!VariablesImpl.isIdentifier(name)) {
+            throw new RuntimeException("Invalid identifer name: " + name);
+        }
+    }
+
     private void unsetProperty(final String name) {
         log.info("Unsetting system property: " + name);
+
+        ensureIsIdentifier(name);
+
         System.getProperties().remove(name);
     }
 
     private void unsetVariable(final String name) {
         log.info("Unsetting variable: " + name);
 
+        ensureIsIdentifier(name);
+        
         // Command vars always has a parent, set only makes sence when setting in parent's
scope
         Variables vars = this.getVariables().parent();
 

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/VariablesImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/VariablesImpl.java?rev=411615&r1=411614&r2=411615&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/VariablesImpl.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/VariablesImpl.java
Sun Jun  4 15:41:36 2006
@@ -193,4 +193,24 @@
     public Variables parent() {
         return parent;
     }
+
+    public static boolean isIdentifier(final String name) {
+        if (name == null || name.length() == 0) {
+            return false;
+        }
+
+        char[] chars = name.toCharArray();
+
+        if (!Character.isJavaIdentifierStart(chars[0])) {
+            return false;
+        }
+
+        for (int i=1; i<chars.length; i++) {
+            if (!Character.isJavaIdentifierPart(chars[i])) {
+                return false;
+            }
+        }
+
+        return true;
+    }
 }



Mime
View raw message