manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1160664 - /incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/
Date Tue, 23 Aug 2011 12:38:49 GMT
Author: kwright
Date: Tue Aug 23 12:38:48 2011
New Revision: 1160664

URL: http://svn.apache.org/viewvc?rev=1160664&view=rev
Log:
Add an operation that will check for null.

Modified:
    incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ContextVariableReference.java
    incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/NullVariableReference.java
    incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java
    incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBase.java
    incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfiguration.java
    incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfigurationNode.java
    incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableReference.java

Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ContextVariableReference.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ContextVariableReference.java?rev=1160664&r1=1160663&r2=1160664&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ContextVariableReference.java
(original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ContextVariableReference.java
Tue Aug 23 12:38:48 2011
@@ -45,4 +45,10 @@ public class ContextVariableReference im
     return variable;
   }
 
+  /** Check if this reference is null */
+  public boolean isNull()
+  {
+    return variable == null;
+  }
+
 }

Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/NullVariableReference.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/NullVariableReference.java?rev=1160664&r1=1160663&r2=1160664&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/NullVariableReference.java
(original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/NullVariableReference.java
Tue Aug 23 12:38:48 2011
@@ -41,4 +41,10 @@ public class NullVariableReference imple
     throw new ScriptException("Attempt to dereference null variable pointer");
   }
 
+  /** Check if this reference is null */
+  public boolean isNull()
+  {
+    return true;
+  }
+
 }

Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java?rev=1160664&r1=1160663&r2=1160664&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java
(original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java
Tue Aug 23 12:38:48 2011
@@ -597,6 +597,41 @@ public class ScriptParser
   protected VariableReference parseVariableReference(TokenStream currentStream)
     throws ScriptException
   {
+    // variable_reference -> 'isnull' variable_reference
+    // variable_reference -> variable_reference_0
+    Token t = currentStream.peek();
+    if (t != null && t.getToken() != null && t.getToken().equals("isnull"))
+    {
+      currentStream.skip();
+      VariableReference reference = parseVariableReference(currentStream);
+      if (reference == null)
+        syntaxError(currentStream,"Missing variable reference");
+      return new VariableBoolean(reference.isNull());
+    }
+    else
+      return parseVariableReference_0(currentStream);
+  }
+
+  protected boolean skipVariableReference(TokenStream currentStream)
+    throws ScriptException
+  {
+    // variable_reference -> 'isnull' variable_reference
+    // variable_reference -> variable_reference_0
+    Token t = currentStream.peek();
+    if (t != null && t.getToken() != null && t.getToken().equals("isnull"))
+    {
+      currentStream.skip();
+      if (skipVariableReference(currentStream) == false)
+        syntaxError(currentStream,"Missing variable reference");
+      return true;
+    }
+    else
+      return skipVariableReference_0(currentStream);
+  }
+  
+  protected VariableReference parseVariableReference_0(TokenStream currentStream)
+    throws ScriptException
+  {
     // variable_reference -> variable_reference '[' expression ']'
     // variable_reference -> variable_reference.property_name
     // variable_reference -> variable_reference_1
@@ -698,7 +733,7 @@ public class ScriptParser
       return null;
   }
   
-  protected boolean skipVariableReference(TokenStream currentStream)
+  protected boolean skipVariableReference_0(TokenStream currentStream)
     throws ScriptException
   {
     if (skipVariableReference_1(currentStream) == false)

Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBase.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBase.java?rev=1160664&r1=1160663&r2=1160664&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBase.java
(original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBase.java
Tue Aug 23 12:38:48 2011
@@ -195,4 +195,10 @@ public class VariableBase implements Var
     return this;
   }
 
+  /** Check if this reference is null */
+  public boolean isNull()
+  {
+    return false;
+  }
+
 }

Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfiguration.java?rev=1160664&r1=1160663&r2=1160664&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfiguration.java
(original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfiguration.java
Tue Aug 23 12:38:48 2011
@@ -115,5 +115,11 @@ public class VariableConfiguration exten
       return new VariableConfigurationNode(configuration.findChild(index));
     }
     
+    /** Check if this reference is null */
+    public boolean isNull()
+    {
+      return index >= configuration.getChildCount();
+    }
+
   }
 }

Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfigurationNode.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfigurationNode.java?rev=1160664&r1=1160663&r2=1160664&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfigurationNode.java
(original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfigurationNode.java
Tue Aug 23 12:38:48 2011
@@ -113,5 +113,11 @@ public class VariableConfigurationNode e
       return new VariableConfigurationNode(configurationNode.findChild(index));
     }
 
+    /** Check if this reference is null */
+    public boolean isNull()
+    {
+      return index >= configurationNode.getChildCount();
+    }
+
   }
 }

Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableReference.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableReference.java?rev=1160664&r1=1160663&r2=1160664&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableReference.java
(original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableReference.java
Tue Aug 23 12:38:48 2011
@@ -32,4 +32,8 @@ public interface VariableReference
   /** Resolve the reference */
   public Variable resolve()
     throws ScriptException;
+  
+  /** Check if this reference is null */
+  public boolean isNull();
+  
 }



Mime
View raw message