libcommons-el-java-1.0/0040755000175000017500000000000007674117742014362 5ustar arnaudarnaudlibcommons-el-java-1.0/RELEASE-NOTES.txt0100644000175000017500000000075207670211245017057 0ustar arnaudarnaud$Id: RELEASE-NOTES.txt,v 1.1 2003/06/06 22:16:05 luehe Exp $ Commons EL Package Version 1.0 Release Notes Introduction ------------ This is the first release of the commons-el package, which provides an implementation of the standard interfaces and abstract classes of the javax.servlet.jsp.el package, which is part of the JSP 2.0 specification. Bug Status ---------- There are no outstanding bugs. libcommons-el-java-1.0/LICENSE.txt0100644000175000017500000000537307617603700016201 0ustar arnaudarnaud/* * $Header: /home/cvs/jakarta-commons/el/LICENSE.txt,v 1.1.1.1 2003/02/04 00:22:24 luehe Exp $ * $Revision: 1.1.1.1 $ * $Date: 2003/02/04 00:22:24 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999-2002 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", "Commons", 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 * . * */ libcommons-el-java-1.0/PROPOSAL.html0100644000175000017500000000677507641672631016520 0ustar arnaudarnaud Proposal for JSP 2.0 Expression Language Interpreter Package

Proposal for JSP 2.0 Expression Language Interpreter Package

(0) Rationale

The JSP Standard Tag Library (JSTL), version 1.0, introduced the concept of an Expression Language (EL), whose main goal is to provide page authors with an easy way to access and manipulate application data without requiring the use of scriptlets

JSP 2.0 adopted the EL specification from JSTL, and expanded its scope: EL expressions are no longer limited to JSTL action attributes, but may be used in any standard or custom action attribute declared to accept a runtime expression. In addition, EL expressions may now also be used directly in template text outside of any actions. JSP 2.0 also added an important feature to the EL specification: EL functions, which allow page authors to invoke static methods in Java classes from EL expressions. Additionally, JSP 2.0 allows programmatic access and customization of the EL evaluator through a set of standard interfaces and abstract classes.

Currently, there are a number of projects (including Tomcat 5 and Java Server Faces) that leverage the EL implementation of the Standard Taglib. In addition, there seems to be interest in leveraging the EL in the context of scripting workflow activities using custom tag libraries.

In order to make the EL implementation available to Tomcat 5, the Tomcat team defined a new "ant" target for the Standard Taglib that builds just the EL portion and packages it in a JAR file ("jsp20el.jar") which is stored in Tomcat's common/lib directory. This approach has always been considered an interim solution only, until the EL implementation would move from the Standard Taglib to a more visible location such as jakarta-commons.

(1) Scope of the package

The package shall provide an implementation of the Expression Language specification which is part of the JSP 2.0 standard.

(1.5) Interaction with other packages

The package shall provide an implementation of the standard interfaces and abstract classes of the javax.servlet.jsp.el package, which is defined in the JSP 2.0 specification.

(2) Identify the initial source for the package

The initial codebase will be taken from the Standard Taglib project hosted at jakarta-taglibs. The source of the Standard Taglib is available as part of the jakarta-taglibs nightly source distribution.

(2.1) Identify the base name for the package

The base name of the package shall be org.apache.commons.el

(2.2) Identify the coding conventions for this package

The package follows Sun's Java coding conventions.

(3) Identify any Jakarta-Commons resources to be created

(3.1) Mailing list

The package shall use the jakarta-commons mailing list.

(3.2) CVS repositories

The package shall use a root branch of the jakarta-commons CVS.

(3.3) Bugzilla

The package shall be listed as the "EL" component under the "Commons" project in Bugzilla.

(3.4) Jyve FAQ (when available)

n/a

(4) Initial Committers

libcommons-el-java-1.0/build.properties0100755000175000017500000000046307642104426017570 0ustar arnaudarnaud# The home directory for the Servlet 2.4 and JSP 2.0 classes distribution api.home = ../../jakarta-servletapi-5 # The directory containing your binary distribution of JUnit, # version 3.7 or later junit.home = ../../junit3.7 # The pathname of the "junit.jar" JAR file junit.jar = ${junit.home}/junit.jar libcommons-el-java-1.0/STATUS.html0100644000175000017500000000443507670203542016264 0ustar arnaudarnaud Status File for Jakarta Commons "EL" Component

The Jakarta Commons EL Component

$Id: STATUS.html,v 1.1 2003/06/06 21:28:02 luehe Exp $
[Introduction] [Dependencies] [Release Info] [Committers] [Action Items]

1. INTRODUCTION

The commons-el package provides an implementation of the standard interfaces and abstract classes of the javax.servlet.jsp.el package, which is part of the JSP 2.0 specification.

The classes that are now released as commons-el used to be part of the JSTL 1.0 reference implementation. JSTL 1.0 originally introduced the concept of an Expression Language (EL). The EL has since been integrated into the JSP 2.0 specification, which also added new features to it, such as EL Functions.

2. DEPENDENCIES

The EL component is dependent upon the following external components for compilation:

3. RELEASE INFO

Version Release Date
commons-el-1.0 7-Jun-2003

Planned Next Release: TBD

4. COMMITTERS

5. ACTION ITEMS

TO DO List:

Action Item Volunteer
libcommons-el-java-1.0/src/0040755000175000017500000000000007674117666015156 5ustar arnaudarnaudlibcommons-el-java-1.0/src/conf/0040755000175000017500000000000007674117666016103 5ustar arnaudarnaudlibcommons-el-java-1.0/src/conf/MANIFEST.MF0100644000175000017500000000042407670203663017517 0ustar arnaudarnaudExtension-Name: org.apache.commons.el Specification-Title: Jakarta Commons EL Specification-Vendor: Apache Software Foundation Specification-Version: 2.0 Implementation-Title: org.apache.commons.el Implementation-Vendor: Apache Software Foundation Implementation-Version: 1.0 libcommons-el-java-1.0/src/java/0040755000175000017500000000000007674117666016077 5ustar arnaudarnaudlibcommons-el-java-1.0/src/java/org/0040755000175000017500000000000007674117666016666 5ustar arnaudarnaudlibcommons-el-java-1.0/src/java/org/apache/0040755000175000017500000000000007674117667020110 5ustar arnaudarnaudlibcommons-el-java-1.0/src/java/org/apache/commons/0040755000175000017500000000000007674117667021563 5ustar arnaudarnaudlibcommons-el-java-1.0/src/java/org/apache/commons/el/0040755000175000017500000000000007674117675022162 5ustar arnaudarnaudlibcommons-el-java-1.0/src/java/org/apache/commons/el/ArithmeticOperator.java0100644000175000017500000001015007674115771026617 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import javax.servlet.jsp.el.ELException; import java.math.BigDecimal; import java.math.BigInteger; /** * *

This is the superclass for all binary arithmetic operators * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public abstract class ArithmeticOperator extends BinaryOperator { //------------------------------------- /** * * Applies the operator to the given value **/ public Object apply (Object pLeft, Object pRight, Logger pLogger) throws ELException { return Coercions.applyArithmeticOperator (pLeft, pRight, this, pLogger); } //------------------------------------- /** * * Applies the operator to the given double values, returning a double **/ public abstract double apply (double pLeft, double pRight); //------------------------------------- /** * * Applies the operator to the given double values, returning a double **/ public abstract long apply (long pLeft, long pRight); //------------------------------------- /** * * Applies the operator to the given BigDecimal values, returning a * BigDecimal. **/ public abstract BigDecimal apply(BigDecimal pLeft, BigDecimal pRight); //------------------------------------- /** * * Applies the operator to the given BigInteger values, returning a * BigInteger. **/ public abstract BigInteger apply(BigInteger pLeft, BigInteger pRight); //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/AndOperator.java0100644000175000017500000001070007617603700025220 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import javax.servlet.jsp.el.ELException; /** * *

