You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by sh...@apache.org on 2001/12/18 22:46:46 UTC
cvs commit: jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/spel/parser SpelParser.java SpelParserConstants.java SpelParserTokenManager.java
shawn 01/12/18 13:46:46
Modified: standard/src/org/apache/taglibs/standard/lang/spel
Constants.java IntegerLiteral.java
PropertyExpression.java Resources.properties
SpelParser.jj
standard/src/org/apache/taglibs/standard/lang/spel/parser
SpelParser.java SpelParserConstants.java
SpelParserTokenManager.java
Added: standard/src/org/apache/taglibs/standard/lang/spel
Indexer.java LiteralIndexes.java
Log:
Array support for SPEL
Revision Changes Path
1.2 +106 -103 jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/spel/Constants.java
Index: Constants.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/spel/Constants.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Constants.java 2001/11/21 07:38:20 1.1
+++ Constants.java 2001/12/18 21:46:46 1.2
@@ -53,106 +53,109 @@
*
*/
-package org.apache.taglibs.standard.lang.spel;
-
-import java.util.ResourceBundle;
-import java.util.MissingResourceException;
-
-/**
- *
- * <p>This contains all of the non-public constants, including
- * messsage strings read from the resource file.
- *
- * @author Nathan Abramson - Art Technology Group
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: shawn $
- **/
-
-public class Constants
-{
- //-------------------------------------
- // Resources
-
- static ResourceBundle sResources =
- ResourceBundle.getBundle ("org.apache.taglibs.standard.lang.spel.Resources");
-
- //-------------------------------------
- // Messages from the resource bundle
- //-------------------------------------
-
- public static final String EXCEPTION_GETTING_BEANINFO =
- getStringResource ("EXCEPTION_GETTING_BEANINFO");
-
- public static final String CANT_GET_PROPERTY_OF_NULL =
- getStringResource ("CANT_GET_PROPERTY_OF_NULL");
-
- public static final String NO_SUCH_PROPERTY =
- getStringResource ("NO_SUCH_PROPERTY");
-
- public static final String NO_GETTER_METHOD =
- getStringResource ("NO_GETTER_METHOD");
-
- public static final String ERROR_GETTING_PROPERTY =
- getStringResource ("ERROR_GETTING_PROPERTY");
-
- public static final String COMPARISON_OF_NULL =
- getStringResource ("COMPARISON_OF_NULL");
-
- public static final String ILLEGAL_COMPARISON =
- getStringResource ("ILLEGAL_COMPARISON");
-
- public static final String NULL_TO_PRIMITIVE =
- getStringResource ("NULL_TO_PRIMITIVE");
-
- public static final String ILLEGAL_CONVERSION =
- getStringResource ("ILLEGAL_CONVERSION");
-
- public static final String NULL_EXPRESSION =
- getStringResource ("NULL_EXPRESSION");
-
- public static final String PARSE_EXCEPTION =
- getStringResource ("PARSE_EXCEPTION");
-
- public static final String NO_PROPERTY_EDITOR =
- getStringResource ("NO_PROPERTY_EDITOR");
-
- public static final String CANT_PARSE_LITERAL =
- getStringResource ("CANT_PARSE_LITERAL");
-
- public static final String CANT_FIND_ATTRIBUTE =
- getStringResource ("CANT_FIND_ATTRIBUTE");
-
- //-------------------------------------
- // Getting resources
- //-------------------------------------
- /**
- *
- *
- **/
- public static String getStringResource (String pResourceName)
- throws MissingResourceException
- {
- try {
- String ret = sResources.getString (pResourceName);
- if (ret == null) {
- String str = "ERROR: Unable to load resource " + pResourceName;
- System.err.println (str);
- throw new MissingResourceException
- (str,
- "org.apache.taglibs.standard.lang.spel.Constants",
- pResourceName);
- }
- else {
- return ret;
- }
- }
- catch (MissingResourceException exc) {
- System.err.println ("ERROR: Unable to load resource " +
- pResourceName +
- ": " +
- exc);
- throw exc;
- }
- }
-
- //-------------------------------------
-}
+package org.apache.taglibs.standard.lang.spel;
+
+import java.util.ResourceBundle;
+import java.util.MissingResourceException;
+
+/**
+ *
+ * <p>This contains all of the non-public constants, including
+ * messsage strings read from the resource file.
+ *
+ * @author Nathan Abramson - Art Technology Group
+ * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: shawn $
+ **/
+
+public class Constants
+{
+ //-------------------------------------
+ // Resources
+
+ static ResourceBundle sResources =
+ ResourceBundle.getBundle ("org.apache.taglibs.standard.lang.spel.Resources");
+
+ //-------------------------------------
+ // Messages from the resource bundle
+ //-------------------------------------
+
+ public static final String EXCEPTION_GETTING_BEANINFO =
+ getStringResource ("EXCEPTION_GETTING_BEANINFO");
+
+ public static final String CANT_GET_PROPERTY_OF_NULL =
+ getStringResource ("CANT_GET_PROPERTY_OF_NULL");
+
+ public static final String NO_SUCH_PROPERTY =
+ getStringResource ("NO_SUCH_PROPERTY");
+
+ public static final String NO_GETTER_METHOD =
+ getStringResource ("NO_GETTER_METHOD");
+
+ public static final String ERROR_GETTING_PROPERTY =
+ getStringResource ("ERROR_GETTING_PROPERTY");
+
+ public static final String COMPARISON_OF_NULL =
+ getStringResource ("COMPARISON_OF_NULL");
+
+ public static final String ILLEGAL_COMPARISON =
+ getStringResource ("ILLEGAL_COMPARISON");
+
+ public static final String NULL_TO_PRIMITIVE =
+ getStringResource ("NULL_TO_PRIMITIVE");
+
+ public static final String ILLEGAL_CONVERSION =
+ getStringResource ("ILLEGAL_CONVERSION");
+
+ public static final String NULL_EXPRESSION =
+ getStringResource ("NULL_EXPRESSION");
+
+ public static final String PARSE_EXCEPTION =
+ getStringResource ("PARSE_EXCEPTION");
+
+ public static final String NO_PROPERTY_EDITOR =
+ getStringResource ("NO_PROPERTY_EDITOR");
+
+ public static final String CANT_PARSE_LITERAL =
+ getStringResource ("CANT_PARSE_LITERAL");
+
+ public static final String CANT_FIND_ATTRIBUTE =
+ getStringResource ("CANT_FIND_ATTRIBUTE");
+
+ public static final String CANT_INDEX =
+ getStringResource ("CANT_INDEX");
+
+ //-------------------------------------
+ // Getting resources
+ //-------------------------------------
+ /**
+ *
+ *
+ **/
+ public static String getStringResource (String pResourceName)
+ throws MissingResourceException
+ {
+ try {
+ String ret = sResources.getString (pResourceName);
+ if (ret == null) {
+ String str = "ERROR: Unable to load resource " + pResourceName;
+ System.err.println (str);
+ throw new MissingResourceException
+ (str,
+ "org.apache.taglibs.standard.lang.spel.Constants",
+ pResourceName);
+ }
+ else {
+ return ret;
+ }
+ }
+ catch (MissingResourceException exc) {
+ System.err.println ("ERROR: Unable to load resource " +
+ pResourceName +
+ ": " +
+ exc);
+ throw exc;
+ }
+ }
+
+ //-------------------------------------
+}
1.2 +49 -48 jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/spel/IntegerLiteral.java
Index: IntegerLiteral.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/spel/IntegerLiteral.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- IntegerLiteral.java 2001/11/21 07:38:22 1.1
+++ IntegerLiteral.java 2001/12/18 21:46:46 1.2
@@ -53,51 +53,52 @@
*
*/
-package org.apache.taglibs.standard.lang.spel;
-
-/**
- *
- * <p>An expression representing an integer literal value. The value
- * is stored internally as a long.
- *
- * @author Nathan Abramson - Art Technology Group
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: shawn $
- **/
-
-public class IntegerLiteral
- extends Literal
-{
- //-------------------------------------
- /**
- *
- * Constructor
- **/
- public IntegerLiteral (String pToken)
- {
- super (getValueFromToken (pToken));
- }
-
- //-------------------------------------
- /**
- *
- * Parses the given token into the literal value
- **/
- static Object getValueFromToken (String pToken)
- {
- return new Long (pToken);
- }
-
- //-------------------------------------
- // Expression methods
- //-------------------------------------
- /**
- *
- * Returns the expression in the expression language syntax
- **/
- public String getExpressionString ()
- {
- return getValue ().toString ();
- }
-
- //-------------------------------------
-}
+package org.apache.taglibs.standard.lang.spel;
+
+/**
+ *
+ * <p>An expression representing an integer literal value. The value
+ * is stored internally as a long.
+ *
+ * @author Nathan Abramson - Art Technology Group
+ * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: shawn $
+ **/
+
+public class IntegerLiteral
+ extends Literal
+{
+ //-------------------------------------
+ /**
+ *
+ * Constructor
+ **/
+ public IntegerLiteral (String pToken)
+ {
+ super (getValueFromToken (pToken));
+ }
+
+ //-------------------------------------
+ /**
+ *
+ * Parses the given token into the literal value
+ **/
+ static Object getValueFromToken (String pToken)
+ {
+ // return new Long (pToken);
+ return new Integer (pToken);
+ }
+
+ //-------------------------------------
+ // Expression methods
+ //-------------------------------------
+ /**
+ *
+ * Returns the expression in the expression language syntax
+ **/
+ public String getExpressionString ()
+ {
+ return getValue ().toString ();
+ }
+
+ //-------------------------------------
+}
1.2 +181 -146 jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/spel/PropertyExpression.java
Index: PropertyExpression.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/spel/PropertyExpression.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PropertyExpression.java 2001/11/21 07:38:24 1.1
+++ PropertyExpression.java 2001/12/18 21:46:46 1.2
@@ -53,149 +53,184 @@
*
*/
-package org.apache.taglibs.standard.lang.spel;
-
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.PageContext;
-
-/**
- *
- * <p>Represents an expression of the form
- * {expression}.{property0}.{property1}...
- *
- * @author Nathan Abramson - Art Technology Group
- * @version $Change: 181181 $$DateTime: 2001/06/26 09:55:09 $$Author: shawn $
- **/
-
-public class PropertyExpression
- extends Expression
-{
- //-------------------------------------
- // Constants
- //-------------------------------------
-
- static Object [] sNoArgs = new Object [0];
-
- //-------------------------------------
- // Properties
- //-------------------------------------
- // property base
-
- Expression mBase;
- public Expression getBase ()
- { return mBase; }
-
- //-------------------------------------
- // property propertyNames
-
- String [] mPropertyNames;
- public String [] getPropertyNames ()
- { return mPropertyNames; }
-
- //-------------------------------------
- /**
- *
- * Constructor
- **/
- public PropertyExpression (Expression pBase,
- String [] pPropertyNames)
- {
- mBase = pBase;
- mPropertyNames = pPropertyNames;
- }
-
- //-------------------------------------
- // Expression methods
- //-------------------------------------
- /**
- *
- * Returns the expression in the expression language syntax
- **/
- public String getExpressionString ()
- {
- StringBuffer buf = new StringBuffer ();
- buf.append (mBase.getExpressionString ());
- for (int i = 0; i < mPropertyNames.length; i++) {
- buf.append ('.');
- buf.append (StringLiteral.toIdentifierToken (mPropertyNames [i]));
- }
- return buf.toString ();
- }
-
- //-------------------------------------
- /**
- *
- * Evaluates by traversing the list of properties
- **/
- public Object evaluate (PageContext pContext)
- throws JspException
- {
- // Evaluate the base first
- Object baseVal = mBase.evaluate (pContext);
-
- // Now evaluate each property
- Object ret = baseVal;
- for (int i = 0; i < mPropertyNames.length; i++) {
- String propertyName = mPropertyNames [i];
-
- // Check for null value
- if (ret == null) {
- throw new SpelExpressionException
- (Constants.CANT_GET_PROPERTY_OF_NULL,
- propertyName);
- }
-
- // Get the BeanInfoProperty
- BeanInfoProperty bip =
- BeanInfoManager.getBeanInfoProperty (ret.getClass (), propertyName);
- if (bip == null) {
- throw new SpelExpressionException
- (Constants.NO_SUCH_PROPERTY,
- ret.getClass ().getName (),
- propertyName);
- }
-
- // Get the method
- Method m = bip.getReadMethod ();
- if (m == null) {
- throw new SpelExpressionException
- (Constants.NO_GETTER_METHOD,
- propertyName,
- ret.getClass ().getName ());
- }
-
- // Invoke the method
- try {
- ret = m.invoke (ret, sNoArgs);
- }
- catch (IllegalAccessException exc) {
- throw new SpelExpressionException
- (Constants.ERROR_GETTING_PROPERTY,
- propertyName,
- ret.getClass ().getName (),
- exc);
- }
- catch (IllegalArgumentException exc) {
- throw new SpelExpressionException
- (Constants.ERROR_GETTING_PROPERTY,
- propertyName,
- ret.getClass ().getName (),
- exc);
- }
- catch (InvocationTargetException exc) {
- throw new SpelExpressionException
- (Constants.ERROR_GETTING_PROPERTY,
- propertyName,
- ret.getClass ().getName (),
- exc.getTargetException ());
- }
- }
-
- return ret;
- }
-
- //-------------------------------------
-}
+package org.apache.taglibs.standard.lang.spel;
+
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.PageContext;
+import java.util.List;
+
+/**
+ *
+ * <p>Represents an expression of the form
+ * {expression}.{property0}.{property1}...
+ *
+ * @author Nathan Abramson - Art Technology Group
+ * @author Shawn Bayern
+ **/
+
+public class PropertyExpression
+ extends Expression
+{
+ //-------------------------------------
+ // Constants
+ //-------------------------------------
+
+ static Object [] sNoArgs = new Object [0];
+
+ //-------------------------------------
+ // Properties
+ //-------------------------------------
+ // property base
+
+ Expression mBase;
+ public Expression getBase ()
+ { return mBase; }
+
+ //-------------------------------------
+ // property propertyNames
+
+ String [] mPropertyNames;
+ public String [] getPropertyNames ()
+ { return mPropertyNames; }
+
+ //-------------------------------------
+ // property baseIndexes
+ List mBaseIndexes;
+
+ //-------------------------------------
+ // property propertyIndexes
+ List mPropertyIndexes;
+
+ //-------------------------------------
+ /**
+ *
+ * Constructors
+ **/
+ public PropertyExpression (Expression pBase,
+ String [] pPropertyNames)
+ {
+ // mBase = pBase;
+ // mPropertyNames = pPropertyNames;
+ this(pBase, null, pPropertyNames, null);
+ }
+
+ public PropertyExpression (Expression pBase,
+ List pBaseIndexes,
+ String [] pPropertyNames,
+ List pPropertyIndexes)
+ {
+ mBase = pBase;
+ mBaseIndexes = pBaseIndexes;
+ mPropertyNames = pPropertyNames;
+ mPropertyIndexes = pPropertyIndexes;
+ }
+
+ //-------------------------------------
+ // Expression methods
+ //-------------------------------------
+ /**
+ *
+ * Returns the expression in the expression language syntax
+ **/
+ public String getExpressionString ()
+ {
+ StringBuffer buf = new StringBuffer ();
+ buf.append (mBase.getExpressionString ());
+ for (int i = 0; i < mPropertyNames.length; i++) {
+ buf.append ('.');
+ buf.append (StringLiteral.toIdentifierToken (mPropertyNames [i]));
+ }
+ return buf.toString ();
+ }
+
+ //-------------------------------------
+ /**
+ *
+ * Evaluates by traversing the list of properties
+ **/
+ public Object evaluate (PageContext pContext)
+ throws JspException
+ {
+ // Evaluate the base first
+ Object baseVal = mBase.evaluate (pContext);
+
+ // Retrieve indexed value from baseVal as appropriate
+ if (mBaseIndexes != null) {
+ Indexer ind = new LiteralIndexes(mBaseIndexes);
+ baseVal = ind.index(baseVal);
+ }
+
+ // Now evaluate each property (if we've got any)
+ Object ret = baseVal;
+ if (mPropertyNames == null)
+ return ret;
+ for (int i = 0; i < mPropertyNames.length; i++) {
+ String propertyName = mPropertyNames [i];
+
+ // Check for null value
+ if (ret == null) {
+ throw new SpelExpressionException
+ (Constants.CANT_GET_PROPERTY_OF_NULL,
+ propertyName);
+ }
+
+ // Get the BeanInfoProperty
+ BeanInfoProperty bip =
+ BeanInfoManager.getBeanInfoProperty (ret.getClass (), propertyName);
+ if (bip == null) {
+ throw new SpelExpressionException
+ (Constants.NO_SUCH_PROPERTY,
+ ret.getClass ().getName (),
+ propertyName);
+ }
+
+ // Get the method
+ Method m = bip.getReadMethod ();
+ if (m == null) {
+ throw new SpelExpressionException
+ (Constants.NO_GETTER_METHOD,
+ propertyName,
+ ret.getClass ().getName ());
+ }
+
+ // Invoke the method
+ try {
+ ret = m.invoke (ret, sNoArgs);
+ }
+ catch (IllegalAccessException exc) {
+ throw new SpelExpressionException
+ (Constants.ERROR_GETTING_PROPERTY,
+ propertyName,
+ ret.getClass ().getName (),
+ exc);
+ }
+ catch (IllegalArgumentException exc) {
+ throw new SpelExpressionException
+ (Constants.ERROR_GETTING_PROPERTY,
+ propertyName,
+ ret.getClass ().getName (),
+ exc);
+ }
+ catch (InvocationTargetException exc) {
+ throw new SpelExpressionException
+ (Constants.ERROR_GETTING_PROPERTY,
+ propertyName,
+ ret.getClass ().getName (),
+ exc.getTargetException ());
+ }
+
+ // Retrieve indexed value from result if necessary
+ if (mPropertyIndexes != null && mPropertyIndexes.get(i) != null) {
+ Indexer ind = new LiteralIndexes((List) mPropertyIndexes.get(i));
+ ret = ind.index(ret);
+ }
+ }
+
+ return ret;
+ }
+
+ //-------------------------------------
+}
1.2 +48 -45 jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/spel/Resources.properties
Index: Resources.properties
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/spel/Resources.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Resources.properties 2001/11/21 07:38:26 1.1
+++ Resources.properties 2001/12/18 21:46:46 1.2
@@ -1,45 +1,48 @@
-EXCEPTION_GETTING_BEANINFO=\
- An Exception occurred getting the BeanInfo for class {0}
-
-CANT_GET_PROPERTY_OF_NULL=\
- Attempt to get property "{0}" from a null value
-
-NO_SUCH_PROPERTY=\
- Class {0} does not have a property "{1}"
-
-NO_GETTER_METHOD=\
- Property "{0}" of class {1} does not have a public getter method
-
-ERROR_GETTING_PROPERTY=\
- An error occurred while getting property "{0}" from an instance \
- of class {1}
-
-COMPARISON_OF_NULL=\
- Attempt to compare a null value using the "{0}" operator
-
-ILLEGAL_COMPARISON=\
- Illegal attempt to compare an instance of {0} with an instance of \
- {1} using the "{2}" operator
-
-NULL_TO_PRIMITIVE=\
- Cannot cast a null value to primitive expected type "{0}"
-
-ILLEGAL_CONVERSION=\
- Illegal attempt to convert a value of type "{0}" to \
- expected type "{1}"
-
-NULL_EXPRESSION=\
- A null string may not be passed to the expression evaluator
-
-PARSE_EXCEPTION=\
- Unable to parse the expression
-
-NO_PROPERTY_EDITOR=\
- Unable to parse literal value "{0}" into expected type "{1}" because \
- no PropertyEditor for that type could be found
-
-CANT_PARSE_LITERAL=\
- Unable to parse literal value "{0}" into expected type "{1}"
-
-CANT_FIND_ATTRIBUTE=\
- Unable to find attribute "{0}" in {1} scope.
+EXCEPTION_GETTING_BEANINFO=\
+ An Exception occurred getting the BeanInfo for class {0}
+
+CANT_GET_PROPERTY_OF_NULL=\
+ Attempt to get property "{0}" from a null value
+
+NO_SUCH_PROPERTY=\
+ Class {0} does not have a property "{1}"
+
+NO_GETTER_METHOD=\
+ Property "{0}" of class {1} does not have a public getter method
+
+ERROR_GETTING_PROPERTY=\
+ An error occurred while getting property "{0}" from an instance \
+ of class {1}
+
+COMPARISON_OF_NULL=\
+ Attempt to compare a null value using the "{0}" operator
+
+ILLEGAL_COMPARISON=\
+ Illegal attempt to compare an instance of {0} with an instance of \
+ {1} using the "{2}" operator
+
+NULL_TO_PRIMITIVE=\
+ Cannot cast a null value to primitive expected type "{0}"
+
+ILLEGAL_CONVERSION=\
+ Illegal attempt to convert a value of type "{0}" to \
+ expected type "{1}"
+
+NULL_EXPRESSION=\
+ A null string may not be passed to the expression evaluator
+
+PARSE_EXCEPTION=\
+ Unable to parse the expression
+
+NO_PROPERTY_EDITOR=\
+ Unable to parse literal value "{0}" into expected type "{1}" because \
+ no PropertyEditor for that type could be found
+
+CANT_PARSE_LITERAL=\
+ Unable to parse literal value "{0}" into expected type "{1}"
+
+CANT_FIND_ATTRIBUTE=\
+ Unable to find attribute "{0}" in {1} scope.
+
+CANT_INDEX=\
+ Encountered illegal index for non-indexed object
1.2 +39 -10 jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/spel/SpelParser.jj
Index: SpelParser.jj
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/spel/SpelParser.jj,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SpelParser.jj 2001/11/21 07:38:28 1.1
+++ SpelParser.jj 2001/12/18 21:46:46 1.2
@@ -9,6 +9,7 @@
import org.apache.taglibs.standard.lang.spel.*;
import java.util.ArrayList;
+import java.util.List;
public class SpelParser {
@@ -142,6 +143,8 @@
| < LE: "<=" >
| < GE: ">=" >
| < NE: "!=" >
+| < START_BRACKET: "[" >
+| < END_BRACKET: "]" >
}
@@ -209,28 +212,54 @@
Expression base;
ArrayList l = null;
StringLiteral pname;
+ ArrayList baseIndexes = null; // index values for the base
+ ArrayList pnameIndexes = null; // list of pname indexes (list of lists)
+ IntegerLiteral index; // individual (working) index
}
{
(
base = NamedValue ()
+ (
+ <START_BRACKET> index = IntegerLiteral() <END_BRACKET>
+ {
+ if (baseIndexes == null) baseIndexes = new ArrayList();
+ baseIndexes.add (index.getValue());
+ }
+ )*
(<DOT>
- (pname = Identifier ()
- | pname = StringLiteral ())
- {
- if (l == null) l = new ArrayList ();
+ (pname = Identifier ()
+ | pname = StringLiteral ()
+ )
+ {
+ if (l == null) {
+ l = new ArrayList ();
+ pnameIndexes = new ArrayList();
+ }
l.add (pname.getValue ());
- }
+ pnameIndexes.add(new ArrayList()); // seed with empty list
+ }
+ (
+ <START_BRACKET> index = IntegerLiteral() <END_BRACKET>
+ {
+ // get the last index-list
+ List ind = (List) pnameIndexes.get(pnameIndexes.size() - 1);
+ ind.add(index.getValue());
+ }
+ )*
)*
)
{
+ String[] pnames;
if (l == null) {
- return base;
- }
- else {
- String [] pnames = (String []) l.toArray (new String [l.size ()]);
- return new PropertyExpression (base, pnames);
+ // (SB: Let's collapse this distinction for simplicity;
+ // it won't matter later -- 'pnames' can sensibly be null.)
+ // return base;
+ pnames = null;
+ } else {
+ pnames = (String []) l.toArray (new String [l.size ()]);
}
+ return new PropertyExpression (base, baseIndexes, pnames, pnameIndexes);
}
}
1.1 jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/spel/Indexer.java
Index: Indexer.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.taglibs.standard.lang.spel;
import java.util.*;
/**
* <p>Represents an entity that can be used to retrieve index properties
* from a base object.</p>
*
* @author Shawn Bayern
*/
interface Indexer {
/** Indexes the base object. */
Object index(Object a);
}
1.1 jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/spel/LiteralIndexes.java
Index: LiteralIndexes.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.taglibs.standard.lang.spel;
import java.util.*;
/**
* <p>An indexer that stores and applies array-like indexes:
* <tt>[a][b][c]...</tt></p>
*
* @author Shawn Bayern
*/
class LiteralIndexes implements Indexer {
//*********************************************************************
// Private data
/** The actual indexes we store. */
private int[] indexes;
//*********************************************************************
// Constructor
/** Constructs a new Indexer representing literal indexes. */
public LiteralIndexes(List l) {
indexes = new int[l.size()];
for (int i = 0; i < indexes.length; i++) {
Object item = l.get(i);
if (!(item instanceof Integer))
throw new IllegalArgumentException();
indexes[i] = ((Integer) item).intValue();
}
}
/** Constructs a new Indexer representing literal indexes. */
public LiteralIndexes(int[] i) {
indexes = i;
}
//*********************************************************************
// Implementation of 'Indexer' contract
/**
* Applies this instance's indexes to the given base object.
* For example, if the base object is 'a', the first index is 0,
* and the second index is 1, then we return a[0][1], throwing
* an IllegalArgumentException if 'a' does not support the
* requisite indexing.
*/
public Object index(Object a) {
for (int i = 0; i < indexes.length; i++) {
// For the moment, we just support simple arrays.
// If the array is of primitives, "promote" referents to boxed
// types. (Could do this with introspection, but there's something
// comfortingly concrete about explicit enumeration.)
if (!a.getClass().isArray())
throw new IllegalArgumentException(Constants.CANT_INDEX);
else if (a instanceof Object[]) {
a = ((Object[]) a)[indexes[i]];
} else if (a instanceof boolean[]) {
a = new Boolean(((boolean[]) a)[indexes[i]]);
} else if (a instanceof char[]) {
a = new Character(((char[]) a)[indexes[i]]);
} else if (a instanceof byte[]) {
a = new Byte(((byte[]) a)[indexes[i]]);
} else if (a instanceof short[]) {
a = new Short(((short[]) a)[indexes[i]]);
} else if (a instanceof int[]) {
a = new Integer(((int[]) a)[indexes[i]]);
} else if (a instanceof long[]) {
a = new Long(((long[]) a)[indexes[i]]);
} else if (a instanceof float[]) {
a = new Float(((float[]) a)[indexes[i]]);
} else if (a instanceof double[]) {
a = new Double(((double[]) a)[indexes[i]]);
}
}
return a;
}
}
1.2 +298 -223 jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/spel/parser/SpelParser.java
Index: SpelParser.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/spel/parser/SpelParser.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SpelParser.java 2001/11/21 07:38:31 1.1
+++ SpelParser.java 2001/12/18 21:46:46 1.2
@@ -3,6 +3,7 @@
import org.apache.taglibs.standard.lang.spel.*;
import java.util.ArrayList;
+import java.util.List;
public class SpelParser implements SpelParserConstants {
@@ -112,17 +113,36 @@
Expression base;
ArrayList l = null;
StringLiteral pname;
+ ArrayList baseIndexes = null; // index values for the base
+ ArrayList pnameIndexes = null; // list of pname indexes (list of lists)
+ IntegerLiteral index;
base = NamedValue();
label_1:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case DOT:
+ case START_BRACKET:
;
break;
default:
jj_la1[2] = jj_gen;
break label_1;
}
+ jj_consume_token(START_BRACKET);
+ index = IntegerLiteral();
+ jj_consume_token(END_BRACKET);
+ if (baseIndexes == null) baseIndexes = new ArrayList();
+ baseIndexes.add (index.getValue());
+ }
+ label_2:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case DOT:
+ ;
+ break;
+ default:
+ jj_la1[3] = jj_gen;
+ break label_2;
+ }
jj_consume_token(DOT);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case PAGE:
@@ -139,20 +159,45 @@
pname = StringLiteral();
break;
default:
- jj_la1[3] = jj_gen;
+ jj_la1[4] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
- if (l == null) l = new ArrayList ();
+ if (l == null) {
+ l = new ArrayList ();
+ pnameIndexes = new ArrayList();
+ }
l.add (pname.getValue ());
+ pnameIndexes.add(new ArrayList()); // seed with empty list
+
+ label_3:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case START_BRACKET:
+ ;
+ break;
+ default:
+ jj_la1[5] = jj_gen;
+ break label_3;
+ }
+ jj_consume_token(START_BRACKET);
+ index = IntegerLiteral();
+ jj_consume_token(END_BRACKET);
+ // get the last index-list
+ List ind = (List) pnameIndexes.get(pnameIndexes.size() - 1);
+ ind.add(index.getValue());
+ }
}
+ String[] pnames;
if (l == null) {
- {if (true) return base;}
- }
- else {
- String [] pnames = (String []) l.toArray (new String [l.size ()]);
- {if (true) return new PropertyExpression (base, pnames);}
+ // (SB: Let's collapse this distinction for simplicity;
+ // it won't matter later -- 'pnames' can sensibly be null.)
+ // return base;
+ pnames = null;
+ } else {
+ pnames = (String []) l.toArray (new String [l.size ()]);
}
+ {if (true) return new PropertyExpression (base, baseIndexes, pnames, pnameIndexes);}
throw new Error("Missing return statement in function");
}
@@ -214,7 +259,7 @@
{if (true) return Scope.PARAMVALUES;}
break;
default:
- jj_la1[4] = jj_gen;
+ jj_la1[6] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -249,7 +294,7 @@
t = jj_consume_token(PARAMVALUES);
break;
default:
- jj_la1[5] = jj_gen;
+ jj_la1[7] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -277,7 +322,7 @@
ret = NullLiteral();
break;
default:
- jj_la1[6] = jj_gen;
+ jj_la1[8] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -296,7 +341,7 @@
{if (true) return BooleanLiteral.FALSE;}
break;
default:
- jj_la1[7] = jj_gen;
+ jj_la1[9] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -379,240 +424,231 @@
return retval;
}
- final private boolean jj_3R_20() {
- if (jj_scan_token(SESSION)) return true;
+ final private boolean jj_3R_49() {
+ if (jj_scan_token(NULL)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_7() {
- Token xsp;
- xsp = jj_scanpos;
- if (jj_3R_25()) {
- jj_scanpos = xsp;
- if (jj_3R_26()) {
- jj_scanpos = xsp;
- if (jj_3R_27()) {
- jj_scanpos = xsp;
- if (jj_3R_28()) {
- jj_scanpos = xsp;
- if (jj_3R_29()) {
- jj_scanpos = xsp;
- if (jj_3R_30()) return true;
+ final private boolean jj_3_7() {
+ if (jj_3R_7()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_25() {
- if (jj_scan_token(EQ)) return true;
+ final private boolean jj_3_6() {
+ if (jj_scan_token(COLON)) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ if (jj_3R_8()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_19() {
- if (jj_scan_token(REQUEST)) return true;
+ final private boolean jj_3_5() {
+ if (jj_scan_token(COLON)) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ if (jj_3R_7()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_18() {
- if (jj_scan_token(PAGE)) return true;
+ final private boolean jj_3_4() {
+ if (jj_3R_6()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ if (jj_scan_token(COLON)) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ if (jj_3R_8()) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_17() {
- if (jj_scan_token(IDENTIFIER)) return true;
+ final private boolean jj_3_3() {
+ if (jj_3R_6()) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ if (jj_scan_token(COLON)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ if (jj_3R_7()) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_5() {
+ final private boolean jj_3R_35() {
Token xsp;
xsp = jj_scanpos;
- if (jj_3R_17()) {
- jj_scanpos = xsp;
- if (jj_3R_18()) {
- jj_scanpos = xsp;
- if (jj_3R_19()) {
- jj_scanpos = xsp;
- if (jj_3R_20()) {
+ if (jj_3_3()) {
jj_scanpos = xsp;
- if (jj_3R_21()) {
+ if (jj_3_4()) {
jj_scanpos = xsp;
- if (jj_3R_22()) {
+ if (jj_3_5()) {
jj_scanpos = xsp;
- if (jj_3R_23()) {
+ if (jj_3_6()) {
jj_scanpos = xsp;
- if (jj_3R_24()) return true;
+ if (jj_3_7()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
} else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
} else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
} else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
} else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_2() {
- if (jj_3R_3()) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- if (jj_3R_7()) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- if (jj_3R_3()) return true;
+ final private boolean jj_3R_48() {
+ if (jj_scan_token(FLOATING_POINT_LITERAL)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_16() {
- if (jj_scan_token(PARAMVALUES)) return true;
+ final private boolean jj_3R_4() {
+ if (jj_3R_5()) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ if (jj_3R_9()) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ if (jj_3R_5()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_15() {
- if (jj_scan_token(PARAM)) return true;
+ final private boolean jj_3_1() {
+ if (jj_3R_4()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3_1() {
- if (jj_3R_2()) return true;
+ final private boolean jj_3R_43() {
+ if (jj_scan_token(INTEGER_LITERAL)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_14() {
- if (jj_scan_token(HEADER)) return true;
+ final private boolean jj_3_2() {
+ if (jj_3R_5()) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ if (jj_scan_token(0)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_13() {
- if (jj_scan_token(APP)) return true;
+ final private boolean jj_3R_8() {
+ if (jj_scan_token(STRING_LITERAL)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_12() {
- if (jj_scan_token(SESSION)) return true;
+ final private boolean jj_3R_46() {
+ if (jj_scan_token(START_BRACKET)) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ if (jj_3R_43()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ if (jj_scan_token(END_BRACKET)) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_11() {
- if (jj_scan_token(REQUEST)) return true;
+ final private boolean jj_3R_51() {
+ if (jj_scan_token(FALSE)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_10() {
- if (jj_scan_token(PAGE)) return true;
+ final private boolean jj_3R_50() {
+ if (jj_scan_token(TRUE)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_4() {
+ final private boolean jj_3R_47() {
Token xsp;
xsp = jj_scanpos;
- if (jj_3R_10()) {
- jj_scanpos = xsp;
- if (jj_3R_11()) {
- jj_scanpos = xsp;
- if (jj_3R_12()) {
- jj_scanpos = xsp;
- if (jj_3R_13()) {
+ if (jj_3R_50()) {
jj_scanpos = xsp;
- if (jj_3R_14()) {
- jj_scanpos = xsp;
- if (jj_3R_15()) {
- jj_scanpos = xsp;
- if (jj_3R_16()) return true;
+ if (jj_3R_51()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
} else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3_2() {
- if (jj_3R_3()) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- if (jj_scan_token(0)) return true;
+ final private boolean jj_3R_45() {
+ if (jj_3R_8()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_45() {
- if (jj_scan_token(NULL)) return true;
+ final private boolean jj_3R_42() {
+ if (jj_3R_49()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3_7() {
- if (jj_3R_5()) return true;
+ final private boolean jj_3R_41() {
+ if (jj_3R_8()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3_6() {
- if (jj_scan_token(COLON)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- if (jj_3R_6()) return true;
+ final private boolean jj_3R_44() {
+ if (jj_3R_7()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3_5() {
- if (jj_scan_token(COLON)) return true;
+ final private boolean jj_3R_40() {
+ if (jj_3R_48()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- if (jj_3R_5()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_39() {
+ if (jj_3R_43()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3_4() {
- if (jj_3R_4()) return true;
+ final private boolean jj_3R_37() {
+ if (jj_scan_token(DOT)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- if (jj_scan_token(COLON)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_44()) {
+ jj_scanpos = xsp;
+ if (jj_3R_45()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- if (jj_3R_6()) return true;
+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_46()) { jj_scanpos = xsp; break; }
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_38() {
+ if (jj_3R_47()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3_3() {
- if (jj_3R_4()) return true;
+ final private boolean jj_3R_36() {
+ if (jj_scan_token(START_BRACKET)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- if (jj_scan_token(COLON)) return true;
+ if (jj_3R_43()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- if (jj_3R_5()) return true;
+ if (jj_scan_token(END_BRACKET)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_33() {
+ final private boolean jj_3R_34() {
Token xsp;
xsp = jj_scanpos;
- if (jj_3_3()) {
+ if (jj_3R_38()) {
jj_scanpos = xsp;
- if (jj_3_4()) {
+ if (jj_3R_39()) {
jj_scanpos = xsp;
- if (jj_3_5()) {
+ if (jj_3R_40()) {
jj_scanpos = xsp;
- if (jj_3_6()) {
+ if (jj_3R_41()) {
jj_scanpos = xsp;
- if (jj_3_7()) return true;
+ if (jj_3R_42()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
} else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
} else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
@@ -621,207 +657,246 @@
return false;
}
- final private boolean jj_3R_44() {
- if (jj_scan_token(FLOATING_POINT_LITERAL)) return true;
+ final private boolean jj_3R_33() {
+ if (jj_3R_35()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_36()) { jj_scanpos = xsp; break; }
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ }
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_37()) { jj_scanpos = xsp; break; }
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ }
return false;
}
- final private boolean jj_3R_43() {
- if (jj_scan_token(INTEGER_LITERAL)) return true;
+ final private boolean jj_3R_26() {
+ if (jj_scan_token(PARAMVALUES)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_6() {
- if (jj_scan_token(STRING_LITERAL)) return true;
+ final private boolean jj_3R_25() {
+ if (jj_scan_token(PARAM)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_41() {
- if (jj_3R_6()) return true;
+ final private boolean jj_3R_24() {
+ if (jj_scan_token(HEADER)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_40() {
- if (jj_3R_5()) return true;
+ final private boolean jj_3R_23() {
+ if (jj_scan_token(APP)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_34() {
- if (jj_scan_token(DOT)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- Token xsp;
- xsp = jj_scanpos;
- if (jj_3R_40()) {
- jj_scanpos = xsp;
- if (jj_3R_41()) return true;
+ final private boolean jj_3R_22() {
+ if (jj_scan_token(SESSION)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_47() {
- if (jj_scan_token(FALSE)) return true;
+ final private boolean jj_3R_21() {
+ if (jj_scan_token(REQUEST)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_31() {
- if (jj_3R_33()) return true;
+ final private boolean jj_3R_20() {
+ if (jj_scan_token(PAGE)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- Token xsp;
- while (true) {
- xsp = jj_scanpos;
- if (jj_3R_34()) { jj_scanpos = xsp; break; }
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- }
return false;
}
- final private boolean jj_3R_46() {
- if (jj_scan_token(TRUE)) return true;
+ final private boolean jj_3R_19() {
+ if (jj_scan_token(IDENTIFIER)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_42() {
+ final private boolean jj_3R_7() {
Token xsp;
xsp = jj_scanpos;
- if (jj_3R_46()) {
+ if (jj_3R_19()) {
jj_scanpos = xsp;
- if (jj_3R_47()) return true;
+ if (jj_3R_20()) {
+ jj_scanpos = xsp;
+ if (jj_3R_21()) {
+ jj_scanpos = xsp;
+ if (jj_3R_22()) {
+ jj_scanpos = xsp;
+ if (jj_3R_23()) {
+ jj_scanpos = xsp;
+ if (jj_3R_24()) {
+ jj_scanpos = xsp;
+ if (jj_3R_25()) {
+ jj_scanpos = xsp;
+ if (jj_3R_26()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
} else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_39() {
- if (jj_3R_45()) return true;
+ final private boolean jj_3R_11() {
+ if (jj_3R_34()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_38() {
- if (jj_3R_6()) return true;
+ final private boolean jj_3R_10() {
+ if (jj_3R_33()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_37() {
- if (jj_3R_44()) return true;
+ final private boolean jj_3R_5() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_10()) {
+ jj_scanpos = xsp;
+ if (jj_3R_11()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_9() {
- if (jj_3R_32()) return true;
+ final private boolean jj_3R_18() {
+ if (jj_scan_token(PARAMVALUES)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_36() {
- if (jj_3R_43()) return true;
+ final private boolean jj_3R_17() {
+ if (jj_scan_token(PARAM)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_8() {
- if (jj_3R_31()) return true;
+ final private boolean jj_3R_16() {
+ if (jj_scan_token(HEADER)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_35() {
- if (jj_3R_42()) return true;
+ final private boolean jj_3R_15() {
+ if (jj_scan_token(APP)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_3() {
- Token xsp;
- xsp = jj_scanpos;
- if (jj_3R_8()) {
- jj_scanpos = xsp;
- if (jj_3R_9()) return true;
+ final private boolean jj_3R_14() {
+ if (jj_scan_token(SESSION)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_32() {
- Token xsp;
- xsp = jj_scanpos;
- if (jj_3R_35()) {
- jj_scanpos = xsp;
- if (jj_3R_36()) {
- jj_scanpos = xsp;
- if (jj_3R_37()) {
- jj_scanpos = xsp;
- if (jj_3R_38()) {
- jj_scanpos = xsp;
- if (jj_3R_39()) return true;
+ final private boolean jj_3R_13() {
+ if (jj_scan_token(REQUEST)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_30() {
+ final private boolean jj_3R_32() {
if (jj_scan_token(GE)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_29() {
+ final private boolean jj_3R_31() {
if (jj_scan_token(LE)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_28() {
+ final private boolean jj_3R_30() {
if (jj_scan_token(GT)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_24() {
- if (jj_scan_token(PARAMVALUES)) return true;
+ final private boolean jj_3R_12() {
+ if (jj_scan_token(PAGE)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_27() {
- if (jj_scan_token(LT)) return true;
+ final private boolean jj_3R_6() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_12()) {
+ jj_scanpos = xsp;
+ if (jj_3R_13()) {
+ jj_scanpos = xsp;
+ if (jj_3R_14()) {
+ jj_scanpos = xsp;
+ if (jj_3R_15()) {
+ jj_scanpos = xsp;
+ if (jj_3R_16()) {
+ jj_scanpos = xsp;
+ if (jj_3R_17()) {
+ jj_scanpos = xsp;
+ if (jj_3R_18()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_23() {
- if (jj_scan_token(PARAM)) return true;
+ final private boolean jj_3R_29() {
+ if (jj_scan_token(LT)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_26() {
+ final private boolean jj_3R_28() {
if (jj_scan_token(NE)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_22() {
- if (jj_scan_token(HEADER)) return true;
+ final private boolean jj_3R_9() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_27()) {
+ jj_scanpos = xsp;
+ if (jj_3R_28()) {
+ jj_scanpos = xsp;
+ if (jj_3R_29()) {
+ jj_scanpos = xsp;
+ if (jj_3R_30()) {
+ jj_scanpos = xsp;
+ if (jj_3R_31()) {
+ jj_scanpos = xsp;
+ if (jj_3R_32()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
- final private boolean jj_3R_21() {
- if (jj_scan_token(APP)) return true;
+ final private boolean jj_3R_27() {
+ if (jj_scan_token(EQ)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
@@ -835,9 +910,9 @@
public boolean lookingAhead = false;
private boolean jj_semLA;
private int jj_gen;
- final private int[] jj_la1 = new int[8];
- final private int[] jj_la1_0 = {0x0,0x801ffcc0,0x0,0x801fc400,0x1fc000,0x801fc000,0x3cc0,0x1800,};
- final private int[] jj_la1_1 = {0x3f0,0x4,0x8,0x0,0x0,0x0,0x0,0x0,};
+ final private int[] jj_la1 = new int[10];
+ final private int[] jj_la1_0 = {0x0,0x801ffcc0,0x0,0x0,0x801fc400,0x0,0x1fc000,0x801fc000,0x3cc0,0x1800,};
+ final private int[] jj_la1_1 = {0x3f0,0x4,0x400,0x8,0x0,0x400,0x0,0x0,0x0,0x0,};
final private JJCalls[] jj_2_rtns = new JJCalls[7];
private boolean jj_rescan = false;
private int jj_gc = 0;
@@ -848,7 +923,7 @@
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 8; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 10; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
@@ -858,7 +933,7 @@
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 8; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 10; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
@@ -868,7 +943,7 @@
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 8; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 10; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
@@ -878,7 +953,7 @@
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 8; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 10; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
@@ -887,7 +962,7 @@
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 8; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 10; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
@@ -896,7 +971,7 @@
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 8; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 10; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
@@ -1003,15 +1078,15 @@
final public ParseException generateParseException() {
jj_expentries.removeAllElements();
- boolean[] la1tokens = new boolean[42];
- for (int i = 0; i < 42; i++) {
+ boolean[] la1tokens = new boolean[44];
+ for (int i = 0; i < 44; i++) {
la1tokens[i] = false;
}
if (jj_kind >= 0) {
la1tokens[jj_kind] = true;
jj_kind = -1;
}
- for (int i = 0; i < 8; i++) {
+ for (int i = 0; i < 10; i++) {
if (jj_la1[i] == jj_gen) {
for (int j = 0; j < 32; j++) {
if ((jj_la1_0[i] & (1<<j)) != 0) {
@@ -1023,7 +1098,7 @@
}
}
}
- for (int i = 0; i < 42; i++) {
+ for (int i = 0; i < 44; i++) {
if (la1tokens[i]) {
jj_expentry = new int[1];
jj_expentry[0] = i;
1.2 +4 -0 jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/spel/parser/SpelParserConstants.java
Index: SpelParserConstants.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/spel/parser/SpelParserConstants.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SpelParserConstants.java 2001/11/21 07:38:36 1.1
+++ SpelParserConstants.java 2001/12/18 21:46:46 1.2
@@ -40,6 +40,8 @@
int LE = 39;
int GE = 40;
int NE = 41;
+ int START_BRACKET = 42;
+ int END_BRACKET = 43;
int DEFAULT = 0;
@@ -86,6 +88,8 @@
"\"<=\"",
"\">=\"",
"\"!=\"",
+ "\"[\"",
+ "\"]\"",
};
}
1.2 +7 -2 jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/spel/parser/SpelParserTokenManager.java
Index: SpelParserTokenManager.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/spel/parser/SpelParserTokenManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SpelParserTokenManager.java 2001/11/21 07:38:33 1.1
+++ SpelParserTokenManager.java 2001/12/18 21:46:46 1.2
@@ -2,6 +2,7 @@
package org.apache.taglibs.standard.lang.spel.parser;
import org.apache.taglibs.standard.lang.spel.*;
import java.util.ArrayList;
+import java.util.List;
public class SpelParserTokenManager implements SpelParserConstants
{
@@ -147,6 +148,10 @@
case 62:
jjmatchedKind = 36;
return jjMoveStringLiteralDfa1_0(0x10000000000L);
+ case 91:
+ return jjStopAtPos(0, 42);
+ case 93:
+ return jjStopAtPos(0, 43);
case 97:
return jjMoveStringLiteralDfa1_0(0x220000L);
case 101:
@@ -844,12 +849,12 @@
"\160\141\162\141\155", "\160\141\162\141\155\166\141\154\165\145\163", "\141\156\144", "\157\162",
"\156\157\164", "\145\161", "\156\145", "\154\164", "\147\164", "\154\145", "\147\145",
"\151\156\163\164\141\156\143\145\157\146", null, null, null, "\72", "\56", "\76", "\74", "\75\75", "\74\75", "\76\75",
-"\41\75", };
+"\41\75", "\133", "\135", };
public static final String[] lexStateNames = {
"DEFAULT",
};
static final long[] jjtoToken = {
- 0x3fcfffffcc1L,
+ 0xffcfffffcc1L,
};
static final long[] jjtoSkip = {
0x3eL,
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>