You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2006/04/03 13:24:10 UTC

svn commit: r391007 - in /jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl: Script.java ScriptFactory.java ScriptImpl.java

Author: dion
Date: Mon Apr  3 04:24:07 2006
New Revision: 391007

URL: http://svn.apache.org/viewcvs?rev=391007&view=rev
Log:
Properties

Modified:
    jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/Script.java   (contents, props changed)
    jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/ScriptFactory.java   (contents, props changed)
    jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/ScriptImpl.java   (contents, props changed)

Modified: jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/Script.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/Script.java?rev=391007&r1=391006&r2=391007&view=diff
==============================================================================
--- jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/Script.java (original)
+++ jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/Script.java Mon Apr  3 04:24:07 2006
@@ -1,34 +1,34 @@
-/*
- * Copyright 2002-2006 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.jexl;
-
-public interface Script {
-    /**
-     * Executes the script with the variables contained in the
-     * supplied {@link JexlContext}. 
-     * 
-     * @param context A JexlContext containing variables.
-     * @return The result of this script, usually the result of the last statement.
-     */
-    Object execute(JexlContext context) throws Exception;
-
-    /**
-     * Returns the text of this Script.
-     * @return The script to be executed.
-     */
-    String getText();
-
-}
+/*
+ * Copyright 2002-2006 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.jexl;
+
+public interface Script {
+    /**
+     * Executes the script with the variables contained in the
+     * supplied {@link JexlContext}. 
+     * 
+     * @param context A JexlContext containing variables.
+     * @return The result of this script, usually the result of the last statement.
+     */
+    Object execute(JexlContext context) throws Exception;
+
+    /**
+     * Returns the text of this Script.
+     * @return The script to be executed.
+     */
+    String getText();
+
+}

Propchange: jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/Script.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/Script.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Apr  3 04:24:07 2006
@@ -1 +1 @@
-Id
+Date Author Id Revision HeadURL

Modified: jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/ScriptFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/ScriptFactory.java?rev=391007&r1=391006&r2=391007&view=diff
==============================================================================
--- jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/ScriptFactory.java (original)
+++ jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/ScriptFactory.java Mon Apr  3 04:24:07 2006
@@ -1,126 +1,126 @@
-/*
- * Copyright 2002-2006 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.jexl;
-
-import java.io.StringReader;
-
-import org.apache.commons.jexl.parser.ASTJexlScript;
-import org.apache.commons.jexl.parser.Parser;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * <p> 
- * Creates {@link Script}s.  To create a JEXL Script, pass
- * valid JEXL syntax to the static createScript() method:
- * </p>
- * 
- * <pre>
- * String jexl = "y = x * 12 + 44; y = y * 4;";
- * Script script = ScriptFactory.createScript( jexl );
- * </pre>
- * 
- * <p>
- * When an {@link Script} is created, the JEXL syntax is
- * parsed and verified.
- * </p>
- * @since 1.1
- * @version $Id$
- */
-public class ScriptFactory {
-
-    /** The Log to which all ScriptFactory messages will be logged.*/
-    protected static Log log =
-        LogFactory.getLog("org.apache.commons.jexl.ScriptFactory");
-
-    /**
-     * The singleton ScriptFactory also holds a single instance of {@link Parser}.
-     * When parsing expressions, ScriptFactory synchronizes on Parser.
-     */
-    protected static Parser parser = new Parser(new StringReader(";")); //$NON-NLS-1$
-
-    /**
-     * ScriptFactory is a singleton and this is the private
-     * instance fufilling that pattern.
-     */
-    protected static ScriptFactory factory = new ScriptFactory();
-
-    /**
-     * Private constructor, the single instance is always obtained
-     * with a call to getInstance().
-     */
-    private ScriptFactory(){}
-
-    /**
-     * Returns the single instance of ScriptFactory.
-     * @return the instance of ScriptFactory.
-     */
-    protected static  ScriptFactory getInstance()
-    {
-        return factory;
-    }
-
-    /**
-     * Creates a Script from a String containing valid JEXL syntax. 
-     * This method parses the script which validates the syntax.
-     * 
-     * @param scriptText A String containing valid JEXL syntax
-     * @return A {@link Script} which can be executed with a {@link JexlContext}.
-     * @throws Exception An exception can be thrown if there is a problem parsing the script.
-     */
-    public static Script createScript(String scriptText) throws Exception
-    {
-        return getInstance().newScript(scriptText);
-    }
-
-
-    /**
-     *  Creates a new Script based on the string.
-     *
-     *  @param scriptText valid Jexl script
-     *  @return Script a new script
-     *  @throws Exception for a variety of reasons - mostly malformed scripts
-     */
-    protected Script newScript(String scriptText) throws Exception {
-        String cleanText = cleanScript(scriptText);
-        // Parse the Expression
-        ASTJexlScript tree;
-        synchronized(parser)
-        {
-            log.debug( "Parsing script: " + cleanText);
-            tree = (ASTJexlScript) parser.parse(new StringReader(cleanText));
-        }
-
-        return new ScriptImpl(cleanText, tree);
-
-    }
-
-    /**
-     * @todo move to ParseUtils?
-     * Trims the expression and adds a semi-colon if missing.
-     * @param expression to clean
-     * @return trimmed expression ending in a semi-colon
-     */
-    private String cleanScript(String script) {
-        String expr = script.trim();
-        if (!expr.endsWith(";"))
-        {
-            expr += ";";
-        }
-        return expr;
-    }
-
-}
+/*
+ * Copyright 2002-2006 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.jexl;
+
+import java.io.StringReader;
+
+import org.apache.commons.jexl.parser.ASTJexlScript;
+import org.apache.commons.jexl.parser.Parser;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * <p> 
+ * Creates {@link Script}s.  To create a JEXL Script, pass
+ * valid JEXL syntax to the static createScript() method:
+ * </p>
+ * 
+ * <pre>
+ * String jexl = "y = x * 12 + 44; y = y * 4;";
+ * Script script = ScriptFactory.createScript( jexl );
+ * </pre>
+ * 
+ * <p>
+ * When an {@link Script} is created, the JEXL syntax is
+ * parsed and verified.
+ * </p>
+ * @since 1.1
+ * @version $Id$
+ */
+public class ScriptFactory {
+
+    /** The Log to which all ScriptFactory messages will be logged.*/
+    protected static Log log =
+        LogFactory.getLog("org.apache.commons.jexl.ScriptFactory");
+
+    /**
+     * The singleton ScriptFactory also holds a single instance of {@link Parser}.
+     * When parsing expressions, ScriptFactory synchronizes on Parser.
+     */
+    protected static Parser parser = new Parser(new StringReader(";")); //$NON-NLS-1$
+
+    /**
+     * ScriptFactory is a singleton and this is the private
+     * instance fufilling that pattern.
+     */
+    protected static ScriptFactory factory = new ScriptFactory();
+
+    /**
+     * Private constructor, the single instance is always obtained
+     * with a call to getInstance().
+     */
+    private ScriptFactory(){}
+
+    /**
+     * Returns the single instance of ScriptFactory.
+     * @return the instance of ScriptFactory.
+     */
+    protected static  ScriptFactory getInstance()
+    {
+        return factory;
+    }
+
+    /**
+     * Creates a Script from a String containing valid JEXL syntax. 
+     * This method parses the script which validates the syntax.
+     * 
+     * @param scriptText A String containing valid JEXL syntax
+     * @return A {@link Script} which can be executed with a {@link JexlContext}.
+     * @throws Exception An exception can be thrown if there is a problem parsing the script.
+     */
+    public static Script createScript(String scriptText) throws Exception
+    {
+        return getInstance().newScript(scriptText);
+    }
+
+
+    /**
+     *  Creates a new Script based on the string.
+     *
+     *  @param scriptText valid Jexl script
+     *  @return Script a new script
+     *  @throws Exception for a variety of reasons - mostly malformed scripts
+     */
+    protected Script newScript(String scriptText) throws Exception {
+        String cleanText = cleanScript(scriptText);
+        // Parse the Expression
+        ASTJexlScript tree;
+        synchronized(parser)
+        {
+            log.debug( "Parsing script: " + cleanText);
+            tree = (ASTJexlScript) parser.parse(new StringReader(cleanText));
+        }
+
+        return new ScriptImpl(cleanText, tree);
+
+    }
+
+    /**
+     * @todo move to ParseUtils?
+     * Trims the expression and adds a semi-colon if missing.
+     * @param expression to clean
+     * @return trimmed expression ending in a semi-colon
+     */
+    private String cleanScript(String script) {
+        String expr = script.trim();
+        if (!expr.endsWith(";"))
+        {
+            expr += ";";
+        }
+        return expr;
+    }
+
+}

