libcommons-el-java-1.0/ 0040755 0001750 0001750 00000000000 07674117742 014362 5 ustar arnaud arnaud libcommons-el-java-1.0/RELEASE-NOTES.txt 0100644 0001750 0001750 00000000752 07670211245 017057 0 ustar arnaud arnaud $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.txt 0100644 0001750 0001750 00000005373 07617603700 016201 0 ustar arnaud arnaud /*
* $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
*
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.
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.
The EL component is dependent upon the following external components for compilation:
Version | Release Date |
---|---|
commons-el-1.0 | 7-Jun-2003 |
Planned Next Release: TBD
TO DO List:
Action Item | Volunteer |
---|
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.java 0100644 0001750 0001750 00000010700 07617603700 025220 0 ustar arnaud arnaud /*
* 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
*
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.java 0100644 0001750 0001750 00000030755 07617603700 025772 0 ustar arnaud arnaud /*
* 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
*
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.java 0100644 0001750 0001750 00000022375 07642104426 025257 0 ustar arnaud arnaud /*
* 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
*
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: * *
* Evaluating a[b] (assuming a.b == a["b"]) * a is null * return null * b is null * return null * a is Map * !a.containsKey (b) * return null * a.get(b) == null * return null * otherwise * return a.get(b) * a is List or array * coerce b to int (using coercion rules) * coercion couldn't be performed * error * a.get(b) or Array.get(a, b) throws ArrayIndexOutOfBoundsException or IndexOutOfBoundsException * return null * a.get(b) or Array.get(a, b) throws other exception * error * return a.get(b) or Array.get(a, b) * * coerce b to String * b is a readable property of a * getter throws an exception * error * otherwise * return result of getter call * * otherwise * error ** * @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.java 0100644 0001750 0001750 00000010531 07617603700 027533 0 ustar arnaud arnaud /* * 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 *
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.java 0100644 0001750 0001750 00000010306 07617603700 026232 0 ustar arnaud arnaud /*
* 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
*
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.java 0100644 0001750 0001750 00000007653 07617603700 025757 0 ustar arnaud arnaud /*
* 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
*
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.java 0100644 0001750 0001750 00000013324 07642104426 030026 0 ustar arnaud arnaud /*
* 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
*
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.java 0100644 0001750 0001750 00000007455 07617603700 025713 0 ustar arnaud arnaud /*
* 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
*
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.java 0100644 0001750 0001750 00000106035 07673673602 024747 0 ustar arnaud arnaud /*
* 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
*
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* * @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.java 0100644 0001750 0001750 00000011732 07642104426 025413 0 ustar arnaud arnaud /* * 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 *A.add(B)
* if operator is -, returnA.subtract(B)
* if operator is *, returnA.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 +, returnA.add(B)
* if operator is -, returnA.subtract(B)
* if operator is *, returnA.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 * returnA.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, returnA.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 ofA.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 ofA.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, returnA.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, returnA.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, returnA.toBigInteger()
* Otherwise, returnBigInteger.valueOf(A.longValue())
* if N is BigDecimal * If A is a BigInteger, returnnew BigDecimal(A)
* Otherwise, returnnew BigDecimal(A.doubleValue())
* If N is Byte, returnnew Byte(A.byteValue())
* If N is Short, returnnew Short(A.shortValue())
* If N is Integer, returnnew Integer(A.integerValue())
* If N is Long, returnnew Long(A.longValue())
* If N is Float, returnnew Float(A.floatValue())
* If N is Double, returnnew Double(A.doubleValue())
* otherwise ERROR * A is String * If N is BigDecimal then: * Ifnew BigDecimal(A)
throws an exception then ERROR * Otherwise, returnnew BigDecimal(A)
* If N is BigInteger then: * Ifnew BigInteger(A)
throws an exception, then ERROR * Otherwise, returnnew BigInteger(A)
* newN.valueOf(A)
throws exception * error * returnN.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 *
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.java 0100644 0001750 0001750 00000012434 07642104426 027332 0 ustar arnaud arnaud /*
* 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
*
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.java 0100644 0001750 0001750 00000020003 07617603700 024753 0 ustar arnaud arnaud /*
* 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
*
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.java 0100644 0001750 0001750 00000012555 07673673602 025746 0 ustar arnaud arnaud /*
* 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
*
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.jj 0100644 0001750 0001750 00000033141 07641713423 024146 0 ustar arnaud arnaud /*****************************************
* 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 **/
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 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.java 0100644 0001750 0001750 00000014224 07617603700 025536 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000006644 07617603700 026327 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000007131 07617603700 025754 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000007045 07642104426 025150 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000007042 07617603700 027101 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000011456 07642104426 026340 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000014414 07642104426 026626 0 ustar arnaud arnaud /*
* 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
* Represents a function call. 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.java 0100644 0001750 0001750 00000034000 07617603701 026066 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000007322 07642104426 024403 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000012247 07673673602 030420 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000010575 07617603701 027253 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000007014 07617603701 025721 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000012031 07673673602 026250 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000012543 07642104426 027702 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000012222 07673673602 027726 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000036745 07617603701 024243 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000010554 07674115771 025631 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000013620 07673673602 026164 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000011061 07674115771 026347 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000010120 07642104426 025016 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000007152 07617603701 026441 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000007364 07617603701 025273 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000006605 07617603701 025243 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000010673 07617603701 025110 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000010624 07674115771 025457 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000020403 07617603701 026266 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000010472 07642104426 026020 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000012555 07673673602 026634 0 ustar arnaud arnaud /*
* 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
* 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.properties 0100644 0001750 0001750 00000007356 07626523323 026246 0 ustar arnaud arnaud EXCEPTION_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.properties 0100644 0001750 0001750 00000020323 07617603701 026704 0 ustar arnaud arnaud EXCEPTION_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.java 0100644 0001750 0001750 00000014101 07617603701 025565 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000013030 07673673602 026641 0 ustar arnaud arnaud /*
* 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
* 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.java 0100644 0001750 0001750 00000006617 07617603701 025631 0 ustar arnaud arnaud /*
* 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
* 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/ 0040755 0001750 0001750 00000000000 07674117676 023457 5 ustar arnaud arnaud libcommons-el-java-1.0/src/java/org/apache/commons/el/parser/ELParser.java 0100644 0001750 0001750 00000153125 07641713423 025765 0 ustar arnaud arnaud /* 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< 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.java 0100644 0001750 0001750 00000012142 07617603701 027076 0 ustar arnaud arnaud /*
* 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
* 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.html 0100644 0001750 0001750 00000001426 07664766746 020643 0 ustar arnaud arnaud
The JSP 2.0 specification provides a portable API for evaluating
"EL Expressions": The classes and interfaces in the
The
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
*/
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.java 0100644 0001750 0001750 00000005171 07617603701 025365 0 ustar arnaud arnaud /* 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.java 0100644 0001750 0001750 00000010177 07617603701 027047 0 ustar arnaud arnaud /* 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 ? "javax.servlet.jsp.el
package describe and define programmatic
access to the Expression Language evaluator.org.apache.commons.el
and
org.apache.commons.el.parser
packages provide an implementation of this API.