The implementation of the and operator * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class AndOperator extends BinaryOperator { //------------------------------------- // Singleton //------------------------------------- public static final AndOperator SINGLETON = new AndOperator (); //------------------------------------- /** * * Constructor **/ public AndOperator () { } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the symbol representing the operator **/ public String getOperatorSymbol () { return "and"; } //------------------------------------- /** * * Applies the operator to the given value **/ public Object apply (Object pLeft, Object pRight, Logger pLogger) throws ELException { // Coerce the values to booleans boolean left = Coercions.coerceToBoolean (pLeft, pLogger).booleanValue (); boolean right = Coercions.coerceToBoolean (pRight, pLogger).booleanValue (); return PrimitiveObjects.getBoolean (left && right); } //------------------------------------- /** * * Returns true if evaluation is necessary given the specified Left * value. The And/OrOperators make use of this **/ public boolean shouldEvaluate (Object pLeft) { return (pLeft instanceof Boolean) && ((Boolean) pLeft).booleanValue () == true; } //------------------------------------- /** * * Returns true if the operator expects its arguments to be coerced * to Booleans. The And/Or operators set this to true. **/ public boolean shouldCoerceToBoolean () { return true; } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/BeanInfoManager.java0100644000175000017500000003075507617603700025772 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import java.beans.BeanInfo; import java.beans.EventSetDescriptor; import java.beans.IndexedPropertyDescriptor; import java.beans.IntrospectionException; import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.text.MessageFormat; import java.util.HashMap; import java.util.Map; import javax.servlet.jsp.el.ELException; /** * *

Manages the BeanInfo for one class - contains the BeanInfo, and * also a mapping from property name to BeanInfoProperty. There are * also static methods for accessing the BeanInfoManager for a class - * those mappings are cached permanently so that once the * BeanInfoManager is calculated, it doesn't have to be calculated * again. * * @author Nathan Abramson - Art Technology Group * @version $Change: 181181 $$DateTime: 2001/06/26 09:55:09 $$Author: luehe $ **/ public class BeanInfoManager { //------------------------------------- // Properties //------------------------------------- // property beanClass Class mBeanClass; public Class getBeanClass () { return mBeanClass; } //------------------------------------- // Member variables //------------------------------------- // The BeanInfo BeanInfo mBeanInfo; // Mapping from property name to BeanInfoProperty Map mPropertyByName; // Mapping from property name to BeanInfoIndexedProperty Map mIndexedPropertyByName; // Mapping from event set name to event set descriptor Map mEventSetByName; // Flag if this is initialized boolean mInitialized; // The global mapping from class to BeanInfoManager static Map mBeanInfoManagerByClass = new HashMap (); //------------------------------------- /** * * Constructor **/ BeanInfoManager (Class pBeanClass) { mBeanClass = pBeanClass; } //------------------------------------- /** * * Returns the BeanInfoManager for the specified class **/ public static BeanInfoManager getBeanInfoManager (Class pClass) { BeanInfoManager ret = (BeanInfoManager) mBeanInfoManagerByClass.get (pClass); if (ret == null) { ret = createBeanInfoManager (pClass); } return ret; } //------------------------------------- /** * * Creates and registers the BeanInfoManager for the given class if * it isn't already registered. **/ static synchronized BeanInfoManager createBeanInfoManager (Class pClass) { // Because this method is synchronized statically, the // BeanInfoManager is not initialized at this time (otherwise it // could end up being a bottleneck for the entire system). It is // put into the map in an uninitialized state. The first time // someone tries to use it, it will be initialized (with proper // synchronizations in place to make sure it is only initialized // once). BeanInfoManager ret = (BeanInfoManager) mBeanInfoManagerByClass.get (pClass); if (ret == null) { ret = new BeanInfoManager (pClass); mBeanInfoManagerByClass.put (pClass, ret); } return ret; } //------------------------------------- /** * * Returns the BeanInfoProperty for the specified property in the * given class, or null if not found. **/ public static BeanInfoProperty getBeanInfoProperty (Class pClass, String pPropertyName, Logger pLogger) throws ELException { return getBeanInfoManager (pClass).getProperty (pPropertyName, pLogger); } //------------------------------------- /** * * Returns the BeanInfoIndexedProperty for the specified property in * the given class, or null if not found. **/ public static BeanInfoIndexedProperty getBeanInfoIndexedProperty (Class pClass, String pIndexedPropertyName, Logger pLogger) throws ELException { return getBeanInfoManager (pClass).getIndexedProperty (pIndexedPropertyName, pLogger); } //------------------------------------- /** * * Makes sure that this class has been initialized, and synchronizes * the initialization if it's required. **/ void checkInitialized (Logger pLogger) throws ELException { if (!mInitialized) { synchronized (this) { if (!mInitialized) { initialize (pLogger); mInitialized = true; } } } } //------------------------------------- /** * * Initializes by mapping property names to BeanInfoProperties **/ void initialize (Logger pLogger) throws ELException { try { mBeanInfo = Introspector.getBeanInfo (mBeanClass); mPropertyByName = new HashMap (); mIndexedPropertyByName = new HashMap (); PropertyDescriptor [] pds = mBeanInfo.getPropertyDescriptors (); for (int i = 0; pds != null && i < pds.length; i++) { // Treat as both an indexed property and a normal property PropertyDescriptor pd = pds [i]; if (pd instanceof IndexedPropertyDescriptor) { IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd; Method readMethod = getPublicMethod (ipd.getIndexedReadMethod ()); Method writeMethod = getPublicMethod (ipd.getIndexedWriteMethod ()); BeanInfoIndexedProperty property = new BeanInfoIndexedProperty (readMethod, writeMethod, ipd); mIndexedPropertyByName.put (ipd.getName (), property); } Method readMethod = getPublicMethod (pd.getReadMethod ()); Method writeMethod = getPublicMethod (pd.getWriteMethod ()); BeanInfoProperty property = new BeanInfoProperty (readMethod, writeMethod, pd); mPropertyByName.put (pd.getName (), property); } mEventSetByName = new HashMap (); EventSetDescriptor [] esds = mBeanInfo.getEventSetDescriptors (); for (int i = 0; esds != null && i < esds.length; i++) { EventSetDescriptor esd = esds [i]; mEventSetByName.put (esd.getName (), esd); } } catch (IntrospectionException exc) { if (pLogger.isLoggingWarning ()) { pLogger.logWarning (Constants.EXCEPTION_GETTING_BEANINFO, exc, mBeanClass.getName ()); } } } //------------------------------------- /** * * Returns the BeanInfo for the class **/ BeanInfo getBeanInfo (Logger pLogger) throws ELException { checkInitialized (pLogger); return mBeanInfo; } //------------------------------------- /** * * Returns the BeanInfoProperty for the given property name, or null * if not found. **/ public BeanInfoProperty getProperty (String pPropertyName, Logger pLogger) throws ELException { checkInitialized (pLogger); return (BeanInfoProperty) mPropertyByName.get (pPropertyName); } //------------------------------------- /** * * Returns the BeanInfoIndexedProperty for the given property name, * or null if not found. **/ public BeanInfoIndexedProperty getIndexedProperty (String pIndexedPropertyName, Logger pLogger) throws ELException { checkInitialized (pLogger); return (BeanInfoIndexedProperty) mIndexedPropertyByName.get (pIndexedPropertyName); } //------------------------------------- /** * * Returns the EventSetDescriptor for the given event set name, or * null if not found. **/ public EventSetDescriptor getEventSet (String pEventSetName, Logger pLogger) throws ELException { checkInitialized (pLogger); return (EventSetDescriptor) mEventSetByName.get (pEventSetName); } //------------------------------------- // Finding the public version of a method - if a PropertyDescriptor // is obtained for a non-public class that implements a public // interface, the read/write methods will be for the class, and // therefore inaccessible. To correct this, a version of the same // method must be found in a superclass or interface. //------------------------------------- /** * * Returns a publicly-accessible version of the given method, by * searching for a public declaring class. **/ static Method getPublicMethod (Method pMethod) { if (pMethod == null) { return null; } // See if the method is already available from a public class Class cl = pMethod.getDeclaringClass (); if (Modifier.isPublic (cl.getModifiers ())) { return pMethod; } // Otherwise, try to find a public class that declares the method Method ret = getPublicMethod (cl, pMethod); if (ret != null) { return ret; } else { return pMethod; } } //------------------------------------- /** * * If the given class is public and has a Method that declares the * same name and arguments as the given method, then that method is * returned. Otherwise the superclass and interfaces are searched * recursively. **/ static Method getPublicMethod (Class pClass, Method pMethod) { // See if this is a public class declaring the method if (Modifier.isPublic (pClass.getModifiers ())) { try { Method m; try { m = pClass.getDeclaredMethod (pMethod.getName (), pMethod.getParameterTypes ()); } catch (java.security.AccessControlException ex) { // kludge to accommodate J2EE RI's default settings // TODO: see if we can simply replace // getDeclaredMethod() with getMethod() ...? m = pClass.getMethod(pMethod.getName (), pMethod.getParameterTypes ()); } if (Modifier.isPublic (m.getModifiers ())) { return m; } } catch (NoSuchMethodException exc) {} } // Search the interfaces { Class [] interfaces = pClass.getInterfaces (); if (interfaces != null) { for (int i = 0; i < interfaces.length; i++) { Method m = getPublicMethod (interfaces [i], pMethod); if (m != null) { return m; } } } } // Search the superclass { Class superclass = pClass.getSuperclass (); if (superclass != null) { Method m = getPublicMethod (superclass, pMethod); if (m != null) { return m; } } } return null; } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/ArraySuffix.java0100644000175000017500000002237507642104426025257 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import java.lang.reflect.Array; import java.lang.reflect.InvocationTargetException; import java.util.List; import java.util.Map; import javax.servlet.jsp.el.VariableResolver; import javax.servlet.jsp.el.ELException; import javax.servlet.jsp.el.FunctionMapper; /** * *

Represents an operator that obtains a Map entry, an indexed * value, a property value, or an indexed property value of an object. * The following are the rules for evaluating this operator: * *

* * @author Nathan Abramson - Art Technology Group * @author Shawn Bayern * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class ArraySuffix extends ValueSuffix { //------------------------------------- // Constants //------------------------------------- // Zero-argument array static Object [] sNoArgs = new Object [0]; //------------------------------------- // Properties //------------------------------------- // property index Expression mIndex; public Expression getIndex () { return mIndex; } public void setIndex (Expression pIndex) { mIndex = pIndex; } //------------------------------------- /** * * Constructor **/ public ArraySuffix (Expression pIndex) { mIndex = pIndex; } //------------------------------------- /** * * Gets the value of the index **/ Object evaluateIndex (VariableResolver pResolver, FunctionMapper functions, Logger pLogger) throws ELException { return mIndex.evaluate (pResolver, functions, pLogger); } //------------------------------------- /** * * Returns the operator symbol **/ String getOperatorSymbol () { return "[]"; } //------------------------------------- // ValueSuffix methods //------------------------------------- /** * * Returns the expression in the expression language syntax **/ public String getExpressionString () { return "[" + mIndex.getExpressionString () + "]"; } //------------------------------------- /** * * Evaluates the expression in the given context, operating on the * given value. **/ public Object evaluate (Object pValue, VariableResolver pResolver, FunctionMapper functions, Logger pLogger) throws ELException { Object indexVal; String indexStr; BeanInfoProperty property; BeanInfoIndexedProperty ixproperty; // Check for null value if (pValue == null) { if (pLogger.isLoggingWarning ()) { pLogger.logWarning (Constants.CANT_GET_INDEXED_VALUE_OF_NULL, getOperatorSymbol ()); } return null; } // Evaluate the index else if ((indexVal = evaluateIndex (pResolver, functions, pLogger)) == null) { if (pLogger.isLoggingWarning ()) { pLogger.logWarning (Constants.CANT_GET_NULL_INDEX, getOperatorSymbol ()); } return null; } // See if it's a Map else if (pValue instanceof Map) { Map val = (Map) pValue; return val.get (indexVal); } // See if it's a List or array else if (pValue instanceof List || pValue.getClass ().isArray ()) { Integer indexObj = Coercions.coerceToInteger (indexVal, pLogger); if (indexObj == null) { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.BAD_INDEX_VALUE, getOperatorSymbol (), indexVal.getClass ().getName ()); } return null; } else if (pValue instanceof List) { try { return ((List) pValue).get (indexObj.intValue ()); } catch (ArrayIndexOutOfBoundsException exc) { if (pLogger.isLoggingWarning ()) { pLogger.logWarning (Constants.EXCEPTION_ACCESSING_LIST, exc, indexObj); } return null; } catch (IndexOutOfBoundsException exc) { if (pLogger.isLoggingWarning ()) { pLogger.logWarning (Constants.EXCEPTION_ACCESSING_LIST, exc, indexObj); } return null; } catch (Exception exc) { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.EXCEPTION_ACCESSING_LIST, exc, indexObj); } return null; } } else { try { return Array.get (pValue, indexObj.intValue ()); } catch (ArrayIndexOutOfBoundsException exc) { if (pLogger.isLoggingWarning ()) { pLogger.logWarning (Constants.EXCEPTION_ACCESSING_ARRAY, exc, indexObj); } return null; } catch (IndexOutOfBoundsException exc) { if (pLogger.isLoggingWarning ()) { pLogger.logWarning (Constants.EXCEPTION_ACCESSING_ARRAY, exc, indexObj); } return null; } catch (Exception exc) { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.EXCEPTION_ACCESSING_ARRAY, exc, indexObj); } return null; } } } // Coerce to a String for property access else if ((indexStr = Coercions.coerceToString (indexVal, pLogger)) == null) { return null; } // Look for a JavaBean property else if ((property = BeanInfoManager.getBeanInfoProperty (pValue.getClass (), indexStr, pLogger)) != null && property.getReadMethod () != null) { try { return property.getReadMethod ().invoke (pValue, sNoArgs); } catch (InvocationTargetException exc) { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.ERROR_GETTING_PROPERTY, exc.getTargetException (), indexStr, pValue.getClass ().getName ()); } return null; } catch (Exception exc) { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.ERROR_GETTING_PROPERTY, exc, indexStr, pValue.getClass ().getName ()); } return null; } } else { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.CANT_FIND_INDEX, indexVal, pValue.getClass ().getName (), getOperatorSymbol ()); } return null; } } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/BeanInfoIndexedProperty.java0100644000175000017500000001053107617603700027533 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import java.beans.IndexedPropertyDescriptor; import java.beans.PropertyDescriptor; import java.lang.reflect.Method; /** * *

This contains the information for one indexed property in a * BeanInfo - IndexedPropertyDescriptor, read method, and write * method. This class is necessary because the read/write methods in * the IndexedPropertyDescriptor may not be accessible if the bean * given to the introspector is not a public class. In this case, a * publicly accessible version of the method must be found by * searching for a public superclass/interface that declares the * method (this searching is done by the BeanInfoManager). * * @author Nathan Abramson - Art Technology Group * @version $Change: 181181 $$DateTime: 2001/06/26 09:55:09 $$Author: luehe $ **/ public class BeanInfoIndexedProperty { //------------------------------------- // Properties //------------------------------------- // property readMethod Method mReadMethod; public Method getReadMethod () { return mReadMethod; } //------------------------------------- // property writeMethod Method mWriteMethod; public Method getWriteMethod () { return mWriteMethod; } //------------------------------------- // property propertyDescriptor IndexedPropertyDescriptor mIndexedPropertyDescriptor; public IndexedPropertyDescriptor getIndexedPropertyDescriptor () { return mIndexedPropertyDescriptor; } //------------------------------------- /** * * Constructor **/ public BeanInfoIndexedProperty (Method pReadMethod, Method pWriteMethod, IndexedPropertyDescriptor pIndexedPropertyDescriptor) { mReadMethod = pReadMethod; mWriteMethod = pWriteMethod; mIndexedPropertyDescriptor = pIndexedPropertyDescriptor; } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/BeanInfoProperty.java0100644000175000017500000001030607617603700026232 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import java.beans.PropertyDescriptor; import java.lang.reflect.Method; /** * *

This contains the information for one property in a BeanInfo - * PropertyDescriptor, read method, and write method. This class is * necessary because the read/write methods in the PropertyDescriptor * may not be accessible if the bean given to the introspector is not * a public class. In this case, a publicly accessible version of the * method must be found by searching for a public superclass/interface * that declares the method (this searching is done by the * BeanInfoManager). * * @author Nathan Abramson - Art Technology Group * @version $Change: 181181 $$DateTime: 2001/06/26 09:55:09 $$Author: luehe $ **/ public class BeanInfoProperty { //------------------------------------- // Properties //------------------------------------- // property readMethod Method mReadMethod; public Method getReadMethod () { return mReadMethod; } //------------------------------------- // property writeMethod Method mWriteMethod; public Method getWriteMethod () { return mWriteMethod; } //------------------------------------- // property propertyDescriptor PropertyDescriptor mPropertyDescriptor; public PropertyDescriptor getPropertyDescriptor () { return mPropertyDescriptor; } //------------------------------------- /** * * Constructor **/ public BeanInfoProperty (Method pReadMethod, Method pWriteMethod, PropertyDescriptor pPropertyDescriptor) { mReadMethod = pReadMethod; mWriteMethod = pWriteMethod; mPropertyDescriptor = pPropertyDescriptor; } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/BinaryOperator.java0100644000175000017500000000765307617603700025757 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import javax.servlet.jsp.el.ELException; /** * *

This is the superclass for all binary operators * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public abstract class BinaryOperator { //------------------------------------- /** * * Constructor **/ public BinaryOperator () { } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the symbol representing the operator **/ public abstract String getOperatorSymbol (); //------------------------------------- /** * * Applies the operator to the given pair of values **/ public abstract Object apply (Object pLeft, Object pRight, Logger pLogger) throws ELException; //------------------------------------- /** * * Returns true if evaluation is necessary given the specified Left * value. The And/OrOperators make use of this **/ public boolean shouldEvaluate (Object pLeft) { return true; } //------------------------------------- /** * * Returns true if the operator expects its arguments to be coerced * to Booleans. The And/Or operators set this to true. **/ public boolean shouldCoerceToBoolean () { return false; } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/BinaryOperatorExpression.java0100644000175000017500000001332407642104426030026 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import java.util.List; import java.util.Map; import javax.servlet.jsp.el.ELException; import javax.servlet.jsp.el.VariableResolver; import javax.servlet.jsp.el.FunctionMapper; /** * *

An expression representing a binary operator on a value * * @author Nathan Abramson - Art Technology Group * @author Shawn Bayern * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class BinaryOperatorExpression extends Expression { //------------------------------------- // Properties //------------------------------------- // property expression Expression mExpression; public Expression getExpression () { return mExpression; } public void setExpression (Expression pExpression) { mExpression = pExpression; } //------------------------------------- // property operators List mOperators; public List getOperators () { return mOperators; } public void setOperators (List pOperators) { mOperators = pOperators; } //------------------------------------- // property expressions List mExpressions; public List getExpressions () { return mExpressions; } public void setExpressions (List pExpressions) { mExpressions = pExpressions; } //------------------------------------- /** * * Constructor **/ public BinaryOperatorExpression (Expression pExpression, List pOperators, List pExpressions) { mExpression = pExpression; mOperators = pOperators; mExpressions = pExpressions; } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the expression in the expression language syntax **/ public String getExpressionString () { StringBuffer buf = new StringBuffer (); buf.append ("("); buf.append (mExpression.getExpressionString ()); for (int i = 0; i < mOperators.size (); i++) { BinaryOperator operator = (BinaryOperator) mOperators.get (i); Expression expression = (Expression) mExpressions.get (i); buf.append (" "); buf.append (operator.getOperatorSymbol ()); buf.append (" "); buf.append (expression.getExpressionString ()); } buf.append (")"); return buf.toString (); } //------------------------------------- /** * * Evaluates to the literal value **/ public Object evaluate (VariableResolver pResolver, FunctionMapper functions, Logger pLogger) throws ELException { Object value = mExpression.evaluate (pResolver, functions, pLogger); for (int i = 0; i < mOperators.size (); i++) { BinaryOperator operator = (BinaryOperator) mOperators.get (i); // For the And/Or operators, we need to coerce to a boolean // before testing if we shouldEvaluate if (operator.shouldCoerceToBoolean ()) { value = Coercions.coerceToBoolean (value, pLogger); } if (operator.shouldEvaluate (value)) { Expression expression = (Expression) mExpressions.get (i); Object nextValue = expression.evaluate (pResolver, functions, pLogger); value = operator.apply (value, nextValue, pLogger); } } return value; } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/BooleanLiteral.java0100644000175000017500000000745507617603700025713 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; /** * *

An expression representing a boolean literal value * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class BooleanLiteral extends Literal { //------------------------------------- // Member variables //------------------------------------- public static final BooleanLiteral TRUE = new BooleanLiteral ("true"); public static final BooleanLiteral FALSE = new BooleanLiteral ("false"); //------------------------------------- /** * * Constructor **/ public BooleanLiteral (String pToken) { super (getValueFromToken (pToken)); } //------------------------------------- /** * * Parses the given token into the literal value **/ static Object getValueFromToken (String pToken) { return ("true".equals (pToken)) ? Boolean.TRUE : Boolean.FALSE; } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the expression in the expression language syntax **/ public String getExpressionString () { return (getValue () == Boolean.TRUE) ? "true" : "false"; } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/Coercions.java0100644000175000017500000010603507673673602024747 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import java.beans.PropertyEditor; import java.beans.PropertyEditorManager; import java.math.BigInteger; import java.math.BigDecimal; import javax.servlet.jsp.el.ELException; /** * *

This class contains the logic for coercing data types before * operators are applied to them. * *

The following is the list of rules applied for various type * conversions. * *

     * Applying arithmetic operator
     *   Binary operator - A {+,-,*} B
     *     if A and B are null
     *       return 0
     *     if A or B is BigDecimal, coerce both to BigDecimal and then:
     *       if operator is +, return A.add(B)
     *       if operator is -, return A.subtract(B)
     *       if operator is *, return A.multiply(B)
     *     if A or B is Float, Double, or String containing ".", "e", or "E"
     *       if A or B is BigInteger, coerce both A and B to BigDecimal and apply operator
     *       coerce both A and B to Double and apply operator
     *     if A or B is BigInteger, coerce both to BigInteger and then:
     *       if operator is +, return A.add(B)
     *       if operator is -, return A.subtract(B)
     *       if operator is *, return A.multiply(B)
     *     otherwise
     *       coerce both A and B to Long
     *       apply operator
     *     if operator results in exception (such as divide by 0), error
     * 
     *   Binary operator - A {/,div} B
     *     if A and B are null
     *       return 0
     *     if A or B is a BigDecimal or BigInteger, coerce both to BigDecimal and
     *      return A.divide(B, BigDecimal.ROUND_HALF_UP)
     *     otherwise
     *       coerce both A and B to Double
     *       apply operator
     *     if operator results in exception (such as divide by 0), error
     * 
     *   Binary operator - A {%,mod} B
     *     if A and B are null
     *       return 0
     *     if A or B is BigDecimal, Float, Double, or String containing ".", "e" or "E"
     *       coerce both to Double
     *       apply operator
     *     if A or B is BigInteger, coerce both to BigInteger and return
     *      A.remainder(B)
     *     otherwise
     *       coerce both A and B to Long
     *       apply operator
     *     if operator results in exception (such as divide by 0), error
     * 
     *   Unary minus operator - -A
     *     if A is null
     *       return 0
     *     if A is BigInteger or BigDecimal, return A.negate()
     *     if A is String
     *       if A contains ".", "e", or "E"
     *         coerce to Double, apply operator
     *       otherwise
     *         coerce to a Long and apply operator
     *     if A is Byte,Short,Integer,Long,Float,Double
     *       retain type, apply operator
     *     if operator results in exception, error
     *     otherwise
     *       error
     *
     * Applying "empty" operator - empty A
     *   if A is null
     *     return true
     *   if A is zero-length String
     *     return true
     *   if A is zero-length array
     *     return true
     *   if A is List and ((List) A).isEmpty()
     *     return true
     *   if A is Map and ((Map) A).isEmpty()
     *     return true
     *   if A is Collection an ((Collection) A).isEmpty()
     *     return true
     *   otherwise
     *     return false
     * 
     * Applying logical operators
     *   Binary operator - A {and,or} B
     *     coerce both A and B to Boolean, apply operator
     *   NOTE - operator stops as soon as expression can be determined, i.e.,
     *     A and B and C and D - if B is false, then only A and B is evaluated
     *   Unary not operator - not A
     *     coerce A to Boolean, apply operator
     * 
     * Applying relational operator
     *   A {<,>,<=,>=,lt,gt,lte,gte} B
     *     if A==B
     *       if operator is >= or <=
     *         return true
     *       otherwise
     *         return false
     *     if A or B is null
     *       return false
     *     if A or B is BigDecimal, coerce both A and B to BigDecimal and use the
     *      return value of A.compareTo(B)
     *     if A or B is Float or Double
     *       coerce both A and B to Double
     *       apply operator
     *     if A or B is BigInteger, coerce both A and B to BigInteger and use the
     *      return value of A.compareTo(B)
     *     if A or B is Byte,Short,Character,Integer,Long
     *       coerce both A and B to Long
     *       apply operator
     *     if A or B is String
     *       coerce both A and B to String, compare lexically
     *     if A is Comparable
     *       if A.compareTo (B) throws exception
     *         error
     *       otherwise
     *         use result of A.compareTo(B)
     *     if B is Comparable
     *       if B.compareTo (A) throws exception
     *         error
     *       otherwise
     *         use result of B.compareTo(A)
     *     otherwise
     *       error
     * 
     * Applying equality operator
     *   A {==,!=} B
     *     if A==B
     *       apply operator
     *     if A or B is null
     *       return false for ==, true for !=
     *     if A or B is BigDecimal, coerce both A and B to BigDecimal and then:
     *       if operator is == or eq, return A.equals(B)
     *       if operator is != or ne, return !A.equals(B)
     *     if A or B is Float or Double
     *       coerce both A and B to Double
     *       apply operator
     *     if A or B is BigInteger, coerce both A and B to BigInteger and then:
     *       if operator is == or eq, return A.equals(B)
     *       if operator is != or ne, return !A.equals(B)
     *     if A or B is Byte,Short,Character,Integer,Long
     *       coerce both A and B to Long
     *       apply operator
     *     if A or B is Boolean
     *       coerce both A and B to Boolean
     *       apply operator
     *     if A or B is String
     *       coerce both A and B to String, compare lexically
     *     otherwise
     *       if an error occurs while calling A.equals(B)
     *         error
     *       apply operator to result of A.equals(B)
     * 
     * coercions
     * 
     *   coerce A to String
     *     A is String
     *       return A
     *     A is null
     *       return ""
     *     A.toString throws exception
     *       error
     *     otherwise
     *       return A.toString
     * 
     *   coerce A to Number type N
     *     A is null or ""
     *       return 0
     *     A is Character
     *       convert to short, apply following rules
     *     A is Boolean
     *       error
     *     A is Number type N
     *       return A
     *     A is Number, coerce quietly to type N using the following algorithm
     *         If N is BigInteger
     *             If A is BigDecimal, return A.toBigInteger()
     *             Otherwise, return BigInteger.valueOf(A.longValue())
     *        if N is BigDecimal
     *             If A is a BigInteger, return new BigDecimal(A)
     *             Otherwise, return new BigDecimal(A.doubleValue())
     *        If N is Byte, return new Byte(A.byteValue())
     *        If N is Short, return new Short(A.shortValue())
     *        If N is Integer, return new Integer(A.integerValue())
     *        If N is Long, return new Long(A.longValue())
     *        If N is Float, return new Float(A.floatValue())
     *        If N is Double, return new Double(A.doubleValue())
     *        otherwise ERROR
     *     A is String
     *       If N is BigDecimal then:
     *            If new BigDecimal(A) throws an exception then ERROR
     *            Otherwise, return new BigDecimal(A)
     *       If N is BigInteger then:
     *            If new BigInteger(A) throws an exception, then ERROR
     *            Otherwise, return new BigInteger(A)
     *       new N.valueOf(A) throws exception
     *         error
     *       return N.valueOf(A)
     *     otherwise
     *       error
     * 
     *   coerce A to Character should be
     *     A is null or ""
     *       return (char) 0
     *     A is Character
     *       return A
     *     A is Boolean
     *       error
     *     A is Number with less precision than short
     *       coerce quietly - return (char) A
     *     A is Number with greater precision than short
     *       coerce quietly - return (char) A
     *     A is String
     *       return A.charAt (0)
     *     otherwise
     *       error
     * 
     *   coerce A to Boolean
     *     A is null or ""
     *       return false
     *     A is Boolean
     *       return A
     *     A is String
     *       Boolean.valueOf(A) throws exception
     *         error
     *       return Boolean.valueOf(A)
     *     otherwise
     *       error
     * 
     *   coerce A to any other type T
     *     A is null
     *       return null
     *     A is assignable to T
     *       coerce quietly
     *     A is String
     *       T has no PropertyEditor
     *         if A is "", return null
     *         otherwise error
     *       T's PropertyEditor throws exception
     *         if A is "", return null
     *         otherwise error
     *       otherwise
     *         apply T's PropertyEditor
     *     otherwise
     *       error
     * 
* * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class Coercions { private static final Number ZERO = new Integer(0); //------------------------------------- /** * * Coerces the given value to the specified class. **/ public static Object coerce (Object pValue, Class pClass, Logger pLogger) throws ELException { if (pClass == String.class) { return coerceToString (pValue, pLogger); } else if (isNumberClass (pClass)) { return coerceToPrimitiveNumber (pValue, pClass, pLogger); } else if (pClass == Character.class || pClass == Character.TYPE) { return coerceToCharacter (pValue, pLogger); } else if (pClass == Boolean.class || pClass == Boolean.TYPE) { return coerceToBoolean (pValue, pLogger); } else { return coerceToObject (pValue, pClass, pLogger); } } //------------------------------------- /** * * Returns true if the given class is Byte, Short, Integer, Long, * Float, Double, BigInteger, or BigDecimal **/ static boolean isNumberClass (Class pClass) { return pClass == Byte.class || pClass == Byte.TYPE || pClass == Short.class || pClass == Short.TYPE || pClass == Integer.class || pClass == Integer.TYPE || pClass == Long.class || pClass == Long.TYPE || pClass == Float.class || pClass == Float.TYPE || pClass == Double.class || pClass == Double.TYPE || pClass == BigInteger.class || pClass == BigDecimal.class; } //------------------------------------- /** * * Coerces the specified value to a String **/ public static String coerceToString (Object pValue, Logger pLogger) throws ELException { if (pValue == null) { return ""; } else if (pValue instanceof String) { return (String) pValue; } else { try { return pValue.toString (); } catch (Exception exc) { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.TOSTRING_EXCEPTION, exc, pValue.getClass ().getName ()); } return ""; } } } //------------------------------------- /** * * Coerces a value to the given primitive number class **/ public static Number coerceToPrimitiveNumber (Object pValue, Class pClass, Logger pLogger) throws ELException { if (pValue == null || "".equals (pValue)) { return coerceToPrimitiveNumber (ZERO, pClass); } else if (pValue instanceof Character) { char val = ((Character) pValue).charValue (); return coerceToPrimitiveNumber (new Short((short) val), pClass); } else if (pValue instanceof Boolean) { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.BOOLEAN_TO_NUMBER, pValue, pClass.getName ()); } return coerceToPrimitiveNumber (ZERO, pClass); } else if (pValue.getClass () == pClass) { return (Number) pValue; } else if (pValue instanceof Number) { return coerceToPrimitiveNumber ((Number) pValue, pClass); } else if (pValue instanceof String) { try { return coerceToPrimitiveNumber ((String) pValue, pClass); } catch (Exception exc) { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.STRING_TO_NUMBER_EXCEPTION, (String) pValue, pClass.getName ()); } return coerceToPrimitiveNumber (ZERO, pClass); } } else { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.COERCE_TO_NUMBER, pValue.getClass ().getName (), pClass.getName ()); } return coerceToPrimitiveNumber (0, pClass); } } //------------------------------------- /** * * Coerces a value to an Integer, returning null if the coercion * isn't possible. **/ public static Integer coerceToInteger (Object pValue, Logger pLogger) throws ELException { if (pValue == null) { return null; } else if (pValue instanceof Character) { return PrimitiveObjects.getInteger ((int) (((Character) pValue).charValue ())); } else if (pValue instanceof Boolean) { if (pLogger.isLoggingWarning ()) { pLogger.logWarning (Constants.BOOLEAN_TO_NUMBER, pValue, Integer.class.getName ()); } return PrimitiveObjects.getInteger (((Boolean) pValue).booleanValue () ? 1 : 0); } else if (pValue instanceof Integer) { return (Integer) pValue; } else if (pValue instanceof Number) { return PrimitiveObjects.getInteger (((Number) pValue).intValue ()); } else if (pValue instanceof String) { try { return Integer.valueOf ((String) pValue); } catch (Exception exc) { if (pLogger.isLoggingWarning ()) { pLogger.logWarning (Constants.STRING_TO_NUMBER_EXCEPTION, (String) pValue, Integer.class.getName ()); } return null; } } else { if (pLogger.isLoggingWarning ()) { pLogger.logWarning (Constants.COERCE_TO_NUMBER, pValue.getClass ().getName (), Integer.class.getName ()); } return null; } } //------------------------------------- /** * * Coerces a long to the given primitive number class **/ static Number coerceToPrimitiveNumber (long pValue, Class pClass) throws ELException { if (pClass == Byte.class || pClass == Byte.TYPE) { return PrimitiveObjects.getByte ((byte) pValue); } else if (pClass == Short.class || pClass == Short.TYPE) { return PrimitiveObjects.getShort ((short) pValue); } else if (pClass == Integer.class || pClass == Integer.TYPE) { return PrimitiveObjects.getInteger ((int) pValue); } else if (pClass == Long.class || pClass == Long.TYPE) { return PrimitiveObjects.getLong (pValue); } else if (pClass == Float.class || pClass == Float.TYPE) { return PrimitiveObjects.getFloat ((float) pValue); } else if (pClass == Double.class || pClass == Double.TYPE) { return PrimitiveObjects.getDouble ((double) pValue); } else { return PrimitiveObjects.getInteger (0); } } //------------------------------------- /** * * Coerces a double to the given primitive number class **/ static Number coerceToPrimitiveNumber (double pValue, Class pClass) throws ELException { if (pClass == Byte.class || pClass == Byte.TYPE) { return PrimitiveObjects.getByte ((byte) pValue); } else if (pClass == Short.class || pClass == Short.TYPE) { return PrimitiveObjects.getShort ((short) pValue); } else if (pClass == Integer.class || pClass == Integer.TYPE) { return PrimitiveObjects.getInteger ((int) pValue); } else if (pClass == Long.class || pClass == Long.TYPE) { return PrimitiveObjects.getLong ((long) pValue); } else if (pClass == Float.class || pClass == Float.TYPE) { return PrimitiveObjects.getFloat ((float) pValue); } else if (pClass == Double.class || pClass == Double.TYPE) { return PrimitiveObjects.getDouble (pValue); } else { return PrimitiveObjects.getInteger (0); } } //------------------------------------- /** * * Coerces a Number to the given primitive number class **/ static Number coerceToPrimitiveNumber (Number pValue, Class pClass) throws ELException { if (pClass == Byte.class || pClass == Byte.TYPE) { return PrimitiveObjects.getByte (pValue.byteValue ()); } else if (pClass == Short.class || pClass == Short.TYPE) { return PrimitiveObjects.getShort (pValue.shortValue ()); } else if (pClass == Integer.class || pClass == Integer.TYPE) { return PrimitiveObjects.getInteger (pValue.intValue ()); } else if (pClass == Long.class || pClass == Long.TYPE) { return PrimitiveObjects.getLong (pValue.longValue ()); } else if (pClass == Float.class || pClass == Float.TYPE) { return PrimitiveObjects.getFloat (pValue.floatValue ()); } else if (pClass == Double.class || pClass == Double.TYPE) { return PrimitiveObjects.getDouble (pValue.doubleValue ()); } else if (pClass == BigInteger.class) { if (pValue instanceof BigDecimal) return ((BigDecimal) pValue).toBigInteger(); else return BigInteger.valueOf(pValue.longValue()); } else if (pClass == BigDecimal.class) { if (pValue instanceof BigInteger) return new BigDecimal((BigInteger) pValue); else return new BigDecimal(pValue.doubleValue()); } else { return PrimitiveObjects.getInteger (0); } } //------------------------------------- /** * * Coerces a String to the given primitive number class **/ static Number coerceToPrimitiveNumber (String pValue, Class pClass) throws ELException { if (pClass == Byte.class || pClass == Byte.TYPE) { return Byte.valueOf (pValue); } else if (pClass == Short.class || pClass == Short.TYPE) { return Short.valueOf (pValue); } else if (pClass == Integer.class || pClass == Integer.TYPE) { return Integer.valueOf (pValue); } else if (pClass == Long.class || pClass == Long.TYPE) { return Long.valueOf (pValue); } else if (pClass == Float.class || pClass == Float.TYPE) { return Float.valueOf (pValue); } else if (pClass == Double.class || pClass == Double.TYPE) { return Double.valueOf (pValue); } else if (pClass == BigInteger.class) { return new BigInteger(pValue); } else if (pClass == BigDecimal.class) { return new BigDecimal(pValue); } else { return PrimitiveObjects.getInteger (0); } } //------------------------------------- /** * * Coerces a value to a Character **/ public static Character coerceToCharacter (Object pValue, Logger pLogger) throws ELException { if (pValue == null || "".equals (pValue)) { return PrimitiveObjects.getCharacter ((char) 0); } else if (pValue instanceof Character) { return (Character) pValue; } else if (pValue instanceof Boolean) { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.BOOLEAN_TO_CHARACTER, pValue); } return PrimitiveObjects.getCharacter ((char) 0); } else if (pValue instanceof Number) { return PrimitiveObjects.getCharacter ((char) ((Number) pValue).shortValue ()); } else if (pValue instanceof String) { String str = (String) pValue; return PrimitiveObjects.getCharacter (str.charAt (0)); } else { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.COERCE_TO_CHARACTER, pValue.getClass ().getName ()); } return PrimitiveObjects.getCharacter ((char) 0); } } //------------------------------------- /** * * Coerces a value to a Boolean **/ public static Boolean coerceToBoolean (Object pValue, Logger pLogger) throws ELException { if (pValue == null || "".equals (pValue)) { return Boolean.FALSE; } else if (pValue instanceof Boolean) { return (Boolean) pValue; } else if (pValue instanceof String) { String str = (String) pValue; try { return Boolean.valueOf (str); } catch (Exception exc) { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.STRING_TO_BOOLEAN, exc, (String) pValue); } return Boolean.FALSE; } } else { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.COERCE_TO_BOOLEAN, pValue.getClass ().getName ()); } return Boolean.TRUE; } } //------------------------------------- /** * * Coerces a value to the specified Class that is not covered by any * of the above cases **/ public static Object coerceToObject (Object pValue, Class pClass, Logger pLogger) throws ELException { if (pValue == null) { return null; } else if (pClass.isAssignableFrom (pValue.getClass ())) { return pValue; } else if (pValue instanceof String) { String str = (String) pValue; PropertyEditor pe = PropertyEditorManager.findEditor (pClass); if (pe == null) { if ("".equals (str)) { return null; } else { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.NO_PROPERTY_EDITOR, str, pClass.getName ()); } return null; } } try { pe.setAsText (str); return pe.getValue (); } catch (IllegalArgumentException exc) { if ("".equals (str)) { return null; } else { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.PROPERTY_EDITOR_ERROR, exc, pValue, pClass.getName ()); } return null; } } } else { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.COERCE_TO_OBJECT, pValue.getClass ().getName (), pClass.getName ()); } return null; } } //------------------------------------- // Applying operators //------------------------------------- /** * * Performs all of the necessary type conversions, then calls on the * appropriate operator. **/ public static Object applyArithmeticOperator (Object pLeft, Object pRight, ArithmeticOperator pOperator, Logger pLogger) throws ELException { if (pLeft == null && pRight == null) { if (pLogger.isLoggingWarning ()) { pLogger.logWarning (Constants.ARITH_OP_NULL, pOperator.getOperatorSymbol ()); } return PrimitiveObjects.getInteger (0); } else if (isBigDecimal(pLeft) || isBigDecimal(pRight)) { BigDecimal left = (BigDecimal) coerceToPrimitiveNumber(pLeft, BigDecimal.class, pLogger); BigDecimal right = (BigDecimal) coerceToPrimitiveNumber(pRight, BigDecimal.class, pLogger); return pOperator.apply(left, right); } else if (isFloatingPointType(pLeft) || isFloatingPointType(pRight) || isFloatingPointString(pLeft) || isFloatingPointString(pRight)) { if (isBigInteger(pLeft) || isBigInteger(pRight)) { BigDecimal left = (BigDecimal) coerceToPrimitiveNumber(pLeft, BigDecimal.class, pLogger); BigDecimal right = (BigDecimal) coerceToPrimitiveNumber(pRight, BigDecimal.class, pLogger); return pOperator.apply(left, right); } else { double left = coerceToPrimitiveNumber(pLeft, Double.class, pLogger). doubleValue(); double right = coerceToPrimitiveNumber(pRight, Double.class, pLogger). doubleValue(); return PrimitiveObjects.getDouble(pOperator.apply(left, right)); } } else if (isBigInteger(pLeft) || isBigInteger(pRight)) { BigInteger left = (BigInteger) coerceToPrimitiveNumber(pLeft, BigInteger.class, pLogger); BigInteger right = (BigInteger) coerceToPrimitiveNumber(pRight, BigInteger.class, pLogger); return pOperator.apply(left, right); } else { long left = coerceToPrimitiveNumber (pLeft, Long.class, pLogger). longValue (); long right = coerceToPrimitiveNumber (pRight, Long.class, pLogger). longValue (); return PrimitiveObjects.getLong (pOperator.apply (left, right)); } } //------------------------------------- /** * * Performs all of the necessary type conversions, then calls on the * appropriate operator. **/ public static Object applyRelationalOperator (Object pLeft, Object pRight, RelationalOperator pOperator, Logger pLogger) throws ELException { if (isBigDecimal(pLeft) || isBigDecimal(pRight)) { BigDecimal left = (BigDecimal) coerceToPrimitiveNumber(pLeft, BigDecimal.class, pLogger); BigDecimal right = (BigDecimal) coerceToPrimitiveNumber(pRight, BigDecimal.class, pLogger); return PrimitiveObjects.getBoolean(pOperator.apply(left, right)); } else if (isFloatingPointType (pLeft) || isFloatingPointType (pRight)) { double left = coerceToPrimitiveNumber (pLeft, Double.class, pLogger). doubleValue (); double right = coerceToPrimitiveNumber (pRight, Double.class, pLogger). doubleValue (); return PrimitiveObjects.getBoolean (pOperator.apply (left, right)); } else if (isBigInteger(pLeft) || isBigInteger(pRight)) { BigInteger left = (BigInteger) coerceToPrimitiveNumber(pLeft, BigInteger.class, pLogger); BigInteger right = (BigInteger) coerceToPrimitiveNumber(pRight, BigInteger.class, pLogger); return PrimitiveObjects.getBoolean(pOperator.apply(left, right)); } else if (isIntegerType (pLeft) || isIntegerType (pRight)) { long left = coerceToPrimitiveNumber (pLeft, Long.class, pLogger). longValue (); long right = coerceToPrimitiveNumber (pRight, Long.class, pLogger). longValue (); return PrimitiveObjects.getBoolean (pOperator.apply (left, right)); } else if (pLeft instanceof String || pRight instanceof String) { String left = coerceToString (pLeft, pLogger); String right = coerceToString (pRight, pLogger); return PrimitiveObjects.getBoolean (pOperator.apply (left, right)); } else if (pLeft instanceof Comparable) { try { int result = ((Comparable) pLeft).compareTo (pRight); return PrimitiveObjects.getBoolean (pOperator.apply (result, -result)); } catch (Exception exc) { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.COMPARABLE_ERROR, exc, pLeft.getClass ().getName (), (pRight == null) ? "null" : pRight.getClass ().getName (), pOperator.getOperatorSymbol ()); } return Boolean.FALSE; } } else if (pRight instanceof Comparable) { try { int result = ((Comparable) pRight).compareTo (pLeft); return PrimitiveObjects.getBoolean (pOperator.apply (-result, result)); } catch (Exception exc) { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.COMPARABLE_ERROR, exc, pRight.getClass ().getName (), (pLeft == null) ? "null" : pLeft.getClass ().getName (), pOperator.getOperatorSymbol ()); } return Boolean.FALSE; } } else { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.ARITH_OP_BAD_TYPE, pOperator.getOperatorSymbol (), pLeft.getClass ().getName (), pRight.getClass ().getName ()); } return Boolean.FALSE; } } //------------------------------------- /** * * Performs all of the necessary type conversions, then calls on the * appropriate operator. **/ public static Object applyEqualityOperator (Object pLeft, Object pRight, EqualityOperator pOperator, Logger pLogger) throws ELException { if (pLeft == pRight) { return PrimitiveObjects.getBoolean (pOperator.apply (true, pLogger)); } else if (pLeft == null || pRight == null) { return PrimitiveObjects.getBoolean (pOperator.apply (false, pLogger)); } else if (isBigDecimal(pLeft) || isBigDecimal(pRight)) { BigDecimal left = (BigDecimal) coerceToPrimitiveNumber(pLeft, BigDecimal.class, pLogger); BigDecimal right = (BigDecimal) coerceToPrimitiveNumber(pRight, BigDecimal.class, pLogger); return PrimitiveObjects.getBoolean(pOperator.apply(left.equals(right), pLogger)); } else if (isFloatingPointType (pLeft) || isFloatingPointType (pRight)) { double left = coerceToPrimitiveNumber (pLeft, Double.class, pLogger). doubleValue (); double right = coerceToPrimitiveNumber (pRight, Double.class, pLogger). doubleValue (); return PrimitiveObjects.getBoolean (pOperator.apply (left == right, pLogger)); } else if (isBigInteger(pLeft) || isBigInteger(pRight)) { BigInteger left = (BigInteger) coerceToPrimitiveNumber(pLeft, BigInteger.class, pLogger); BigInteger right = (BigInteger) coerceToPrimitiveNumber(pRight, BigInteger.class, pLogger); return PrimitiveObjects.getBoolean(pOperator.apply(left.equals(right), pLogger)); } else if (isIntegerType (pLeft) || isIntegerType (pRight)) { long left = coerceToPrimitiveNumber (pLeft, Long.class, pLogger). longValue (); long right = coerceToPrimitiveNumber (pRight, Long.class, pLogger). longValue (); return PrimitiveObjects.getBoolean (pOperator.apply (left == right, pLogger)); } else if (pLeft instanceof Boolean || pRight instanceof Boolean) { boolean left = coerceToBoolean (pLeft, pLogger).booleanValue (); boolean right = coerceToBoolean (pRight, pLogger).booleanValue (); return PrimitiveObjects.getBoolean (pOperator.apply (left == right, pLogger)); } else if (pLeft instanceof String || pRight instanceof String) { String left = coerceToString (pLeft, pLogger); String right = coerceToString (pRight, pLogger); return PrimitiveObjects.getBoolean (pOperator.apply (left.equals (right), pLogger)); } else { try { return PrimitiveObjects.getBoolean (pOperator.apply (pLeft.equals (pRight), pLogger)); } catch (Exception exc) { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.ERROR_IN_EQUALS, exc, pLeft.getClass ().getName (), pRight.getClass ().getName (), pOperator.getOperatorSymbol ()); } return Boolean.FALSE; } } } //------------------------------------- /** * * Returns true if the given Object is of a floating point type **/ public static boolean isFloatingPointType (Object pObject) { return pObject != null && isFloatingPointType (pObject.getClass ()); } //------------------------------------- /** * * Returns true if the given class is of a floating point type **/ public static boolean isFloatingPointType (Class pClass) { return pClass == Float.class || pClass == Float.TYPE || pClass == Double.class || pClass == Double.TYPE; } //------------------------------------- /** * * Returns true if the given string might contain a floating point * number - i.e., it contains ".", "e", or "E" **/ public static boolean isFloatingPointString (Object pObject) { if (pObject instanceof String) { String str = (String) pObject; int len = str.length (); for (int i = 0; i < len; i++) { char ch = str.charAt (i); if (ch == '.' || ch == 'e' || ch == 'E') { return true; } } return false; } else { return false; } } //------------------------------------- /** * * Returns true if the given Object is of an integer type **/ public static boolean isIntegerType (Object pObject) { return pObject != null && isIntegerType (pObject.getClass ()); } //------------------------------------- /** * * Returns true if the given class is of an integer type **/ public static boolean isIntegerType (Class pClass) { return pClass == Byte.class || pClass == Byte.TYPE || pClass == Short.class || pClass == Short.TYPE || pClass == Character.class || pClass == Character.TYPE || pClass == Integer.class || pClass == Integer.TYPE || pClass == Long.class || pClass == Long.TYPE; } //------------------------------------- /** * Returns true if the given object is BigInteger. * @param pObject - Object to evaluate * @return - true if the given object is BigInteger */ public static boolean isBigInteger(Object pObject) { return pObject != null && pObject instanceof BigInteger; } /** * Returns true if the given object is BigDecimal. * @param pObject - Object to evaluate * @return - true if the given object is BigDecimal */ public static boolean isBigDecimal(Object pObject) { return pObject != null && pObject instanceof BigDecimal; } } libcommons-el-java-1.0/src/java/org/apache/commons/el/ComplexValue.java0100644000175000017500000001173207642104426025413 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import java.util.List; import javax.servlet.jsp.el.ELException; import javax.servlet.jsp.el.VariableResolver; import javax.servlet.jsp.el.FunctionMapper; /** * *

Represents a dynamic value, which consists of a prefix and an * optional set of ValueSuffix elements. A prefix is something like * an identifier, and a suffix is something like a "property of" or * "indexed element of" operator. * * @author Nathan Abramson - Art Technology Group * @author Shawn Bayern * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class ComplexValue extends Expression { //------------------------------------- // Properties //------------------------------------- // property prefix Expression mPrefix; public Expression getPrefix () { return mPrefix; } public void setPrefix (Expression pPrefix) { mPrefix = pPrefix; } //------------------------------------- // property suffixes List mSuffixes; public List getSuffixes () { return mSuffixes; } public void setSuffixes (List pSuffixes) { mSuffixes = pSuffixes; } //------------------------------------- /** * * Constructor **/ public ComplexValue (Expression pPrefix, List pSuffixes) { mPrefix = pPrefix; mSuffixes = pSuffixes; } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the expression in the expression language syntax **/ public String getExpressionString () { StringBuffer buf = new StringBuffer (); buf.append (mPrefix.getExpressionString ()); for (int i = 0; mSuffixes != null && i < mSuffixes.size (); i++) { ValueSuffix suffix = (ValueSuffix) mSuffixes.get (i); buf.append (suffix.getExpressionString ()); } return buf.toString (); } //------------------------------------- /** * * Evaluates by evaluating the prefix, then applying the suffixes **/ public Object evaluate (VariableResolver pResolver, FunctionMapper functions, Logger pLogger) throws ELException { Object ret = mPrefix.evaluate (pResolver, functions, pLogger); // Apply the suffixes for (int i = 0; mSuffixes != null && i < mSuffixes.size (); i++) { ValueSuffix suffix = (ValueSuffix) mSuffixes.get (i); ret = suffix.evaluate (ret, pResolver, functions, pLogger); } return ret; } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/ConditionalExpression.java0100644000175000017500000001243407642104426027332 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import java.util.List; import java.util.Map; import javax.servlet.jsp.el.ELException; import javax.servlet.jsp.el.VariableResolver; import javax.servlet.jsp.el.FunctionMapper; /** * *

Represents a conditional expression. I've decided not to produce an * abstract base "TernaryOperatorExpression" class since (a) future ternary * operators are unlikely and (b) it's not clear that there would be a * meaningful way to abstract them. (For instance, would they all be right- * associative? Would they all have two fixed operator symbols?) * * @author Shawn Bayern **/ public class ConditionalExpression extends Expression { //------------------------------------- // Properties //------------------------------------- // property condition Expression mCondition; public Expression getCondition () { return mCondition; } public void setCondition (Expression pCondition) { mCondition = pCondition; } //------------------------------------- // property trueBranch Expression mTrueBranch; public Expression getTrueBranch () { return mTrueBranch; } public void setTrueBranch (Expression pTrueBranch) { mTrueBranch = pTrueBranch; } //------------------------------------- // property falseBranch Expression mFalseBranch; public Expression getFalseBranch () { return mFalseBranch; } public void setFalseBranch (Expression pFalseBranch) { mFalseBranch = pFalseBranch; } //------------------------------------- /** * * Constructor **/ public ConditionalExpression (Expression pCondition, Expression pTrueBranch, Expression pFalseBranch) { mCondition = pCondition; mTrueBranch = pTrueBranch; mFalseBranch = pFalseBranch; } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the expression in the expression language syntax **/ public String getExpressionString () { return "( " + mCondition.getExpressionString() + " ? " + mTrueBranch.getExpressionString() + " : " + mFalseBranch.getExpressionString() + " )"; } //------------------------------------- /** * * Evaluates the conditional expression and returns the literal result **/ public Object evaluate (VariableResolver vr, FunctionMapper f, Logger l) throws ELException { // first, evaluate the condition (and coerce the result to a boolean value) boolean condition = Coercions.coerceToBoolean( mCondition.evaluate(vr, f, l), l).booleanValue(); // then, use this boolean to branch appropriately if (condition) return mTrueBranch.evaluate(vr, f, l); else return mFalseBranch.evaluate(vr, f, l); } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/Constants.java0100644000175000017500000002000307617603700024753 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import java.util.ResourceBundle; import java.util.MissingResourceException; /** * *

This contains all of the non-public constants, including * messsage strings read from the resource file. * * @author Nathan Abramson - Art Technology Group * @author Shawn Bayern * * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class Constants { //------------------------------------- // Resources static ResourceBundle sResources = ResourceBundle.getBundle ("org.apache.commons.el.Resources"); //------------------------------------- // Messages from the resource bundle //------------------------------------- public static final String EXCEPTION_GETTING_BEANINFO = getStringResource ("EXCEPTION_GETTING_BEANINFO"); public static final String NULL_EXPRESSION_STRING = getStringResource ("NULL_EXPRESSION_STRING"); public static final String PARSE_EXCEPTION = getStringResource ("PARSE_EXCEPTION"); 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 CANT_GET_INDEXED_VALUE_OF_NULL = getStringResource ("CANT_GET_INDEXED_VALUE_OF_NULL"); public static final String CANT_GET_NULL_INDEX = getStringResource ("CANT_GET_NULL_INDEX"); public static final String NULL_INDEX = getStringResource ("NULL_INDEX"); public static final String BAD_INDEX_VALUE = getStringResource ("BAD_INDEX_VALUE"); public static final String EXCEPTION_ACCESSING_LIST = getStringResource ("EXCEPTION_ACCESSING_LIST"); public static final String EXCEPTION_ACCESSING_ARRAY = getStringResource ("EXCEPTION_ACCESSING_ARRAY"); public static final String CANT_FIND_INDEX = getStringResource ("CANT_FIND_INDEX"); public static final String TOSTRING_EXCEPTION = getStringResource ("TOSTRING_EXCEPTION"); public static final String BOOLEAN_TO_NUMBER = getStringResource ("BOOLEAN_TO_NUMBER"); public static final String STRING_TO_NUMBER_EXCEPTION = getStringResource ("STRING_TO_NUMBER_EXCEPTION"); public static final String COERCE_TO_NUMBER = getStringResource ("COERCE_TO_NUMBER"); public static final String BOOLEAN_TO_CHARACTER = getStringResource ("BOOLEAN_TO_CHARACTER"); public static final String EMPTY_STRING_TO_CHARACTER = getStringResource ("EMPTY_STRING_TO_CHARACTER"); public static final String COERCE_TO_CHARACTER = getStringResource ("COERCE_TO_CHARACTER"); public static final String NULL_TO_BOOLEAN = getStringResource ("NULL_TO_BOOLEAN"); public static final String STRING_TO_BOOLEAN = getStringResource ("STRING_TO_BOOLEAN"); public static final String COERCE_TO_BOOLEAN = getStringResource ("COERCE_TO_BOOLEAN"); public static final String COERCE_TO_OBJECT = getStringResource ("COERCE_TO_OBJECT"); public static final String NO_PROPERTY_EDITOR = getStringResource ("NO_PROPERTY_EDITOR"); public static final String PROPERTY_EDITOR_ERROR = getStringResource ("PROPERTY_EDITOR_ERROR"); public static final String ARITH_OP_NULL = getStringResource ("ARITH_OP_NULL"); public static final String ARITH_OP_BAD_TYPE = getStringResource ("ARITH_OP_BAD_TYPE"); public static final String ARITH_ERROR = getStringResource ("ARITH_ERROR"); public static final String ERROR_IN_EQUALS = getStringResource ("ERROR_IN_EQUALS"); public static final String UNARY_OP_BAD_TYPE = getStringResource ("UNARY_OP_BAD_TYPE"); public static final String NAMED_VALUE_NOT_FOUND = getStringResource ("NAMED_VALUE_NOT_FOUND"); public static final String CANT_GET_INDEXED_PROPERTY = getStringResource ("CANT_GET_INDEXED_PROPERTY"); public static final String COMPARABLE_ERROR = getStringResource ("COMPARABLE_ERROR"); public static final String BAD_IMPLICIT_OBJECT = getStringResource ("BAD_IMPLICIT_OBJECT"); public static final String ATTRIBUTE_EVALUATION_EXCEPTION = getStringResource ("ATTRIBUTE_EVALUATION_EXCEPTION"); public static final String ATTRIBUTE_PARSE_EXCEPTION = getStringResource ("ATTRIBUTE_PARSE_EXCEPTION"); public static final String UNKNOWN_FUNCTION = getStringResource ("UNKNOWN_FUNCTION"); public static final String INAPPROPRIATE_FUNCTION_ARG_COUNT = getStringResource ("INAPPROPRIATE_FUNCTION_ARG_COUNT"); public static final String FUNCTION_INVOCATION_ERROR = getStringResource ("FUNCTION_INVOCATION_ERROR"); //------------------------------------- // 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.commons.el.Constants", pResourceName); } else { return ret; } } catch (MissingResourceException exc) { System.err.println ("ERROR: Unable to load resource " + pResourceName + ": " + exc); throw exc; } } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/DivideOperator.java0100644000175000017500000001255507673673602025746 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import javax.servlet.jsp.el.ELException; import java.math.BigDecimal; /** * *

The implementation of the divide operator * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class DivideOperator extends BinaryOperator { //------------------------------------- // Singleton //------------------------------------- public static final DivideOperator SINGLETON = new DivideOperator (); //------------------------------------- /** * * Constructor **/ public DivideOperator () { } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the symbol representing the operator **/ public String getOperatorSymbol () { return "/"; } //------------------------------------- /** * * Applies the operator to the given value **/ public Object apply (Object pLeft, Object pRight, Logger pLogger) throws ELException { if (pLeft == null && pRight == null) { if (pLogger.isLoggingWarning ()) { pLogger.logWarning (Constants.ARITH_OP_NULL, getOperatorSymbol ()); } return PrimitiveObjects.getInteger (0); } if (Coercions.isBigDecimal(pLeft) || Coercions.isBigInteger(pLeft) || Coercions.isBigDecimal(pRight) || Coercions.isBigInteger(pRight)) { BigDecimal left = (BigDecimal) Coercions.coerceToPrimitiveNumber(pLeft, BigDecimal.class, pLogger); BigDecimal right = (BigDecimal) Coercions.coerceToPrimitiveNumber(pRight, BigDecimal.class, pLogger); try { return left.divide(right, BigDecimal.ROUND_HALF_UP); } catch (Exception exc) { if (pLogger.isLoggingError()) { pLogger.logError (Constants.ARITH_ERROR, getOperatorSymbol(), "" + left, "" + right); } return PrimitiveObjects.getInteger(0); } } else { double left = Coercions.coerceToPrimitiveNumber(pLeft, Double.class, pLogger). doubleValue(); double right = Coercions.coerceToPrimitiveNumber(pRight, Double.class, pLogger). doubleValue(); try { return PrimitiveObjects.getDouble(left / right); } catch (Exception exc) { if (pLogger.isLoggingError()) { pLogger.logError (Constants.ARITH_ERROR, getOperatorSymbol(), "" + left, "" + right); } return PrimitiveObjects.getInteger(0); } } } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/ELParser.jj0100644000175000017500000003314107641713423024146 0ustar arnaudarnaud/***************************************** * OPTIONS * *****************************************/ options { JAVA_UNICODE_ESCAPE = false; UNICODE_INPUT = true; STATIC = false; } /***************************************** * PARSER JAVA CODE * *****************************************/ PARSER_BEGIN(ELParser) package org.apache.commons.el.parser; import org.apache.commons.el.*; import java.util.ArrayList; import java.util.List; /** * Generated EL parser. * * @author Nathan Abramson * @author Shawn Bayern */ public class ELParser { public static void main(String args[]) throws ParseException { ELParser parser = new ELParser (System.in); parser.ExpressionString (); } } PARSER_END(ELParser) /***************************************** * TOKENS * *****************************************/ /***************************************** /** Tokens appearing outside of an ${...} construct **/ TOKEN: { < NON_EXPRESSION_TEXT: (~["$"])+ | ("$" (~["{", "$"])+) | "$" > | < START_EXPRESSION: "${" > : IN_EXPRESSION } /***************************************** /** Tokens appearing inside of an ${...} construct **/ /* WHITE SPACE */ SKIP : { " " | "\t" | "\n" | "\r" } TOKEN : { /* Literals */ < INTEGER_LITERAL: ["0"-"9"] (["0"-"9"])* > | < FLOATING_POINT_LITERAL: (["0"-"9"])+ "." (["0"-"9"])* ()? | "." (["0"-"9"])+ ()? | (["0"-"9"])+ > | < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ > | < STRING_LITERAL: ("\"" ((~["\"","\\"]) | ("\\" ( ["\\","\""] )))* "\"") | ("\'" ((~["\'","\\"]) | ("\\" ( ["\\","\'"] )))* "\'") > | < BADLY_ESCAPED_STRING_LITERAL: ("\"" (~["\"","\\"])* ("\\" ( ~["\\","\""] ))) | ("\'" (~["\'","\\"])* ("\\" ( ~["\\","\'"] ))) > /* Reserved Words and Symbols */ | < TRUE: "true" > | < FALSE: "false" > | < NULL: "null" > | < END_EXPRESSION: "}" > : DEFAULT | < DOT: "." > | < GT1: ">" > | < GT2: "gt" > | < LT1: "<" > | < LT2: "lt" > | < EQ1: "==" > | < EQ2: "eq" > | < LE1: "<=" > | < LE2: "le" > | < GE1: ">=" > | < GE2: "ge" > | < NE1: "!=" > | < NE2: "ne" > | < LPAREN: "(" > | < RPAREN: ")" > | < COMMA: "," > | < COLON: ":" > | < LBRACKET: "[" > | < RBRACKET: "]" > | < PLUS: "+" > | < MINUS: "-" > | < MULTIPLY: "*" > | < DIVIDE1: "/" > | < DIVIDE2: "div" > | < MODULUS1: "%" > | < MODULUS2: "mod" > | < NOT1: "not" > | < NOT2: "!" > | < AND1: "and" > | < AND2: "&&" > | < OR1: "or" > | < OR2: "||" > | < EMPTY: "empty" > | < COND: "?" > /* Identifiers */ | < IDENTIFIER: (|) (|)* > | < #IMPL_OBJ_START: "#" > | < #LETTER: [ "\u0024", "\u0041"-"\u005a", "\u005f", "\u0061"-"\u007a", "\u00c0"-"\u00d6", "\u00d8"-"\u00f6", "\u00f8"-"\u00ff", "\u0100"-"\u1fff", "\u3040"-"\u318f", "\u3300"-"\u337f", "\u3400"-"\u3d2d", "\u4e00"-"\u9fff", "\uf900"-"\ufaff" ] > | < #DIGIT: [ "\u0030"-"\u0039", "\u0660"-"\u0669", "\u06f0"-"\u06f9", "\u0966"-"\u096f", "\u09e6"-"\u09ef", "\u0a66"-"\u0a6f", "\u0ae6"-"\u0aef", "\u0b66"-"\u0b6f", "\u0be7"-"\u0bef", "\u0c66"-"\u0c6f", "\u0ce6"-"\u0cef", "\u0d66"-"\u0d6f", "\u0e50"-"\u0e59", "\u0ed0"-"\u0ed9", "\u1040"-"\u1049" ] > /* This is used to catch any non-matching tokens, so as to avoid any TokenMgrErrors */ | < ILLEGAL_CHARACTER: (~[]) > } /***************************************** * GRAMMAR PRODUCTIONS * *****************************************/ /** * * Returns a String if the expression string is a single String, an * Expression if the expression string is a single Expression, an * ExpressionString if it's a mixture of both. **/ Object ExpressionString () : { Object ret = ""; List elems = null; Object elem; } { /** Try to optimize for the case of a single expression or String **/ (ret = AttrValueString () | ret = AttrValueExpression ()) /** If there's more than one, then switch to using a List **/ ( (elem = AttrValueString () | elem = AttrValueExpression ()) { if (elems == null) { elems = new ArrayList (); elems.add (ret); } elems.add (elem); } )* { if (elems != null) { ret = new ExpressionString (elems.toArray ()); } return ret; } } String AttrValueString () : { Token t; } { t = { return t.image; } } Expression AttrValueExpression () : { Expression exp; } { exp = Expression () { return exp; } } Expression Expression () : { Expression ret; } { ( LOOKAHEAD(ConditionalExpression()) ret = ConditionalExpression() | ret = OrExpression () ) { return ret; } } Expression OrExpression () : { Expression startExpression; BinaryOperator operator; Expression expression; List operators = null; List expressions = null; } { startExpression = AndExpression () ( ( ( | ) { operator = OrOperator.SINGLETON; } ) expression = AndExpression () { if (operators == null) { operators = new ArrayList (); expressions = new ArrayList (); } operators.add (operator); expressions.add (expression); } )* { if (operators != null) { return new BinaryOperatorExpression (startExpression, operators, expressions); } else { return startExpression; } } } Expression AndExpression () : { Expression startExpression; BinaryOperator operator; Expression expression; List operators = null; List expressions = null; } { startExpression = EqualityExpression () ( ( ( | ) { operator = AndOperator.SINGLETON; } ) expression = EqualityExpression () { if (operators == null) { operators = new ArrayList (); expressions = new ArrayList (); } operators.add (operator); expressions.add (expression); } )* { if (operators != null) { return new BinaryOperatorExpression (startExpression, operators, expressions); } else { return startExpression; } } } Expression EqualityExpression () : { Expression startExpression; BinaryOperator operator; Expression expression; List operators = null; List expressions = null; } { startExpression = RelationalExpression () ( ( ( | ) { operator = EqualsOperator.SINGLETON; } | ( | ) { operator = NotEqualsOperator.SINGLETON; } ) expression = RelationalExpression () { if (operators == null) { operators = new ArrayList (); expressions = new ArrayList (); } operators.add (operator); expressions.add (expression); } )* { if (operators != null) { return new BinaryOperatorExpression (startExpression, operators, expressions); } else { return startExpression; } } } Expression RelationalExpression () : { Expression startExpression; BinaryOperator operator; Expression expression; List operators = null; List expressions = null; } { startExpression = AddExpression () ( ( ( | ) { operator = LessThanOperator.SINGLETON; } | ( | ) { operator = GreaterThanOperator.SINGLETON; } | ( | ) { operator = GreaterThanOrEqualsOperator.SINGLETON; } | ( | ) { operator = LessThanOrEqualsOperator.SINGLETON; } ) expression = AddExpression () { if (operators == null) { operators = new ArrayList (); expressions = new ArrayList (); } operators.add (operator); expressions.add (expression); } )* { if (operators != null) { return new BinaryOperatorExpression (startExpression, operators, expressions); } else { return startExpression; } } } Expression AddExpression () : { Expression startExpression; BinaryOperator operator; Expression expression; List operators = null; List expressions = null; } { startExpression = MultiplyExpression () ( ( { operator = PlusOperator.SINGLETON; } | { operator = MinusOperator.SINGLETON; } ) expression = MultiplyExpression () { if (operators == null) { operators = new ArrayList (); expressions = new ArrayList (); } operators.add (operator); expressions.add (expression); } )* { if (operators != null) { return new BinaryOperatorExpression (startExpression, operators, expressions); } else { return startExpression; } } } Expression MultiplyExpression () : { Expression startExpression; BinaryOperator operator; Expression expression; List operators = null; List expressions = null; } { startExpression = UnaryExpression () ( ( { operator = MultiplyOperator.SINGLETON; } | ( | ) { operator = DivideOperator.SINGLETON; } | ( | ) { operator = ModulusOperator.SINGLETON; } ) expression = UnaryExpression () { if (operators == null) { operators = new ArrayList (); expressions = new ArrayList (); } operators.add (operator); expressions.add (expression); } )* { if (operators != null) { return new BinaryOperatorExpression (startExpression, operators, expressions); } else { return startExpression; } } } Expression ConditionalExpression () : { Expression condition, trueBranch, falseBranch; } { ( condition = OrExpression () trueBranch = Expression () falseBranch = Expression () ) { return new ConditionalExpression(condition, trueBranch, falseBranch); } } Expression UnaryExpression () : { Expression expression; UnaryOperator singleOperator = null; UnaryOperator operator; List operators = null; } { ( ( ( | ) { operator = NotOperator.SINGLETON; } | { operator = UnaryMinusOperator.SINGLETON; } | { operator = EmptyOperator.SINGLETON; } ) { if (singleOperator == null) { singleOperator = operator; } else if (operators == null) { operators = new ArrayList (); operators.add (singleOperator); operators.add (operator); } else { operators.add (operator); } } )* expression = Value () { if (operators != null) { return new UnaryOperatorExpression (null, operators, expression); } else if (singleOperator != null) { return new UnaryOperatorExpression (singleOperator, null, expression); } else { return expression; } } } Expression Value () : { Expression prefix; ValueSuffix suffix; List suffixes = null; } { prefix = ValuePrefix () (suffix = ValueSuffix () { if (suffixes == null) { suffixes = new ArrayList (); } suffixes.add (suffix); } )* { if (suffixes == null) { return prefix; } else { return new ComplexValue (prefix, suffixes); } } } /** * This is an element that can start a value **/ Expression ValuePrefix () : { Expression ret; } { ( ret = Literal () | ret = Expression () | LOOKAHEAD(QualifiedName() ) ret = FunctionInvocation () | ret = NamedValue () ) { return ret; } } NamedValue NamedValue () : { Token t; } { t = { return new NamedValue (t.image); } } FunctionInvocation FunctionInvocation () : { String qualifiedName; List argumentList = new ArrayList(); Expression exp; } { ( qualifiedName = QualifiedName() ( ( exp = Expression () { argumentList.add(exp); } ) ( exp = Expression () { argumentList.add(exp); } )* )? ) { return new FunctionInvocation(qualifiedName, argumentList); } } ValueSuffix ValueSuffix () : { ValueSuffix suffix; } { ( suffix = PropertySuffix () | suffix = ArraySuffix () ) { return suffix; } } PropertySuffix PropertySuffix () : { Token t; String property; } { (property = Identifier ()) { return new PropertySuffix (property); } } ArraySuffix ArraySuffix () : { Expression index; } { index = Expression () { return new ArraySuffix (index); } } Literal Literal () : { Literal ret; } { ( ret = BooleanLiteral () | ret = IntegerLiteral () | ret = FloatingPointLiteral () | ret = StringLiteral () | ret = NullLiteral () ) { return ret; } } BooleanLiteral BooleanLiteral () : { } { { return BooleanLiteral.TRUE; } | { return BooleanLiteral.FALSE; } } StringLiteral StringLiteral () : { Token t; } { t = { return StringLiteral.fromToken (t.image); } } IntegerLiteral IntegerLiteral () : { Token t; } { t = { return new IntegerLiteral (t.image); } } FloatingPointLiteral FloatingPointLiteral () : { Token t; } { t = { return new FloatingPointLiteral (t.image); } } NullLiteral NullLiteral () : { } { { return NullLiteral.SINGLETON; } } String Identifier () : { Token t; } { ( t = ) { return t.image; } } String QualifiedName () : { String prefix = null, localPart = null; } { ( ( LOOKAHEAD(Identifier() ) prefix = Identifier () )? localPart = Identifier () ) { if (prefix == null) return localPart; else return prefix + ":" + localPart; } } libcommons-el-java-1.0/src/java/org/apache/commons/el/ExpressionEvaluatorImpl.java0100644000175000017500000004324607642104426027660 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import java.io.Reader; import java.io.StringReader; import java.text.MessageFormat; import java.util.Collections; import java.util.HashMap; import java.util.Map; import javax.servlet.jsp.el.ExpressionEvaluator; import javax.servlet.jsp.el.ELException; import javax.servlet.jsp.el.VariableResolver; import javax.servlet.jsp.el.FunctionMapper; import org.apache.commons.el.parser.ELParser; import org.apache.commons.el.parser.ParseException; import org.apache.commons.el.parser.Token; import org.apache.commons.el.parser.TokenMgrError; /** * *

This is the main class for evaluating expression Strings. An * expression String is a String that may contain expressions of the * form ${...}. Multiple expressions may appear in the same * expression String. In such a case, the expression String's value * is computed by concatenating the String values of those evaluated * expressions and any intervening non-expression text, then * converting the resulting String to the expected type using the * PropertyEditor mechanism. * *

In the special case where the expression String is a single * expression, the value of the expression String is determined by * evaluating the expression, without any intervening conversion to a * String. * *

The evaluator maintains a cache mapping expression Strings to * their parsed results. For expression Strings containing no * expression elements, it maintains a cache mapping * ExpectedType/ExpressionString to parsed value, so that static * expression Strings won't have to go through a conversion step every * time they are used. All instances of the evaluator share the same * cache. The cache may be bypassed by setting a flag on the * evaluator's constructor. * *

The evaluator must be passed a VariableResolver in its * constructor. The VariableResolver is used to resolve variable * names encountered in expressions, and can also be used to implement * "implicit objects" that are always present in the namespace. * Different applications will have different policies for variable * lookups and implicit objects - these differences can be * encapsulated in the VariableResolver passed to the evaluator's * constructor. * *

Most VariableResolvers will need to perform their resolution * against some context. For example, a JSP environment needs a * PageContext to resolve variables. The evaluate() method takes a * generic Object context which is eventually passed to the * VariableResolver - the VariableResolver is responsible for casting * the context to the proper type. * *

Once an evaluator instance has been constructed, it may be used * multiple times, and may be used by multiple simultaneous Threads. * In other words, an evaluator instance is well-suited for use as a * singleton. * * @author Nathan Abramson - Art Technology Group * @author Shawn Bayern * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class ExpressionEvaluatorImpl extends ExpressionEvaluator { //------------------------------------- // Properties //------------------------------------- //------------------------------------- // Member variables //------------------------------------- /** The mapping from expression String to its parsed form (String, Expression, or ExpressionString) **/ static Map sCachedExpressionStrings = Collections.synchronizedMap (new HashMap ()); /** The mapping from ExpectedType to Maps mapping literal String to parsed value **/ static Map sCachedExpectedTypes = new HashMap (); /** The static Logger **/ static Logger sLogger = new Logger (System.out); /** Flag if the cache should be bypassed **/ boolean mBypassCache; //------------------------------------- /** * * Constructor **/ public ExpressionEvaluatorImpl () { } /** * * Constructor * * @param pBypassCache flag indicating if the cache should be * bypassed **/ public ExpressionEvaluatorImpl (boolean pBypassCache) { mBypassCache = pBypassCache; } //------------------------------------- /** * * Evaluates the given expression String * * @param pExpressionString The expression to be evaluated. * @param pExpectedType The expected type of the result of the evaluation * @param pResolver A VariableResolver instance that can be used at * runtime to resolve the name of implicit objects into Objects. * @param functions A FunctionMapper to resolve functions found in * the expression. It can be null, in which case no functions * are supported for this invocation. * @return the expression String evaluated to the given expected * type **/ public Object evaluate (String pExpressionString, Class pExpectedType, VariableResolver pResolver, FunctionMapper functions) throws ELException { return evaluate (pExpressionString, pExpectedType, pResolver, functions, sLogger); } /** * * Prepare an expression for later evaluation. This method should perform * syntactic validation of the expression; if in doing so it detects * errors, it should raise an ELParseException. * * @param expression The expression to be evaluated. * @param expectedType The expected type of the result of the evaluation * @param fMapper A FunctionMapper to resolve functions found in * the expression. It can be null, in which case no functions * are supported for this invocation. The ExpressionEvaluator * must not hold on to the FunctionMapper reference after * returning from parseExpression(). The * Expression object returned must invoke the same * functions regardless of whether the mappings in the * provided FunctionMapper instance change between * calling ExpressionEvaluator.parseExpression() * and Expression.evaluate(). * @return The Expression object encapsulating the arguments. * * @exception ELException Thrown if parsing errors were found. **/ public javax.servlet.jsp.el.Expression parseExpression(String expression, Class expectedType, FunctionMapper fMapper) throws ELException { // Validate and then create an Expression object. parseExpressionString(expression); // Create an Expression object that knows how to evaluate this. return new JSTLExpression(this, expression, expectedType, fMapper); } //------------------------------------- /** * * Evaluates the given expression string **/ Object evaluate (String pExpressionString, Class pExpectedType, VariableResolver pResolver, FunctionMapper functions, Logger pLogger) throws ELException { // Check for null expression strings if (pExpressionString == null) { throw new ELException (Constants.NULL_EXPRESSION_STRING); } // Get the parsed version of the expression string Object parsedValue = parseExpressionString (pExpressionString); // Evaluate differently based on the parsed type if (parsedValue instanceof String) { // Convert the String, and cache the conversion String strValue = (String) parsedValue; return convertStaticValueToExpectedType (strValue, pExpectedType, pLogger); } else if (parsedValue instanceof Expression) { // Evaluate the expression and convert Object value = ((Expression) parsedValue).evaluate (pResolver, functions, pLogger); return convertToExpectedType (value, pExpectedType, pLogger); } else if (parsedValue instanceof ExpressionString) { // Evaluate the expression/string list and convert String strValue = ((ExpressionString) parsedValue).evaluate (pResolver, functions, pLogger); return convertToExpectedType (strValue, pExpectedType, pLogger); } else { // This should never be reached return null; } } //------------------------------------- /** * * Gets the parsed form of the given expression string. If the * parsed form is cached (and caching is not bypassed), return the * cached form, otherwise parse and cache the value. Returns either * a String, Expression, or ExpressionString. **/ public Object parseExpressionString (String pExpressionString) throws ELException { // See if it's an empty String if (pExpressionString.length () == 0) { return ""; } // See if it's in the cache Object ret = mBypassCache ? null : sCachedExpressionStrings.get (pExpressionString); if (ret == null) { // Parse the expression Reader r = new StringReader (pExpressionString); ELParser parser = new ELParser (r); try { ret = parser.ExpressionString (); sCachedExpressionStrings.put (pExpressionString, ret); } catch (ParseException exc) { throw new ELException (formatParseException (pExpressionString, exc)); } catch (TokenMgrError exc) { // Note - this should never be reached, since the parser is // constructed to tokenize any input (illegal inputs get // parsed to or // throw new ELException (exc.getMessage ()); } } return ret; } //------------------------------------- /** * * Converts the given value to the specified expected type. **/ Object convertToExpectedType (Object pValue, Class pExpectedType, Logger pLogger) throws ELException { return Coercions.coerce (pValue, pExpectedType, pLogger); } //------------------------------------- /** * * Converts the given String, specified as a static expression * string, to the given expected type. The conversion is cached. **/ Object convertStaticValueToExpectedType (String pValue, Class pExpectedType, Logger pLogger) throws ELException { // See if the value is already of the expected type if (pExpectedType == String.class || pExpectedType == Object.class) { return pValue; } // Find the cached value Map valueByString = getOrCreateExpectedTypeMap (pExpectedType); if (!mBypassCache && valueByString.containsKey (pValue)) { return valueByString.get (pValue); } else { // Convert from a String Object ret = Coercions.coerce (pValue, pExpectedType, pLogger); valueByString.put (pValue, ret); return ret; } } //------------------------------------- /** * * Creates or returns the Map that maps string literals to parsed * values for the specified expected type. **/ static Map getOrCreateExpectedTypeMap (Class pExpectedType) { synchronized (sCachedExpectedTypes) { Map ret = (Map) sCachedExpectedTypes.get (pExpectedType); if (ret == null) { ret = Collections.synchronizedMap (new HashMap ()); sCachedExpectedTypes.put (pExpectedType, ret); } return ret; } } //------------------------------------- // Formatting ParseException //------------------------------------- /** * * Formats a ParseException into an error message suitable for * displaying on a web page **/ static String formatParseException (String pExpressionString, ParseException pExc) { // Generate the String of expected tokens StringBuffer expectedBuf = new StringBuffer (); int maxSize = 0; boolean printedOne = false; if (pExc.expectedTokenSequences == null) return pExc.toString(); for (int i = 0; i < pExc.expectedTokenSequences.length; i++) { if (maxSize < pExc.expectedTokenSequences [i].length) { maxSize = pExc.expectedTokenSequences [i].length; } for (int j = 0; j < pExc.expectedTokenSequences [i].length; j++) { if (printedOne) { expectedBuf.append (", "); } expectedBuf.append (pExc.tokenImage [pExc.expectedTokenSequences [i] [j]]); printedOne = true; } } String expected = expectedBuf.toString (); // Generate the String of encountered tokens StringBuffer encounteredBuf = new StringBuffer (); Token tok = pExc.currentToken.next; for (int i = 0; i < maxSize; i++) { if (i != 0) encounteredBuf.append (" "); if (tok.kind == 0) { encounteredBuf.append (pExc.tokenImage [0]); break; } encounteredBuf.append (addEscapes (tok.image)); tok = tok.next; } String encountered = encounteredBuf.toString (); // Format the error message return MessageFormat.format (Constants.PARSE_EXCEPTION, new Object [] { expected, encountered, }); } //------------------------------------- /** * * Used to convert raw characters to their escaped version when * these raw version cannot be used as part of an ASCII string * literal. **/ static String addEscapes (String str) { StringBuffer retval = new StringBuffer (); char ch; for (int i = 0; i < str.length (); i++) { switch (str.charAt (i)) { case 0 : continue; case '\b': retval.append ("\\b"); continue; case '\t': retval.append ("\\t"); continue; case '\n': retval.append ("\\n"); continue; case '\f': retval.append ("\\f"); continue; case '\r': retval.append ("\\r"); continue; default: if ((ch = str.charAt (i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString (ch, 16); retval.append ("\\u" + s.substring (s.length () - 4, s.length ())); } else { retval.append (ch); } continue; } } return retval.toString (); } //------------------------------------- // Testing methods //------------------------------------- /** * * Parses the given expression string, then converts it back to a * String in its canonical form. This is used to test parsing. **/ public String parseAndRender (String pExpressionString) throws ELException { Object val = parseExpressionString (pExpressionString); if (val instanceof String) { return (String) val; } else if (val instanceof Expression) { return "${" + ((Expression) val).getExpressionString () + "}"; } else if (val instanceof ExpressionString) { return ((ExpressionString) val).getExpressionString (); } else { return ""; } } /** * An object that encapsulates an expression to be evaluated by * the JSTL evaluator. */ private class JSTLExpression extends javax.servlet.jsp.el.Expression { private ExpressionEvaluatorImpl evaluator; private String expression; private Class expectedType; private FunctionMapper fMapper; public JSTLExpression(ExpressionEvaluatorImpl evaluator, String expression, Class expectedType, FunctionMapper fMapper) { this.evaluator = evaluator; this.expression = expression; this.expectedType = expectedType; this.fMapper = fMapper; } public Object evaluate( VariableResolver vResolver ) throws ELException { return evaluator.evaluate(this.expression, this.expectedType, vResolver, this.fMapper); } } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/EmptyOperator.java0100644000175000017500000001105607631526752025630 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import java.lang.reflect.Array; import java.util.Collection; import java.util.Map; import javax.servlet.jsp.el.ELException; /** * *

The implementation of the empty operator * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class EmptyOperator extends UnaryOperator { //------------------------------------- // Singleton //------------------------------------- public static final EmptyOperator SINGLETON = new EmptyOperator (); //------------------------------------- /** * * Constructor **/ public EmptyOperator () { } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the symbol representing the operator **/ public String getOperatorSymbol () { return "empty"; } //------------------------------------- /** * * Applies the operator to the given value **/ public Object apply (Object pValue, Logger pLogger) throws ELException { // See if the value is null if (pValue == null) { return PrimitiveObjects.getBoolean (true); } // See if the value is a zero-length String else if ("".equals (pValue)) { return PrimitiveObjects.getBoolean (true); } // See if the value is a zero-length array else if (pValue.getClass ().isArray () && Array.getLength (pValue) == 0) { return PrimitiveObjects.getBoolean (true); } // See if the value is an empty Map else if (pValue instanceof Map && ((Map) pValue).isEmpty ()) { return PrimitiveObjects.getBoolean (true); } // See if the value is an empty Collection else if (pValue instanceof Collection && ((Collection) pValue).isEmpty ()) { return PrimitiveObjects.getBoolean (true); } // Otherwise, not empty else { return PrimitiveObjects.getBoolean (false); } } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/EnumeratedMap.java0100644000175000017500000001422407617603700025536 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import java.util.Collection; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; import java.util.Set; /** * *

This is a Map implementation driven by a data source that only * provides an enumeration of keys and a getValue(key) method. This * class must be subclassed to implement those methods. * *

Some of the methods may incur a performance penalty that * involves enumerating the entire data source. In these cases, the * Map will try to save the results of that enumeration, but only if * the underlying data source is immutable. * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public abstract class EnumeratedMap implements Map { //------------------------------------- // Member variables //------------------------------------- Map mMap; //------------------------------------- public void clear () { throw new UnsupportedOperationException (); } //------------------------------------- public boolean containsKey (Object pKey) { return getValue (pKey) != null; } //------------------------------------- public boolean containsValue (Object pValue) { return getAsMap ().containsValue (pValue); } //------------------------------------- public Set entrySet () { return getAsMap ().entrySet (); } //------------------------------------- public Object get (Object pKey) { return getValue (pKey); } //------------------------------------- public boolean isEmpty () { return !enumerateKeys ().hasMoreElements (); } //------------------------------------- public Set keySet () { return getAsMap ().keySet (); } //------------------------------------- public Object put (Object pKey, Object pValue) { throw new UnsupportedOperationException (); } //------------------------------------- public void putAll (Map pMap) { throw new UnsupportedOperationException (); } //------------------------------------- public Object remove (Object pKey) { throw new UnsupportedOperationException (); } //------------------------------------- public int size () { return getAsMap ().size (); } //------------------------------------- public Collection values () { return getAsMap ().values (); } //------------------------------------- // Abstract methods //------------------------------------- /** * * Returns an enumeration of the keys **/ public abstract Enumeration enumerateKeys (); //------------------------------------- /** * * Returns true if it is possible for this data source to change **/ public abstract boolean isMutable (); //------------------------------------- /** * * Returns the value associated with the given key, or null if not * found. **/ public abstract Object getValue (Object pKey); //------------------------------------- /** * * Converts the MapSource to a Map. If the map is not mutable, this * is cached **/ public Map getAsMap () { if (mMap != null) { return mMap; } else { Map m = convertToMap (); if (!isMutable ()) { mMap = m; } return m; } } //------------------------------------- /** * * Converts to a Map **/ Map convertToMap () { Map ret = new HashMap (); for (Enumeration e = enumerateKeys (); e.hasMoreElements (); ) { Object key = e.nextElement (); Object value = getValue (key); ret.put (key, value); } return ret; } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/EqualityOperator.java0100644000175000017500000000664407617603700026327 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import javax.servlet.jsp.el.ELException; /** * *

This is the superclass for all equality operators (==, !=) * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public abstract class EqualityOperator extends BinaryOperator { //------------------------------------- /** * * Applies the operator to the given value **/ public Object apply (Object pLeft, Object pRight, Logger pLogger) throws ELException { return Coercions.applyEqualityOperator (pLeft, pRight, this, pLogger); } //------------------------------------- /** * * Applies the operator given the fact that the two elements are * equal. **/ public abstract boolean apply (boolean pAreEqual, Logger pLogger); //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/EqualsOperator.java0100644000175000017500000000713107617603700025754 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; /** * *

The implementation of the equals operator * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class EqualsOperator extends EqualityOperator { //------------------------------------- // Singleton //------------------------------------- public static final EqualsOperator SINGLETON = new EqualsOperator (); //------------------------------------- /** * * Constructor **/ public EqualsOperator () { } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the symbol representing the operator **/ public String getOperatorSymbol () { return "=="; } //------------------------------------- /** * * Applies the operator given the fact that the two elements are * equal. **/ public boolean apply (boolean pAreEqual, Logger pLogger) { return pAreEqual; } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/Expression.java0100644000175000017500000000704507642104426025150 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import java.util.Map; import javax.servlet.jsp.el.ELException; import javax.servlet.jsp.el.VariableResolver; import javax.servlet.jsp.el.FunctionMapper; /** * *

The abstract class from which all expression types * derive. * * @author Nathan Abramson - Art Technology Group * @author Shawn Bayern * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public abstract class Expression { //------------------------------------- // Member variables //------------------------------------- //------------------------------------- /** * * Returns the expression in the expression language syntax **/ public abstract String getExpressionString (); //------------------------------------- /** * * Evaluates the expression in the given context **/ public abstract Object evaluate (VariableResolver pResolver, FunctionMapper functions, Logger pLogger) throws ELException; //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/FloatingPointLiteral.java0100644000175000017500000000704207617603700027101 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; /** * *

An expression representing a floating point literal value. The * value is stored internally as a double. * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class FloatingPointLiteral extends Literal { //------------------------------------- /** * * Constructor **/ public FloatingPointLiteral (String pToken) { super (getValueFromToken (pToken)); } //------------------------------------- /** * * Parses the given token into the literal value **/ static Object getValueFromToken (String pToken) { return new Double (pToken); } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the expression in the expression language syntax **/ public String getExpressionString () { return getValue ().toString (); } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/ExpressionString.java0100644000175000017500000001145607642104426026340 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import javax.servlet.jsp.el.ELException; import javax.servlet.jsp.el.VariableResolver; import javax.servlet.jsp.el.FunctionMapper; /** * *

Represents an expression String consisting of a mixture of * Strings and Expressions. * * @author Nathan Abramson - Art Technology Group * @author Shawn Bayern * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class ExpressionString { //------------------------------------- // Properties //------------------------------------- // property elements Object [] mElements; public Object [] getElements () { return mElements; } public void setElements (Object [] pElements) { mElements = pElements; } //------------------------------------- /** * * Constructor **/ public ExpressionString (Object [] pElements) { mElements = pElements; } //------------------------------------- /** * * Evaluates the expression string by evaluating each element, * converting it to a String (using toString, or "" for null values) * and concatenating the results into a single String. **/ public String evaluate (VariableResolver pResolver, FunctionMapper functions, Logger pLogger) throws ELException { StringBuffer buf = new StringBuffer (); for (int i = 0; i < mElements.length; i++) { Object elem = mElements [i]; if (elem instanceof String) { buf.append ((String) elem); } else if (elem instanceof Expression) { Object val = ((Expression) elem).evaluate (pResolver, functions, pLogger); if (val != null) { buf.append (val.toString ()); } } } return buf.toString (); } //------------------------------------- /** * * Returns the expression in the expression language syntax **/ public String getExpressionString () { StringBuffer buf = new StringBuffer (); for (int i = 0; i < mElements.length; i++) { Object elem = mElements [i]; if (elem instanceof String) { buf.append ((String) elem); } else if (elem instanceof Expression) { buf.append ("${"); buf.append (((Expression) elem).getExpressionString ()); buf.append ("}"); } } return buf.toString (); } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/FunctionInvocation.java0100644000175000017500000001441407642104426026626 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import java.util.List; import java.util.Map; import java.util.Iterator; import java.lang.reflect.*; import javax.servlet.jsp.el.ELException; import javax.servlet.jsp.el.VariableResolver; import javax.servlet.jsp.el.FunctionMapper; /** * *

Represents a function call.

* * @author Shawn Bayern (in the style of Nathan's other classes) **/ public class FunctionInvocation extends Expression { //------------------------------------- // Properties //------------------------------------- // property index private String functionName; private List argumentList; public String getFunctionName() { return functionName; } public void setFunctionName(String f) { functionName = f; } public List getArgumentList() { return argumentList; } public void setArgumentList(List l) { argumentList = l; } //------------------------------------- /** * Constructor **/ public FunctionInvocation (String functionName, List argumentList) { this.functionName = functionName; this.argumentList = argumentList; } //------------------------------------- // Expression methods //------------------------------------- /** * Returns the expression in the expression language syntax **/ public String getExpressionString () { StringBuffer b = new StringBuffer(); b.append(functionName); b.append("("); Iterator i = argumentList.iterator(); while (i.hasNext()) { b.append(((Expression) i.next()).getExpressionString()); if (i.hasNext()) b.append(", "); } b.append(")"); return b.toString(); } //------------------------------------- /** * * Evaluates by looking up the name in the VariableResolver **/ public Object evaluate (VariableResolver pResolver, FunctionMapper functions, Logger pLogger) throws ELException { // if the Map is null, then the function is invalid if (functions == null) pLogger.logError(Constants.UNKNOWN_FUNCTION, functionName); // normalize function name String prefix = null; String localName = null; int index = functionName.indexOf( ':' ); if (index == -1) { prefix = ""; localName = functionName; } else { prefix = functionName.substring( 0, index ); localName = functionName.substring( index + 1 ); } // ensure that the function's name is mapped Method target = (Method) functions.resolveFunction(prefix, localName); if (target == null) pLogger.logError(Constants.UNKNOWN_FUNCTION, functionName); // ensure that the number of arguments matches the number of parameters Class[] params = target.getParameterTypes(); if (params.length != argumentList.size()) pLogger.logError(Constants.INAPPROPRIATE_FUNCTION_ARG_COUNT, functionName, new Integer(params.length), new Integer(argumentList.size())); // now, walk through each parameter, evaluating and casting its argument Object[] arguments = new Object[argumentList.size()]; for (int i = 0; i < params.length; i++) { // evaluate arguments[i] = ((Expression) argumentList.get(i)).evaluate(pResolver, functions, pLogger); // coerce arguments[i] = Coercions.coerce(arguments[i], params[i], pLogger); } // finally, invoke the target method, which we know to be static try { return (target.invoke(null, arguments)); } catch (InvocationTargetException ex) { pLogger.logError(Constants.FUNCTION_INVOCATION_ERROR, ex.getTargetException(), functionName); return null; } catch (Exception ex) { pLogger.logError(Constants.FUNCTION_INVOCATION_ERROR, ex, functionName); return null; } } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/GreaterThanOperator.java0100644000175000017500000001205607673673602026742 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import javax.servlet.jsp.el.ELException; import java.math.BigDecimal; import java.math.BigInteger; /** * *

The implementation of the greater than operator * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class GreaterThanOperator extends RelationalOperator { //------------------------------------- // Singleton //------------------------------------- public static final GreaterThanOperator SINGLETON = new GreaterThanOperator (); //------------------------------------- /** * * Constructor **/ public GreaterThanOperator () { } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the symbol representing the operator **/ public String getOperatorSymbol () { return ">"; } //------------------------------------- /** * * Applies the operator to the given value **/ public Object apply (Object pLeft, Object pRight, Logger pLogger) throws ELException { if (pLeft == pRight) { return Boolean.FALSE; } else if (pLeft == null || pRight == null) { return Boolean.FALSE; } else { return super.apply (pLeft, pRight, pLogger); } } //------------------------------------- /** * * Applies the operator to the given double values **/ public boolean apply (double pLeft, double pRight) { return pLeft > pRight; } //------------------------------------- /** * * Applies the operator to the given long values **/ public boolean apply (long pLeft, long pRight) { return pLeft > pRight; } //------------------------------------- /** * * Applies the operator to the given String values **/ public boolean apply (String pLeft, String pRight) { return pLeft.compareTo (pRight) > 0; } //------------------------------------- /** * * Applies the operator to the given BigDecimal values, returning a BigDecimal **/ public boolean apply(BigDecimal pLeft, BigDecimal pRight) { return isGreater(pLeft.compareTo(pRight)); } //------------------------------------- /** * * Applies the operator to the given BigDecimal values, returning a BigDecimal **/ public boolean apply(BigInteger pLeft, BigInteger pRight) { return isGreater(pLeft.compareTo(pRight)); } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/ImplicitObjects.java0100644000175000017500000003400007617603701026066 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.Enumeration; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.servlet.ServletContext; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.jsp.PageContext; /** * *

This class is used to generate the implicit Map and List objects * that wrap various elements of the PageContext. It also returns the * correct implicit object for a given implicit object name. * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class ImplicitObjects { //------------------------------------- // Constants //------------------------------------- static final String sAttributeName = "org.apache.taglibs.standard.ImplicitObjects"; //------------------------------------- // Member variables //------------------------------------- PageContext mContext; Map mPage; Map mRequest; Map mSession; Map mApplication; Map mParam; Map mParams; Map mHeader; Map mHeaders; Map mInitParam; Map mCookie; //------------------------------------- /** * * Constructor **/ public ImplicitObjects (PageContext pContext) { mContext = pContext; } //------------------------------------- /** * * Finds the ImplicitObjects associated with the PageContext, * creating it if it doesn't yet exist. **/ public static ImplicitObjects getImplicitObjects (PageContext pContext) { ImplicitObjects objs = (ImplicitObjects) pContext.getAttribute (sAttributeName, PageContext.PAGE_SCOPE); if (objs == null) { objs = new ImplicitObjects (pContext); pContext.setAttribute (sAttributeName, objs, PageContext.PAGE_SCOPE); } return objs; } //------------------------------------- /** * * Returns the Map that "wraps" page-scoped attributes **/ public Map getPageScopeMap () { if (mPage == null) { mPage = createPageScopeMap (mContext); } return mPage; } //------------------------------------- /** * * Returns the Map that "wraps" request-scoped attributes **/ public Map getRequestScopeMap () { if (mRequest == null) { mRequest = createRequestScopeMap (mContext); } return mRequest; } //------------------------------------- /** * * Returns the Map that "wraps" session-scoped attributes **/ public Map getSessionScopeMap () { if (mSession == null) { mSession = createSessionScopeMap (mContext); } return mSession; } //------------------------------------- /** * * Returns the Map that "wraps" application-scoped attributes **/ public Map getApplicationScopeMap () { if (mApplication == null) { mApplication = createApplicationScopeMap (mContext); } return mApplication; } //------------------------------------- /** * * Returns the Map that maps parameter name to a single parameter * values. **/ public Map getParamMap () { if (mParam == null) { mParam = createParamMap (mContext); } return mParam; } //------------------------------------- /** * * Returns the Map that maps parameter name to an array of parameter * values. **/ public Map getParamsMap () { if (mParams == null) { mParams = createParamsMap (mContext); } return mParams; } //------------------------------------- /** * * Returns the Map that maps header name to a single header * values. **/ public Map getHeaderMap () { if (mHeader == null) { mHeader = createHeaderMap (mContext); } return mHeader; } //------------------------------------- /** * * Returns the Map that maps header name to an array of header * values. **/ public Map getHeadersMap () { if (mHeaders == null) { mHeaders = createHeadersMap (mContext); } return mHeaders; } //------------------------------------- /** * * Returns the Map that maps init parameter name to a single init * parameter values. **/ public Map getInitParamMap () { if (mInitParam == null) { mInitParam = createInitParamMap (mContext); } return mInitParam; } //------------------------------------- /** * * Returns the Map that maps cookie name to the first matching * Cookie in request.getCookies(). **/ public Map getCookieMap () { if (mCookie == null) { mCookie = createCookieMap (mContext); } return mCookie; } //------------------------------------- // Methods for generating wrapper maps //------------------------------------- /** * * Creates the Map that "wraps" page-scoped attributes **/ public static Map createPageScopeMap (PageContext pContext) { final PageContext context = pContext; return new EnumeratedMap () { public Enumeration enumerateKeys () { return context.getAttributeNamesInScope (PageContext.PAGE_SCOPE); } public Object getValue (Object pKey) { if (pKey instanceof String) { return context.getAttribute ((String) pKey, PageContext.PAGE_SCOPE); } else { return null; } } public boolean isMutable () { return true; } }; } //------------------------------------- /** * * Creates the Map that "wraps" request-scoped attributes **/ public static Map createRequestScopeMap (PageContext pContext) { final PageContext context = pContext; return new EnumeratedMap () { public Enumeration enumerateKeys () { return context.getAttributeNamesInScope (PageContext.REQUEST_SCOPE); } public Object getValue (Object pKey) { if (pKey instanceof String) { return context.getAttribute ((String) pKey, PageContext.REQUEST_SCOPE); } else { return null; } } public boolean isMutable () { return true; } }; } //------------------------------------- /** * * Creates the Map that "wraps" session-scoped attributes **/ public static Map createSessionScopeMap (PageContext pContext) { final PageContext context = pContext; return new EnumeratedMap () { public Enumeration enumerateKeys () { return context.getAttributeNamesInScope (PageContext.SESSION_SCOPE); } public Object getValue (Object pKey) { if (pKey instanceof String) { return context.getAttribute ((String) pKey, PageContext.SESSION_SCOPE); } else { return null; } } public boolean isMutable () { return true; } }; } //------------------------------------- /** * * Creates the Map that "wraps" application-scoped attributes **/ public static Map createApplicationScopeMap (PageContext pContext) { final PageContext context = pContext; return new EnumeratedMap () { public Enumeration enumerateKeys () { return context.getAttributeNamesInScope (PageContext.APPLICATION_SCOPE); } public Object getValue (Object pKey) { if (pKey instanceof String) { return context.getAttribute ((String) pKey, PageContext.APPLICATION_SCOPE); } else { return null; } } public boolean isMutable () { return true; } }; } //------------------------------------- /** * * Creates the Map that maps parameter name to single parameter * value. **/ public static Map createParamMap (PageContext pContext) { final HttpServletRequest request = (HttpServletRequest) pContext.getRequest (); return new EnumeratedMap () { public Enumeration enumerateKeys () { return request.getParameterNames (); } public Object getValue (Object pKey) { if (pKey instanceof String) { return request.getParameter ((String) pKey); } else { return null; } } public boolean isMutable () { return false; } }; } //------------------------------------- /** * * Creates the Map that maps parameter name to an array of parameter * values. **/ public static Map createParamsMap (PageContext pContext) { final HttpServletRequest request = (HttpServletRequest) pContext.getRequest (); return new EnumeratedMap () { public Enumeration enumerateKeys () { return request.getParameterNames (); } public Object getValue (Object pKey) { if (pKey instanceof String) { return request.getParameterValues ((String) pKey); } else { return null; } } public boolean isMutable () { return false; } }; } //------------------------------------- /** * * Creates the Map that maps header name to single header * value. **/ public static Map createHeaderMap (PageContext pContext) { final HttpServletRequest request = (HttpServletRequest) pContext.getRequest (); return new EnumeratedMap () { public Enumeration enumerateKeys () { return request.getHeaderNames (); } public Object getValue (Object pKey) { if (pKey instanceof String) { return request.getHeader ((String) pKey); } else { return null; } } public boolean isMutable () { return false; } }; } //------------------------------------- /** * * Creates the Map that maps header name to an array of header * values. **/ public static Map createHeadersMap (PageContext pContext) { final HttpServletRequest request = (HttpServletRequest) pContext.getRequest (); return new EnumeratedMap () { public Enumeration enumerateKeys () { return request.getHeaderNames (); } public Object getValue (Object pKey) { if (pKey instanceof String) { // Drain the header enumeration List l = new ArrayList (); Enumeration enum = request.getHeaders ((String) pKey); if (enum != null) { while (enum.hasMoreElements ()) { l.add (enum.nextElement ()); } } String [] ret = (String []) l.toArray (new String [l.size ()]); return ret; } else { return null; } } public boolean isMutable () { return false; } }; } //------------------------------------- /** * * Creates the Map that maps init parameter name to single init * parameter value. **/ public static Map createInitParamMap (PageContext pContext) { final ServletContext context = pContext.getServletContext (); return new EnumeratedMap () { public Enumeration enumerateKeys () { return context.getInitParameterNames (); } public Object getValue (Object pKey) { if (pKey instanceof String) { return context.getInitParameter ((String) pKey); } else { return null; } } public boolean isMutable () { return false; } }; } //------------------------------------- /** * * Creates the Map that maps cookie name to the first matching * Cookie in request.getCookies(). **/ public static Map createCookieMap (PageContext pContext) { // Read all the cookies and construct the entire map HttpServletRequest request = (HttpServletRequest) pContext.getRequest (); Cookie [] cookies = request.getCookies (); Map ret = new HashMap (); for (int i = 0; cookies != null && i < cookies.length; i++) { Cookie cookie = cookies [i]; if (cookie != null) { String name = cookie.getName (); if (!ret.containsKey (name)) { ret.put (name, cookie); } } } return ret; } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/Literal.java0100644000175000017500000000732207642104426024403 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import java.util.Map; import javax.servlet.jsp.el.ELException; import javax.servlet.jsp.el.VariableResolver; import javax.servlet.jsp.el.FunctionMapper; /** * *

An expression representing a literal value * * @author Nathan Abramson - Art Technology Group * @author Shawn Bayern * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public abstract class Literal extends Expression { //------------------------------------- // Properties //------------------------------------- // property value Object mValue; public Object getValue () { return mValue; } public void setValue (Object pValue) { mValue = pValue; } //------------------------------------- /** * * Constructor **/ public Literal (Object pValue) { mValue = pValue; } //------------------------------------- // Expression methods //------------------------------------- /** * * Evaluates to the literal value **/ public Object evaluate (VariableResolver pResolver, FunctionMapper functions, Logger pLogger) throws ELException { return mValue; } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/GreaterThanOrEqualsOperator.java0100644000175000017500000001224707673673602030420 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import javax.servlet.jsp.el.ELException; import java.math.BigDecimal; import java.math.BigInteger; /** * *

The implementation of the greater than or equals operator * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class GreaterThanOrEqualsOperator extends RelationalOperator { //------------------------------------- // Singleton //------------------------------------- public static final GreaterThanOrEqualsOperator SINGLETON = new GreaterThanOrEqualsOperator (); //------------------------------------- /** * * Constructor **/ public GreaterThanOrEqualsOperator () { } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the symbol representing the operator **/ public String getOperatorSymbol () { return ">="; } //------------------------------------- /** * * Applies the operator to the given value **/ public Object apply (Object pLeft, Object pRight, Logger pLogger) throws ELException { if (pLeft == pRight) { return Boolean.TRUE; } else if (pLeft == null || pRight == null) { return Boolean.FALSE; } else { return super.apply (pLeft, pRight, pLogger); } } //------------------------------------- /** * * Applies the operator to the given double values **/ public boolean apply (double pLeft, double pRight) { return pLeft >= pRight; } //------------------------------------- /** * * Applies the operator to the given long values **/ public boolean apply (long pLeft, long pRight) { return pLeft >= pRight; } //------------------------------------- /** * * Applies the operator to the given String values **/ public boolean apply (String pLeft, String pRight) { return pLeft.compareTo (pRight) >= 0; } //------------------------------------- /** * * Applies the operator to the given BigDecimal values, returning a BigDecimal **/ public boolean apply(BigDecimal pLeft, BigDecimal pRight) { return (isGreater(pLeft.compareTo(pRight)) || isEqual(pLeft.compareTo(pRight))); } //------------------------------------- /** * * Applies the operator to the given BigDecimal values, returning a BigDecimal **/ public boolean apply(BigInteger pLeft, BigInteger pRight) { return (isGreater(pLeft.compareTo(pRight)) || isEqual(pLeft.compareTo(pRight))); } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/IntegerDivideOperator.java0100644000175000017500000001057507617603701027253 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import javax.servlet.jsp.el.ELException; /** * *

The implementation of the integer divide operator * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class IntegerDivideOperator extends BinaryOperator { //------------------------------------- // Singleton //------------------------------------- public static final IntegerDivideOperator SINGLETON = new IntegerDivideOperator (); //------------------------------------- /** * * Constructor **/ public IntegerDivideOperator () { } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the symbol representing the operator **/ public String getOperatorSymbol () { return "idiv"; } //------------------------------------- /** * * Applies the operator to the given value **/ public Object apply (Object pLeft, Object pRight, Logger pLogger) throws ELException { if (pLeft == null && pRight == null) { if (pLogger.isLoggingWarning ()) { pLogger.logWarning (Constants.ARITH_OP_NULL, getOperatorSymbol ()); } return PrimitiveObjects.getInteger (0); } long left = Coercions.coerceToPrimitiveNumber (pLeft, Long.class, pLogger). longValue (); long right = Coercions.coerceToPrimitiveNumber (pRight, Long.class, pLogger). longValue (); try { return PrimitiveObjects.getLong (left / right); } catch (Exception exc) { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.ARITH_ERROR, getOperatorSymbol (), "" + left, "" + right); } return PrimitiveObjects.getInteger (0); } } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/IntegerLiteral.java0100644000175000017500000000701407617603701025721 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; /** * *

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: luehe $ **/ 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 (); } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/LessThanOperator.java0100644000175000017500000001203107673673602026250 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import javax.servlet.jsp.el.ELException; import java.math.BigDecimal; import java.math.BigInteger; /** * *

The implementation of the less than operator * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class LessThanOperator extends RelationalOperator { //------------------------------------- // Singleton //------------------------------------- public static final LessThanOperator SINGLETON = new LessThanOperator (); //------------------------------------- /** * * Constructor **/ public LessThanOperator () { } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the symbol representing the operator **/ public String getOperatorSymbol () { return "<"; } //------------------------------------- /** * * Applies the operator to the given value **/ public Object apply (Object pLeft, Object pRight, Logger pLogger) throws ELException { if (pLeft == pRight) { return Boolean.FALSE; } else if (pLeft == null || pRight == null) { return Boolean.FALSE; } else { return super.apply (pLeft, pRight, pLogger); } } //------------------------------------- /** * * Applies the operator to the given double values **/ public boolean apply (double pLeft, double pRight) { return pLeft < pRight; } //------------------------------------- /** * * Applies the operator to the given long values **/ public boolean apply (long pLeft, long pRight) { return pLeft < pRight; } //------------------------------------- /** * * Applies the operator to the given String values **/ public boolean apply (String pLeft, String pRight) { return pLeft.compareTo (pRight) < 0; } //------------------------------------- /** * * Applies the operator to the given BigDecimal values, returning a BigDecimal **/ public boolean apply(BigDecimal pLeft, BigDecimal pRight) { return isLess(pLeft.compareTo(pRight)); } //------------------------------------- /** * * Applies the operator to the given BigDecimal values, returning a BigDecimal **/ public boolean apply(BigInteger pLeft, BigInteger pRight) { return isLess(pLeft.compareTo(pRight)); } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/UnaryOperatorExpression.java0100644000175000017500000001254307642104426027702 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import java.util.List; import javax.servlet.jsp.el.ELException; import javax.servlet.jsp.el.VariableResolver; import javax.servlet.jsp.el.FunctionMapper; /** * *

An expression representing one or more unary operators on a * value * * @author Nathan Abramson - Art Technology Group * @author Shawn Bayern * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class UnaryOperatorExpression extends Expression { //------------------------------------- // Properties //------------------------------------- // property operator UnaryOperator mOperator; public UnaryOperator getOperator () { return mOperator; } public void setOperator (UnaryOperator pOperator) { mOperator = pOperator; } //------------------------------------- // property operators List mOperators; public List getOperators () { return mOperators; } public void setOperators (List pOperators) { mOperators = pOperators; } //------------------------------------- // property expression Expression mExpression; public Expression getExpression () { return mExpression; } public void setExpression (Expression pExpression) { mExpression = pExpression; } //------------------------------------- /** * * Constructor **/ public UnaryOperatorExpression (UnaryOperator pOperator, List pOperators, Expression pExpression) { mOperator = pOperator; mOperators = pOperators; mExpression = pExpression; } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the expression in the expression language syntax **/ public String getExpressionString () { StringBuffer buf = new StringBuffer (); buf.append ("("); if (mOperator != null) { buf.append (mOperator.getOperatorSymbol ()); buf.append (" "); } else { for (int i = 0; i < mOperators.size (); i++) { UnaryOperator operator = (UnaryOperator) mOperators.get (i); buf.append (operator.getOperatorSymbol ()); buf.append (" "); } } buf.append (mExpression.getExpressionString ()); buf.append (")"); return buf.toString (); } //------------------------------------- /** * * Evaluates to the literal value **/ public Object evaluate (VariableResolver pResolver, FunctionMapper functions, Logger pLogger) throws ELException { Object value = mExpression.evaluate (pResolver, functions, pLogger); if (mOperator != null) { value = mOperator.apply (value, pLogger); } else { for (int i = mOperators.size () - 1; i >= 0; i--) { UnaryOperator operator = (UnaryOperator) mOperators.get (i); value = operator.apply (value, pLogger); } } return value; } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/LessThanOrEqualsOperator.java0100644000175000017500000001222207673673602027726 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import javax.servlet.jsp.el.ELException; import java.math.BigDecimal; import java.math.BigInteger; /** * *

The implementation of the less than or equals operator * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class LessThanOrEqualsOperator extends RelationalOperator { //------------------------------------- // Singleton //------------------------------------- public static final LessThanOrEqualsOperator SINGLETON = new LessThanOrEqualsOperator (); //------------------------------------- /** * * Constructor **/ public LessThanOrEqualsOperator () { } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the symbol representing the operator **/ public String getOperatorSymbol () { return "<="; } //------------------------------------- /** * * Applies the operator to the given value **/ public Object apply (Object pLeft, Object pRight, Logger pLogger) throws ELException { if (pLeft == pRight) { return Boolean.TRUE; } else if (pLeft == null || pRight == null) { return Boolean.FALSE; } else { return super.apply (pLeft, pRight, pLogger); } } //------------------------------------- /** * * Applies the operator to the given double values **/ public boolean apply (double pLeft, double pRight) { return pLeft <= pRight; } //------------------------------------- /** * * Applies the operator to the given long values **/ public boolean apply (long pLeft, long pRight) { return pLeft <= pRight; } //------------------------------------- /** * * Applies the operator to the given String values **/ public boolean apply (String pLeft, String pRight) { return pLeft.compareTo (pRight) <= 0; } //------------------------------------- /** * * Applies the operator to the given BigDecimal values, returning a BigDecimal **/ public boolean apply(BigDecimal pLeft, BigDecimal pRight) { return (isLess(pLeft.compareTo(pRight)) || isEqual(pLeft.compareTo(pRight))); } //------------------------------------- /** * * Applies the operator to the given BigDecimal values, returning a BigDecimal **/ public boolean apply(BigInteger pLeft, BigInteger pRight) { return (isLess(pLeft.compareTo(pRight)) || isEqual(pLeft.compareTo(pRight))); } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/Logger.java0100644000175000017500000003674507617603701024243 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import java.io.PrintStream; import java.text.MessageFormat; import javax.servlet.jsp.el.ELException; /** * *

The evaluator may pass an instance of this class to operators * and expressions during evaluation. They should use this to log any * warning or error messages that might come up. This allows all of * our logging policies to be concentrated in one class. * *

Errors are conditions that are severe enough to abort operation. * Warnings are conditions through which the operation may continue, * but which should be reported to the developer. * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class Logger { //------------------------------------- // Member variables //------------------------------------- PrintStream mOut; //------------------------------------- /** * * Constructor * * @param pOut the PrintStream to which warnings should be printed **/ public Logger (PrintStream pOut) { mOut = pOut; } //------------------------------------- /** * * Returns true if the application should even bother to try logging * a warning. **/ public boolean isLoggingWarning () { return false; } //------------------------------------- /** * * Logs a warning **/ public void logWarning (String pMessage, Throwable pRootCause) throws ELException { if (isLoggingWarning ()) { if (pMessage == null) { System.out.println (pRootCause); } else if (pRootCause == null) { System.out.println (pMessage); } else { System.out.println (pMessage + ": " + pRootCause); } } } //------------------------------------- /** * * Logs a warning **/ public void logWarning (String pTemplate) throws ELException { if (isLoggingWarning ()) { logWarning (pTemplate, null); } } //------------------------------------- /** * * Logs a warning **/ public void logWarning (Throwable pRootCause) throws ELException { if (isLoggingWarning ()) { logWarning (null, pRootCause); } } //------------------------------------- /** * * Logs a warning **/ public void logWarning (String pTemplate, Object pArg0) throws ELException { if (isLoggingWarning ()) { logWarning (MessageFormat.format (pTemplate, new Object [] { "" + pArg0, })); } } //------------------------------------- /** * * Logs a warning **/ public void logWarning (String pTemplate, Throwable pRootCause, Object pArg0) throws ELException { if (isLoggingWarning ()) { logWarning (MessageFormat.format (pTemplate, new Object [] { "" + pArg0, }), pRootCause); } } //------------------------------------- /** * * Logs a warning **/ public void logWarning (String pTemplate, Object pArg0, Object pArg1) throws ELException { if (isLoggingWarning ()) { logWarning (MessageFormat.format (pTemplate, new Object [] { "" + pArg0, "" + pArg1, })); } } //------------------------------------- /** * * Logs a warning **/ public void logWarning (String pTemplate, Throwable pRootCause, Object pArg0, Object pArg1) throws ELException { if (isLoggingWarning ()) { logWarning (MessageFormat.format (pTemplate, new Object [] { "" + pArg0, "" + pArg1, }), pRootCause); } } //------------------------------------- /** * * Logs a warning **/ public void logWarning (String pTemplate, Object pArg0, Object pArg1, Object pArg2) throws ELException { if (isLoggingWarning ()) { logWarning (MessageFormat.format (pTemplate, new Object [] { "" + pArg0, "" + pArg1, "" + pArg2, })); } } //------------------------------------- /** * * Logs a warning **/ public void logWarning (String pTemplate, Throwable pRootCause, Object pArg0, Object pArg1, Object pArg2) throws ELException { if (isLoggingWarning ()) { logWarning (MessageFormat.format (pTemplate, new Object [] { "" + pArg0, "" + pArg1, "" + pArg2, }), pRootCause); } } //------------------------------------- /** * * Logs a warning **/ public void logWarning (String pTemplate, Object pArg0, Object pArg1, Object pArg2, Object pArg3) throws ELException { if (isLoggingWarning ()) { logWarning (MessageFormat.format (pTemplate, new Object [] { "" + pArg0, "" + pArg1, "" + pArg2, "" + pArg3, })); } } //------------------------------------- /** * * Logs a warning **/ public void logWarning (String pTemplate, Throwable pRootCause, Object pArg0, Object pArg1, Object pArg2, Object pArg3) throws ELException { if (isLoggingWarning ()) { logWarning (MessageFormat.format (pTemplate, new Object [] { "" + pArg0, "" + pArg1, "" + pArg2, "" + pArg3, }), pRootCause); } } //------------------------------------- /** * * Logs a warning **/ public void logWarning (String pTemplate, Object pArg0, Object pArg1, Object pArg2, Object pArg3, Object pArg4) throws ELException { if (isLoggingWarning ()) { logWarning (MessageFormat.format (pTemplate, new Object [] { "" + pArg0, "" + pArg1, "" + pArg2, "" + pArg3, "" + pArg4, })); } } //------------------------------------- /** * * Logs a warning **/ public void logWarning (String pTemplate, Throwable pRootCause, Object pArg0, Object pArg1, Object pArg2, Object pArg3, Object pArg4) throws ELException { if (isLoggingWarning ()) { logWarning (MessageFormat.format (pTemplate, new Object [] { "" + pArg0, "" + pArg1, "" + pArg2, "" + pArg3, "" + pArg4, }), pRootCause); } } //------------------------------------- /** * * Logs a warning **/ public void logWarning (String pTemplate, Object pArg0, Object pArg1, Object pArg2, Object pArg3, Object pArg4, Object pArg5) throws ELException { if (isLoggingWarning ()) { logWarning (MessageFormat.format (pTemplate, new Object [] { "" + pArg0, "" + pArg1, "" + pArg2, "" + pArg3, "" + pArg4, "" + pArg5, })); } } //------------------------------------- /** * * Logs a warning **/ public void logWarning (String pTemplate, Throwable pRootCause, Object pArg0, Object pArg1, Object pArg2, Object pArg3, Object pArg4, Object pArg5) throws ELException { if (isLoggingWarning ()) { logWarning (MessageFormat.format (pTemplate, new Object [] { "" + pArg0, "" + pArg1, "" + pArg2, "" + pArg3, "" + pArg4, "" + pArg5, }), pRootCause); } } //------------------------------------- /** * * Returns true if the application should even bother to try logging * an error. **/ public boolean isLoggingError () { return true; } //------------------------------------- /** * * Logs an error **/ public void logError (String pMessage, Throwable pRootCause) throws ELException { if (isLoggingError ()) { if (pMessage == null) { throw new ELException (pRootCause); } else if (pRootCause == null) { throw new ELException (pMessage); } else { throw new ELException (pMessage, pRootCause); } } } //------------------------------------- /** * * Logs an error **/ public void logError (String pTemplate) throws ELException { if (isLoggingError ()) { logError (pTemplate, null); } } //------------------------------------- /** * * Logs an error **/ public void logError (Throwable pRootCause) throws ELException { if (isLoggingError ()) { logError (null, pRootCause); } } //------------------------------------- /** * * Logs an error **/ public void logError (String pTemplate, Object pArg0) throws ELException { if (isLoggingError ()) { logError (MessageFormat.format (pTemplate, new Object [] { "" + pArg0, })); } } //------------------------------------- /** * * Logs an error **/ public void logError (String pTemplate, Throwable pRootCause, Object pArg0) throws ELException { if (isLoggingError ()) { logError (MessageFormat.format (pTemplate, new Object [] { "" + pArg0, }), pRootCause); } } //------------------------------------- /** * * Logs an error **/ public void logError (String pTemplate, Object pArg0, Object pArg1) throws ELException { if (isLoggingError ()) { logError (MessageFormat.format (pTemplate, new Object [] { "" + pArg0, "" + pArg1, })); } } //------------------------------------- /** * * Logs an error **/ public void logError (String pTemplate, Throwable pRootCause, Object pArg0, Object pArg1) throws ELException { if (isLoggingError ()) { logError (MessageFormat.format (pTemplate, new Object [] { "" + pArg0, "" + pArg1, }), pRootCause); } } //------------------------------------- /** * * Logs an error **/ public void logError (String pTemplate, Object pArg0, Object pArg1, Object pArg2) throws ELException { if (isLoggingError ()) { logError (MessageFormat.format (pTemplate, new Object [] { "" + pArg0, "" + pArg1, "" + pArg2, })); } } //------------------------------------- /** * * Logs an error **/ public void logError (String pTemplate, Throwable pRootCause, Object pArg0, Object pArg1, Object pArg2) throws ELException { if (isLoggingError ()) { logError (MessageFormat.format (pTemplate, new Object [] { "" + pArg0, "" + pArg1, "" + pArg2, }), pRootCause); } } //------------------------------------- /** * * Logs an error **/ public void logError (String pTemplate, Object pArg0, Object pArg1, Object pArg2, Object pArg3) throws ELException { if (isLoggingError ()) { logError (MessageFormat.format (pTemplate, new Object [] { "" + pArg0, "" + pArg1, "" + pArg2, "" + pArg3, })); } } //------------------------------------- /** * * Logs an error **/ public void logError (String pTemplate, Throwable pRootCause, Object pArg0, Object pArg1, Object pArg2, Object pArg3) throws ELException { if (isLoggingError ()) { logError (MessageFormat.format (pTemplate, new Object [] { "" + pArg0, "" + pArg1, "" + pArg2, "" + pArg3, }), pRootCause); } } //------------------------------------- /** * * Logs an error **/ public void logError (String pTemplate, Object pArg0, Object pArg1, Object pArg2, Object pArg3, Object pArg4) throws ELException { if (isLoggingError ()) { logError (MessageFormat.format (pTemplate, new Object [] { "" + pArg0, "" + pArg1, "" + pArg2, "" + pArg3, "" + pArg4, })); } } //------------------------------------- /** * * Logs an error **/ public void logError (String pTemplate, Throwable pRootCause, Object pArg0, Object pArg1, Object pArg2, Object pArg3, Object pArg4) throws ELException { if (isLoggingError ()) { logError (MessageFormat.format (pTemplate, new Object [] { "" + pArg0, "" + pArg1, "" + pArg2, "" + pArg3, "" + pArg4, }), pRootCause); } } //------------------------------------- /** * * Logs an error **/ public void logError (String pTemplate, Object pArg0, Object pArg1, Object pArg2, Object pArg3, Object pArg4, Object pArg5) throws ELException { if (isLoggingError ()) { logError (MessageFormat.format (pTemplate, new Object [] { "" + pArg0, "" + pArg1, "" + pArg2, "" + pArg3, "" + pArg4, "" + pArg5, })); } } //------------------------------------- /** * * Logs an error **/ public void logError (String pTemplate, Throwable pRootCause, Object pArg0, Object pArg1, Object pArg2, Object pArg3, Object pArg4, Object pArg5) throws ELException { if (isLoggingError ()) { logError (MessageFormat.format (pTemplate, new Object [] { "" + pArg0, "" + pArg1, "" + pArg2, "" + pArg3, "" + pArg4, "" + pArg5, }), pRootCause); } } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/MinusOperator.java0100644000175000017500000001055407674115771025631 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import java.math.BigDecimal; import java.math.BigInteger; /** * *

The implementation of the minus operator * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class MinusOperator extends ArithmeticOperator { //------------------------------------- // Singleton //------------------------------------- public static final MinusOperator SINGLETON = new MinusOperator (); //------------------------------------- /** * * Constructor **/ public MinusOperator () { } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the symbol representing the operator **/ public String getOperatorSymbol () { return "-"; } //------------------------------------- /** * * Applies the operator to the given double values, returning a double **/ public double apply (double pLeft, double pRight) { return pLeft - pRight; } //------------------------------------- /** * * Applies the operator to the given double values, returning a double **/ public long apply (long pLeft, long pRight) { return pLeft - pRight; } //------------------------------------- /** * * Applies the operator to the given BigDecimal values, returning a BigDecimal. **/ public BigDecimal apply(BigDecimal pLeft, BigDecimal pRight) { return pLeft.subtract(pRight); } //------------------------------------- /** * * Applies the operator to the given BigInteger values, returning a BigInteger. **/ public BigInteger apply(BigInteger pLeft, BigInteger pRight) { return pLeft.subtract(pRight); } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/ModulusOperator.java0100644000175000017500000001362007673673602026164 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import javax.servlet.jsp.el.ELException; import java.math.BigInteger; /** * *

The implementation of the modulus operator * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class ModulusOperator extends BinaryOperator { //------------------------------------- // Singleton //------------------------------------- public static final ModulusOperator SINGLETON = new ModulusOperator (); //------------------------------------- /** * * Constructor **/ public ModulusOperator () { } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the symbol representing the operator **/ public String getOperatorSymbol () { return "%"; } //------------------------------------- /** * * Applies the operator to the given value **/ public Object apply (Object pLeft, Object pRight, Logger pLogger) throws ELException { if (pLeft == null && pRight == null) { if (pLogger.isLoggingWarning ()) { pLogger.logWarning (Constants.ARITH_OP_NULL, getOperatorSymbol ()); } return PrimitiveObjects.getInteger (0); } if ((pLeft != null && (Coercions.isFloatingPointType (pLeft) || Coercions.isFloatingPointString (pLeft))) || Coercions.isBigDecimal(pLeft) || (pRight != null && (Coercions.isFloatingPointType (pRight) || Coercions.isFloatingPointString (pRight) || Coercions.isBigDecimal(pRight)))) { double left = Coercions.coerceToPrimitiveNumber (pLeft, Double.class, pLogger). doubleValue (); double right = Coercions.coerceToPrimitiveNumber (pRight, Double.class, pLogger). doubleValue (); try { return PrimitiveObjects.getDouble (left % right); } catch (Exception exc) { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.ARITH_ERROR, getOperatorSymbol (), "" + left, "" + right); } return PrimitiveObjects.getInteger (0); } } else if (Coercions.isBigInteger(pLeft) || Coercions.isBigInteger(pRight)) { BigInteger left = (BigInteger) Coercions.coerceToPrimitiveNumber(pLeft, BigInteger.class, pLogger); BigInteger right = (BigInteger) Coercions.coerceToPrimitiveNumber(pRight, BigInteger.class, pLogger); try { return left.remainder(right); } catch (Exception exc) { if (pLogger.isLoggingError()) { pLogger.logError (Constants.ARITH_ERROR, getOperatorSymbol(), "" + left, "" + right); } return PrimitiveObjects.getInteger(0); } } else { long left = Coercions.coerceToPrimitiveNumber (pLeft, Long.class, pLogger). longValue (); long right = Coercions.coerceToPrimitiveNumber (pRight, Long.class, pLogger). longValue (); try { return PrimitiveObjects.getLong (left % right); } catch (Exception exc) { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.ARITH_ERROR, getOperatorSymbol (), "" + left, "" + right); } return PrimitiveObjects.getInteger (0); } } } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/MultiplyOperator.java0100644000175000017500000001106107674115771026347 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import java.math.BigDecimal; import java.math.BigInteger; /** * *

The implementation of the multiply operator * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class MultiplyOperator extends ArithmeticOperator { //------------------------------------- // Singleton //------------------------------------- public static final MultiplyOperator SINGLETON = new MultiplyOperator (); //------------------------------------- /** * * Constructor **/ public MultiplyOperator () { } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the symbol representing the operator **/ public String getOperatorSymbol () { return "*"; } //------------------------------------- /** * * Applies the operator to the given double values, returning a double **/ public double apply (double pLeft, double pRight ) { return pLeft * pRight; } //------------------------------------- /** * * Applies the operator to the given double values, returning a double **/ public long apply (long pLeft, long pRight ) { return pLeft * pRight; } //------------------------------------- /** * * Applies the operator to the given BigDecimal values, returning a BigDecimal. **/ public BigDecimal apply(BigDecimal pLeft, BigDecimal pRight ) { return pLeft.multiply(pRight); } //------------------------------------- /** * * Applies the operator to the given BigInteger values, returning a BigInteger. **/ public BigInteger apply(BigInteger pLeft, BigInteger pRight ) { return pLeft.multiply(pRight); } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/NamedValue.java0100644000175000017500000001012007642104426025016 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import javax.servlet.jsp.el.VariableResolver; import javax.servlet.jsp.el.ELException; import javax.servlet.jsp.el.FunctionMapper; /** * *

Represents a name that can be used as the first element of a * value. * * @author Nathan Abramson - Art Technology Group * @author Shawn Bayern * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class NamedValue extends Expression { //------------------------------------- // Constants //------------------------------------- //------------------------------------- // Properties //------------------------------------- // property name String mName; public String getName () { return mName; } //------------------------------------- /** * * Constructor **/ public NamedValue (String pName) { mName = pName; } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the expression in the expression language syntax **/ public String getExpressionString () { return StringLiteral.toIdentifierToken (mName); } //------------------------------------- /** * * Evaluates by looking up the name in the VariableResolver **/ public Object evaluate (VariableResolver pResolver, FunctionMapper functions, Logger pLogger) throws ELException { if (pResolver == null) { return null; } else { return pResolver.resolveVariable (mName); } } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/NotEqualsOperator.java0100644000175000017500000000715207617603701026441 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; /** * *

The implementation of the not equals operator * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class NotEqualsOperator extends EqualityOperator { //------------------------------------- // Singleton //------------------------------------- public static final NotEqualsOperator SINGLETON = new NotEqualsOperator (); //------------------------------------- /** * * Constructor **/ public NotEqualsOperator () { } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the symbol representing the operator **/ public String getOperatorSymbol () { return "!="; } //------------------------------------- /** * * Applies the operator given the fact that the two elements are * equal. **/ public boolean apply (boolean pAreEqual, Logger pLogger) { return !pAreEqual; } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/NotOperator.java0100644000175000017500000000736407617603701025273 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import javax.servlet.jsp.el.ELException; /** * *

The implementation of the not operator * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class NotOperator extends UnaryOperator { //------------------------------------- // Singleton //------------------------------------- public static final NotOperator SINGLETON = new NotOperator (); //------------------------------------- /** * * Constructor **/ public NotOperator () { } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the symbol representing the operator **/ public String getOperatorSymbol () { return "not"; } //------------------------------------- /** * * Applies the operator to the given value **/ public Object apply (Object pValue, Logger pLogger) throws ELException { // Coerce the value to a boolean boolean val = Coercions.coerceToBoolean (pValue, pLogger).booleanValue (); return PrimitiveObjects.getBoolean (!val); } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/NullLiteral.java0100644000175000017500000000660507617603701025243 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; /** * *

An expression representing a null literal value * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class NullLiteral extends Literal { //------------------------------------- // Member variables //------------------------------------- public static final NullLiteral SINGLETON = new NullLiteral (); //------------------------------------- /** * * Constructor **/ public NullLiteral () { super (null); } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the expression in the expression language syntax **/ public String getExpressionString () { return "null"; } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/OrOperator.java0100644000175000017500000001067307617603701025110 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import javax.servlet.jsp.el.ELException; /** * *

The implementation of the or operator * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class OrOperator extends BinaryOperator { //------------------------------------- // Singleton //------------------------------------- public static final OrOperator SINGLETON = new OrOperator (); //------------------------------------- /** * * Constructor **/ public OrOperator () { } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the symbol representing the operator **/ public String getOperatorSymbol () { return "or"; } //------------------------------------- /** * * Applies the operator to the given value **/ public Object apply (Object pLeft, Object pRight, Logger pLogger) throws ELException { // Coerce the values to booleans boolean left = Coercions.coerceToBoolean (pLeft, pLogger).booleanValue (); boolean right = Coercions.coerceToBoolean (pRight, pLogger).booleanValue (); return PrimitiveObjects.getBoolean (left || right); } //------------------------------------- /** * * Returns true if evaluation is necessary given the specified Left * value. The And/OrOperators make use of this **/ public boolean shouldEvaluate (Object pLeft) { return (pLeft instanceof Boolean) && ((Boolean) pLeft).booleanValue () == false; } //------------------------------------- /** * * Returns true if the operator expects its arguments to be coerced * to Booleans. The And/Or operators set this to true. **/ public boolean shouldCoerceToBoolean () { return true; } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/PlusOperator.java0100644000175000017500000001062407674115771025457 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import javax.servlet.jsp.el.ELException; import java.math.BigDecimal; import java.math.BigInteger; /** * *

The implementation of the plus operator * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class PlusOperator extends ArithmeticOperator { //------------------------------------- // Singleton //------------------------------------- public static final PlusOperator SINGLETON = new PlusOperator (); //------------------------------------- /** * * Constructor **/ public PlusOperator () { } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the symbol representing the operator **/ public String getOperatorSymbol () { return "+"; } //------------------------------------- /** * * Applies the operator to the given double values, returning a double **/ public double apply (double pLeft, double pRight) { return pLeft + pRight; } //------------------------------------- /** * * Applies the operator to the given double values, returning a double **/ public long apply (long pLeft, long pRight) { return pLeft + pRight; } //------------------------------------- /** * * Applies the operator to the given BigDecimal values, returning a * BigDecimal. **/ public BigDecimal apply(BigDecimal pLeft, BigDecimal pRight) { return pLeft.add(pRight); } //------------------------------------- /** * * Applies the operator to the given BigInteger values, returning a * BigInteger. **/ public BigInteger apply(BigInteger pLeft, BigInteger pRight) { return pLeft.add(pRight); } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/PrimitiveObjects.java0100644000175000017500000002040307617603701026266 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; /** * *

This converts primitive values to their Object counterparts. * For bytes and chars, values from 0 to 255 are cached. For shorts, * ints, and longs, values -1000 to 1000 are cached. * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ class PrimitiveObjects { //------------------------------------- // Constants //------------------------------------- static int BYTE_LOWER_BOUND = 0; static int BYTE_UPPER_BOUND = 255; static int CHARACTER_LOWER_BOUND = 0; static int CHARACTER_UPPER_BOUND = 255; static int SHORT_LOWER_BOUND = -1000; static int SHORT_UPPER_BOUND = 1000; static int INTEGER_LOWER_BOUND = -1000; static int INTEGER_UPPER_BOUND = 1000; static int LONG_LOWER_BOUND = -1000; static int LONG_UPPER_BOUND = 1000; //------------------------------------- // Member variables //------------------------------------- static Byte [] mBytes = createBytes (); static Character [] mCharacters = createCharacters (); static Short [] mShorts = createShorts (); static Integer [] mIntegers = createIntegers (); static Long [] mLongs = createLongs (); //------------------------------------- // Getting primitive values //------------------------------------- public static Boolean getBoolean (boolean pValue) { return pValue ? Boolean.TRUE : Boolean.FALSE; } //------------------------------------- public static Byte getByte (byte pValue) { if (pValue >= BYTE_LOWER_BOUND && pValue <= BYTE_UPPER_BOUND) { return mBytes [((int) pValue) - BYTE_LOWER_BOUND]; } else { return new Byte (pValue); } } //------------------------------------- public static Character getCharacter (char pValue) { if (pValue >= CHARACTER_LOWER_BOUND && pValue <= CHARACTER_UPPER_BOUND) { return mCharacters [((int) pValue) - CHARACTER_LOWER_BOUND]; } else { return new Character (pValue); } } //------------------------------------- public static Short getShort (short pValue) { if (pValue >= SHORT_LOWER_BOUND && pValue <= SHORT_UPPER_BOUND) { return mShorts [((int) pValue) - SHORT_LOWER_BOUND]; } else { return new Short (pValue); } } //------------------------------------- public static Integer getInteger (int pValue) { if (pValue >= INTEGER_LOWER_BOUND && pValue <= INTEGER_UPPER_BOUND) { return mIntegers [((int) pValue) - INTEGER_LOWER_BOUND]; } else { return new Integer (pValue); } } //------------------------------------- public static Long getLong (long pValue) { if (pValue >= LONG_LOWER_BOUND && pValue <= LONG_UPPER_BOUND) { return mLongs [((int) pValue) - LONG_LOWER_BOUND]; } else { return new Long (pValue); } } //------------------------------------- public static Float getFloat (float pValue) { return new Float (pValue); } //------------------------------------- public static Double getDouble (double pValue) { return new Double (pValue); } //------------------------------------- // Object class equivalents of primitive classes //------------------------------------- /** * * If the given class is a primitive class, returns the object * version of that class. Otherwise, the class is just returned. **/ public static Class getPrimitiveObjectClass (Class pClass) { if (pClass == Boolean.TYPE) { return Boolean.class; } else if (pClass == Byte.TYPE) { return Byte.class; } else if (pClass == Short.TYPE) { return Short.class; } else if (pClass == Character.TYPE) { return Character.class; } else if (pClass == Integer.TYPE) { return Integer.class; } else if (pClass == Long.TYPE) { return Long.class; } else if (pClass == Float.TYPE) { return Float.class; } else if (pClass == Double.TYPE) { return Double.class; } else { return pClass; } } //------------------------------------- // Initializing the cached values //------------------------------------- static Byte [] createBytes () { int len = BYTE_UPPER_BOUND - BYTE_LOWER_BOUND + 1; Byte [] ret = new Byte [len]; byte val = (byte) BYTE_LOWER_BOUND; for (int i = 0; i < len; i++, val++) { ret [i] = new Byte (val); } return ret; } //------------------------------------- static Character [] createCharacters () { int len = CHARACTER_UPPER_BOUND - CHARACTER_LOWER_BOUND + 1; Character [] ret = new Character [len]; char val = (char) CHARACTER_LOWER_BOUND; for (int i = 0; i < len; i++, val++) { ret [i] = new Character (val); } return ret; } //------------------------------------- static Short [] createShorts () { int len = SHORT_UPPER_BOUND - SHORT_LOWER_BOUND + 1; Short [] ret = new Short [len]; short val = (short) SHORT_LOWER_BOUND; for (int i = 0; i < len; i++, val++) { ret [i] = new Short (val); } return ret; } //------------------------------------- static Integer [] createIntegers () { int len = INTEGER_UPPER_BOUND - INTEGER_LOWER_BOUND + 1; Integer [] ret = new Integer [len]; int val = (int) INTEGER_LOWER_BOUND; for (int i = 0; i < len; i++, val++) { ret [i] = new Integer (val); } return ret; } //------------------------------------- static Long [] createLongs () { int len = LONG_UPPER_BOUND - LONG_LOWER_BOUND + 1; Long [] ret = new Long [len]; long val = (long) LONG_LOWER_BOUND; for (int i = 0; i < len; i++, val++) { ret [i] = new Long (val); } return ret; } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/PropertySuffix.java0100644000175000017500000001047207642104426026020 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Map; import javax.servlet.jsp.el.ELException; import javax.servlet.jsp.el.VariableResolver; import javax.servlet.jsp.el.FunctionMapper; /** * *

Represents an operator that obtains the value of another value's * property. This is a specialization of ArraySuffix - a.b is * equivalent to a["b"] * * @author Nathan Abramson - Art Technology Group * @author Shawn Bayern * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class PropertySuffix extends ArraySuffix { //------------------------------------- // Properties //------------------------------------- // property name String mName; public String getName () { return mName; } public void setName (String pName) { mName = pName; } //------------------------------------- /** * * Constructor **/ public PropertySuffix (String pName) { super (null); mName = pName; } //------------------------------------- /** * * Gets the value of the index **/ Object evaluateIndex (VariableResolver pResolver, FunctionMapper functions, Logger pLogger) throws ELException { return mName; } //------------------------------------- /** * * Returns the operator symbol **/ String getOperatorSymbol () { return "."; } //------------------------------------- // ValueSuffix methods //------------------------------------- /** * * Returns the expression in the expression language syntax **/ public String getExpressionString () { return "." + StringLiteral.toIdentifierToken (mName); } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/RelationalOperator.java0100644000175000017500000001255507673673602026634 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import javax.servlet.jsp.el.ELException; import java.math.BigDecimal; import java.math.BigInteger; /** * *

This is the superclass for all relational operators (except == * or !=) * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public abstract class RelationalOperator extends BinaryOperator { //------------------------------------- /** * * Applies the operator to the given value **/ public Object apply (Object pLeft, Object pRight, Logger pLogger) throws ELException { return Coercions.applyRelationalOperator (pLeft, pRight, this, pLogger); } //------------------------------------- /** * * Applies the operator to the given double values **/ public abstract boolean apply (double pLeft, double pRight ); //------------------------------------- /** * * Applies the operator to the given long values **/ public abstract boolean apply (long pLeft, long pRight ); //------------------------------------- /** * * Applies the operator to the given String values **/ public abstract boolean apply (String pLeft, String pRight ); //------------------------------------- /** * Applies the operator to the given BigDecimal values, returning a BigDecimal **/ public abstract boolean apply(BigDecimal pLeft, BigDecimal pRight); //------------------------------------- /** * Applies the operator to the given BigDecimal values, returning a BigDecimal **/ public abstract boolean apply(BigInteger pLeft, BigInteger pRight); //------------------------------------- /** * Test return value of BigInteger/BigDecimal A.compareTo(B). * @param val - result of BigInteger/BigDecimal compareTo() call * @return - true if result is less than 0, otherwise false */ protected boolean isLess(int val) { if (val < 0) return true; else return false; } /** * Test return value of BigInteger/BigDecimal A.compareTo(B). * @param val - result of BigInteger/BigDecimal compareTo() call * @return - true if result is equal to 0, otherwise false */ protected boolean isEqual(int val) { if (val == 0) return true; else return false; } /** * Test return value of BigInteger/BigDecimal A.compareTo(B). * @param val - result of BigInteger/BigDecimal compareTo() call * @return - true if result is greater than 0, otherwise false */ protected boolean isGreater(int val) { if (val > 0) return true; else return false; } } libcommons-el-java-1.0/src/java/org/apache/commons/el/Resources.properties0100644000175000017500000000735607626523323026246 0ustar arnaudarnaudEXCEPTION_GETTING_BEANINFO=\ An Exception occurred getting the BeanInfo for class {0} NULL_EXPRESSION_STRING=\ A null expression string may not be passed to the \ expression evaluator PARSE_EXCEPTION=\ Encountered "{1}", expected one of [{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} CANT_GET_INDEXED_VALUE_OF_NULL=\ Attempt to apply the "{0}" operator to a null value CANT_GET_NULL_INDEX=\ Attempt to apply a null index to the "{0}" operator NULL_INDEX=\ The index supplied to the "{0}" operator may not be null BAD_INDEX_VALUE=\ The "{0}" operator was supplied with an index value of type \ "{1}" to be applied to a List or array, but \ that value cannot be converted to an integer. EXCEPTION_ACCESSING_LIST=\ An exception occurred while trying to access index {0} of a \ List EXCEPTION_ACCESSING_ARRAY=\ An exception occurred while trying to access index {0} of an \ Array CANT_FIND_INDEX=\ Unable to find a value for "{0}" in object of class "{1}" using \ operator "{2}" TOSTRING_EXCEPTION=\ An object of type "{0}" threw an exception in its toString() \ method while trying to be coerced to a String BOOLEAN_TO_NUMBER=\ Attempt to coerce a boolean value "{0}" to type \ "{1}" STRING_TO_NUMBER_EXCEPTION=\ An exception occured trying to convert String "{0}" to type "{1}" COERCE_TO_NUMBER=\ Attempt to coerce a value of type "{0}" to type "{1}" BOOLEAN_TO_CHARACTER=\ Attempt to coerce a boolean value "{0}" to type Character EMPTY_STRING_TO_CHARACTER=\ Attempt to coerce an empty String to type Character COERCE_TO_CHARACTER=\ Attempt to coerce a value of type "{0}" to Character NULL_TO_BOOLEAN=\ Attempt to coerce a null value to a Boolean STRING_TO_BOOLEAN=\ An exception occurred trying to convert String "{0}" to type Boolean COERCE_TO_BOOLEAN=\ Attempt to coerce a value of type "{0}" to Boolean COERCE_TO_OBJECT=\ Attempt to coerce a value of type "{0}" to type "{1}" NO_PROPERTY_EDITOR=\ Attempt to convert String "{0}" to type "{1}", but there is \ no PropertyEditor for that type PROPERTY_EDITOR_ERROR=\ Unable to parse value "{0}" into expected type "{1}" ARITH_OP_NULL=\ Attempt to apply operator "{0}" to null value ARITH_OP_BAD_TYPE=\ Attempt to apply operator "{0}" to arguments of type "{1}" \ and "{2}" ARITH_ERROR=\ An error occurred applying operator "{0}" to operands "{1}" \ and "{2}" ERROR_IN_EQUALS= An error occurred calling equals() on an object of type "{0}" \ when comparing with an object of type "{1}" for operator "{2}" UNARY_OP_BAD_TYPE=\ Attempt to apply operator "{0}" to arguments of type "{1}" NAMED_VALUE_NOT_FOUND=\ Unable to find a value for name "{0}" CANT_GET_INDEXED_PROPERTY=\ An error occurred obtaining the indexed property value of an \ object of type "{0}" with index "{1}" COMPARABLE_ERROR=\ An exception occurred while trying to compare a value of \ Comparable type "{0}" with a value of type "{1}" for operator \ "{2}" BAD_IMPLICIT_OBJECT=\ No such implicit object "{0}" - the only implicit objects are: \ {1} ATTRIBUTE_EVALUATION_EXCEPTION=\ An error occurred while evaluating custom action attribute "{0}" \ with value "{1}": {2} ({3}) ATTRIBUTE_PARSE_EXCEPTION=\ An error occurred while parsing custom action attribute "{0}" \ with value "{1}": {2} UNKNOWN_FUNCTION=\ No function is mapped to the name "{0}" INAPPROPRIATE_FUNCTION_ARG_COUNT=\ The function "{0}" requires {1} arguments but was passed {2} FUNCTION_INVOCATION_ERROR=\ An error occurred while evaluating function "{0}" libcommons-el-java-1.0/src/java/org/apache/commons/el/Resources_ja.properties0100644000175000017500000002032307617603701026704 0ustar arnaudarnaudEXCEPTION_GETTING_BEANINFO=\ \u30af\u30e9\u30b9 {0} \u306e BeanInfo \u3092\u53d6\u5f97\u3059\u308b\u904e\u7a0b\u3067\u4f8b\u5916\u304c\u767a\u751f\u3057\u307e\u3057\u305f NULL_EXPRESSION_STRING=\ null \u8868\u73fe\u6587\u5b57\u5217\u306f\u3001\u5f0f\u306e\u8a55\u4fa1\u3068\u3057\u3066\u901a\u3089\u306a\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093 PARSE_EXCEPTION=\ [{0}] \u306e\uff11\u3064\u3092\u671f\u5f85\u3057\u307e\u3057\u305f\u304c\u3001"{1}" \u306b\u906d\u9047\u3057\u307e\u3057\u305f CANT_GET_PROPERTY_OF_NULL=\ null \u5024\u3088\u308a\u30d7\u30ed\u30d1\u30c6\u30a3 "{0}" \u3092\u53d6\u5f97\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u307e\u3059 NO_SUCH_PROPERTY=\ \u30af\u30e9\u30b9 {0} \u306b\u306f\u3001\u30d7\u30ed\u30d1\u30c6\u30a3 "{1}" \u304c\u5b58\u5728\u3057\u307e\u305b\u3093 NO_GETTER_METHOD=\ \u30af\u30e9\u30b9 {1} \u306b\u3042\u308b\u30d7\u30ed\u30d1\u30c6\u30a3 "{0}" \u7528\u306e \ public \u3067\u5ba3\u8a00\u3055\u308c\u305f getter \u30e1\u30bd\u30c3\u30c9\u304c\u3042\u308a\u307e\u305b\u3093 ERROR_GETTING_PROPERTY=\ \u30af\u30e9\u30b9 {1} \u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304b\u3089\u30d7\u30ed\u30d1\u30c6\u30a3 "{0}" \ \u3092\u53d6\u5f97\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u308b\u904e\u7a0b\u3067\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f CANT_GET_INDEXED_VALUE_OF_NULL=\ null \u5024\u306b\u5bfe\u3057\u3066 "{0}" \u30aa\u30da\u30ec\u30fc\u30bf\u3092\u9069\u7528\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u307e\u3059 CANT_GET_NULL_INDEX=\ "{0}" \u30aa\u30da\u30ec\u30fc\u30bf\u306b\u5bfe\u3057\u3066 null \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u9069\u7528\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u307e\u3059 NULL_INDEX=\ "{0}" \u30aa\u30da\u30ec\u30fc\u30bf\u306b\u5bfe\u3057\u3066\u4f9b\u7d66\u3055\u308c\u305f\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306f \ null \u3067\u3042\u3063\u3066\u306f\u3044\u3051\u307e\u305b\u3093 BAD_INDEX_VALUE=\ "{0}" \u30aa\u30da\u30ec\u30fc\u30bf\u306b\u3088\u3063\u3066 List \u3082\u3057\u304f\u306f\u914d\u5217\u306b\u9069\u7528\u3055\u308c\u305f \ "{1}" \u578b\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u5024\u3092\u4f9b\u7d66\u3057\u307e\u3057\u305f\u304c\u3001\ \u305d\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u5024\u3092\u6574\u6570\u5024\u3078\u5909\u63db\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093 EXCEPTION_ACCESSING_LIST=\ List \u306e\u4e2d\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9 {0} \u3078\u30a2\u30af\u30bb\u30b9\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u308b\u904e\u7a0b\u3067\ \u4f8b\u5916\u304c\u767a\u751f\u3057\u307e\u3057\u305f EXCEPTION_ACCESSING_ARRAY=\ Array \u306e\u4e2d\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9 {0} \u3078\u30a2\u30af\u30bb\u30b9\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u308b\u904e\u7a0b\u3067\ \u4f8b\u5916\u304c\u767a\u751f\u3057\u307e\u3057\u305f CANT_FIND_INDEX=\ \u30aa\u30da\u30ec\u30fc\u30bf "{2}" \u3092\u5229\u7528\u3057\u307e\u3057\u305f\u304c\u3001\u30af\u30e9\u30b9 "{1}" \u306e\ \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u304a\u3044\u3066 "{0}" \u306b\u5bfe\u5fdc\u3059\u308b\u5024\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093 TOSTRING_EXCEPTION=\ "{0}" \u578b\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092 String \u306b\u5909\u63db\u3059\u308b\u904e\u7a0b\u306b\u304a\u3044\u3066\u3001\ \u3053\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e toString() \u30e1\u30bd\u30c3\u30c9\u304c\u4f8b\u5916\u3092\u30b9\u30ed\u30fc\u3057\u307e\u3057\u305f BOOLEAN_TO_NUMBER=\ boolean \u5024 "{0}" \u3092 "{1}" \u578b\u306b\u5909\u63db\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u307e\u3059 STRING_TO_NUMBER_EXCEPTION=\ String "{0}" \u3092 "{1}" \u578b\u306b\u5909\u63db\u3057\u3088\u3046\u3068\u3057\u305f\u969b\u306b\u4f8b\u5916\u304c\u767a\u751f\u3057\u307e\u3057\u305f COERCE_TO_NUMBER=\ "{0}" \u578b\u306e\u5024\u3092 "{1}" \u578b\u306b\u5909\u63db\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u307e\u3059 BOOLEAN_TO_CHARACTER=\ boolean \u5024 "{0}" \u3092 Character \u578b\u306b\u5909\u63db\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u307e\u3059 EMPTY_STRING_TO_CHARACTER=\ \u7a7a\u306e String \u3092 Character \u578b\u306b\u5909\u63db\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u307e\u3059 COERCE_TO_CHARACTER=\ "{0}" \u578b\u306e\u5024\u3092 Character \u578b\u306b\u5909\u63db\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u307e\u3059 NULL_TO_BOOLEAN=\ null \u5024\u3092 Boolean \u578b\u306b\u5909\u63db\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u307e\u3059 STRING_TO_BOOLEAN=\ String "{0}" \u3092 Boolean \u578b\u306b\u5909\u63db\u3057\u3088\u3046\u3068\u3057\u305f\u969b\u306b\u4f8b\u5916\u304c\u767a\u751f\u3057\u307e\u3057\u305f COERCE_TO_BOOLEAN=\ "{0}" \u578b\u306e\u5024\u3092 Boolean \u578b\u306b\u5909\u63db\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u307e\u3059 COERCE_TO_OBJECT=\ "{0}" \u578b\u306e\u5024\u3092 "{1}" \u578b\u306b\u5909\u63db\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u307e\u3059 NO_PROPERTY_EDITOR=\ String "{0}" \u3092 "{1}" \u578b\u306b\u5909\u63db\u3057\u3088\u3046\u3068\u3057\u307e\u3057\u305f\u304c\u3001\ \u305d\u306e\u578b\u306b\u5bfe\u5fdc\u3059\u308b PropertyEditor \u304c\u5b58\u5728\u3057\u307e\u305b\u3093 PROPERTY_EDITOR_ERROR=\ \u5024 "{0}" \u3092\u69cb\u6587\u89e3\u6790\u3057\u307e\u3057\u305f\u304c\u3001\u671f\u5f85\u3055\u308c\u308b "{1}" \ \u578b\u306b\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093 ARITH_OP_NULL=\ null \u5024\u306b\u5bfe\u3057\u3066\u30aa\u30da\u30ec\u30fc\u30bf "{0}" \u3092\u9069\u7528\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u307e\u3059 ARITH_OP_BAD_TYPE=\ "{1}" \u578b\u304a\u3088\u3073 "{2}" \u578b\u306e\u5909\u6570\u306b\u5bfe\u3057\u3066\u30aa\u30da\u30ec\u30fc\u30bf \ "{0}" \u3092\u9069\u7528\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u307e\u3059 ARITH_ERROR=\ \u30aa\u30da\u30e9\u30f3\u30c9 "{1}" \u304a\u3088\u3073 "{2}" \u306b\u5bfe\u3057\u3066\u30aa\u30da\u30ec\u30fc\u30bf \ {0} \u3092\u9069\u7528\u3057\u3066\u3044\u308b\u904e\u7a0b\u3067\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f ERROR_IN_EQUALS= \u30aa\u30da\u30ec\u30fc\u30bf "{2}" \u306b\u5bfe\u3057\u3066 \ "{1}" \u578b\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u6bd4\u8f03\u3057\u3088\u3046\u3068\u3057\u307e\u3057\u305f\u304c\u3001\ "{0}" \u578b\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e equals() \u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3057\u3066\u3044\u308b\u904e\u7a0b\u3067\ \u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f UNARY_OP_BAD_TYPE=\ "{1}" \u578b\u306e\u5909\u6570\u306b\u5bfe\u3057\u3066\u30aa\u30da\u30ec\u30fc\u30bf "{0}" \u3092\u9069\u7528\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u307e\u3059 NAMED_VALUE_NOT_FOUND=\ \u540d\u79f0 "{0}" \u306b\u5bfe\u5fdc\u3059\u308b\u5024\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093 CANT_GET_INDEXED_PROPERTY=\ \u30a4\u30f3\u30c7\u30c3\u30af\u30b9 "{1}" \u3092\u4ed8\u4e0e\u3057\u305f "{0}" \u578b\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\ \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u30fb\u30d7\u30ed\u30d1\u30c6\u30a3\u5024\u3092\u5f97\u3088\u3046\u3068\u3057\u305f\u904e\u7a0b\u3067\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f COMPARABLE_ERROR=\ \u30aa\u30da\u30ec\u30fc\u30bf "{2}" \u306b\u5bfe\u3057\u3066 \ Comparable \u578b\u3067\u3042\u308b "{0}" \u306e\u5024\u3068 "{1}" \u578b\u306e\u5024\u3068\u3092\ \u6bd4\u8f03\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u308b\u904e\u7a0b\u3067\u4f8b\u5916\u304c\u767a\u751f\u3057\u307e\u3057\u305f BAD_IMPLICIT_OBJECT=\ \u305d\u306e\u3088\u3046\u306a\u6697\u9ed9\u7684\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8 "{0}" \u306f\u5b58\u5728\u3057\u307e\u305b\u3093 - \ \u552f\u4e00\u306e\u6697\u9ed9\u7684\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059: {1} ATTRIBUTE_EVALUATION_EXCEPTION=\ \u5024 "{1}" \u306e\u30bb\u30c3\u30c8\u3055\u308c\u305f\u30ab\u30b9\u30bf\u30e0\u30fb\u30a2\u30af\u30b7\u30e7\u30f3\u5c5e\u6027 \ "{0}" \u3092\u8a55\u4fa1\u3057\u3066\u3044\u308b\u904e\u7a0b\u3067\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f: {2} ATTRIBUTE_PARSE_EXCEPTION=\ \u5024 "{1}" \u306e\u30bb\u30c3\u30c8\u3055\u308c\u305f\u30ab\u30b9\u30bf\u30e0\u30fb\u30a2\u30af\u30b7\u30e7\u30f3\u5c5e\u6027 \ "{0}" \u3092\u69cb\u6587\u89e3\u6790\u3057\u3066\u3044\u308b\u904e\u7a0b\u3067\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f: {2} libcommons-el-java-1.0/src/java/org/apache/commons/el/StringLiteral.java0100644000175000017500000001410107617603701025565 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; /** * *

An expression representing a String literal value. * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class StringLiteral extends Literal { //------------------------------------- /** * * Constructor **/ StringLiteral (Object pValue) { super (pValue); } //------------------------------------- /** * * Returns a StringLiteral parsed from the given token (enclosed by * single or double quotes) **/ public static StringLiteral fromToken (String pToken) { return new StringLiteral (getValueFromToken (pToken)); } //------------------------------------- /** * * Returns a StringLiteral with the given string value **/ public static StringLiteral fromLiteralValue (String pValue) { return new StringLiteral (pValue); } //------------------------------------- /** * * Parses the given token into the literal value **/ public static String getValueFromToken (String pToken) { StringBuffer buf = new StringBuffer (); int len = pToken.length () - 1; boolean escaping = false; for (int i = 1; i < len; i++) { char ch = pToken.charAt (i); if (escaping) { buf.append (ch); escaping = false; } else if (ch == '\\') { escaping = true; } else { buf.append (ch); } } return buf.toString (); } //------------------------------------- /** * * Converts the specified value to a String token, using " as the * enclosing quotes and escaping any characters that need escaping. **/ public static String toStringToken (String pValue) { // See if any escaping is needed if (pValue.indexOf ('\"') < 0 && pValue.indexOf ('\\') < 0) { return "\"" + pValue + "\""; } // Escaping is needed else { StringBuffer buf = new StringBuffer (); buf.append ('\"'); int len = pValue.length (); for (int i = 0; i < len; i++) { char ch = pValue.charAt (i); if (ch == '\\') { buf.append ('\\'); buf.append ('\\'); } else if (ch == '\"') { buf.append ('\\'); buf.append ('\"'); } else { buf.append (ch); } } buf.append ('\"'); return buf.toString (); } } //------------------------------------- /** * * Converts the specified value to an identifier token, escaping it * as a string literal if necessary. **/ public static String toIdentifierToken (String pValue) { // See if it's a valid java identifier if (isJavaIdentifier (pValue)) { return pValue; } // Return as a String literal else { return toStringToken (pValue); } } //------------------------------------- /** * * Returns true if the specified value is a legal java identifier **/ static boolean isJavaIdentifier (String pValue) { int len = pValue.length (); if (len == 0) { return false; } else { if (!Character.isJavaIdentifierStart (pValue.charAt (0))) { return false; } else { for (int i = 1; i < len; i++) { if (!Character.isJavaIdentifierPart (pValue.charAt (i))) { return false; } } return true; } } } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the expression in the expression language syntax **/ public String getExpressionString () { return toStringToken ((String) getValue ()); } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/UnaryMinusOperator.java0100644000175000017500000001303007673673602026641 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import javax.servlet.jsp.el.ELException; import java.math.BigInteger; import java.math.BigDecimal; /** * *

The implementation of the unary minus operator * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class UnaryMinusOperator extends UnaryOperator { //------------------------------------- // Singleton //------------------------------------- public static final UnaryMinusOperator SINGLETON = new UnaryMinusOperator (); //------------------------------------- /** * * Constructor **/ public UnaryMinusOperator () { } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the symbol representing the operator **/ public String getOperatorSymbol () { return "-"; } //------------------------------------- /** * * Applies the operator to the given value **/ public Object apply (Object pValue, Logger pLogger) throws ELException { if (pValue == null) { /* if (pLogger.isLoggingWarning ()) { pLogger.logWarning (Constants.ARITH_OP_NULL, getOperatorSymbol ()); } */ return PrimitiveObjects.getInteger (0); } else if (pValue instanceof BigInteger) { return ((BigInteger) pValue).negate(); } else if (pValue instanceof BigDecimal) { return ((BigDecimal) pValue).negate(); } else if (pValue instanceof String) { if (Coercions.isFloatingPointString (pValue)) { double dval = ((Number) (Coercions.coerceToPrimitiveNumber (pValue, Double.class, pLogger))). doubleValue (); return PrimitiveObjects.getDouble (-dval); } else { long lval = ((Number) (Coercions.coerceToPrimitiveNumber (pValue, Long.class, pLogger))). longValue (); return PrimitiveObjects.getLong (-lval); } } else if (pValue instanceof Byte) { return PrimitiveObjects.getByte ((byte) -(((Byte) pValue).byteValue ())); } else if (pValue instanceof Short) { return PrimitiveObjects.getShort ((short) -(((Short) pValue).shortValue ())); } else if (pValue instanceof Integer) { return PrimitiveObjects.getInteger ((int) -(((Integer) pValue).intValue ())); } else if (pValue instanceof Long) { return PrimitiveObjects.getLong ((long) -(((Long) pValue).longValue ())); } else if (pValue instanceof Float) { return PrimitiveObjects.getFloat ((float) -(((Float) pValue).floatValue ())); } else if (pValue instanceof Double) { return PrimitiveObjects.getDouble ((double) -(((Double) pValue).doubleValue ())); } else { if (pLogger.isLoggingError ()) { pLogger.logError (Constants.UNARY_OP_BAD_TYPE, getOperatorSymbol (), pValue.getClass ().getName ()); } return PrimitiveObjects.getInteger (0); } } //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/UnaryOperator.java0100644000175000017500000000661707617603701025631 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import javax.servlet.jsp.el.ELException; /** * *

This is the superclass for all unary operators * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public abstract class UnaryOperator { //------------------------------------- /** * * Constructor **/ public UnaryOperator () { } //------------------------------------- // Expression methods //------------------------------------- /** * * Returns the symbol representing the operator **/ public abstract String getOperatorSymbol (); //------------------------------------- /** * * Applies the operator to the given value **/ public abstract Object apply (Object pValue, Logger pLogger) throws ELException; //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/parser/0040755000175000017500000000000007674117676023457 5ustar arnaudarnaudlibcommons-el-java-1.0/src/java/org/apache/commons/el/parser/ELParser.java0100644000175000017500000015312507641713423025765 0ustar arnaudarnaud/* Generated By:JavaCC: Do not edit this line. ELParser.java */ package org.apache.commons.el.parser; import org.apache.commons.el.*; import java.util.ArrayList; import java.util.List; /** * Generated EL parser. * * @author Nathan Abramson * @author Shawn Bayern */ public class ELParser implements ELParserConstants { public static void main(String args[]) throws ParseException { ELParser parser = new ELParser (System.in); parser.ExpressionString (); } /***************************************** * GRAMMAR PRODUCTIONS * *****************************************/ /** * * Returns a String if the expression string is a single String, an * Expression if the expression string is a single Expression, an * ExpressionString if it's a mixture of both. **/ final public Object ExpressionString() throws ParseException { Object ret = ""; List elems = null; Object elem; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case NON_EXPRESSION_TEXT: ret = AttrValueString(); break; case START_EXPRESSION: ret = AttrValueExpression(); break; default: jj_la1[0] = jj_gen; jj_consume_token(-1); throw new ParseException(); } label_1: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case NON_EXPRESSION_TEXT: case START_EXPRESSION: ; break; default: jj_la1[1] = jj_gen; break label_1; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case NON_EXPRESSION_TEXT: elem = AttrValueString(); break; case START_EXPRESSION: elem = AttrValueExpression(); break; default: jj_la1[2] = jj_gen; jj_consume_token(-1); throw new ParseException(); } if (elems == null) { elems = new ArrayList (); elems.add (ret); } elems.add (elem); } if (elems != null) { ret = new ExpressionString (elems.toArray ()); } {if (true) return ret;} throw new Error("Missing return statement in function"); } final public String AttrValueString() throws ParseException { Token t; t = jj_consume_token(NON_EXPRESSION_TEXT); {if (true) return t.image;} throw new Error("Missing return statement in function"); } final public Expression AttrValueExpression() throws ParseException { Expression exp; jj_consume_token(START_EXPRESSION); exp = Expression(); jj_consume_token(END_EXPRESSION); {if (true) return exp;} throw new Error("Missing return statement in function"); } final public Expression Expression() throws ParseException { Expression ret; if (jj_2_1(2147483647)) { ret = ConditionalExpression(); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case STRING_LITERAL: case TRUE: case FALSE: case NULL: case LPAREN: case MINUS: case NOT1: case NOT2: case EMPTY: case IDENTIFIER: ret = OrExpression(); break; default: jj_la1[3] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } {if (true) return ret;} throw new Error("Missing return statement in function"); } final public Expression OrExpression() throws ParseException { Expression startExpression; BinaryOperator operator; Expression expression; List operators = null; List expressions = null; startExpression = AndExpression(); label_2: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case OR1: case OR2: ; break; default: jj_la1[4] = jj_gen; break label_2; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case OR1: jj_consume_token(OR1); break; case OR2: jj_consume_token(OR2); break; default: jj_la1[5] = jj_gen; jj_consume_token(-1); throw new ParseException(); } operator = OrOperator.SINGLETON; expression = AndExpression(); if (operators == null) { operators = new ArrayList (); expressions = new ArrayList (); } operators.add (operator); expressions.add (expression); } if (operators != null) { {if (true) return new BinaryOperatorExpression (startExpression, operators, expressions);} } else { {if (true) return startExpression;} } throw new Error("Missing return statement in function"); } final public Expression AndExpression() throws ParseException { Expression startExpression; BinaryOperator operator; Expression expression; List operators = null; List expressions = null; startExpression = EqualityExpression(); label_3: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case AND1: case AND2: ; break; default: jj_la1[6] = jj_gen; break label_3; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case AND1: jj_consume_token(AND1); break; case AND2: jj_consume_token(AND2); break; default: jj_la1[7] = jj_gen; jj_consume_token(-1); throw new ParseException(); } operator = AndOperator.SINGLETON; expression = EqualityExpression(); if (operators == null) { operators = new ArrayList (); expressions = new ArrayList (); } operators.add (operator); expressions.add (expression); } if (operators != null) { {if (true) return new BinaryOperatorExpression (startExpression, operators, expressions);} } else { {if (true) return startExpression;} } throw new Error("Missing return statement in function"); } final public Expression EqualityExpression() throws ParseException { Expression startExpression; BinaryOperator operator; Expression expression; List operators = null; List expressions = null; startExpression = RelationalExpression(); label_4: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case EQ1: case EQ2: case NE1: case NE2: ; break; default: jj_la1[8] = jj_gen; break label_4; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case EQ1: case EQ2: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case EQ1: jj_consume_token(EQ1); break; case EQ2: jj_consume_token(EQ2); break; default: jj_la1[9] = jj_gen; jj_consume_token(-1); throw new ParseException(); } operator = EqualsOperator.SINGLETON; break; case NE1: case NE2: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case NE1: jj_consume_token(NE1); break; case NE2: jj_consume_token(NE2); break; default: jj_la1[10] = jj_gen; jj_consume_token(-1); throw new ParseException(); } operator = NotEqualsOperator.SINGLETON; break; default: jj_la1[11] = jj_gen; jj_consume_token(-1); throw new ParseException(); } expression = RelationalExpression(); if (operators == null) { operators = new ArrayList (); expressions = new ArrayList (); } operators.add (operator); expressions.add (expression); } if (operators != null) { {if (true) return new BinaryOperatorExpression (startExpression, operators, expressions);} } else { {if (true) return startExpression;} } throw new Error("Missing return statement in function"); } final public Expression RelationalExpression() throws ParseException { Expression startExpression; BinaryOperator operator; Expression expression; List operators = null; List expressions = null; startExpression = AddExpression(); label_5: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case GT1: case GT2: case LT1: case LT2: case LE1: case LE2: case GE1: case GE2: ; break; default: jj_la1[12] = jj_gen; break label_5; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LT1: case LT2: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LT1: jj_consume_token(LT1); break; case LT2: jj_consume_token(LT2); break; default: jj_la1[13] = jj_gen; jj_consume_token(-1); throw new ParseException(); } operator = LessThanOperator.SINGLETON; break; case GT1: case GT2: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case GT1: jj_consume_token(GT1); break; case GT2: jj_consume_token(GT2); break; default: jj_la1[14] = jj_gen; jj_consume_token(-1); throw new ParseException(); } operator = GreaterThanOperator.SINGLETON; break; case GE1: case GE2: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case GE1: jj_consume_token(GE1); break; case GE2: jj_consume_token(GE2); break; default: jj_la1[15] = jj_gen; jj_consume_token(-1); throw new ParseException(); } operator = GreaterThanOrEqualsOperator.SINGLETON; break; case LE1: case LE2: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LE1: jj_consume_token(LE1); break; case LE2: jj_consume_token(LE2); break; default: jj_la1[16] = jj_gen; jj_consume_token(-1); throw new ParseException(); } operator = LessThanOrEqualsOperator.SINGLETON; break; default: jj_la1[17] = jj_gen; jj_consume_token(-1); throw new ParseException(); } expression = AddExpression(); if (operators == null) { operators = new ArrayList (); expressions = new ArrayList (); } operators.add (operator); expressions.add (expression); } if (operators != null) { {if (true) return new BinaryOperatorExpression (startExpression, operators, expressions);} } else { {if (true) return startExpression;} } throw new Error("Missing return statement in function"); } final public Expression AddExpression() throws ParseException { Expression startExpression; BinaryOperator operator; Expression expression; List operators = null; List expressions = null; startExpression = MultiplyExpression(); label_6: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PLUS: case MINUS: ; break; default: jj_la1[18] = jj_gen; break label_6; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PLUS: jj_consume_token(PLUS); operator = PlusOperator.SINGLETON; break; case MINUS: jj_consume_token(MINUS); operator = MinusOperator.SINGLETON; break; default: jj_la1[19] = jj_gen; jj_consume_token(-1); throw new ParseException(); } expression = MultiplyExpression(); if (operators == null) { operators = new ArrayList (); expressions = new ArrayList (); } operators.add (operator); expressions.add (expression); } if (operators != null) { {if (true) return new BinaryOperatorExpression (startExpression, operators, expressions);} } else { {if (true) return startExpression;} } throw new Error("Missing return statement in function"); } final public Expression MultiplyExpression() throws ParseException { Expression startExpression; BinaryOperator operator; Expression expression; List operators = null; List expressions = null; startExpression = UnaryExpression(); label_7: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case MULTIPLY: case DIVIDE1: case DIVIDE2: case MODULUS1: case MODULUS2: ; break; default: jj_la1[20] = jj_gen; break label_7; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case MULTIPLY: jj_consume_token(MULTIPLY); operator = MultiplyOperator.SINGLETON; break; case DIVIDE1: case DIVIDE2: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case DIVIDE1: jj_consume_token(DIVIDE1); break; case DIVIDE2: jj_consume_token(DIVIDE2); break; default: jj_la1[21] = jj_gen; jj_consume_token(-1); throw new ParseException(); } operator = DivideOperator.SINGLETON; break; case MODULUS1: case MODULUS2: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case MODULUS1: jj_consume_token(MODULUS1); break; case MODULUS2: jj_consume_token(MODULUS2); break; default: jj_la1[22] = jj_gen; jj_consume_token(-1); throw new ParseException(); } operator = ModulusOperator.SINGLETON; break; default: jj_la1[23] = jj_gen; jj_consume_token(-1); throw new ParseException(); } expression = UnaryExpression(); if (operators == null) { operators = new ArrayList (); expressions = new ArrayList (); } operators.add (operator); expressions.add (expression); } if (operators != null) { {if (true) return new BinaryOperatorExpression (startExpression, operators, expressions);} } else { {if (true) return startExpression;} } throw new Error("Missing return statement in function"); } final public Expression ConditionalExpression() throws ParseException { Expression condition, trueBranch, falseBranch; condition = OrExpression(); jj_consume_token(COND); trueBranch = Expression(); jj_consume_token(COLON); falseBranch = Expression(); {if (true) return new ConditionalExpression(condition, trueBranch, falseBranch);} throw new Error("Missing return statement in function"); } final public Expression UnaryExpression() throws ParseException { Expression expression; UnaryOperator singleOperator = null; UnaryOperator operator; List operators = null; label_8: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case MINUS: case NOT1: case NOT2: case EMPTY: ; break; default: jj_la1[24] = jj_gen; break label_8; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case NOT1: case NOT2: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case NOT1: jj_consume_token(NOT1); break; case NOT2: jj_consume_token(NOT2); break; default: jj_la1[25] = jj_gen; jj_consume_token(-1); throw new ParseException(); } operator = NotOperator.SINGLETON; break; case MINUS: jj_consume_token(MINUS); operator = UnaryMinusOperator.SINGLETON; break; case EMPTY: jj_consume_token(EMPTY); operator = EmptyOperator.SINGLETON; break; default: jj_la1[26] = jj_gen; jj_consume_token(-1); throw new ParseException(); } if (singleOperator == null) { singleOperator = operator; } else if (operators == null) { operators = new ArrayList (); operators.add (singleOperator); operators.add (operator); } else { operators.add (operator); } } expression = Value(); if (operators != null) { {if (true) return new UnaryOperatorExpression (null, operators, expression);} } else if (singleOperator != null) { {if (true) return new UnaryOperatorExpression (singleOperator, null, expression);} } else { {if (true) return expression;} } throw new Error("Missing return statement in function"); } final public Expression Value() throws ParseException { Expression prefix; ValueSuffix suffix; List suffixes = null; prefix = ValuePrefix(); label_9: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case DOT: case LBRACKET: ; break; default: jj_la1[27] = jj_gen; break label_9; } suffix = ValueSuffix(); if (suffixes == null) { suffixes = new ArrayList (); } suffixes.add (suffix); } if (suffixes == null) { {if (true) return prefix;} } else { {if (true) return new ComplexValue (prefix, suffixes);} } throw new Error("Missing return statement in function"); } /** * This is an element that can start a value **/ final public Expression ValuePrefix() throws ParseException { Expression ret; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case STRING_LITERAL: case TRUE: case FALSE: case NULL: ret = Literal(); break; case LPAREN: jj_consume_token(LPAREN); ret = Expression(); jj_consume_token(RPAREN); break; default: jj_la1[28] = jj_gen; if (jj_2_2(2147483647)) { ret = FunctionInvocation(); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENTIFIER: ret = NamedValue(); break; default: jj_la1[29] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } } {if (true) return ret;} throw new Error("Missing return statement in function"); } final public NamedValue NamedValue() throws ParseException { Token t; t = jj_consume_token(IDENTIFIER); {if (true) return new NamedValue (t.image);} throw new Error("Missing return statement in function"); } final public FunctionInvocation FunctionInvocation() throws ParseException { String qualifiedName; List argumentList = new ArrayList(); Expression exp; qualifiedName = QualifiedName(); jj_consume_token(LPAREN); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case STRING_LITERAL: case TRUE: case FALSE: case NULL: case LPAREN: case MINUS: case NOT1: case NOT2: case EMPTY: case IDENTIFIER: exp = Expression(); argumentList.add(exp); label_10: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: ; break; default: jj_la1[30] = jj_gen; break label_10; } jj_consume_token(COMMA); exp = Expression(); argumentList.add(exp); } break; default: jj_la1[31] = jj_gen; ; } jj_consume_token(RPAREN); {if (true) return new FunctionInvocation(qualifiedName, argumentList);} throw new Error("Missing return statement in function"); } final public ValueSuffix ValueSuffix() throws ParseException { ValueSuffix suffix; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case DOT: suffix = PropertySuffix(); break; case LBRACKET: suffix = ArraySuffix(); break; default: jj_la1[32] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return suffix;} throw new Error("Missing return statement in function"); } final public PropertySuffix PropertySuffix() throws ParseException { Token t; String property; jj_consume_token(DOT); property = Identifier(); {if (true) return new PropertySuffix (property);} throw new Error("Missing return statement in function"); } final public ArraySuffix ArraySuffix() throws ParseException { Expression index; jj_consume_token(LBRACKET); index = Expression(); jj_consume_token(RBRACKET); {if (true) return new ArraySuffix (index);} throw new Error("Missing return statement in function"); } final public Literal Literal() throws ParseException { Literal ret; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case TRUE: case FALSE: ret = BooleanLiteral(); break; case INTEGER_LITERAL: ret = IntegerLiteral(); break; case FLOATING_POINT_LITERAL: ret = FloatingPointLiteral(); break; case STRING_LITERAL: ret = StringLiteral(); break; case NULL: ret = NullLiteral(); break; default: jj_la1[33] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return ret;} throw new Error("Missing return statement in function"); } final public BooleanLiteral BooleanLiteral() throws ParseException { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case TRUE: jj_consume_token(TRUE); {if (true) return BooleanLiteral.TRUE;} break; case FALSE: jj_consume_token(FALSE); {if (true) return BooleanLiteral.FALSE;} break; default: jj_la1[34] = jj_gen; jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); } final public StringLiteral StringLiteral() throws ParseException { Token t; t = jj_consume_token(STRING_LITERAL); {if (true) return StringLiteral.fromToken (t.image);} throw new Error("Missing return statement in function"); } final public IntegerLiteral IntegerLiteral() throws ParseException { Token t; t = jj_consume_token(INTEGER_LITERAL); {if (true) return new IntegerLiteral (t.image);} throw new Error("Missing return statement in function"); } final public FloatingPointLiteral FloatingPointLiteral() throws ParseException { Token t; t = jj_consume_token(FLOATING_POINT_LITERAL); {if (true) return new FloatingPointLiteral (t.image);} throw new Error("Missing return statement in function"); } final public NullLiteral NullLiteral() throws ParseException { jj_consume_token(NULL); {if (true) return NullLiteral.SINGLETON;} throw new Error("Missing return statement in function"); } final public String Identifier() throws ParseException { Token t; t = jj_consume_token(IDENTIFIER); {if (true) return t.image;} throw new Error("Missing return statement in function"); } final public String QualifiedName() throws ParseException { String prefix = null, localPart = null; if (jj_2_3(2147483647)) { prefix = Identifier(); jj_consume_token(COLON); } else { ; } localPart = Identifier(); if (prefix == null) {if (true) return localPart;} else {if (true) return prefix + ":" + localPart;} throw new Error("Missing return statement in function"); } final private boolean jj_2_1(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; boolean retval = !jj_3_1(); jj_save(0, xla); return retval; } final private boolean jj_2_2(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; boolean retval = !jj_3_2(); jj_save(1, xla); return retval; } final private boolean jj_2_3(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; boolean retval = !jj_3_3(); jj_save(2, xla); return retval; } final private boolean jj_3R_42() { if (jj_scan_token(NE2)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_91() { 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_40() { if (jj_scan_token(EQ2)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_41() { if (jj_scan_token(NE1)) return true; 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_41()) { jj_scanpos = xsp; 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; return false; } final private boolean jj_3R_90() { 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_39() { if (jj_scan_token(EQ1)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_31() { Token xsp; xsp = jj_scanpos; if (jj_3R_39()) { jj_scanpos = xsp; if (jj_3R_40()) 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_26() { Token xsp; xsp = jj_scanpos; 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; if (jj_3R_25()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_70() { if (jj_scan_token(NOT2)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_21() { if (jj_3R_25()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_26()) { jj_scanpos = xsp; break; } if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; } return false; } final private boolean jj_3R_92() { 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_62() { if (jj_scan_token(EMPTY)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_61() { if (jj_scan_token(MINUS)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_69() { if (jj_scan_token(NOT1)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_60() { Token xsp; xsp = jj_scanpos; if (jj_3R_69()) { jj_scanpos = xsp; if (jj_3R_70()) 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_55() { Token xsp; xsp = jj_scanpos; if (jj_3R_60()) { jj_scanpos = xsp; if (jj_3R_61()) { jj_scanpos = xsp; if (jj_3R_62()) 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; return false; } final private boolean jj_3R_96() { if (jj_scan_token(FALSE)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_43() { Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_55()) { jj_scanpos = xsp; break; } if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; } if (jj_3R_56()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_95() { if (jj_scan_token(TRUE)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_89() { Token xsp; xsp = jj_scanpos; if (jj_3R_95()) { jj_scanpos = xsp; if (jj_3R_96()) 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_85() { if (jj_3R_93()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_84() { if (jj_3R_92()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_83() { if (jj_3R_91()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_82() { if (jj_3R_90()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_28() { if (jj_scan_token(AND2)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_81() { if (jj_3R_89()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_76() { Token xsp; xsp = jj_scanpos; if (jj_3R_81()) { jj_scanpos = xsp; if (jj_3R_82()) { jj_scanpos = xsp; if (jj_3R_83()) { jj_scanpos = xsp; if (jj_3R_84()) { jj_scanpos = xsp; if (jj_3R_85()) 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_11() { if (jj_3R_14()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; if (jj_scan_token(COND)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; if (jj_3R_15()) 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_15()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_27() { if (jj_scan_token(AND1)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_22() { Token xsp; xsp = jj_scanpos; if (jj_3R_27()) { jj_scanpos = xsp; if (jj_3R_28()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; if (jj_3R_21()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_17() { if (jj_3R_21()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_22()) { jj_scanpos = xsp; break; } if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; } return false; } final private boolean jj_3R_68() { if (jj_scan_token(MODULUS2)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_88() { if (jj_scan_token(LBRACKET)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; if (jj_3R_15()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; if (jj_scan_token(RBRACKET)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_66() { if (jj_scan_token(DIVIDE2)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_67() { if (jj_scan_token(MODULUS1)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_59() { Token xsp; xsp = jj_scanpos; if (jj_3R_67()) { jj_scanpos = xsp; if (jj_3R_68()) 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_65() { if (jj_scan_token(DIVIDE1)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_87() { if (jj_scan_token(DOT)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; if (jj_3R_13()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_58() { Token xsp; xsp = jj_scanpos; if (jj_3R_65()) { jj_scanpos = xsp; if (jj_3R_66()) 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_57() { if (jj_scan_token(MULTIPLY)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_44() { Token xsp; xsp = jj_scanpos; if (jj_3R_57()) { jj_scanpos = xsp; if (jj_3R_58()) { jj_scanpos = xsp; if (jj_3R_59()) 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; if (jj_3R_43()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_24() { if (jj_scan_token(OR2)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_80() { if (jj_3R_88()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_33() { if (jj_3R_43()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_44()) { jj_scanpos = xsp; break; } if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; } return false; } final private boolean jj_3R_79() { if (jj_3R_87()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_75() { Token xsp; xsp = jj_scanpos; if (jj_3R_79()) { jj_scanpos = xsp; if (jj_3R_80()) 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_23() { if (jj_scan_token(OR1)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_18() { Token xsp; xsp = jj_scanpos; if (jj_3R_23()) { jj_scanpos = xsp; if (jj_3R_24()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; if (jj_3R_17()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_14() { if (jj_3R_17()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_18()) { jj_scanpos = xsp; break; } if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; } return false; } final private boolean jj_3R_94() { if (jj_scan_token(COMMA)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; if (jj_3R_15()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3_1() { if (jj_3R_11()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_86() { if (jj_3R_15()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_94()) { jj_scanpos = xsp; break; } if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; } return false; } final private boolean jj_3R_20() { if (jj_3R_14()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_19() { if (jj_3R_11()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_46() { if (jj_scan_token(MINUS)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_15() { Token xsp; xsp = jj_scanpos; if (jj_3R_19()) { jj_scanpos = xsp; if (jj_3R_20()) 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_45() { if (jj_scan_token(PLUS)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_34() { Token xsp; xsp = jj_scanpos; if (jj_3R_45()) { jj_scanpos = xsp; if (jj_3R_46()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; if (jj_3R_33()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_77() { if (jj_3R_12()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; if (jj_scan_token(LPAREN)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; Token xsp; xsp = jj_scanpos; if (jj_3R_86()) jj_scanpos = xsp; else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; if (jj_scan_token(RPAREN)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_29() { if (jj_3R_33()) 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_3_2() { if (jj_3R_12()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; if (jj_scan_token(LPAREN)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_78() { if (jj_scan_token(IDENTIFIER)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_74() { if (jj_3R_78()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_73() { if (jj_3R_77()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_72() { if (jj_scan_token(LPAREN)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; if (jj_3R_15()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; if (jj_scan_token(RPAREN)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_71() { if (jj_3R_76()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3_3() { if (jj_3R_13()) 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; return false; } final private boolean jj_3R_63() { Token xsp; xsp = jj_scanpos; if (jj_3R_71()) { jj_scanpos = xsp; if (jj_3R_72()) { jj_scanpos = xsp; if (jj_3R_73()) { jj_scanpos = xsp; if (jj_3R_74()) 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; return false; } final private boolean jj_3R_54() { if (jj_scan_token(LE2)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_52() { if (jj_scan_token(GE2)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_50() { if (jj_scan_token(GT2)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_48() { if (jj_scan_token(LT2)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_53() { if (jj_scan_token(LE1)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_16() { if (jj_3R_13()) 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; return false; } final private boolean jj_3R_38() { Token xsp; xsp = jj_scanpos; if (jj_3R_53()) { jj_scanpos = xsp; if (jj_3R_54()) 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_51() { if (jj_scan_token(GE1)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_37() { Token xsp; xsp = jj_scanpos; if (jj_3R_51()) { jj_scanpos = xsp; if (jj_3R_52()) 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_49() { if (jj_scan_token(GT1)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_36() { Token xsp; xsp = jj_scanpos; if (jj_3R_49()) { jj_scanpos = xsp; if (jj_3R_50()) 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(LT1)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_35() { Token xsp; xsp = jj_scanpos; if (jj_3R_47()) { jj_scanpos = xsp; if (jj_3R_48()) 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_12() { Token xsp; xsp = jj_scanpos; if (jj_3R_16()) jj_scanpos = xsp; else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; if (jj_3R_13()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_30() { 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()) 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; if (jj_3R_29()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_25() { if (jj_3R_29()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_30()) { jj_scanpos = xsp; break; } if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; } return false; } final private boolean jj_3R_64() { if (jj_3R_75()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_13() { if (jj_scan_token(IDENTIFIER)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } final private boolean jj_3R_56() { if (jj_3R_63()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_64()) { jj_scanpos = xsp; break; } if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; } return false; } final private boolean jj_3R_93() { if (jj_scan_token(NULL)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } public ELParserTokenManager token_source; SimpleCharStream jj_input_stream; public Token token, jj_nt; private int jj_ntk; private Token jj_scanpos, jj_lastpos; private int jj_la; public boolean lookingAhead = false; private boolean jj_semLA; private int jj_gen; final private int[] jj_la1 = new int[35]; final private int[] jj_la1_0 = {0x6,0x6,0x6,0x20007580,0x0,0x0,0x0,0x0,0x18600000,0x600000,0x18000000,0x18600000,0x79e0000,0x180000,0x60000,0x6000000,0x1800000,0x79e0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10000,0x20007580,0x0,0x80000000,0x20007580,0x10000,0x7580,0x3000,}; final private int[] jj_la1_1 = {0x0,0x0,0x0,0x50c10,0xc000,0xc000,0x3000,0x3000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x18,0x18,0x3e0,0xc0,0x300,0x3e0,0x10c10,0xc00,0x10c10,0x2,0x0,0x40000,0x0,0x50c10,0x2,0x0,0x0,}; final private JJCalls[] jj_2_rtns = new JJCalls[3]; private boolean jj_rescan = false; private int jj_gc = 0; public ELParser(java.io.InputStream stream) { jj_input_stream = new SimpleCharStream(stream, 1, 1); token_source = new ELParserTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 35; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } public void ReInit(java.io.InputStream stream) { jj_input_stream.ReInit(stream, 1, 1); token_source.ReInit(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 35; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } public ELParser(java.io.Reader stream) { jj_input_stream = new SimpleCharStream(stream, 1, 1); token_source = new ELParserTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 35; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } public void ReInit(java.io.Reader stream) { jj_input_stream.ReInit(stream, 1, 1); token_source.ReInit(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 35; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } public ELParser(ELParserTokenManager tm) { token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 35; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } public void ReInit(ELParserTokenManager tm) { token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 35; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } final private Token jj_consume_token(int kind) throws ParseException { Token oldToken; if ((oldToken = token).next != null) token = token.next; else token = token.next = token_source.getNextToken(); jj_ntk = -1; if (token.kind == kind) { jj_gen++; if (++jj_gc > 100) { jj_gc = 0; for (int i = 0; i < jj_2_rtns.length; i++) { JJCalls c = jj_2_rtns[i]; while (c != null) { if (c.gen < jj_gen) c.first = null; c = c.next; } } } return token; } token = oldToken; jj_kind = kind; throw generateParseException(); } final private boolean jj_scan_token(int kind) { if (jj_scanpos == jj_lastpos) { jj_la--; if (jj_scanpos.next == null) { jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken(); } else { jj_lastpos = jj_scanpos = jj_scanpos.next; } } else { jj_scanpos = jj_scanpos.next; } if (jj_rescan) { int i = 0; Token tok = token; while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; } if (tok != null) jj_add_error_token(kind, i); } return (jj_scanpos.kind != kind); } final public Token getNextToken() { if (token.next != null) token = token.next; else token = token.next = token_source.getNextToken(); jj_ntk = -1; jj_gen++; return token; } final public Token getToken(int index) { Token t = lookingAhead ? jj_scanpos : token; for (int i = 0; i < index; i++) { if (t.next != null) t = t.next; else t = t.next = token_source.getNextToken(); } return t; } final private int jj_ntk() { if ((jj_nt=token.next) == null) return (jj_ntk = (token.next=token_source.getNextToken()).kind); else return (jj_ntk = jj_nt.kind); } private java.util.Vector jj_expentries = new java.util.Vector(); private int[] jj_expentry; private int jj_kind = -1; private int[] jj_lasttokens = new int[100]; private int jj_endpos; private void jj_add_error_token(int kind, int pos) { if (pos >= 100) return; if (pos == jj_endpos + 1) { jj_lasttokens[jj_endpos++] = kind; } else if (jj_endpos != 0) { jj_expentry = new int[jj_endpos]; for (int i = 0; i < jj_endpos; i++) { jj_expentry[i] = jj_lasttokens[i]; } boolean exists = false; for (java.util.Enumeration enum = jj_expentries.elements(); enum.hasMoreElements();) { int[] oldentry = (int[])(enum.nextElement()); if (oldentry.length == jj_expentry.length) { exists = true; for (int i = 0; i < jj_expentry.length; i++) { if (oldentry[i] != jj_expentry[i]) { exists = false; break; } } if (exists) break; } } if (!exists) jj_expentries.addElement(jj_expentry); if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind; } } final public ParseException generateParseException() { jj_expentries.removeAllElements(); boolean[] la1tokens = new boolean[55]; for (int i = 0; i < 55; i++) { la1tokens[i] = false; } if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 35; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1< jj_gen) { jj_la = p.arg; jj_lastpos = jj_scanpos = p.first; switch (i) { case 0: jj_3_1(); break; case 1: jj_3_2(); break; case 2: jj_3_3(); break; } } p = p.next; } while (p != null); } jj_rescan = false; } final private void jj_save(int index, int xla) { JJCalls p = jj_2_rtns[index]; while (p.gen > jj_gen) { if (p.next == null) { p = p.next = new JJCalls(); break; } p = p.next; } p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla; } static final class JJCalls { int gen; Token first; int arg; JJCalls next; } } libcommons-el-java-1.0/src/java/org/apache/commons/el/parser/ParseException.java0100644000175000017500000001434507617603701027241 0ustar arnaudarnaud/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 2.1 */ package org.apache.commons.el.parser; /** * This exception is thrown when parse errors are encountered. * You can explicitly create objects of this exception type by * calling the method generateParseException in the generated * parser. * * You can modify this class to customize your error reporting * mechanisms so long as you retain the public fields. */ public class ParseException extends Exception { /** * This constructor is used by the method "generateParseException" * in the generated parser. Calling this constructor generates * a new object of this type with the fields "currentToken", * "expectedTokenSequences", and "tokenImage" set. The boolean * flag "specialConstructor" is also set to true to indicate that * this constructor was used to create this object. * This constructor calls its super class with the empty string * to force the "toString" method of parent class "Throwable" to * print the error message in the form: * ParseException: */ public ParseException(Token currentTokenVal, int[][] expectedTokenSequencesVal, String[] tokenImageVal ) { super(""); specialConstructor = true; currentToken = currentTokenVal; expectedTokenSequences = expectedTokenSequencesVal; tokenImage = tokenImageVal; } /** * The following constructors are for use by you for whatever * purpose you can think of. Constructing the exception in this * manner makes the exception behave in the normal way - i.e., as * documented in the class "Throwable". The fields "errorToken", * "expectedTokenSequences", and "tokenImage" do not contain * relevant information. The JavaCC generated code does not use * these constructors. */ public ParseException() { super(); specialConstructor = false; } public ParseException(String message) { super(message); specialConstructor = false; } /** * This variable determines which constructor was used to create * this object and thereby affects the semantics of the * "getMessage" method (see below). */ protected boolean specialConstructor; /** * This is the last token that has been consumed successfully. If * this object has been created due to a parse error, the token * followng this token will (therefore) be the first error token. */ public Token currentToken; /** * Each entry in this array is an array of integers. Each array * of integers represents a sequence of tokens (by their ordinal * values) that is expected at this point of the parse. */ public int[][] expectedTokenSequences; /** * This is a reference to the "tokenImage" array of the generated * parser within which the parse error occurred. This array is * defined in the generated ...Constants interface. */ public String[] tokenImage; /** * This method has the standard behavior when this object has been * created using the standard constructors. Otherwise, it uses * "currentToken" and "expectedTokenSequences" to generate a parse * error message and returns it. If this object has been created * due to a parse error, and you do not catch it (it gets thrown * from the parser), then this method is called during the printing * of the final stack trace, and hence the correct error message * gets displayed. */ public String getMessage() { if (!specialConstructor) { return super.getMessage(); } String expected = ""; int maxSize = 0; for (int i = 0; i < expectedTokenSequences.length; i++) { if (maxSize < expectedTokenSequences[i].length) { maxSize = expectedTokenSequences[i].length; } for (int j = 0; j < expectedTokenSequences[i].length; j++) { expected += tokenImage[expectedTokenSequences[i][j]] + " "; } if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { expected += "..."; } expected += eol + " "; } String retval = "Encountered \""; Token tok = currentToken.next; for (int i = 0; i < maxSize; i++) { if (i != 0) retval += " "; if (tok.kind == 0) { retval += tokenImage[0]; break; } retval += add_escapes(tok.image); tok = tok.next; } retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn; retval += "." + eol; if (expectedTokenSequences.length == 1) { retval += "Was expecting:" + eol + " "; } else { retval += "Was expecting one of:" + eol + " "; } retval += expected; return retval; } /** * The end of line string for this machine. */ protected String eol = System.getProperty("line.separator", "\n"); /** * Used to convert raw characters to their escaped version * when these raw version cannot be used as part of an ASCII * string literal. */ protected String add_escapes(String str) { StringBuffer retval = new StringBuffer(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { case 0 : continue; case '\b': retval.append("\\b"); continue; case '\t': retval.append("\\t"); continue; case '\n': retval.append("\\n"); continue; case '\f': retval.append("\\f"); continue; case '\r': retval.append("\\r"); continue; case '\"': retval.append("\\\""); continue; case '\'': retval.append("\\\'"); continue; case '\\': retval.append("\\\\"); continue; default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); retval.append("\\u" + s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } continue; } } return retval.toString(); } } libcommons-el-java-1.0/src/java/org/apache/commons/el/parser/ELParserConstants.java0100644000175000017500000000410507641713423027653 0ustar arnaudarnaud/* Generated By:JavaCC: Do not edit this line. ELParserConstants.java */ package org.apache.commons.el.parser; public interface ELParserConstants { int EOF = 0; int NON_EXPRESSION_TEXT = 1; int START_EXPRESSION = 2; int INTEGER_LITERAL = 7; int FLOATING_POINT_LITERAL = 8; int EXPONENT = 9; int STRING_LITERAL = 10; int BADLY_ESCAPED_STRING_LITERAL = 11; int TRUE = 12; int FALSE = 13; int NULL = 14; int END_EXPRESSION = 15; int DOT = 16; int GT1 = 17; int GT2 = 18; int LT1 = 19; int LT2 = 20; int EQ1 = 21; int EQ2 = 22; int LE1 = 23; int LE2 = 24; int GE1 = 25; int GE2 = 26; int NE1 = 27; int NE2 = 28; int LPAREN = 29; int RPAREN = 30; int COMMA = 31; int COLON = 32; int LBRACKET = 33; int RBRACKET = 34; int PLUS = 35; int MINUS = 36; int MULTIPLY = 37; int DIVIDE1 = 38; int DIVIDE2 = 39; int MODULUS1 = 40; int MODULUS2 = 41; int NOT1 = 42; int NOT2 = 43; int AND1 = 44; int AND2 = 45; int OR1 = 46; int OR2 = 47; int EMPTY = 48; int COND = 49; int IDENTIFIER = 50; int IMPL_OBJ_START = 51; int LETTER = 52; int DIGIT = 53; int ILLEGAL_CHARACTER = 54; int DEFAULT = 0; int IN_EXPRESSION = 1; String[] tokenImage = { "", "", "\"${\"", "\" \"", "\"\\t\"", "\"\\n\"", "\"\\r\"", "", "", "", "", "", "\"true\"", "\"false\"", "\"null\"", "\"}\"", "\".\"", "\">\"", "\"gt\"", "\"<\"", "\"lt\"", "\"==\"", "\"eq\"", "\"<=\"", "\"le\"", "\">=\"", "\"ge\"", "\"!=\"", "\"ne\"", "\"(\"", "\")\"", "\",\"", "\":\"", "\"[\"", "\"]\"", "\"+\"", "\"-\"", "\"*\"", "\"/\"", "\"div\"", "\"%\"", "\"mod\"", "\"not\"", "\"!\"", "\"and\"", "\"&&\"", "\"or\"", "\"||\"", "\"empty\"", "\"?\"", "", "\"#\"", "", "", "", }; } libcommons-el-java-1.0/src/java/org/apache/commons/el/parser/ELParserTokenManager.java0100644000175000017500000007524507641713423030267 0ustar arnaudarnaud/* Generated By:JavaCC: Do not edit this line. ELParserTokenManager.java */ package org.apache.commons.el.parser; import org.apache.commons.el.*; import java.util.ArrayList; import java.util.List; public class ELParserTokenManager implements ELParserConstants { public java.io.PrintStream debugStream = System.out; public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } private final int jjStopStringLiteralDfa_0(int pos, long active0) { switch (pos) { case 0: if ((active0 & 0x4L) != 0L) { jjmatchedKind = 1; return 2; } return -1; default : return -1; } } private final int jjStartNfa_0(int pos, long active0) { return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1); } private final int jjStopAtPos(int pos, int kind) { jjmatchedKind = kind; jjmatchedPos = pos; return pos + 1; } private final int jjStartNfaWithStates_0(int pos, int kind, int state) { jjmatchedKind = kind; jjmatchedPos = pos; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return pos + 1; } return jjMoveNfa_0(state, pos + 1); } private final int jjMoveStringLiteralDfa0_0() { switch(curChar) { case 36: return jjMoveStringLiteralDfa1_0(0x4L); default : return jjMoveNfa_0(1, 0); } } private final int jjMoveStringLiteralDfa1_0(long active0) { try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(0, active0); return 1; } switch(curChar) { case 123: if ((active0 & 0x4L) != 0L) return jjStopAtPos(1, 2); break; default : break; } return jjStartNfa_0(0, active0); } private final void jjCheckNAdd(int state) { if (jjrounds[state] != jjround) { jjstateSet[jjnewStateCnt++] = state; jjrounds[state] = jjround; } } private final void jjAddStates(int start, int end) { do { jjstateSet[jjnewStateCnt++] = jjnextStates[start]; } while (start++ != end); } private final void jjCheckNAddTwoStates(int state1, int state2) { jjCheckNAdd(state1); jjCheckNAdd(state2); } private final void jjCheckNAddStates(int start, int end) { do { jjCheckNAdd(jjnextStates[start]); } while (start++ != end); } private final void jjCheckNAddStates(int start) { jjCheckNAdd(jjnextStates[start]); jjCheckNAdd(jjnextStates[start + 1]); } static final long[] jjbitVec0 = { 0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL }; static final long[] jjbitVec2 = { 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL }; private final int jjMoveNfa_0(int startState, int curPos) { int[] nextStates; int startsAt = 0; jjnewStateCnt = 3; int i = 1; jjstateSet[0] = startState; int j, kind = 0x7fffffff; for (;;) { if (++jjround == 0x7fffffff) ReInitRounds(); if (curChar < 64) { long l = 1L << curChar; MatchLoop: do { switch(jjstateSet[--i]) { case 1: if ((0xffffffefffffffffL & l) != 0L) { if (kind > 1) kind = 1; jjCheckNAdd(0); } else if (curChar == 36) { if (kind > 1) kind = 1; jjCheckNAdd(2); } break; case 0: if ((0xffffffefffffffffL & l) == 0L) break; if (kind > 1) kind = 1; jjCheckNAdd(0); break; case 2: if ((0xffffffefffffffffL & l) == 0L) break; if (kind > 1) kind = 1; jjCheckNAdd(2); break; default : break; } } while(i != startsAt); } else if (curChar < 128) { long l = 1L << (curChar & 077); MatchLoop: do { switch(jjstateSet[--i]) { case 1: case 0: if (kind > 1) kind = 1; jjCheckNAdd(0); break; case 2: if ((0xf7ffffffffffffffL & l) == 0L) break; if (kind > 1) kind = 1; jjstateSet[jjnewStateCnt++] = 2; break; default : break; } } while(i != startsAt); } else { int hiByte = (int)(curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; long l2 = 1L << (curChar & 077); MatchLoop: do { switch(jjstateSet[--i]) { case 1: case 0: if (!jjCanMove_0(hiByte, i1, i2, l1, l2)) break; if (kind > 1) kind = 1; jjCheckNAdd(0); break; case 2: if (!jjCanMove_0(hiByte, i1, i2, l1, l2)) break; if (kind > 1) kind = 1; jjstateSet[jjnewStateCnt++] = 2; break; default : break; } } while(i != startsAt); } if (kind != 0x7fffffff) { jjmatchedKind = kind; jjmatchedPos = curPos; kind = 0x7fffffff; } ++curPos; if ((i = jjnewStateCnt) == (startsAt = 3 - (jjnewStateCnt = startsAt))) return curPos; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return curPos; } } } private final int jjStopStringLiteralDfa_1(int pos, long active0) { switch (pos) { case 0: if ((active0 & 0x10000L) != 0L) return 1; if ((active0 & 0x1568015547000L) != 0L) { jjmatchedKind = 50; return 6; } return -1; case 1: if ((active0 & 0x400015540000L) != 0L) return 6; if ((active0 & 0x1168000007000L) != 0L) { jjmatchedKind = 50; jjmatchedPos = 1; return 6; } return -1; case 2: if ((active0 & 0x168000000000L) != 0L) return 6; if ((active0 & 0x1000000007000L) != 0L) { jjmatchedKind = 50; jjmatchedPos = 2; return 6; } return -1; case 3: if ((active0 & 0x1000000002000L) != 0L) { jjmatchedKind = 50; jjmatchedPos = 3; return 6; } if ((active0 & 0x5000L) != 0L) return 6; return -1; default : return -1; } } private final int jjStartNfa_1(int pos, long active0) { return jjMoveNfa_1(jjStopStringLiteralDfa_1(pos, active0), pos + 1); } private final int jjStartNfaWithStates_1(int pos, int kind, int state) { jjmatchedKind = kind; jjmatchedPos = pos; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return pos + 1; } return jjMoveNfa_1(state, pos + 1); } private final int jjMoveStringLiteralDfa0_1() { switch(curChar) { case 33: jjmatchedKind = 43; return jjMoveStringLiteralDfa1_1(0x8000000L); case 37: return jjStopAtPos(0, 40); case 38: return jjMoveStringLiteralDfa1_1(0x200000000000L); case 40: return jjStopAtPos(0, 29); case 41: return jjStopAtPos(0, 30); case 42: return jjStopAtPos(0, 37); case 43: return jjStopAtPos(0, 35); case 44: return jjStopAtPos(0, 31); case 45: return jjStopAtPos(0, 36); case 46: return jjStartNfaWithStates_1(0, 16, 1); case 47: return jjStopAtPos(0, 38); case 58: return jjStopAtPos(0, 32); case 60: jjmatchedKind = 19; return jjMoveStringLiteralDfa1_1(0x800000L); case 61: return jjMoveStringLiteralDfa1_1(0x200000L); case 62: jjmatchedKind = 17; return jjMoveStringLiteralDfa1_1(0x2000000L); case 63: return jjStopAtPos(0, 49); case 91: return jjStopAtPos(0, 33); case 93: return jjStopAtPos(0, 34); case 97: return jjMoveStringLiteralDfa1_1(0x100000000000L); case 100: return jjMoveStringLiteralDfa1_1(0x8000000000L); case 101: return jjMoveStringLiteralDfa1_1(0x1000000400000L); case 102: return jjMoveStringLiteralDfa1_1(0x2000L); case 103: return jjMoveStringLiteralDfa1_1(0x4040000L); case 108: return jjMoveStringLiteralDfa1_1(0x1100000L); case 109: return jjMoveStringLiteralDfa1_1(0x20000000000L); case 110: return jjMoveStringLiteralDfa1_1(0x40010004000L); case 111: return jjMoveStringLiteralDfa1_1(0x400000000000L); case 116: return jjMoveStringLiteralDfa1_1(0x1000L); case 124: return jjMoveStringLiteralDfa1_1(0x800000000000L); case 125: return jjStopAtPos(0, 15); default : return jjMoveNfa_1(0, 0); } } private final int jjMoveStringLiteralDfa1_1(long active0) { try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_1(0, active0); return 1; } switch(curChar) { case 38: if ((active0 & 0x200000000000L) != 0L) return jjStopAtPos(1, 45); break; case 61: if ((active0 & 0x200000L) != 0L) return jjStopAtPos(1, 21); else if ((active0 & 0x800000L) != 0L) return jjStopAtPos(1, 23); else if ((active0 & 0x2000000L) != 0L) return jjStopAtPos(1, 25); else if ((active0 & 0x8000000L) != 0L) return jjStopAtPos(1, 27); break; case 97: return jjMoveStringLiteralDfa2_1(active0, 0x2000L); case 101: if ((active0 & 0x1000000L) != 0L) return jjStartNfaWithStates_1(1, 24, 6); else if ((active0 & 0x4000000L) != 0L) return jjStartNfaWithStates_1(1, 26, 6); else if ((active0 & 0x10000000L) != 0L) return jjStartNfaWithStates_1(1, 28, 6); break; case 105: return jjMoveStringLiteralDfa2_1(active0, 0x8000000000L); case 109: return jjMoveStringLiteralDfa2_1(active0, 0x1000000000000L); case 110: return jjMoveStringLiteralDfa2_1(active0, 0x100000000000L); case 111: return jjMoveStringLiteralDfa2_1(active0, 0x60000000000L); case 113: if ((active0 & 0x400000L) != 0L) return jjStartNfaWithStates_1(1, 22, 6); break; case 114: if ((active0 & 0x400000000000L) != 0L) return jjStartNfaWithStates_1(1, 46, 6); return jjMoveStringLiteralDfa2_1(active0, 0x1000L); case 116: if ((active0 & 0x40000L) != 0L) return jjStartNfaWithStates_1(1, 18, 6); else if ((active0 & 0x100000L) != 0L) return jjStartNfaWithStates_1(1, 20, 6); break; case 117: return jjMoveStringLiteralDfa2_1(active0, 0x4000L); case 124: if ((active0 & 0x800000000000L) != 0L) return jjStopAtPos(1, 47); break; default : break; } return jjStartNfa_1(0, active0); } private final int jjMoveStringLiteralDfa2_1(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_1(0, old0); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_1(1, active0); return 2; } switch(curChar) { case 100: if ((active0 & 0x20000000000L) != 0L) return jjStartNfaWithStates_1(2, 41, 6); else if ((active0 & 0x100000000000L) != 0L) return jjStartNfaWithStates_1(2, 44, 6); break; case 108: return jjMoveStringLiteralDfa3_1(active0, 0x6000L); case 112: return jjMoveStringLiteralDfa3_1(active0, 0x1000000000000L); case 116: if ((active0 & 0x40000000000L) != 0L) return jjStartNfaWithStates_1(2, 42, 6); break; case 117: return jjMoveStringLiteralDfa3_1(active0, 0x1000L); case 118: if ((active0 & 0x8000000000L) != 0L) return jjStartNfaWithStates_1(2, 39, 6); break; default : break; } return jjStartNfa_1(1, active0); } private final int jjMoveStringLiteralDfa3_1(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_1(1, old0); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_1(2, active0); return 3; } switch(curChar) { case 101: if ((active0 & 0x1000L) != 0L) return jjStartNfaWithStates_1(3, 12, 6); break; case 108: if ((active0 & 0x4000L) != 0L) return jjStartNfaWithStates_1(3, 14, 6); break; case 115: return jjMoveStringLiteralDfa4_1(active0, 0x2000L); case 116: return jjMoveStringLiteralDfa4_1(active0, 0x1000000000000L); default : break; } return jjStartNfa_1(2, active0); } private final int jjMoveStringLiteralDfa4_1(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_1(2, old0); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_1(3, active0); return 4; } switch(curChar) { case 101: if ((active0 & 0x2000L) != 0L) return jjStartNfaWithStates_1(4, 13, 6); break; case 121: if ((active0 & 0x1000000000000L) != 0L) return jjStartNfaWithStates_1(4, 48, 6); break; default : break; } return jjStartNfa_1(3, active0); } static final long[] jjbitVec3 = { 0x1ff00000fffffffeL, 0xffffffffffffc000L, 0xffffffffL, 0x600000000000000L }; static final long[] jjbitVec4 = { 0x0L, 0x0L, 0x0L, 0xff7fffffff7fffffL }; static final long[] jjbitVec5 = { 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL }; static final long[] jjbitVec6 = { 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffL, 0x0L }; static final long[] jjbitVec7 = { 0xffffffffffffffffL, 0xffffffffffffffffL, 0x0L, 0x0L }; static final long[] jjbitVec8 = { 0x3fffffffffffL, 0x0L, 0x0L, 0x0L }; private final int jjMoveNfa_1(int startState, int curPos) { int[] nextStates; int startsAt = 0; jjnewStateCnt = 35; int i = 1; jjstateSet[0] = startState; int j, kind = 0x7fffffff; for (;;) { if (++jjround == 0x7fffffff) ReInitRounds(); if (curChar < 64) { long l = 1L << curChar; MatchLoop: do { switch(jjstateSet[--i]) { case 0: if ((0x3ff000000000000L & l) != 0L) { if (kind > 7) kind = 7; jjCheckNAddStates(0, 4); } else if ((0x1800000000L & l) != 0L) { if (kind > 50) kind = 50; jjCheckNAdd(6); } else if (curChar == 39) jjCheckNAddStates(5, 9); else if (curChar == 34) jjCheckNAddStates(10, 14); else if (curChar == 46) jjCheckNAdd(1); break; case 1: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 8) kind = 8; jjCheckNAddTwoStates(1, 2); break; case 3: if ((0x280000000000L & l) != 0L) jjCheckNAdd(4); break; case 4: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 8) kind = 8; jjCheckNAdd(4); break; case 5: if ((0x1800000000L & l) == 0L) break; if (kind > 50) kind = 50; jjCheckNAdd(6); break; case 6: if ((0x3ff001000000000L & l) == 0L) break; if (kind > 50) kind = 50; jjCheckNAdd(6); break; case 7: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 7) kind = 7; jjCheckNAddStates(0, 4); break; case 8: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 7) kind = 7; jjCheckNAdd(8); break; case 9: if ((0x3ff000000000000L & l) != 0L) jjCheckNAddTwoStates(9, 10); break; case 10: if (curChar != 46) break; if (kind > 8) kind = 8; jjCheckNAddTwoStates(11, 12); break; case 11: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 8) kind = 8; jjCheckNAddTwoStates(11, 12); break; case 13: if ((0x280000000000L & l) != 0L) jjCheckNAdd(14); break; case 14: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 8) kind = 8; jjCheckNAdd(14); break; case 15: if ((0x3ff000000000000L & l) != 0L) jjCheckNAddTwoStates(15, 16); break; case 17: if ((0x280000000000L & l) != 0L) jjCheckNAdd(18); break; case 18: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 8) kind = 8; jjCheckNAdd(18); break; case 19: if (curChar == 34) jjCheckNAddStates(10, 14); break; case 20: if ((0xfffffffbffffffffL & l) != 0L) jjCheckNAddStates(15, 17); break; case 22: if (curChar == 34) jjCheckNAddStates(15, 17); break; case 23: if (curChar == 34 && kind > 10) kind = 10; break; case 24: if ((0xfffffffbffffffffL & l) != 0L) jjCheckNAddTwoStates(24, 25); break; case 26: if ((0xfffffffbffffffffL & l) != 0L && kind > 11) kind = 11; break; case 27: if (curChar == 39) jjCheckNAddStates(5, 9); break; case 28: if ((0xffffff7fffffffffL & l) != 0L) jjCheckNAddStates(18, 20); break; case 30: if (curChar == 39) jjCheckNAddStates(18, 20); break; case 31: if (curChar == 39 && kind > 10) kind = 10; break; case 32: if ((0xffffff7fffffffffL & l) != 0L) jjCheckNAddTwoStates(32, 33); break; case 34: if ((0xffffff7fffffffffL & l) != 0L && kind > 11) kind = 11; break; default : break; } } while(i != startsAt); } else if (curChar < 128) { long l = 1L << (curChar & 077); MatchLoop: do { switch(jjstateSet[--i]) { case 0: case 6: if ((0x7fffffe87fffffeL & l) == 0L) break; if (kind > 50) kind = 50; jjCheckNAdd(6); break; case 2: if ((0x2000000020L & l) != 0L) jjAddStates(21, 22); break; case 12: if ((0x2000000020L & l) != 0L) jjAddStates(23, 24); break; case 16: if ((0x2000000020L & l) != 0L) jjAddStates(25, 26); break; case 20: if ((0xffffffffefffffffL & l) != 0L) jjCheckNAddStates(15, 17); break; case 21: if (curChar == 92) jjstateSet[jjnewStateCnt++] = 22; break; case 22: if (curChar == 92) jjCheckNAddStates(15, 17); break; case 24: if ((0xffffffffefffffffL & l) != 0L) jjAddStates(27, 28); break; case 25: if (curChar == 92) jjstateSet[jjnewStateCnt++] = 26; break; case 26: case 34: if ((0xffffffffefffffffL & l) != 0L && kind > 11) kind = 11; break; case 28: if ((0xffffffffefffffffL & l) != 0L) jjCheckNAddStates(18, 20); break; case 29: if (curChar == 92) jjstateSet[jjnewStateCnt++] = 30; break; case 30: if (curChar == 92) jjCheckNAddStates(18, 20); break; case 32: if ((0xffffffffefffffffL & l) != 0L) jjAddStates(29, 30); break; case 33: if (curChar == 92) jjstateSet[jjnewStateCnt++] = 34; break; default : break; } } while(i != startsAt); } else { int hiByte = (int)(curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; long l2 = 1L << (curChar & 077); MatchLoop: do { switch(jjstateSet[--i]) { case 0: case 6: if (!jjCanMove_1(hiByte, i1, i2, l1, l2)) break; if (kind > 50) kind = 50; jjCheckNAdd(6); break; case 20: if (jjCanMove_0(hiByte, i1, i2, l1, l2)) jjAddStates(15, 17); break; case 24: if (jjCanMove_0(hiByte, i1, i2, l1, l2)) jjAddStates(27, 28); break; case 26: case 34: if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 11) kind = 11; break; case 28: if (jjCanMove_0(hiByte, i1, i2, l1, l2)) jjAddStates(18, 20); break; case 32: if (jjCanMove_0(hiByte, i1, i2, l1, l2)) jjAddStates(29, 30); break; default : break; } } while(i != startsAt); } if (kind != 0x7fffffff) { jjmatchedKind = kind; jjmatchedPos = curPos; kind = 0x7fffffff; } ++curPos; if ((i = jjnewStateCnt) == (startsAt = 35 - (jjnewStateCnt = startsAt))) return curPos; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return curPos; } } } static final int[] jjnextStates = { 8, 9, 10, 15, 16, 28, 29, 31, 32, 33, 20, 21, 23, 24, 25, 20, 21, 23, 28, 29, 31, 3, 4, 13, 14, 17, 18, 24, 25, 32, 33, }; private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2) { switch(hiByte) { case 0: return ((jjbitVec2[i2] & l2) != 0L); default : if ((jjbitVec0[i1] & l1) != 0L) return true; return false; } } private static final boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, long l2) { switch(hiByte) { case 0: return ((jjbitVec4[i2] & l2) != 0L); case 48: return ((jjbitVec5[i2] & l2) != 0L); case 49: return ((jjbitVec6[i2] & l2) != 0L); case 51: return ((jjbitVec7[i2] & l2) != 0L); case 61: return ((jjbitVec8[i2] & l2) != 0L); default : if ((jjbitVec3[i1] & l1) != 0L) return true; return false; } } public static final String[] jjstrLiteralImages = { "", null, "\44\173", null, null, null, null, null, null, null, null, null, "\164\162\165\145", "\146\141\154\163\145", "\156\165\154\154", "\175", "\56", "\76", "\147\164", "\74", "\154\164", "\75\75", "\145\161", "\74\75", "\154\145", "\76\75", "\147\145", "\41\75", "\156\145", "\50", "\51", "\54", "\72", "\133", "\135", "\53", "\55", "\52", "\57", "\144\151\166", "\45", "\155\157\144", "\156\157\164", "\41", "\141\156\144", "\46\46", "\157\162", "\174\174", "\145\155\160\164\171", "\77", null, null, null, null, null, }; public static final String[] lexStateNames = { "DEFAULT", "IN_EXPRESSION", }; public static final int[] jjnewLexState = { -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }; static final long[] jjtoToken = { 0x47fffffffffd87L, }; static final long[] jjtoSkip = { 0x78L, }; private SimpleCharStream input_stream; private final int[] jjrounds = new int[35]; private final int[] jjstateSet = new int[70]; protected char curChar; public ELParserTokenManager(SimpleCharStream stream) { if (SimpleCharStream.staticFlag) throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); input_stream = stream; } public ELParserTokenManager(SimpleCharStream stream, int lexState) { this(stream); SwitchTo(lexState); } public void ReInit(SimpleCharStream stream) { jjmatchedPos = jjnewStateCnt = 0; curLexState = defaultLexState; input_stream = stream; ReInitRounds(); } private final void ReInitRounds() { int i; jjround = 0x80000001; for (i = 35; i-- > 0;) jjrounds[i] = 0x80000000; } public void ReInit(SimpleCharStream stream, int lexState) { ReInit(stream); SwitchTo(lexState); } public void SwitchTo(int lexState) { if (lexState >= 2 || lexState < 0) throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); else curLexState = lexState; } private final Token jjFillToken() { Token t = Token.newToken(jjmatchedKind); t.kind = jjmatchedKind; String im = jjstrLiteralImages[jjmatchedKind]; t.image = (im == null) ? input_stream.GetImage() : im; t.beginLine = input_stream.getBeginLine(); t.beginColumn = input_stream.getBeginColumn(); t.endLine = input_stream.getEndLine(); t.endColumn = input_stream.getEndColumn(); return t; } int curLexState = 0; int defaultLexState = 0; int jjnewStateCnt; int jjround; int jjmatchedPos; int jjmatchedKind; public final Token getNextToken() { int kind; Token specialToken = null; Token matchedToken; int curPos = 0; EOFLoop : for (;;) { try { curChar = input_stream.BeginToken(); } catch(java.io.IOException e) { jjmatchedKind = 0; matchedToken = jjFillToken(); return matchedToken; } switch(curLexState) { case 0: jjmatchedKind = 0x7fffffff; jjmatchedPos = 0; curPos = jjMoveStringLiteralDfa0_0(); break; case 1: try { input_stream.backup(0); while (curChar <= 32 && (0x100002600L & (1L << curChar)) != 0L) curChar = input_stream.BeginToken(); } catch (java.io.IOException e1) { continue EOFLoop; } jjmatchedKind = 0x7fffffff; jjmatchedPos = 0; curPos = jjMoveStringLiteralDfa0_1(); if (jjmatchedPos == 0 && jjmatchedKind > 54) { jjmatchedKind = 54; } break; } if (jjmatchedKind != 0x7fffffff) { if (jjmatchedPos + 1 < curPos) input_stream.backup(curPos - jjmatchedPos - 1); if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) { matchedToken = jjFillToken(); if (jjnewLexState[jjmatchedKind] != -1) curLexState = jjnewLexState[jjmatchedKind]; return matchedToken; } else { if (jjnewLexState[jjmatchedKind] != -1) curLexState = jjnewLexState[jjmatchedKind]; continue EOFLoop; } } int error_line = input_stream.getEndLine(); int error_column = input_stream.getEndColumn(); String error_after = null; boolean EOFSeen = false; try { input_stream.readChar(); input_stream.backup(1); } catch (java.io.IOException e1) { EOFSeen = true; error_after = curPos <= 1 ? "" : input_stream.GetImage(); if (curChar == '\n' || curChar == '\r') { error_line++; error_column = 0; } else error_column++; } if (!EOFSeen) { input_stream.backup(1); error_after = curPos <= 1 ? "" : input_stream.GetImage(); } throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); } } } libcommons-el-java-1.0/src/java/org/apache/commons/el/parser/SimpleCharStream.java0100644000175000017500000002300607617603701027505 0ustar arnaudarnaud/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 2.1 */ package org.apache.commons.el.parser; /** * An implementation of interface CharStream, where the stream is assumed to * contain only ASCII characters (without unicode processing). */ public final class SimpleCharStream { public static final boolean staticFlag = false; int bufsize; int available; int tokenBegin; public int bufpos = -1; private int bufline[]; private int bufcolumn[]; private int column = 0; private int line = 1; private boolean prevCharIsCR = false; private boolean prevCharIsLF = false; private java.io.Reader inputStream; private char[] buffer; private int maxNextCharInd = 0; private int inBuf = 0; private final void ExpandBuff(boolean wrapAround) { char[] newbuffer = new char[bufsize + 2048]; int newbufline[] = new int[bufsize + 2048]; int newbufcolumn[] = new int[bufsize + 2048]; try { if (wrapAround) { System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos); buffer = newbuffer; System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); bufline = newbufline; System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); bufcolumn = newbufcolumn; maxNextCharInd = (bufpos += (bufsize - tokenBegin)); } else { System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); buffer = newbuffer; System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); bufline = newbufline; System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); bufcolumn = newbufcolumn; maxNextCharInd = (bufpos -= tokenBegin); } } catch (Throwable t) { throw new Error(t.getMessage()); } bufsize += 2048; available = bufsize; tokenBegin = 0; } private final void FillBuff() throws java.io.IOException { if (maxNextCharInd == available) { if (available == bufsize) { if (tokenBegin > 2048) { bufpos = maxNextCharInd = 0; available = tokenBegin; } else if (tokenBegin < 0) bufpos = maxNextCharInd = 0; else ExpandBuff(false); } else if (available > tokenBegin) available = bufsize; else if ((tokenBegin - available) < 2048) ExpandBuff(true); else available = tokenBegin; } int i; try { if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1) { inputStream.close(); throw new java.io.IOException(); } else maxNextCharInd += i; return; } catch(java.io.IOException e) { --bufpos; backup(0); if (tokenBegin == -1) tokenBegin = bufpos; throw e; } } public final char BeginToken() throws java.io.IOException { tokenBegin = -1; char c = readChar(); tokenBegin = bufpos; return c; } private final void UpdateLineColumn(char c) { column++; if (prevCharIsLF) { prevCharIsLF = false; line += (column = 1); } else if (prevCharIsCR) { prevCharIsCR = false; if (c == '\n') { prevCharIsLF = true; } else line += (column = 1); } switch (c) { case '\r' : prevCharIsCR = true; break; case '\n' : prevCharIsLF = true; break; case '\t' : column--; column += (8 - (column & 07)); break; default : break; } bufline[bufpos] = line; bufcolumn[bufpos] = column; } public final char readChar() throws java.io.IOException { if (inBuf > 0) { --inBuf; if (++bufpos == bufsize) bufpos = 0; return buffer[bufpos]; } if (++bufpos >= maxNextCharInd) FillBuff(); char c = buffer[bufpos]; UpdateLineColumn(c); return (c); } /** * @deprecated * @see #getEndColumn */ public final int getColumn() { return bufcolumn[bufpos]; } /** * @deprecated * @see #getEndLine */ public final int getLine() { return bufline[bufpos]; } public final int getEndColumn() { return bufcolumn[bufpos]; } public final int getEndLine() { return bufline[bufpos]; } public final int getBeginColumn() { return bufcolumn[tokenBegin]; } public final int getBeginLine() { return bufline[tokenBegin]; } public final void backup(int amount) { inBuf += amount; if ((bufpos -= amount) < 0) bufpos += bufsize; } public SimpleCharStream(java.io.Reader dstream, int startline, int startcolumn, int buffersize) { inputStream = dstream; line = startline; column = startcolumn - 1; available = bufsize = buffersize; buffer = new char[buffersize]; bufline = new int[buffersize]; bufcolumn = new int[buffersize]; } public SimpleCharStream(java.io.Reader dstream, int startline, int startcolumn) { this(dstream, startline, startcolumn, 4096); } public SimpleCharStream(java.io.Reader dstream) { this(dstream, 1, 1, 4096); } public void ReInit(java.io.Reader dstream, int startline, int startcolumn, int buffersize) { inputStream = dstream; line = startline; column = startcolumn - 1; if (buffer == null || buffersize != buffer.length) { available = bufsize = buffersize; buffer = new char[buffersize]; bufline = new int[buffersize]; bufcolumn = new int[buffersize]; } prevCharIsLF = prevCharIsCR = false; tokenBegin = inBuf = maxNextCharInd = 0; bufpos = -1; } public void ReInit(java.io.Reader dstream, int startline, int startcolumn) { ReInit(dstream, startline, startcolumn, 4096); } public void ReInit(java.io.Reader dstream) { ReInit(dstream, 1, 1, 4096); } public SimpleCharStream(java.io.InputStream dstream, int startline, int startcolumn, int buffersize) { this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); } public SimpleCharStream(java.io.InputStream dstream, int startline, int startcolumn) { this(dstream, startline, startcolumn, 4096); } public SimpleCharStream(java.io.InputStream dstream) { this(dstream, 1, 1, 4096); } public void ReInit(java.io.InputStream dstream, int startline, int startcolumn, int buffersize) { ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); } public void ReInit(java.io.InputStream dstream) { ReInit(dstream, 1, 1, 4096); } public void ReInit(java.io.InputStream dstream, int startline, int startcolumn) { ReInit(dstream, startline, startcolumn, 4096); } public final String GetImage() { if (bufpos >= tokenBegin) return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); else return new String(buffer, tokenBegin, bufsize - tokenBegin) + new String(buffer, 0, bufpos + 1); } public final char[] GetSuffix(int len) { char[] ret = new char[len]; if ((bufpos + 1) >= len) System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); else { System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, len - bufpos - 1); System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); } return ret; } public void Done() { buffer = null; bufline = null; bufcolumn = null; } /** * Method to adjust line and column numbers for the start of a token.
*/ public void adjustBeginLineColumn(int newLine, int newCol) { int start = tokenBegin; int len; if (bufpos >= tokenBegin) { len = bufpos - tokenBegin + inBuf + 1; } else { len = bufsize - tokenBegin + bufpos + 1 + inBuf; } int i = 0, j = 0, k = 0; int nextColDiff = 0, columnDiff = 0; while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) { bufline[j] = newLine; nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; bufcolumn[j] = newCol + columnDiff; columnDiff = nextColDiff; i++; } if (i < len) { bufline[j] = newLine++; bufcolumn[j] = newCol + columnDiff; while (i++ < len) { if (bufline[j = start % bufsize] != bufline[++start % bufsize]) bufline[j] = newLine++; else bufline[j] = newLine; } } line = bufline[j]; column = bufcolumn[j]; } } libcommons-el-java-1.0/src/java/org/apache/commons/el/parser/Token.java0100644000175000017500000000517107617603701025365 0ustar arnaudarnaud/* Generated By:JavaCC: Do not edit this line. Token.java Version 2.1 */ package org.apache.commons.el.parser; /** * Describes the input token stream. */ public class Token { /** * An integer that describes the kind of this token. This numbering * system is determined by JavaCCParser, and a table of these numbers is * stored in the file ...Constants.java. */ public int kind; /** * beginLine and beginColumn describe the position of the first character * of this token; endLine and endColumn describe the position of the * last character of this token. */ public int beginLine, beginColumn, endLine, endColumn; /** * The string image of the token. */ public String image; /** * A reference to the next regular (non-special) token from the input * stream. If this is the last token from the input stream, or if the * token manager has not read tokens beyond this one, this field is * set to null. This is true only if this token is also a regular * token. Otherwise, see below for a description of the contents of * this field. */ public Token next; /** * This field is used to access special tokens that occur prior to this * token, but after the immediately preceding regular (non-special) token. * If there are no such special tokens, this field is set to null. * When there are more than one such special token, this field refers * to the last of these special tokens, which in turn refers to the next * previous special token through its specialToken field, and so on * until the first special token (whose specialToken field is null). * The next fields of special tokens refer to other special tokens that * immediately follow it (without an intervening regular token). If there * is no such token, this field is null. */ public Token specialToken; /** * Returns the image. */ public final String toString() { return image; } /** * Returns a new Token object, by default. However, if you want, you * can create and return subclass objects based on the value of ofKind. * Simply add the cases to the switch for all those special cases. * For example, if you have a subclass of Token called IDToken that * you want to create if ofKind is ID, simlpy add something like : * * case MyParserConstants.ID : return new IDToken(); * * to the following switch statement. Then you can cast matchedToken * variable to the appropriate type and use it in your lexical actions. */ public static final Token newToken(int ofKind) { switch(ofKind) { default : return new Token(); } } } libcommons-el-java-1.0/src/java/org/apache/commons/el/parser/TokenMgrError.java0100644000175000017500000001017707617603701027047 0ustar arnaudarnaud/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 2.1 */ package org.apache.commons.el.parser; public class TokenMgrError extends Error { /* * Ordinals for various reasons why an Error of this type can be thrown. */ /** * Lexical error occured. */ static final int LEXICAL_ERROR = 0; /** * An attempt wass made to create a second instance of a static token manager. */ static final int STATIC_LEXER_ERROR = 1; /** * Tried to change to an invalid lexical state. */ static final int INVALID_LEXICAL_STATE = 2; /** * Detected (and bailed out of) an infinite loop in the token manager. */ static final int LOOP_DETECTED = 3; /** * Indicates the reason why the exception is thrown. It will have * one of the above 4 values. */ int errorCode; /** * Replaces unprintable characters by their espaced (or unicode escaped) * equivalents in the given string */ protected static final String addEscapes(String str) { StringBuffer retval = new StringBuffer(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { case 0 : continue; case '\b': retval.append("\\b"); continue; case '\t': retval.append("\\t"); continue; case '\n': retval.append("\\n"); continue; case '\f': retval.append("\\f"); continue; case '\r': retval.append("\\r"); continue; case '\"': retval.append("\\\""); continue; case '\'': retval.append("\\\'"); continue; case '\\': retval.append("\\\\"); continue; default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); retval.append("\\u" + s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } continue; } } return retval.toString(); } /** * Returns a detailed message for the Error when it is thrown by the * token manager to indicate a lexical error. * Parameters : * EOFSeen : indicates if EOF caused the lexicl error * curLexState : lexical state in which this error occured * errorLine : line number when the error occured * errorColumn : column number when the error occured * errorAfter : prefix that was seen before this error occured * curchar : the offending character * Note: You can customize the lexical error message by modifying this method. */ private static final String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { return("Lexical error at line " + errorLine + ", column " + errorColumn + ". Encountered: " + (EOFSeen ? " " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + "after : \"" + addEscapes(errorAfter) + "\""); } /** * You can also modify the body of this method to customize your error messages. * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not * of end-users concern, so you can return something like : * * "Internal Error : Please file a bug report .... " * * from this method for such cases in the release version of your parser. */ public String getMessage() { return super.getMessage(); } /* * Constructors of various flavors follow. */ public TokenMgrError() { } public TokenMgrError(String message, int reason) { super(message); errorCode = reason; } public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); } } libcommons-el-java-1.0/src/java/org/apache/commons/el/ValueSuffix.java0100644000175000017500000000711407642104426025247 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import javax.servlet.jsp.el.ELException; import javax.servlet.jsp.el.VariableResolver; import javax.servlet.jsp.el.FunctionMapper; /** * *

Represents an element that can appear as a suffix in a complex * value, such as a property or index operator, or a method call (should * they ever need to be supported). * * @author Nathan Abramson - Art Technology Group * @author Shawn Bayern * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public abstract class ValueSuffix { //------------------------------------- /** * * Returns the expression in the expression language syntax **/ public abstract String getExpressionString (); //------------------------------------- /** * * Evaluates the expression in the given context, operating on the * given value. **/ public abstract Object evaluate (Object pValue, VariableResolver pResolver, FunctionMapper functions, Logger pLogger) throws ELException; //------------------------------------- } libcommons-el-java-1.0/src/java/org/apache/commons/el/VariableResolverImpl.java0100644000175000017500000001214207617603701027076 0ustar arnaudarnaud/* * 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 * . * */ package org.apache.commons.el; import javax.servlet.jsp.PageContext; import javax.servlet.jsp.el.VariableResolver; import javax.servlet.jsp.el.ELException; /** * *

This is the JSTL-specific implementation of VariableResolver. * It looks up variable references in the PageContext, and also * recognizes references to implicit objects. * * @author Nathan Abramson - Art Technology Group * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $ **/ public class VariableResolverImpl implements VariableResolver { //------------------------------------- // Member variables //------------------------------------- private PageContext mCtx; //------------------------------------- /** * * Constructor **/ public VariableResolverImpl (PageContext pCtx) { mCtx = pCtx; } //------------------------------------- /** * * Resolves the specified variable within the given context. * Returns null if the variable is not found. **/ public Object resolveVariable (String pName) throws ELException { // Check for implicit objects if ("pageContext".equals (pName)) { return mCtx; } else if ("pageScope".equals (pName)) { return ImplicitObjects. getImplicitObjects (mCtx). getPageScopeMap (); } else if ("requestScope".equals (pName)) { return ImplicitObjects. getImplicitObjects (mCtx). getRequestScopeMap (); } else if ("sessionScope".equals (pName)) { return ImplicitObjects. getImplicitObjects (mCtx). getSessionScopeMap (); } else if ("applicationScope".equals (pName)) { return ImplicitObjects. getImplicitObjects (mCtx). getApplicationScopeMap (); } else if ("param".equals (pName)) { return ImplicitObjects. getImplicitObjects (mCtx). getParamMap (); } else if ("paramValues".equals (pName)) { return ImplicitObjects. getImplicitObjects (mCtx). getParamsMap (); } else if ("header".equals (pName)) { return ImplicitObjects. getImplicitObjects (mCtx). getHeaderMap (); } else if ("headerValues".equals (pName)) { return ImplicitObjects. getImplicitObjects (mCtx). getHeadersMap (); } else if ("initParam".equals (pName)) { return ImplicitObjects. getImplicitObjects (mCtx). getInitParamMap (); } else if ("cookie".equals (pName)) { return ImplicitObjects. getImplicitObjects (mCtx). getCookieMap (); } // Otherwise, just look it up in the page context else { return mCtx.findAttribute (pName); } } //------------------------------------- } libcommons-el-java-1.0/src/java/overview.html0100644000175000017500000000142607664766746020643 0ustar arnaudarnaud Overview Documentation for COMMONS-EL The EL component of the Jakarta Commons subproject provides an implementation of the JavaServer Pages (JSP) 2.0 Expression Language interpreter.

The JSP 2.0 specification provides a portable API for evaluating "EL Expressions": The classes and interfaces in the javax.servlet.jsp.el package describe and define programmatic access to the Expression Language evaluator.

The org.apache.commons.el and org.apache.commons.el.parser packages provide an implementation of this API.

libcommons-el-java-1.0/build.properties.sample0100755000175000017500000000047507617603700021054 0ustar arnaudarnaud# The home directory for the Servlet 2.4 and JSP 2.0 classes distribution api.home = /usr/local/jakarta-servletapi-5 # The directory containing your binary distribution of JUnit, # version 3.7 or later junit.home = /usr/local/junit3.7 # The pathname of the "junit.jar" JAR file junit.jar = ${junit.home}/junit.jar libcommons-el-java-1.0/build.xml0100755000175000017500000002313707670213460016177 0ustar arnaudarnaud ========== Building: ${servlet-api.jar} ========== Building: ${jsp-api.jar} libcommons-el-java-1.0/maven.xml0100644000175000017500000000010007617603700016165 0ustar arnaudarnaud libcommons-el-java-1.0/project.properties0100644000175000017500000000013007617603700020124 0ustar arnaudarnaud# documentation properties maven.xdoc.date=left maven.xdoc.version=${pom.currentVersion}libcommons-el-java-1.0/project.xml0100644000175000017500000000276507617603700016550 0ustar arnaudarnaud ../project.xml EL commons-el 1.0 2003 JSP 2.0 Expression Language Interpreter JSP 2.0 Expression Language Interpreter Implementation http://jakarta.apache.org/commons/el/ Nathan Abramson arista arista@alum.mit.edu Massachusetts Institute of Technology Shawn Bayern shawn shawn@apache.org Apache Software Foundation Pierre Delisle pierred pierre.delisle@sun.com Sun Microsystems, Inc. Craig McClanahan craigmcc craigmcc@apache.org Apache Software Foundation Jan Luehe luehe jan.luehe@sun.com Sun Microsystems, Inc. jakarta-servletapi-5