Propchange: jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/ScriptFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/ScriptFactory.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Apr  3 04:24:07 2006
@@ -1 +1 @@
-Id
+Date Author Id Revision HeadURL

Modified: jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/ScriptImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/ScriptImpl.java?rev=391007&r1=391006&r2=391007&view=diff
==============================================================================
--- jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/ScriptImpl.java (original)
+++ jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/ScriptImpl.java Mon Apr  3 04:24:07 2006
@@ -1,48 +1,48 @@
-/*
- * Copyright 2002,2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.commons.jexl;
-
-import org.apache.commons.jexl.parser.ASTJexlScript;
-
-public class ScriptImpl implements Script {
-
-    /** text of the script */
-    private String text;
-    /** syntax tree */
-    private ASTJexlScript parsedScript;
-    
-    public ScriptImpl(String scriptText, ASTJexlScript scriptTree) {
-        text = scriptText;
-        parsedScript = scriptTree;
-    }
-
-    /**
-     * @see Script#execute(JexlContext)
-     */
-    public Object execute(JexlContext context) throws Exception {
-        // TODO Auto-generated method stub
-        return parsedScript.value(context);
-    }
-
-    /**
-     * @see Script#getText()
-     */
-    public String getText() {
-        return text;
-    }
-
-}
+/*
+ * Copyright 2002,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.jexl;
+
+import org.apache.commons.jexl.parser.ASTJexlScript;
+
+public class ScriptImpl implements Script {
+
+    /** text of the script */
+    private String text;
+    /** syntax tree */
+    private ASTJexlScript parsedScript;
+    
+    public ScriptImpl(String scriptText, ASTJexlScript scriptTree) {
+        text = scriptText;
+        parsedScript = scriptTree;
+    }
+
+    /**
+     * @see Script#execute(JexlContext)
+     */
+    public Object execute(JexlContext context) throws Exception {
+        // TODO Auto-generated method stub
+        return parsedScript.value(context);
+    }
+
+    /**
+     * @see Script#getText()
+     */
+    public String getText() {
+        return text;
+    }
+
+}

Propchange: jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/ScriptImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/ScriptImpl.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Apr  3 04:24:07 2006
@@ -1 +1 @@
-Id
+Date Author Id Revision HeadURL



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org