jenkins-commons-jexl-1.1-jenkins-20111212/ 0000775 0001750 0001750 00000000000 11746230570 020434 5 ustar jamespage jamespage jenkins-commons-jexl-1.1-jenkins-20111212/LICENSE.txt 0000664 0001750 0001750 00000026450 11671435474 022275 0 ustar jamespage jamespage
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
jenkins-commons-jexl-1.1-jenkins-20111212/.checkclipse 0000664 0001750 0001750 00000000403 11671435474 022716 0 ustar jamespage jamespage #Tue May 02 15:43:07 EST 2006
filenames.properties=/Jexl/src/conf/checkstyle.properties
enabled=true
projectclassloader=true
filenames.config=/Jexl/src/conf/checkstyle.xml
additional_jars=|
filenames.filter=/Jexl/src/conf/checkclipse-filter.properties
jenkins-commons-jexl-1.1-jenkins-20111212/pom.xml 0000664 0001750 0001750 00000007265 11671435474 021772 0 ustar jamespage jamespage
* Creates Expression objects. To create a JEXL Expression object, pass * valid JEXL syntax to the static createExpression() method: *
* ** String jexl = "array[1]"; * Expression expression = ExpressionFactory.createExpression( jexl ); ** *
* When an {@link Expression} object is created, the JEXL syntax is * parsed and verified. If the supplied expression is neither an * expression nor a reference, an exception is thrown from createException(). *
* @since 1.0 * @author Geir Magnusson Jr. * @version $Id: ExpressionFactory.java 429169 2006-08-06 11:36:29 -0700 (Sun, 06 Aug 2006) rahul $ */ public class ExpressionFactory { /** * The Log to which all ExpressionFactory messages will be logged. */ protected static Log log = LogFactory.getLog("org.apache.commons.jexl.ExpressionFactory"); /** * The singleton ExpressionFactory also holds a single instance of * {@link Parser}. * When parsing expressions, ExpressionFactory synchronizes on Parser. */ protected static Parser parser = new Parser(new StringReader(";")); //$NON-NLS-1$ /** * ExpressionFactory is a singleton and this is the private * instance fufilling that pattern. */ protected static ExpressionFactory ef = new ExpressionFactory(); /** * Private constructor, the single instance is always obtained * with a call to getInstance(). */ private ExpressionFactory() { } /** * Returns the single instance of ExpressionFactory. * @return the instance of ExpressionFactory. */ protected static ExpressionFactory getInstance() { return ef; } /** * Creates an Expression from a String containing valid * JEXL syntax. This method parses the expression which * must contain either a reference or an expression. * @param expression A String containing valid JEXL syntax * @return An Expression object which can be evaluated with a JexlContext * @throws Exception An exception can be thrown if there is a problem * parsing this expression, or if the expression is neither an * expression or a reference. */ public static Expression createExpression(String expression) throws Exception { return getInstance().createNewExpression(expression); } /** * Creates a new Expression based on the expression string. * * @param expression valid Jexl expression * @return Expression * @throws Exception for a variety of reasons - mostly malformed * Jexl expression */ protected Expression createNewExpression(final String expression) throws Exception { String expr = cleanExpression(expression); // Parse the Expression SimpleNode tree; synchronized (parser) { log.debug("Parsing expression: " + expr); try { tree = parser.parse(new StringReader(expr)); } catch (TokenMgrError e) { // this is thrown if there's syntax error. // most callers aren't expecting the parsing error to be this fatal, // so let's wrap it to Exception (not Error) to let the caller catch it throw new JexlException("Failed to parse "+expr,e); } } if (tree.jjtGetNumChildren() > 1 && log.isWarnEnabled()) { log.warn("The JEXL Expression created will be a reference" + " to the first expression from the supplied script: \"" + expression + "\" "); } // Must be a simple reference, expression, statement or if, otherwise // throw an exception. SimpleNode node = (SimpleNode) tree.jjtGetChild(0); // TODO: Can we get rid of these checks? if (node instanceof ASTReferenceExpression || node instanceof ASTExpressionExpression || node instanceof ASTStatementExpression || node instanceof ASTIfStatement || node instanceof ASTWhileStatement || node instanceof ASTForeachStatement ) { return new ExpressionImpl(expression, node); } log.error("Invalid Expression, node of type: " + node.getClass().getName()); throw new Exception("Invalid Expression: not a Reference, Expression, " + "Statement or If"); } /** * Trims the expression and adds a semi-colon if missing. * @param expression to clean * @return trimmed expression ending in a semi-colon */ private String cleanExpression(String expression) { String expr = expression.trim(); if (!expr.endsWith(";")) { expr += ";"; } return expr; } } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/package.html 0000664 0001750 0001750 00000005362 11671435474 031067 0 ustar jamespage jamespage
Java Expression Language (JEXL) is an expression language engine which can be embedded in applications and frameworks. JEXL is inspired by Jakarta Velocity and the Expression Language defined in the JavaServer Pages Standard Tag Library version 1.1 (JSTL) and JavaServer Pages version 2.0 (JSP).
JEXL attempts to bring some of the lessons learned by the Velocity community about expression languages in templating to a wider audience. Commons Jelly needed Velocity-ish method access, it just had to have it.
It must be noted that JEXL is not a compatibile implementation of EL as defined in JSTL 1.1 (JSR-052) or JSP 2.0 (JSR-152). For a compatible implementation of these specifications, see the Commons EL project.
When evaluating expressions, JEXL merges an Expression with a JexlContext. An Expression is created using ExpressionFactory.createExpression(), passing a String containing valid JEXL syntax. A JexlContext is created using JexlHelper.createContext(), and variables are put into a map exposed through the getVars() method on JexlContext. The following example, takes a variable named foo, and invokes the bar() method on the property innerFoo:
// Create an expression object String jexlExp = "foo.innerFoo.bar()"; Expression e = ExpressionFactory.createExpression( jexlExp ); // Create a context and add data JexlContext jc = JexlHelper.createContext(); jc.getVars().put("foo", new Foo() ); // Now evaluate the expression, getting the result Object o = e.evaluate(jc);jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/context/ 0000775 0001750 0001750 00000000000 11671435474 030264 5 ustar jamespage jamespage jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/context/package.html 0000664 0001750 0001750 00000001026 11671435474 032544 0 ustar jamespage jamespage
This package only contains one JexlContext implementation, the HashMapContext. A HashMapContext is simply an extension of HashMap which implements the JexlContext interface.
././@LongLink 0000000 0000000 0000000 00000000147 00000000000 011567 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/context/HashMapContext.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/context/HashMapContext.ja0000664 0001750 0001750 00000003112 11671435474 033463 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.context; import org.apache.commons.jexl.JexlContext; import java.util.HashMap; import java.util.Map; /** * Implementation of JexlContext based on a HashMap. * * @since 1.0 * @author Geir Magnusson Jr. * @version $Id: HashMapContext.java 480412 2006-11-29 05:11:23Z bayard $ */ public class HashMapContext extends HashMap implements JexlContext { /** serialization version id jdk13 generated. */ static final long serialVersionUID = 5715964743204418854L; /** * {@inheritDoc} */ public void setVars(Map vars) { clear(); putAll(vars); } /** * {@inheritDoc} */ public Map getVars() { return this; } } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/JexlExprResolver.java 0000664 0001750 0001750 00000003372 11671435474 032733 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl; /** * A Resolver allows custom resolution of the expression, and can be * added in front of the jexl engine, or after in the evaluation. * * @todo This needs to be explained in detail. Why do this? * @since 1.0 * @author Geir Magnusson Jr. * @version $Id: JexlExprResolver.java 480412 2006-11-29 05:11:23Z bayard $ */ public interface JexlExprResolver { /** represents an expression result of no value. */ Object NO_VALUE = new Object(); /** * Evaluates an expression against the context. * * @todo Must detail the expectations and effects of this resolver. * @param context current data context * @param expression expression to evauluate * @return value (may be null) or the NO_VALUE object to * indicate no resolution. */ Object evaluate(JexlContext context, String expression); } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/Script.java 0000664 0001750 0001750 00000003530 11671435474 030710 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl; /** *A JEXL Script.
*A script is some valid JEXL syntax to be executed with * a given set of {@link JexlContext variables}.
*A script is a group of statements, separated by semicolons.
*The statements can be blocks
(curly braces containing code),
* Control statements such as if
and while
* as well as expressions and assignment statements.
This package only contains one class, Asserter, which allows you to use a JEXL expression in a JUnit assertion. The following example demonstrates the use of the Asserter class. An instance is created, and the internal JexlContext is populated via calls to setVariable(). Calls to assertExpression() succeed if the expression evaluates to the value of the second parameter, otherwise an AssertionFailedException is thrown.
Asserter asserter = new Asserter(); asserter.setVariable("foo", new Foo()); asserter.setVariable("person", "James"); asserter.assertExpression("person", "James"); asserter.assertExpression("size(person)", new Integer(5)); asserter.assertExpression("foo.getCount()", new Integer(5)); asserter.assertExpression("foo.count", new Integer(5));jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/junit/Asserter.java 0000664 0001750 0001750 00000005763 11671435474 032377 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.junit; import java.util.HashMap; import java.util.Map; import junit.framework.Assert; import org.apache.commons.jexl.Expression; import org.apache.commons.jexl.ExpressionFactory; import org.apache.commons.jexl.JexlContext; import org.apache.commons.jexl.JexlHelper; /** * A utility class for performing JUnit based assertions using Jexl * expressions. This class can make it easier to do unit tests using * Jexl navigation expressions. * * @since 1.0 * @author James Strachan * @version $Revision: 480412 $ */ public class Asserter extends Assert { /** variables used during asserts. */ private final Map variables = new HashMap(); /** context to use during asserts. */ private final JexlContext context = JexlHelper.createContext(); /** * * Create an asserter. */ public Asserter() { } /** * This constructor will register the given variableValue as the * "this" variable. * * @param variableValue 'this'. */ public Asserter(Object variableValue) { setVariable("this", variableValue); } /** * Performs an assertion that the value of the given Jexl expression * evaluates to the given expected value. * * @param expression is the Jexl expression to evaluate * @param expected is the expected value of the expression * @throws Exception if the expression could not be evaluationed or an assertion * fails */ public void assertExpression(String expression, Object expected) throws Exception { Expression exp = ExpressionFactory.createExpression(expression); context.setVars(variables); Object value = exp.evaluate(context); assertEquals("expression: " + expression, expected, value); } /** * Puts a variable of a certain name in the context so that it can be used from * assertion expressions. * * @param name variable name * @param value variable value */ public void setVariable(String name, Object value) { variables.put(name, value); } } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/ScriptImpl.java 0000664 0001750 0001750 00000003375 11671435474 031541 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl; import org.apache.commons.jexl.parser.ASTJexlScript; /** * Simple script implementation. * @since 1.1 */ class ScriptImpl implements Script { /** text of the script. */ private final String text; /** syntax tree. */ private final ASTJexlScript parsedScript; /** * Create a new Script from the given string and parsed syntax. * @param scriptText the text of the script. * @param scriptTree the parsed script. */ public ScriptImpl(String scriptText, ASTJexlScript scriptTree) { text = scriptText; parsedScript = scriptTree; } /** * {@inheritDoc} */ public Object execute(JexlContext context) throws Exception { // TODO Auto-generated method stub return parsedScript.value(context); } /** * {@inheritDoc} */ public String getText() { return text; } } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/JexlContext.java 0000664 0001750 0001750 00000003530 11671435474 031713 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl; import java.util.Map; /** * Holds a Map of variables which are referenced in a JEXL expression. * * @since 1.0 * @author Geir Magnusson Jr. * @version $Id: JexlContext.java 480412 2006-11-29 05:11:23Z bayard $ */ public interface JexlContext { /** * Replaces variables in a JexlContext with the variables contained * in the supplied Map. When setVars() is called on a JexlContext, * it clears the current Map and puts each entry of the * supplied Map into the current variable Map. * * @param vars Contents of vars will be replaced with the content * of this Map */ void setVars(Map vars); /** * Retrives the Map of variables associated with this JexlContext. The * keys of this map correspond to variable names referenced in a * JEXL expression. * * @return A reference to the variable Map associated with this JexlContext. */ Map getVars(); } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/JexlException.java 0000664 0001750 0001750 00000002257 11671435474 032232 0 ustar jamespage jamespage /* * Copyright 2002-2006 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl; /** * Signals an error inside JEXL. * * @author Kohsuke Kawaguchi */ public class JexlException extends Exception { private Throwable cause; public JexlException(String message) { this(message,null); } public JexlException(String message, Throwable cause) { super(message); this.cause = cause; } public JexlException(Throwable cause) { this(cause.getMessage(),cause); } public Throwable getCause() { return cause; } } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/Expression.java 0000664 0001750 0001750 00000004630 11671435474 031605 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl; /** *
* Represents a single JEXL expression. This simple interface * provides access to the underlying expression through getExpression(), * and it provides hooks to add a pre- and post- expression resolver. *
* ** An expression is different than a script - it is simply a reference of * an expression. *
* * @since 1.0 * @author Geir Magnusson Jr. * @version $Id: Expression.java 480412 2006-11-29 05:11:23Z bayard $ */ public interface Expression { /** * Evaluates the expression with the variables contained in the * supplied {@link JexlContext}. * * @param context A JexlContext containing variables. * @return The result of this evaluation * @throws Exception on any error */ Object evaluate(JexlContext context) throws Exception; /** * Returns the JEXL expression this Expression was created with. * * @return The JEXL expression to be evaluated */ String getExpression(); /** * Allows addition of a resolver to allow custom interdiction of * expression evaluation. * * @param resolver resolver to be called before Jexl expression evaluated */ void addPreResolver(JexlExprResolver resolver); /** * Allows addition of a resolver to allow custom interdiction of * expression evaluation. * * @param resolver resolver to be called if Jexl expression * evaluated to null. */ void addPostResolver(JexlExprResolver resolver); } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/ScriptFactory.java 0000664 0001750 0001750 00000016370 11671435474 032246 0 ustar jamespage jamespage /* * Copyright 2002-2006 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.StringReader; import java.net.URL; import java.net.URLConnection; import org.apache.commons.jexl.parser.ASTJexlScript; import org.apache.commons.jexl.parser.ParseException; import org.apache.commons.jexl.parser.Parser; import org.apache.commons.jexl.parser.SimpleNode; import org.apache.commons.jexl.parser.TokenMgrError; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** ** Creates {@link Script}s. To create a JEXL Script, pass * valid JEXL syntax to the static createScript() method: *
* ** String jexl = "y = x * 12 + 44; y = y * 4;"; * Script script = ScriptFactory.createScript( jexl ); ** *
* When an {@link Script} is created, the JEXL syntax is * parsed and verified. *
* @since 1.1 * @version $Id: ScriptFactory.java 429175 2006-08-06 12:05:23 -0700 (Sun, 06 Aug 2006) rahul $ */ public class ScriptFactory { /** The Log to which all ScriptFactory messages will be logged.*/ protected static Log log = LogFactory.getLog("org.apache.commons.jexl.ScriptFactory"); /** * The singleton ScriptFactory also holds a single instance of * {@link Parser}. When parsing expressions, ScriptFactory * synchronizes on Parser. */ protected static Parser parser = new Parser(new StringReader(";")); /** * ScriptFactory is a singleton and this is the private * instance fufilling that pattern. */ protected static ScriptFactory factory = new ScriptFactory(); /** * Private constructor, the single instance is always obtained * with a call to getInstance(). */ private ScriptFactory() { } /** * Returns the single instance of ScriptFactory. * @return the instance of ScriptFactory. */ protected static ScriptFactory getInstance() { return factory; } /** * Creates a Script from a String containing valid JEXL syntax. * This method parses the script which validates the syntax. * * @param scriptText A String containing valid JEXL syntax * @return A {@link Script} which can be executed with a * {@link JexlContext}. * @throws Exception An exception can be thrown if there is a * problem parsing the script. */ public static Script createScript(String scriptText) throws Exception { return getInstance().createNewScript(scriptText); } /** * Creates a Script from a {@link File} containing valid JEXL syntax. * This method parses the script and validates the syntax. * * @param scriptFile A {@link File} containing valid JEXL syntax. * Must not be null. Must be a readable file. * @return A {@link Script} which can be executed with a * {@link JexlContext}. * @throws Exception An exception can be thrown if there is a problem * parsing the script. */ public static Script createScript(File scriptFile) throws Exception { if (scriptFile == null) { throw new NullPointerException("scriptFile is null"); } if (!scriptFile.canRead()) { throw new IOException("Can't read scriptFile (" + scriptFile.getCanonicalPath() + ")"); } BufferedReader reader = new BufferedReader(new FileReader(scriptFile)); return createScript(readerToString(reader)); } /** * Creates a Script from a {@link URL} containing valid JEXL syntax. * This method parses the script and validates the syntax. * * @param scriptUrl A {@link URL} containing valid JEXL syntax. * Must not be null. Must be a readable file. * @return A {@link Script} which can be executed with a * {@link JexlContext}. * @throws Exception An exception can be thrown if there is a problem * parsing the script. */ public static Script createScript(URL scriptUrl) throws Exception { if (scriptUrl == null) { throw new NullPointerException("scriptUrl is null"); } URLConnection connection = scriptUrl.openConnection(); BufferedReader reader = new BufferedReader( new InputStreamReader(connection.getInputStream())); return createScript(readerToString(reader)); } /** * Creates a new Script based on the string. * * @param scriptText valid Jexl script * @return Script a new script * @throws Exception for a variety of reasons - mostly malformed scripts */ protected Script createNewScript(String scriptText) throws Exception { String cleanText = cleanScript(scriptText); SimpleNode script; // Parse the Expression synchronized (parser) { log.debug("Parsing script: " + cleanText); try { script = parser.parse(new StringReader(cleanText)); } catch (TokenMgrError tme) { throw new ParseException(tme.getMessage()); } } if (script instanceof ASTJexlScript) { return new ScriptImpl(cleanText, (ASTJexlScript) script); } else { throw new IllegalStateException("Parsed script is not " + "an ASTJexlScript"); } } /** * @todo move to ParseUtils? * Trims the expression and adds a semi-colon if missing. * @param script to clean * @return trimmed expression ending in a semi-colon */ private String cleanScript(String script) { String expr = script.trim(); if (!expr.endsWith(";")) { expr += ";"; } return expr; } /** * Read a buffered reader into a StringBuffer and return a String with * the contents of the reader. * @param reader to be read. * @return the contents of the reader as a String. * @throws IOException on any error reading the reader. */ private static String readerToString(BufferedReader reader) throws IOException { StringBuffer buffer = new StringBuffer(); try { String line = null; while ((line = reader.readLine()) != null) { buffer.append(line).append('\n'); } return buffer.toString(); } finally { reader.close(); } } } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/ 0000775 0001750 0001750 00000000000 11671435474 027555 5 ustar jamespage jamespage ././@LongLink 0000000 0000000 0000000 00000000151 00000000000 011562 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/EnumerationIterator.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/EnumerationIterator.0000664 0001750 0001750 00000004124 11671435474 033557 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.util; import java.util.Iterator; import java.util.Enumeration; /** * An Iterator wrapper for an Enumeration. * * @since 1.0 * @author Geir Magnusson Jr. * @version $Id: EnumerationIterator.java 480412 2006-11-29 05:11:23Z bayard $ */ public class EnumerationIterator implements Iterator { /** * The enumeration to iterate over. */ private final Enumeration enumeration; /** * Creates a new iteratorwrapper instance for the specified * Enumeration. * * @param enumer The Enumeration to wrap. */ public EnumerationIterator(Enumeration enumer) { enumeration = enumer; } /** * Move to next element in the array. * * @return The next object in the array. */ public Object next() { return enumeration.nextElement(); } /** * Check to see if there is another element in the array. * * @return Whether there is another element. */ public boolean hasNext() { return enumeration.hasMoreElements(); } /** * Unimplemented. No analogy in Enumeration */ public void remove() { // not implemented } } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/ArrayIterator.java 0000664 0001750 0001750 00000006624 11671435474 033220 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.util; import java.util.Iterator; import java.util.NoSuchElementException; import java.lang.reflect.Array; /** ** An Iterator wrapper for an Object[]. This will * allow us to deal with all array like structures * in a consistent manner. *
** WARNING : this class's operations are NOT synchronized. * It is meant to be used in a single thread, newly created * for each use in the #foreach() directive. * If this is used or shared, synchronize in the * next() method. *
* * @since 1.0 * @author Jason van Zyl * @author Geir Magnusson Jr. * @version $Id: ArrayIterator.java 480412 2006-11-29 05:11:23Z bayard $ */ public class ArrayIterator implements Iterator { /** * The objects to iterate over. */ private final Object array; /** * The current position and size in the array. */ private int pos; /** * The size of the array. */ private final int size; /** * Creates a new iterator instance for the specified array. * * @param arr The array for which an iterator is desired. */ public ArrayIterator(Object arr) { /* * if this isn't an array, then throw. Note that this is * for internal use - so this should never happen - if it does * we screwed up. */ if (!arr.getClass().isArray()) { throw new IllegalArgumentException("Programmer error :" + " internal ArrayIterator invoked w/o array"); } array = arr; pos = 0; size = Array.getLength(array); } /** * Move to next element in the array. * * @return The next object in the array. */ public Object next() { if (pos < size) { return Array.get(array, pos++); } /* * we screwed up... */ throw new NoSuchElementException("No more elements: " + pos + " / " + size); } /** * Check to see if there is another element in the array. * * @return Whether there is another element. */ public boolean hasNext() { return (pos < size); } /** * No op--merely added to satify theIterator
interface.
*/
public void remove() {
throw new UnsupportedOperationException();
}
}
././@LongLink 0000000 0000000 0000000 00000000146 00000000000 011566 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/PropertyExecutor.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/PropertyExecutor.jav0000664 0001750 0001750 00000007444 11671435474 033633 0 ustar jamespage jamespage /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.jexl.util;
import java.lang.reflect.InvocationTargetException;
import org.apache.commons.jexl.util.introspection.Introspector;
import org.apache.commons.logging.Log;
/**
* Returned the value of object property when executed.
* @since 1.0
*/
public class PropertyExecutor extends AbstractExecutor {
/** index of the first character of the property. */
private static final int PROPERTY_START_INDEX = 3;
/** The JEXL introspector used. */
protected Introspector introspector = null;
/** The method used. */
protected String methodUsed = null;
/**
* Constructor.
*
* @param r The log for this property executor instance.
* @param ispctr The JEXL introspector.
* @param clazz The class being examined.
* @param property The property being addressed.
*/
public PropertyExecutor(Log r, Introspector ispctr,
Class clazz, String property) {
rlog = r;
introspector = ispctr;
discover(clazz, property);
}
/**
* Locate the getter method for this property.
*
* @param clazz The class being analyzed.
* @param property Name of the property.
*/
protected void discover(Class clazz, String property) {
/*
* this is gross and linear, but it keeps it straightforward.
*/
try {
char c;
StringBuffer sb;
Object[] params = {};
/*
* start with getsource
.
* @param column The column number from source
.
*/
public Info(String source, int line, int column)
{
this.templateName = source;
this.line = line;
this.column = column;
}
/**
* Force callers to set the location information.
*/
private Info()
{
}
/**
* @return The template name.
*/
public String getTemplateName()
{
return templateName;
}
/**
* @return The line number.
*/
public int getLine()
{
return line;
}
/**
* @return The column number.
*/
public int getColumn()
{
return column;
}
/**
* Formats a textual representation of this object as SOURCE
* [line X, column Y]
.
*
* @return String representing this object.
*/
public String toString()
{
return getTemplateName() + " [line " + getLine() + ", column " +
getColumn() + ']';
}
}
././@LongLink 0000000 0000000 0000000 00000000154 00000000000 011565 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/introspection/ClassMap.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/introspection/ClassM0000664 0001750 0001750 00000030626 11671435474 033571 0 ustar jamespage jamespage /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.jexl.util.introspection;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
/**
* Taken from the Velocity tree so we can be self-sufficient
*
* A cache of introspection information for a specific class instance. Keys
* {@link Method} objects by a concatenation of the method name and
* the names of classes that make up the parameters.
*
* @author Jason van Zyl
* @author Bob McWhirter
* @author Attila Szegedi
* @author Geir Magnusson Jr.
* @author Henning P. Schmiedehausen
* @version $Id: ClassMap.java 584046 2007-10-12 05:14:37Z proyal $
* @since 1.0
*/
public class ClassMap {
/**
* Class passed into the constructor used to as the basis for the Method
* map.
*/
private final Class clazz;
private final Log rlog;
private final MethodCache methodCache;
/**
* Standard constructor.
*
* @param aClass the class to deconstruct.
*/
public ClassMap(Class aClass, Log rlog) {
clazz = aClass;
this.rlog = rlog;
methodCache = new MethodCache();
populateMethodCache();
}
/**
* @return the class object whose methods are cached by this map.
*/
Class getCachedClass() {
return clazz;
}
/**
* Find a Method using the method name and parameter objects.
*
* @param name The method name to look up.
* @param params An array of parameters for the method.
* @return A Method object representing the method to invoke or null.
* @throws MethodMap.AmbiguousException When more than one method is a match for the parameters.
*/
public Method findMethod(final String name, final Object[] params)
throws MethodMap.AmbiguousException {
return methodCache.get(name, params);
}
/**
* Populate the Map of direct hits. These
* are taken from all the public methods
* that our class, its parents and their implemented interfaces provide.
*/
private void populateMethodCache() {
//
// Build a list of all elements in the class hierarchy. This one is bottom-first (i.e. we start
// with the actual declaring class and its interfaces and then move up (superclass etc.) until we
// hit java.lang.Object. That is important because it will give us the methods of the declaring class
// which might in turn be abstract further up the tree.
//
// We also ignore all SecurityExceptions that might happen due to SecurityManager restrictions (prominently
// hit with Tomcat 5.5).
//
// We can also omit all that complicated getPublic, getAccessible and upcast logic that the class map had up
// until Velocity 1.4. As we always reflect all elements of the tree (that's what we have a cache for), we will
// hit the public elements sooner or later because we reflect all the public elements anyway.
//
List classesToReflect = new ArrayList();
// Ah, the miracles of Java for(;;) ...
for (Class classToReflect = getCachedClass(); classToReflect != null; classToReflect = classToReflect.getSuperclass())
{
if (Modifier.isPublic(classToReflect.getModifiers())) {
classesToReflect.add(classToReflect);
}
Class[] interfaces = classToReflect.getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
if (Modifier.isPublic(interfaces[i].getModifiers())) {
classesToReflect.add(interfaces[i]);
}
}
}
for (Iterator it = classesToReflect.iterator(); it.hasNext();) {
Class classToReflect = (Class) it.next();
try {
Method[] methods = classToReflect.getMethods();
for (int i = 0; i < methods.length; i++) {
// Strictly spoken that check shouldn't be necessary
// because getMethods only returns public methods.
int modifiers = methods[i].getModifiers();
if (Modifier.isPublic(modifiers) && (modifiers&ACC_BRIDGE)==0) // && !)
{
// Some of the interfaces contain abstract methods. That is fine, because the actual object must
// implement them anyway (else it wouldn't be implementing the interface). If we find an abstract
// method in a non-interface, we skip it, because we do want to make sure that no abstract methods end up in
// the cache.
// KK: if (classToReflect.isInterface() || !Modifier.isAbstract(modifiers)) {
methodCache.put(methods[i]);
// KK: }
// KK: this abstract check prevents us from having a public base class definining a public abstract method
// and use private subclass to implement that. When we actually try to invoke the method on an object,
// we can reasonably expect that all the abstract methods are implemented.
}
}
}
catch (SecurityException se) // Everybody feels better with...
{
if (rlog.isDebugEnabled()) {
rlog.debug("While accessing methods of " + classToReflect + ": ", se);
}
}
}
}
/**
* This is the cache to store and look up the method information.
*
* @author Henning P. Schmiedehausen
* @version $Id: ClassMap.java 584046 2007-10-12 05:14:37Z proyal $
*/
private static final class MethodCache {
private static final class CacheMiss {
}
private static final CacheMiss CACHE_MISS = new CacheMiss();
private static final Object OBJECT = new Object();
private static final Map convertPrimitives = new HashMap();
static {
convertPrimitives.put(Boolean.TYPE, Boolean.class.getName());
convertPrimitives.put(Byte.TYPE, Byte.class.getName());
convertPrimitives.put(Character.TYPE, Character.class.getName());
convertPrimitives.put(Double.TYPE, Double.class.getName());
convertPrimitives.put(Float.TYPE, Float.class.getName());
convertPrimitives.put(Integer.TYPE, Integer.class.getName());
convertPrimitives.put(Long.TYPE, Long.class.getName());
convertPrimitives.put(Short.TYPE, Short.class.getName());
}
/**
* Cache of Methods, or CACHE_MISS, keyed by method
* name and actual arguments used to find it.
*/
private final Map cache = new HashMap();
/**
* Map of methods that are searchable according to method parameters to find a match
*/
private final MethodMap methodMap = new MethodMap();
/**
* Find a Method using the method name and parameter objects.
*
* Look in the methodMap for an entry. If found,
* it'll either be a CACHE_MISS, in which case we
* simply give up, or it'll be a Method, in which
* case, we return it.
*
* If nothing is found, then we must actually go
* and introspect the method from the MethodMap.
*
* @param name The method name to look up.
* @param params An array of parameters for the method.
* @return A Method object representing the method to invoke or null.
* @throws MethodMap.AmbiguousException When more than one method is a match for the parameters.
*/
public synchronized Method get(final String name, final Object[] params)
throws MethodMap.AmbiguousException {
String methodKey = makeMethodKey(name, params);
Object cacheEntry = cache.get(methodKey);
// We looked this up before and failed.
if (cacheEntry == CACHE_MISS) {
return null;
}
if (cacheEntry == null) {
try {
// That one is expensive...
cacheEntry = methodMap.find(name, params);
}
catch (MethodMap.AmbiguousException ae) {
/*
* that's a miss :-)
*/
cache.put(methodKey, CACHE_MISS);
throw ae;
}
cache.put(methodKey,
(cacheEntry != null) ? cacheEntry : CACHE_MISS);
}
// Yes, this might just be null.
return (Method) cacheEntry;
}
public synchronized void put(Method method) {
String methodKey = makeMethodKey(method);
// We don't overwrite methods. Especially not if we fill the
// cache from defined class towards java.lang.Object because
// abstract methods in superclasses would else overwrite concrete
// classes further down the hierarchy.
if (cache.get(methodKey) == null) {
cache.put(methodKey, method);
methodMap.add(method);
}
}
/**
* Make a methodKey for the given method using
* the concatenation of the name and the
* types of the method parameters.
*
* @param method to be stored as key
* @return key for ClassMap
*/
private String makeMethodKey(final Method method) {
Class[] parameterTypes = method.getParameterTypes();
StringBuffer methodKey = new StringBuffer(method.getName());
for (int j = 0; j < parameterTypes.length; j++) {
/*
* If the argument type is primitive then we want
* to convert our primitive type signature to the
* corresponding Object type so introspection for
* methods with primitive types will work correctly.
*
* The lookup map (convertPrimitives) contains all eight
* primitives (boolean, byte, char, double, float, int, long, short)
* known to Java. So it should never return null for the key passed in.
*/
if (parameterTypes[j].isPrimitive()) {
methodKey.append((String) convertPrimitives.get(parameterTypes[j]));
} else {
methodKey.append(parameterTypes[j].getName());
}
}
return methodKey.toString();
}
private String makeMethodKey(String method, Object[] params) {
StringBuffer methodKey = new StringBuffer().append(method);
for (int j = 0; j < params.length; j++) {
Object arg = params[j];
if (arg == null) {
arg = OBJECT;
}
methodKey.append(arg.getClass().getName());
}
return methodKey.toString();
}
}
private static final int ACC_BRIDGE = 0x00000040;
}
././@LongLink 0000000 0000000 0000000 00000000161 00000000000 011563 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/introspection/UberspectImpl.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/introspection/Ubersp0000664 0001750 0001750 00000027373 11671435474 033654 0 ustar jamespage jamespage /*
* Copyright 2002,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.jexl.util.introspection;
import org.apache.commons.jexl.util.ArrayIterator;
import org.apache.commons.jexl.util.EnumerationIterator;
import org.apache.commons.jexl.util.AbstractExecutor;
import org.apache.commons.jexl.util.GetExecutor;
import org.apache.commons.jexl.util.BooleanPropertyExecutor;
import org.apache.commons.jexl.util.PropertyExecutor;
import org.apache.commons.logging.Log;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Field;
import java.util.Iterator;
import java.util.Collection;
import java.util.Map;
import java.util.Enumeration;
import java.util.ArrayList;
/**
* Implementation of Uberspect to provide the default introspective
* functionality of Velocity.
*
* @since 1.0
* @author Geir Magnusson Jr.
* @version $Id: UberspectImpl.java 398509 2006-05-01 03:34:35Z dion $
*/
public class UberspectImpl implements Uberspect, UberspectLoggable {
/** index of the first character of the property. */
private static final int PROPERTY_START_INDEX = 3;
/**
* Our runtime logger.
*/
private Log rlog;
/**
* the default Velocity introspector.
*/
private static Introspector introspector;
/**
* init - does nothing - we need to have setRuntimeLogger called before
* getting our introspector, as the default vel introspector depends upon
* it.
* @throws Exception on any error.
*/
public void init() throws Exception {
}
/**
* Sets the runtime logger - this must be called before anything else
* besides init() as to get the logger. Makes the pull model appealing...
* @param runtimeLogger service to use for logging.
*/
public void setRuntimeLogger(Log runtimeLogger) {
rlog = runtimeLogger;
introspector = new Introspector(rlog);
}
/**
* {@inheritDoc}
*/
public Iterator getIterator(Object obj, Info i) throws Exception {
if (obj.getClass().isArray()) {
return new ArrayIterator(obj);
} else if (obj instanceof Collection) {
return ((Collection) obj).iterator();
} else if (obj instanceof Map) {
return ((Map) obj).values().iterator();
} else if (obj instanceof Iterator) {
rlog.warn("Warning! The iterative " + " is an Iterator in the #foreach() loop at [" + i.getLine() + ","
+ i.getColumn() + "]" + " in template " + i.getTemplateName() + ". Because it's not resetable,"
+ " if used in more than once, this may lead to" + " unexpected results.");
return ((Iterator) obj);
} else if (obj instanceof Enumeration) {
rlog.warn("Warning! The iterative " + " is an Enumeration in the #foreach() loop at [" + i.getLine() + ","
+ i.getColumn() + "]" + " in template " + i.getTemplateName() + ". Because it's not resetable,"
+ " if used in more than once, this may lead to" + " unexpected results.");
return new EnumerationIterator((Enumeration) obj);
}
/* we have no clue what this is */
rlog.warn("Could not determine type of iterator in " + "#foreach loop " + " at [" + i.getLine() + ","
+ i.getColumn() + "]" + " in template " + i.getTemplateName());
return null;
}
/**
* {@inheritDoc}
*/
public VelMethod getMethod(Object obj, String methodName, Object[] args, Info i) throws Exception {
if (obj == null) {
return null;
}
Method m = introspector.getMethod(obj.getClass(), methodName, args);
if (m == null && obj instanceof Class) {
m = introspector.getMethod((Class) obj, methodName, args);
}
return (m == null) ? null : new VelMethodImpl(m);
}
/**
* {@inheritDoc}
*/
public VelPropertyGet getPropertyGet(Object obj, final String identifier, Info i) throws Exception {
AbstractExecutor executor;
Class claz = obj.getClass();
/*
* first try for a getFoo() type of property (also getfoo() )
*/
executor = new PropertyExecutor(rlog, introspector, claz, identifier);
/*
* look for boolean isFoo()
*/
if (!executor.isAlive()) {
executor = new BooleanPropertyExecutor(rlog, introspector, claz, identifier);
}
// llok for field
if (!executor.isAlive()) {
try {
final Field field = obj.getClass().getField(identifier);
return new VelPropertyGet() {
public Object invoke(Object o) throws Exception {
return field.get(o);
}
public boolean isCacheable() {
return false;
}
public String getMethodName() {
return identifier;
}
public boolean isAlive() {
return true;
}
};
} catch (NoSuchFieldException e) {
// fall through
}
}
/*
* if that didn't work, look for get("foo")
*/
if (!executor.isAlive()) {
executor = new GetExecutor(rlog, introspector, claz, identifier);
}
return (executor == null) ? null : new VelGetterImpl(executor);
}
/**
* {@inheritDoc}
*/
public VelPropertySet getPropertySet(Object obj, String identifier, Object arg, Info i) throws Exception {
Class claz = obj.getClass();
VelMethod vm = null;
try {
/*
* first, we introspect for the setname
and
* params
for the Class c
.
*
* @param c Class in which the method search is taking place
* @param name Name of the method being searched for
* @param params An array of Objects (not Classes) that describe the
* the parameters
*
* @return The desired Method object.
* @throws IllegalArgumentException When the parameters passed in can not be used for introspection.
*/
public Method getMethod(Class c, String name, Object[] params) throws IllegalArgumentException {
/*
* just delegate to the base class
*/
try {
return super.getMethod(c, name, params);
} catch (MethodMap.AmbiguousException ae) {
/*
* whoops. Ambiguous. Make a nice log message and return null...
*/
StringBuffer msg = new StringBuffer("Introspection Error : Ambiguous method invocation ")
.append(name).append("( ");
for (int i = 0; i < params.length; i++) {
if (i > 0) {
msg.append(", ");
}
msg.append(null == params[i] ? "null" : params[i].getClass().getName());
}
msg.append(") for class ").append(c.getName());
rlog.error(msg.toString());
}
return null;
}
/**
* Clears the classmap and classname
* caches, and logs that we did so.
*/
protected void clearCache() {
super.clearCache();
rlog.info(CACHEDUMP_MSG);
}
}
././@LongLink 0000000 0000000 0000000 00000000162 00000000000 011564 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/introspection/VelPropertySet.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/introspection/VelPro0000664 0001750 0001750 00000003656 11671435474 033621 0 ustar jamespage jamespage /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.jexl.util.introspection;
/**
* Interface used for setting values that appear to be properties in Velocity.
* Ex.
*
* #set($foo.bar = "hello")
*
* @since 1.0
* @author Geir Magnusson Jr.
* @version $Id: VelPropertySet.java 584046 2007-10-12 05:14:37Z proyal $
*/
public interface VelPropertySet {
/**
* method used to set the value in the object.
*
* @param o Object on which the method will be called with the arg
* @param arg value to be set
* @return the value returned from the set operation (impl specific)
* @throws Exception on any error.
*/
Object invoke(Object o, Object arg) throws Exception;
/**
* specifies if this VelPropertySet is cacheable and able to be reused for
* this class of object it was returned for.
*
* @return true if can be reused for this class, false if not
*/
boolean isCacheable();
/**
* returns the method name used to set this 'property'.
* @return the method name.
*/
String getMethodName();
}
././@LongLink 0000000 0000000 0000000 00000000165 00000000000 011567 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/introspection/UberspectLoggable.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/introspection/Ubersp0000664 0001750 0001750 00000002633 11671435474 033644 0 ustar jamespage jamespage /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.jexl.util.introspection;
import org.apache.commons.logging.Log;
/**
* Marker interface to let an uberspector indicate it can and wants to log.
*
* Thanks to Paulo for the suggestion
*
* @since 1.0
* @author Geir Magnusson Jr.
* @version $Id: UberspectLoggable.java 480412 2006-11-29 05:11:23Z bayard $
*
*/
public interface UberspectLoggable {
/**
* Sets the logger. This will be called before any calls to the uberspector
* @param logger the logger.
*/
void setRuntimeLogger(Log logger);
}
././@LongLink 0000000 0000000 0000000 00000000155 00000000000 011566 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/introspection/VelMethod.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/introspection/VelMet0000664 0001750 0001750 00000003734 11671435474 033603 0 ustar jamespage jamespage package org.apache.commons.jexl.util.introspection;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Method used for regular method invocation
*
* $foo.bar()
*
*
* @author Geir Magnusson Jr.
* @version $Id: VelMethod.java 584046 2007-10-12 05:14:37Z proyal $
*/
public interface VelMethod
{
/**
* invocation method - called when the method invocation should be
* performed and a value returned
* @param o
* @param params
* @return The resulting object.
* @throws Exception
*/
public Object invoke(Object o, Object[] params)
throws Exception;
/**
* specifies if this VelMethod is cacheable and able to be
* reused for this class of object it was returned for
*
* @return true if can be reused for this class, false if not
*/
public boolean isCacheable();
/**
* returns the method name used
* @return The method name used
*/
public String getMethodName();
/**
* returns the return type of the method invoked
* @return The return type of the method invoked
*/
public Class getReturnType();
}
././@LongLink 0000000 0000000 0000000 00000000155 00000000000 011566 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/introspection/MethodMap.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/introspection/Method0000664 0001750 0001750 00000032252 11671435474 033624 0 ustar jamespage jamespage /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.jexl.util.introspection;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
* @author Jason van Zyl
* @author Bob McWhirter
* @author Christoph Reck
* @author Geir Magnusson Jr.
* @author Attila Szegedi
* @version $Id: MethodMap.java 584046 2007-10-12 05:14:37Z proyal $
* @since 1.0
*/
public class MethodMap {
/**
* whether a method is more specific than a previously compared one.
*/
private static final int MORE_SPECIFIC = 0;
/**
* whether a method is less specific than a previously compared one.
*/
private static final int LESS_SPECIFIC = 1;
/**
* A method doesn't match a previously compared one.
*/
private static final int INCOMPARABLE = 2;
/**
* Keep track of all methods with the same name.
*/
Map methodByNameMap = new Hashtable();
/**
* Add a method to a list of methods by name. For a particular class we are
* keeping track of all the methods with the same name.
*
* @param method the method.
*/
public void add(Method method) {
String methodName = method.getName();
List l = get(methodName);
if (l == null) {
l = new ArrayList();
methodByNameMap.put(methodName, l);
}
l.add(method);
}
/**
* Return a list of methods with the same name.
*
* @param key
* @return List list of methods
*/
public List get(String key) {
return (List) methodByNameMap.get(key);
}
/**
* * Find a method. Attempts to find the * most specific applicable method using the * algorithm described in the JLS section * 15.12.2 (with the exception that it can't * distinguish a primitive type argument from * an object type argument, since in reflection * primitive type arguments are represented by * their object counterparts, so for an argument of * type (say) java.lang.Integer, it will not be able * to decide between a method that takes int and a * method that takes java.lang.Integer as a parameter. *
* ** This turns out to be a relatively rare case * where this is needed - however, functionality * like this is needed. *
* * @param methodName name of method * @param args the actual arguments with which the method is called * @return the most specific applicable method, or null if no * method is applicable. * @throws AmbiguousException if there is more than one maximally * specific applicable method */ public Method find(String methodName, Object[] args) throws AmbiguousException { List methodList = get(methodName); if (methodList == null) { return null; } int l = args.length; Class[] classes = new Class[l]; for (int i = 0; i < l; ++i) { Object arg = args[i]; /* * if we are careful down below, a null argument goes in there * so we can know that the null was passed to the method */ classes[i] = arg == null ? null : arg.getClass(); } return getMostSpecific(methodList, classes); } /** * Simple distinguishable exception, used when * we run across ambiguous overloading. Caught * by the introspector. */ public static class AmbiguousException extends RuntimeException { /** * Version Id for serializable */ private static final long serialVersionUID = -2314636505414551663L; } private static Method getMostSpecific(List methods, Class[] classes) throws AmbiguousException { LinkedList applicables = getApplicables(methods, classes); if (applicables.isEmpty()) { return null; } if (applicables.size() == 1) { return (Method) applicables.getFirst(); } /* * This list will contain the maximally specific methods. Hopefully at * the end of the below loop, the list will contain exactly one method, * (the most specific method) otherwise we have ambiguity. */ LinkedList maximals = new LinkedList(); for (Iterator applicable = applicables.iterator(); applicable.hasNext();) { Method app = (Method) applicable.next(); Class[] appArgs = app.getParameterTypes(); boolean lessSpecific = false; for (Iterator maximal = maximals.iterator(); !lessSpecific && maximal.hasNext();) { Method max = (Method) maximal.next(); switch (moreSpecific(appArgs, max.getParameterTypes())) { case MORE_SPECIFIC: { /* * This method is more specific than the previously * known maximally specific, so remove the old maximum. */ maximal.remove(); break; } case LESS_SPECIFIC: { /* * This method is less specific than some of the * currently known maximally specific methods, so we * won't add it into the set of maximally specific * methods */ lessSpecific = true; break; } } } if (!lessSpecific) { maximals.addLast(app); } } if (maximals.size() > 1) { // We have more than one maximally specific method throw new AmbiguousException(); } return (Method) maximals.getFirst(); } /** * Determines which method signature (represented by a class array) is more * specific. This defines a partial ordering on the method signatures. * * @param c1 first signature to compare * @param c2 second signature to compare * @return MORE_SPECIFIC if c1 is more specific than c2, LESS_SPECIFIC if * c1 is less specific than c2, INCOMPARABLE if they are incomparable. */ private static int moreSpecific(Class[] c1, Class[] c2) { boolean c1MoreSpecific = false; boolean c2MoreSpecific = false; // compare lengths to handle comparisons where the size of the arrays // doesn't match, but the methods are both applicable due to the fact // that one is a varargs method if (c1.length > c2.length) { return MORE_SPECIFIC; } if (c2.length > c1.length) { return LESS_SPECIFIC; } // ok, move on and compare those of equal lengths for (int i = 0; i < c1.length; ++i) { if (c1[i] != c2[i]) { boolean last = (i == c1.length - 1); c1MoreSpecific = c1MoreSpecific || isStrictConvertible(c2[i], c1[i], last); c2MoreSpecific = c2MoreSpecific || isStrictConvertible(c1[i], c2[i], last); } } if (c1MoreSpecific) { if (c2MoreSpecific) { /* * Incomparable due to cross-assignable arguments (i.e. * foo(String, Object) vs. foo(Object, String)) */ return INCOMPARABLE; } return MORE_SPECIFIC; } if (c2MoreSpecific) { return LESS_SPECIFIC; } /* * Incomparable due to non-related arguments (i.e. * foo(Runnable) vs. foo(Serializable)) */ return INCOMPARABLE; } /** * Returns all methods that are applicable to actual argument types. * * @param methods list of all candidate methods * @param classes the actual types of the arguments * @return a list that contains only applicable methods (number of * formal and actual arguments matches, and argument types are assignable * to formal types through a method invocation conversion). */ private static LinkedList getApplicables(List methods, Class[] classes) { LinkedList list = new LinkedList(); for (Iterator imethod = methods.iterator(); imethod.hasNext();) { Method method = (Method) imethod.next(); if (isApplicable(method, classes)) { list.add(method); } } return list; } /** * Returns true if the supplied method is applicable to actual * argument types. * * @param method method that will be called * @param classes arguments to method * @return true if method is applicable to arguments */ private static boolean isApplicable(Method method, Class[] classes) { Class[] methodArgs = method.getParameterTypes(); if (methodArgs.length > classes.length) { // if there's just one more methodArg than class arg // and the last methodArg is an array, then treat it as a vararg return methodArgs.length == classes.length + 1 && methodArgs[methodArgs.length - 1].isArray(); } if (methodArgs.length == classes.length) { // this will properly match when the last methodArg // is an array/varargs and the last class is the type of array // (e.g. String when the method is expecting String...) for (int i = 0; i < classes.length; ++i) { if (!isConvertible(methodArgs[i], classes[i], false)) { // if we're on the last arg and the method expects an array if (i == classes.length - 1 && methodArgs[i].isArray()) { // check to see if the last arg is convertible // to the array's component type return isConvertible(methodArgs[i], classes[i], true); } return false; } } return true; } if (methodArgs.length > 0) {// more arguments given than the method accepts; check for varargs // check that the last methodArg is an array Class lastarg = methodArgs[methodArgs.length - 1]; if (!lastarg.isArray()) { return false; } // check that they all match up to the last method arg for (int i = 0; i < methodArgs.length - 1; ++i) { if (!isConvertible(methodArgs[i], classes[i], false)) { return false; } } // check that all remaining arguments are convertible to the vararg type Class vararg = lastarg.getComponentType(); for (int i = methodArgs.length - 1; i < classes.length; ++i) { if (!isConvertible(vararg, classes[i], false)) { return false; } } return true; } return false; } private static boolean isConvertible(Class formal, Class actual, boolean possibleVarArg) { return IntrospectionUtils. isMethodInvocationConvertible(formal, actual, possibleVarArg); } private static boolean isStrictConvertible(Class formal, Class actual, boolean possibleVarArg) { return IntrospectionUtils. isStrictMethodInvocationConvertible(formal, actual, possibleVarArg); } } ././@LongLink 0000000 0000000 0000000 00000000162 00000000000 011564 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/introspection/VelPropertyGet.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/introspection/VelPro0000664 0001750 0001750 00000004147 11671435474 033615 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.util.introspection; /** * Interface defining a 'getter'. For uses when looking for resolution of * property references * * $foo.bar * * @since 1.0 * @author Geir Magnusson Jr. * @version $Id: VelPropertyGet.java 584050 2007-10-12 05:27:50Z proyal $ */ public interface VelPropertyGet { /** * invocation method - called when the 'get action' should be performed and * a value returned. * @param o the object to get the property from. * @return the property value. * @throws Exception on any error. */ Object invoke(Object o) throws Exception; /** * specifies if this VelPropertyGet is cacheable and able to be reused for * this class of object it was returned for. * * @return true if can be reused for this class, false if not */ boolean isCacheable(); /** * returns the method name used to return this 'property'. * @return the method name. */ String getMethodName(); /** * Tell whether the method underlying this 'property' is alive by * checking to see if represents a successful name resolution. * * @return boolean Whether 'property' is alive. */ boolean isAlive(); } ././@LongLink 0000000 0000000 0000000 00000000164 00000000000 011566 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/introspection/IntrospectorBase.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/introspection/Intros0000664 0001750 0001750 00000012742 11671435474 033664 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.util.introspection; import java.lang.reflect.Method; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import org.apache.commons.logging.Log; /** * This basic function of this class is to return a Method object for a * particular class given the name of a method and the parameters to the method * in the form of an Object[] * * The first time the Introspector sees a class it creates a class method map * for the class in question. Basically the class method map is a Hastable where * Method objects are keyed by a concatenation of the method name and the names * of classes that make up the parameters. * * For example, a method with the following signature: * * public void method(String a, StringBuffer b) * * would be mapped by the key: * * "method" + "java.lang.String" + "java.lang.StringBuffer" * * This mapping is performed for all the methods in a class and stored for * * @author Jason van Zyl * @author Bob McWhirter * @author Attila Szegedi * @author Paulo Gaspar * @author Henning P. Schmiedehausen * @version $Id: IntrospectorBase.java 584046 2007-10-12 05:14:37Z proyal $ * @since 1.0 */ public class IntrospectorBase { private final Log rlog; /** * Holds the method maps for the classes we know about, keyed by Class * object. */ protected final Map classMethodMaps = new HashMap(); /** * Holds the qualified class names for the classes we hold in the * classMethodMaps hash. */ private Set cachedClassNames = new HashSet(); public IntrospectorBase(Log rlog) { this.rlog = rlog; } /** * Gets the method defined byname
and params
* for the Class c
.
*
* @param c Class in which the method search is taking place
* @param name Name of the method being searched for
* @param params An array of Objects (not Classes) that describe the the
* parameters
* @return The desired Method object.
* @throws IllegalArgumentException When the parameters passed in can not be used for introspection.
* @throws MethodMap.AmbiguousException When the method map contains more than one match for the requested signature.
*/
public Method getMethod(Class c, String name, Object[] params) throws IllegalArgumentException, MethodMap.AmbiguousException {
if (c == null) {
throw new IllegalArgumentException("Introspector.getMethod(): Class method key was null: " + name);
}
if (params == null) {
throw new IllegalArgumentException("params object is null!");
}
ClassMap classMap;
synchronized (classMethodMaps) {
classMap = (ClassMap) classMethodMaps.get(c);
/*
* if we don't have this, check to see if we have it by name. if so,
* then we have a classloader change so dump our caches.
*/
if (classMap == null) {
if (cachedClassNames.contains(c.getName())) {
/*
* we have a map for a class with same name, but not this
* class we are looking at. This implies a classloader
* change, so dump
*/
clearCache();
}
classMap = createClassMap(c);
}
}
return classMap.findMethod(name, params);
}
/**
* Creates a class map for specific class and registers it in the cache.
* Also adds the qualified name to the name->class map for later Classloader
* change detection.
* @param c class.
* @return a {@link ClassMap}
*/
protected ClassMap createClassMap(Class c) {
ClassMap classMap = new ClassMap(c,rlog);
classMethodMaps.put(c, classMap);
cachedClassNames.add(c.getName());
return classMap;
}
/**
* Clears the classmap and classname caches.
*/
protected void clearCache() {
/*
* since we are synchronizing on this object, we have to clear it rather
* than just dump it.
*/
classMethodMaps.clear();
/*
* for speed, we can just make a new one and let the old one be GC'd
*/
cachedClassNames = new HashSet();
}
}
jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/Introspector.java 0000664 0001750 0001750 00000003724 11671435474 033121 0 ustar jamespage jamespage /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.jexl.util;
import org.apache.commons.jexl.util.introspection.Uberspect;
import org.apache.commons.jexl.util.introspection.UberspectImpl;
import org.apache.commons.jexl.util.introspection.UberspectLoggable;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Little class to manage a Velocity uberspector (Vel 1.4+) for instrospective
* services.
*
* @since 1.0
* @author Geir Magnusson Jr.
* @version $Id: Introspector.java 480412 2006-11-29 05:11:23Z bayard $
*/
public class Introspector {
/**
* The uberspector from Velocity that handles all instrospection patterns.
*/
private static Uberspect uberSpect;
static {
Log logger = LogFactory.getLog(Introspector.class);
uberSpect = new UberspectImpl();
((UberspectLoggable) uberSpect).setRuntimeLogger(logger);
}
/**
* For now, expose the raw uberspector to the AST.
*
* @return Uberspect The Velocity uberspector.
*/
public static Uberspect getUberspect() {
return uberSpect;
}
}
././@LongLink 0000000 0000000 0000000 00000000146 00000000000 011566 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/ArrayListWrapper.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/ArrayListWrapper.jav0000664 0001750 0001750 00000003123 11671435474 033531 0 ustar jamespage jamespage /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.commons.jexl.util;
import java.lang.reflect.Array;
import java.util.AbstractList;
/**
* A class that wraps an array with a List interface.
*
* @author Chris Schultz <chris@christopherschultz.net$gt;
* @version $Revision$ $Date: 2006-04-14 19:40:41 $
*/
public class ArrayListWrapper extends AbstractList {
private Object array;
public ArrayListWrapper( Object array ) {
this.array = array;
}
public Object get( int index ) {
return Array.get( array, index );
}
public Object set( int index, Object element ) {
Object old = get( index );
Array.set( array, index, element );
return old;
}
public int size() {
return Array.getLength( array );
}
}
jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/GetExecutor.java 0000664 0001750 0001750 00000005677 11671435474 032675 0 ustar jamespage jamespage /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.jexl.util;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import org.apache.commons.logging.Log;
/**
* Executor that simply tries to execute a get(key)
* operation. This will try to find a get(key) method
* for any type of object, not just objects that
* implement the Map interface as was previously
* the case.
*
* @since 1.0
* @author Jason van Zyl
* @version $Id: GetExecutor.java 584046 2007-10-12 05:14:37Z proyal $
*/
public class GetExecutor extends AbstractExecutor {
/**
* Container to hold the 'key' part of
* get(key).
*/
private final Object[] args;
/**
* Default constructor.
*
* @param r The instance log.
* @param ispect The JEXL introspector.
* @param c The class being examined.
* @param key The key for the get(key) operation.
* @throws Exception Failure while trying to obtain the pertinent method.
*/
public GetExecutor(Log r,
org.apache.commons.jexl.util.introspection.Introspector ispect,
Class c, String key) throws Exception {
rlog = r;
// If you passed in null as property, we don't use the value
// for parameter lookup. Instead we just look for get() without
// any parameters.
//
// In any other case, the following condition will set up an array
// for looking up get(String) on the class.
if (key != null)
{
args = new Object[] { key };
} else {
args = null;
}
method = ispect.getMethod(c, "get", args);
}
/**
* {@inheritDoc}
*/
public Object execute(Object o)
throws IllegalAccessException, InvocationTargetException {
if (method == null) {
return null;
}
try {
return method.invoke(o, args);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Failed to invoke "+method+" on "+o+" with "+ Arrays.asList(args),e);
}
}
}
././@LongLink 0000000 0000000 0000000 00000000155 00000000000 011566 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/BooleanPropertyExecutor.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/util/BooleanPropertyExecu0000664 0001750 0001750 00000007003 11671435474 033616 0 ustar jamespage jamespage /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.jexl.util;
import org.apache.commons.logging.Log;
/**
* Handles discovery and valuation of a
* boolean object property, of the
* form public boolean is<Property> when executed.
*
* We do this separately as to preserve the current
* quasi-broken semantics of get <as is property>
* get<flip 1st char> get("property") and now followed
* by is<Property>.
*
* @since 1.0
* @author Geir Magnusson Jr.
* @version $Id: BooleanPropertyExecutor.java 584046 2007-10-12 05:14:37Z proyal $
*/
public class BooleanPropertyExecutor extends PropertyExecutor {
/**
* Constructor.
*
* @param rlog The instance log.
* @param is The JEXL introspector.
* @param clazz The class being analyzed.
* @param property The boolean property.
*/
public BooleanPropertyExecutor(Log rlog,
org.apache.commons.jexl.util.introspection.Introspector is,
Class clazz, String property) {
super(rlog, is, clazz, property);
}
/**
* Locate the getter method for this boolean property.
*
* @param clazz The class being analyzed.
* @param property Name of boolean property.
*/
protected void discover(Class clazz, String property) {
try {
char c;
StringBuffer sb;
Object[] params = {};
/*
* now look for a boolean isFoo
*/
sb = new StringBuffer("is");
sb.append(property);
methodUsed = sb.toString();
method = introspector.getMethod(clazz, methodUsed, params);
if (null == method)
{
c = sb.charAt(2);
if (Character.isLowerCase(c)) {
sb.setCharAt(2, Character.toUpperCase(c));
} else {
sb.setCharAt(2, Character.toLowerCase(c));
}
methodUsed = sb.toString();
method = introspector.getMethod(clazz, methodUsed, params);
}
if (method != null) {
/*
* now, this has to return a boolean
*/
if (method.getReturnType() == Boolean.TYPE) {
return;
}
method = null;
}
/**
* pass through application level runtime exceptions
*/
} catch( RuntimeException e ) {
throw e;
} catch (Exception e) {
rlog.error("PROGRAMMER ERROR : BooleanPropertyExector() : " + e, e);
}
}
}
jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/JexlHelper.java 0000664 0001750 0001750 00000004035 11671435474 031507 0 ustar jamespage jamespage /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.jexl;
import org.apache.commons.jexl.context.HashMapContext;
/**
* Helper to create a context. In the current implementation of JEXL, there
* is one implementation of JexlContext - {@link HashMapContext}, and there
* is no reason not to directly instantiate {@link HashMapContext} in your
* own application.
*
* @since 1.0
* @author Geir Magnusson Jr.
* @version $Id: JexlHelper.java 480412 2006-11-29 05:11:23Z bayard $
*/
public class JexlHelper {
/** singleton instance. */
protected static JexlHelper helper = new JexlHelper();
/** @return the single instance. */
protected static JexlHelper getInstance() {
return helper;
}
/**
* Returns a new {@link JexlContext}.
* @return a new JexlContext
*/
public static JexlContext createContext() {
return getInstance().newContext();
}
/**
* Creates and returns a new {@link JexlContext}.
* The current implementation creates a new instance of
* {@link HashMapContext}.
* @return a new JexlContext
*/
protected JexlContext newContext() {
return new HashMapContext();
}
}
jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ 0000775 0001750 0001750 00000000000 11671435474 030074 5 ustar jamespage jamespage ././@LongLink 0000000 0000000 0000000 00000000146 00000000000 011566 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/JJTParserState.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/JJTParserState.jav0000664 0001750 0001750 00000010474 11671435474 033411 0 ustar jamespage jamespage /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* Generated By:JJTree: Do not edit this line. JJTParserState.java */
package org.apache.commons.jexl.parser;
import java.util.Stack;
class JJTParserState {
private final Stack nodes;
private final Stack marks;
private int sp; // number of nodes on stack
private int mk; // current mark
private boolean node_created;
JJTParserState() {
nodes = new Stack();
marks = new Stack();
sp = 0;
mk = 0;
}
/*
* Determines whether the current node was actually closed and pushed. This
* should only be called in the final user action of a node scope.
*/
boolean nodeCreated() {
return node_created;
}
/*
* Call this to reinitialize the node stack. It is called automatically by
* the parser's ReInit() method.
*/
void reset() {
nodes.removeAllElements();
marks.removeAllElements();
sp = 0;
mk = 0;
}
/*
* Returns the root node of the AST. It only makes sense to call this after
* a successful parse.
*/
Node rootNode() {
return (Node) nodes.elementAt(0);
}
/* Pushes a node on to the stack. */
void pushNode(Node n) {
nodes.push(n);
++sp;
}
/*
* Returns the node on the top of the stack, and remove it from the stack.
*/
Node popNode() {
if (--sp < mk) {
mk = ((Integer) marks.pop()).intValue();
}
return (Node) nodes.pop();
}
/* Returns the node currently on the top of the stack. */
Node peekNode() {
return (Node) nodes.peek();
}
/*
* Returns the number of children on the stack in the current node scope.
*/
int nodeArity() {
return sp - mk;
}
void clearNodeScope(Node n) {
while (sp > mk) {
popNode();
}
mk = ((Integer) marks.pop()).intValue();
}
void openNodeScope(Node n) {
marks.push(new Integer(mk));
mk = sp;
n.jjtOpen();
}
/*
* A definite node is constructed from a specified number of children. That
* number of nodes are popped from the stack and made the children of the
* definite node. Then the definite node is pushed on to the stack.
*/
void closeNodeScope(Node n, int num) {
mk = ((Integer) marks.pop()).intValue();
while (num-- > 0) {
Node c = popNode();
c.jjtSetParent(n);
n.jjtAddChild(c, num);
}
n.jjtClose();
pushNode(n);
node_created = true;
}
/*
* A conditional node is constructed if its condition is true. All the nodes
* that have been pushed since the node was opened are made children of the
* the conditional node, which is then pushed on to the stack. If the
* condition is false the node is not constructed and they are left on the
* stack.
*/
void closeNodeScope(Node n, boolean condition) {
if (condition) {
int a = nodeArity();
mk = ((Integer) marks.pop()).intValue();
while (a-- > 0) {
Node c = popNode();
c.jjtSetParent(n);
n.jjtAddChild(c, a);
}
n.jjtClose();
pushNode(n);
node_created = true;
} else {
mk = ((Integer) marks.pop()).intValue();
node_created = false;
}
}
}
jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/Parser.jjt 0000664 0001750 0001750 00000020741 11671435474 032045 0 ustar jamespage jamespage /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Jexl : Java Expression Language
*
* @author Geir Magnusson Jr.
* @author Mark H. Wilkinson
*
* @version $Id: Parser.jjt 584037 2007-10-12 03:35:21Z proyal $
*/
options
{
MULTI=true;
STATIC=false;
VISITOR=true;
NODE_USES_PARSER=true;
UNICODE_INPUT=true;
}
PARSER_BEGIN(Parser)
package org.apache.commons.jexl.parser;
import java.io.Reader;
import java.io.ByteArrayInputStream;
import org.apache.commons.jexl.util.Introspector;
import org.apache.commons.jexl.util.introspection.Uberspect;
public class Parser
{
private Uberspect uberspect = Introspector.getUberspect();
public void setUberspect(Uberspect uberspect)
{
this.uberspect = uberspect;
}
protected Uberspect getUberspect()
{
return uberspect;
}
public SimpleNode parse(Reader reader)
throws Exception
{
ReInit(reader);
/*
* lets do the 'Unique Init' in here to be
* safe - it's a pain to remember
*/
SimpleNode tree = JexlScript();
return tree;
}
}
PARSER_END(Parser)
SKIP : /* WHITE SPACE */
{
size
of various types: Collection, Array, Map, String,
* and anything that has a int size() method.
*
* @param val the object to get the size of.
* @param uberspect
* @return the size of val
* @throws Exception if the size cannot be determined.
*/
public static int sizeOf(Object val, Uberspect uberspect) throws Exception {
if (val instanceof Collection) {
return ((Collection) val).size();
} else if (val.getClass().isArray()) {
return Array.getLength(val);
} else if (val instanceof Map) {
return ((Map) val).size();
} else if (val instanceof String) {
return ((String) val).length();
} else {
// check if there is a size method on the object that returns an
// integer
// and if so, just use it
Object[] params = new Object[0];
Info velInfo = new Info("", 1, 1);
VelMethod vm = uberspect.getMethod(val, "size", params, velInfo);
if (vm != null && vm.getReturnType() == Integer.TYPE) {
Integer result = (Integer) vm.invoke(val, params);
return result.intValue();
}
throw new Exception("size() : unknown type : " + val.getClass());
}
}
}
jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTEQNode.java 0000664 0001750 0001750 00000010175 11671435474 032426 0 ustar jamespage jamespage /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.jexl.parser;
import org.apache.commons.jexl.JexlContext;
import org.apache.commons.jexl.util.Coercion;
/**
* Represents equality between values.
*
* If the values are of the same class, .equals() is used.
*
* If either value is a {@link Float} or {@link Double} (but both are not the same class),
* the values are coerced to {@link Double}s before comparing.
*
* If either value is a {@link Number} or {@link Character} (but both are not the same class),
* the values are coerced to {@link Long}s before comparing.
*
* If either value is a {@link Boolean} (but both are not the same class),
* the values are coerced to {@link Boolean}s before comparing.
*
* If either value is a {@link String} (but both are not the same class),
* toString() is called on both before comparing.
*
* Otherwise left.equals(right) is returned.
*
* @author Geir Magnusson Jr.
* @version $Id: ASTEQNode.java 480412 2006-11-29 05:11:23Z bayard $
*/
public class ASTEQNode extends SimpleNode {
/**
* Create the node given an id.
*
* @param id node id.
*/
public ASTEQNode(int id) {
super(id);
}
/**
* Create a node with the given parser and id.
*
* @param p a parser.
* @param id node id.
*/
public ASTEQNode(Parser p, int id) {
super(p, id);
}
/** {@inheritDoc} */
public Object jjtAccept(ParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
/** {@inheritDoc} */
public Object value(JexlContext pc) throws Exception {
Object left = ((SimpleNode) jjtGetChild(0)).value(pc);
Object right = ((SimpleNode) jjtGetChild(1)).value(pc);
if (left == null && right == null) {
/*
* if both are null L == R
*/
return Boolean.TRUE;
} else if (left == null || right == null) {
/*
* we know both aren't null, therefore L != R
*/
return Boolean.FALSE;
} else if (left.getClass().equals(right.getClass())) {
return left.equals(right) ? Boolean.TRUE : Boolean.FALSE;
} else if (left instanceof Float || left instanceof Double
|| right instanceof Float || right instanceof Double) {
Double l = Coercion.coerceDouble(left);
Double r = Coercion.coerceDouble(right);
return l.equals(r) ? Boolean.TRUE : Boolean.FALSE;
} else if (left instanceof Number || right instanceof Number
|| left instanceof Character || right instanceof Character) {
return Coercion.coerceLong(left).equals(Coercion.coerceLong(right)) ? Boolean.TRUE
: Boolean.FALSE;
} else if (left instanceof Boolean || right instanceof Boolean) {
return Coercion.coerceBoolean(left).equals(
Coercion.coerceBoolean(right)) ? Boolean.TRUE
: Boolean.FALSE;
} else if (left instanceof java.lang.String || right instanceof String) {
return left.toString().equals(right.toString()) ? Boolean.TRUE
: Boolean.FALSE;
}
return left.equals(right) ? Boolean.TRUE : Boolean.FALSE;
}
}
././@LongLink 0000000 0000000 0000000 00000000146 00000000000 011566 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTArrayAccess.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTArrayAccess.jav0000664 0001750 0001750 00000014025 11671435474 033350 0 ustar jamespage jamespage /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.jexl.parser;
import java.lang.reflect.Array;
import java.util.List;
import java.util.Map;
import org.apache.commons.jexl.JexlContext;
import org.apache.commons.jexl.util.Coercion;
import org.apache.commons.jexl.util.introspection.Info;
import org.apache.commons.jexl.util.introspection.Uberspect;
import org.apache.commons.jexl.util.introspection.VelPropertyGet;
/**
* Like an ASTIdentifier, but with array access allowed.
*
* $foo[2]
*
* @author Geir Magnusson Jr.
* @version $Id: ASTArrayAccess.java 548229 2007-06-18 06:11:32Z dion $
*/
public class ASTArrayAccess extends SimpleNode {
/** dummy velocity info. */
private static final Info DUMMY = new Info("", 1, 1);
/**
* Create the node given an id.
*
* @param id node id.
*/
public ASTArrayAccess(int id) {
super(id);
}
/**
* Create a node with the given parser and id.
*
* @param p a parser.
* @param id node id.
*/
public ASTArrayAccess(Parser p, int id) {
super(p, id);
}
/** {@inheritDoc} */
public Object jjtAccept(ParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
/**
* evaluate array access upon a base object.
*
* foo.bar[2]
*
* makes me rethink the array operator :)
* @param jc the {@link JexlContext} to evaluate against.
* @param obj not used.
* @return the value of the array expression.
* @throws Exception on any error
*/
public Object execute(Object obj, JexlContext jc) throws Exception {
ASTIdentifier base = (ASTIdentifier) jjtGetChild(0);
Object result = base.execute(obj, jc);
/*
* ignore the first child - it's our identifier
*/
for (int i = 1; i < jjtGetNumChildren(); i++) {
Object loc = ((SimpleNode) jjtGetChild(i)).value(jc);
if (loc == null) {
return null;
}
result = evaluateExpr(result, loc, getUberspect());
}
return result;
}
/** {@inheritDoc} */
public Object value(JexlContext jc) throws Exception {
/*
* get the base ASTIdentifier
*/
ASTIdentifier base = (ASTIdentifier) jjtGetChild(0);
Object o = base.value(jc);
/*
* ignore the first child - it's our identifier
*/
for (int i = 1; i < jjtGetNumChildren(); i++) {
Object loc = ((SimpleNode) jjtGetChild(i)).value(jc);
if (loc == null) {
return null;
}
o = evaluateExpr(o, loc, getUberspect());
}
return o;
}
/**
* Evaluate the Array expression 'loc' on the given object, o.
* e.g. in 'a[2]', 2
is 'loc' and a
is 'o'.
*
* If o or loc are null, null is returned.
* If o is a Map, o.get(loc) is returned.
* If o is a List, o.get(loc) is returned. loc must resolve to an int value.
* If o is an Array, o[loc] is returned. loc must resolve to an int value.
* Otherwise loc is treated as a bean property of o.
*
* @param o an object to be accessed using the array operator or '.' operator.
* @param loc the index of the object to be returned.
* @param uberspect Uberspector to use during evaluation
* @return the resulting value.
* @throws Exception on any error.
*/
public static Object evaluateExpr(Object o, Object loc, Uberspect uberspect) throws Exception {
/*
* following the JSTL EL rules
*/
if (o == null) {
return null;
}
if (loc == null) {
return null;
}
if (o instanceof Map) {
if (!((Map) o).containsKey(loc)) {
return null;
}
return ((Map) o).get(loc);
} else if (o instanceof List) {
int idx = Coercion.coerceInteger(loc).intValue();
try {
return ((List) o).get(idx);
} catch (IndexOutOfBoundsException iobe) {
return null;
}
} else if (o.getClass().isArray()) {
int idx = Coercion.coerceInteger(loc).intValue();
try {
return Array.get(o, idx);
} catch (ArrayIndexOutOfBoundsException aiobe) {
return null;
}
} else {
/*
* "Otherwise (a JavaBean object)..." huh? :)
*/
String s = loc.toString();
VelPropertyGet vg = uberspect.getPropertyGet(o, s, DUMMY);
if (vg != null) {
return vg.invoke(o);
}
}
throw new Exception("Unsupported object type for array [] accessor");
}
/**
* Gets the variable name piece of the expression.
* @return a String of the identifer.
* @see ASTIdentifier#getIdentifierString().
*/
public String getIdentifierString() {
return ((ASTIdentifier) jjtGetChild(0)).getIdentifierString();
}
}
jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/package.html 0000664 0001750 0001750 00000000621 11671435474 032354 0 ustar jamespage jamespage
This package contains the Parser for JEXL script.
jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTFalseNode.java 0000664 0001750 0001750 00000003367 11671435474 033160 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.parser; import org.apache.commons.jexl.JexlContext; /** * represents Boolean false. * * @author Geir Magnusson Jr. * @version $Id: ASTFalseNode.java 480412 2006-11-29 05:11:23Z bayard $ */ public class ASTFalseNode extends SimpleNode { /** * Create the node given an id. * * @param id node id. */ public ASTFalseNode(int id) { super(id); } /** * Create a node with the given parser and id. * * @param p a parser. * @param id node id. */ public ASTFalseNode(Parser p, int id) { super(p, id); } /** {@inheritDoc} */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } /** {@inheritDoc} */ public Object value(JexlContext jc) throws Exception { return Boolean.FALSE; } } ././@LongLink 0000000 0000000 0000000 00000000147 00000000000 011567 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTSubtractNode.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTSubtractNode.ja0000664 0001750 0001750 00000006405 11671435474 033362 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.parser; import org.apache.commons.jexl.util.Coercion; import org.apache.commons.jexl.JexlContext; /** * Subtraction. * * @author Geir Magnusson Jr. * @author Mark H. Wilkinson * @version $Id: ASTSubtractNode.java 480412 2006-11-29 05:11:23Z bayard $ */ public class ASTSubtractNode extends SimpleNode { /** * Create the node given an id. * * @param id node id. */ public ASTSubtractNode(int id) { super(id); } /** * Create a node with the given parser and id. * * @param p a parser. * @param id node id. */ public ASTSubtractNode(Parser p, int id) { super(p, id); } /** {@inheritDoc} */ public Object value(JexlContext context) throws Exception { Object left = ((SimpleNode) jjtGetChild(0)).value(context); Object right = ((SimpleNode) jjtGetChild(1)).value(context); /* * the spec says 'and', I think 'or' */ if (left == null && right == null) { return new Byte((byte) 0); } /* * if anything is float, double or string with ( "." | "E" | "e") coerce * all to doubles and do it */ if (left instanceof Float || left instanceof Double || right instanceof Float || right instanceof Double || (left instanceof String && (((String) left).indexOf(".") != -1 || ((String) left).indexOf("e") != -1 || ((String) left).indexOf("E") != -1)) || (right instanceof String && (((String) right).indexOf(".") != -1 || ((String) right).indexOf("e") != -1 || ((String) right).indexOf("E") != -1))) { Double l = Coercion.coerceDouble(left); Double r = Coercion.coerceDouble(right); return new Double(l.doubleValue() - r.doubleValue()); } /* * otherwise to longs with thee! */ Long l = Coercion.coerceLong(left); Long r = Coercion.coerceLong(right); return new Long(l.longValue() - r.longValue()); } /** {@inheritDoc} */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTNotNode.java 0000664 0001750 0001750 00000004121 11671435474 032653 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.parser; import org.apache.commons.jexl.JexlContext; import org.apache.commons.jexl.util.Coercion; /** * Not : 'not' or '!'. * * @author Geir Magnusson Jr. * @version $Id: ASTNotNode.java 480412 2006-11-29 05:11:23Z bayard $ */ public class ASTNotNode extends SimpleNode { /** * Create the node given an id. * * @param id node id. */ public ASTNotNode(int id) { super(id); } /** * Create a node with the given parser and id. * * @param p a parser. * @param id node id. */ public ASTNotNode(Parser p, int id) { super(p, id); } /** {@inheritDoc} */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } /** {@inheritDoc} */ public Object value(JexlContext jc) throws Exception { Object val = ((SimpleNode) jjtGetChild(0)).value(jc); /* * coercion rules */ Boolean b = Coercion.coerceBoolean(val); if (b != null) { return b.booleanValue() ? Boolean.FALSE : Boolean.TRUE; } throw new Exception("expression not boolean valued"); } } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTMulNode.java 0000664 0001750 0001750 00000006261 11671435474 032657 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.parser; import org.apache.commons.jexl.JexlContext; import org.apache.commons.jexl.util.Coercion; /** * Multiplication. * * @author Geir Magnusson Jr. * @version $Id: ASTMulNode.java 480412 2006-11-29 05:11:23Z bayard $ */ public class ASTMulNode extends SimpleNode { /** * Create the node given an id. * * @param id node id. */ public ASTMulNode(int id) { super(id); } /** * Create a node with the given parser and id. * * @param p a parser. * @param id node id. */ public ASTMulNode(Parser p, int id) { super(p, id); } /** {@inheritDoc} */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } /** {@inheritDoc} */ public Object value(JexlContext context) throws Exception { Object left = ((SimpleNode) jjtGetChild(0)).value(context); Object right = ((SimpleNode) jjtGetChild(1)).value(context); /* * the spec says 'and', I think 'or' */ if (left == null && right == null) { return new Byte((byte) 0); } /* * if anything is float, double or string with ( "." | "E" | "e") coerce * all to doubles and do it */ if (left instanceof Float || left instanceof Double || right instanceof Float || right instanceof Double || (left instanceof String && (((String) left).indexOf(".") != -1 || ((String) left).indexOf("e") != -1 || ((String) left).indexOf("E") != -1)) || (right instanceof String && (((String) right).indexOf(".") != -1 || ((String) right).indexOf("e") != -1 || ((String) right).indexOf("E") != -1))) { Double l = Coercion.coerceDouble(left); Double r = Coercion.coerceDouble(right); return new Double(l.doubleValue() * r.doubleValue()); } /* * otherwise to longs with thee! */ Long l = Coercion.coerceLong(left); Long r = Coercion.coerceLong(right); return new Long(l.longValue() * r.longValue()); } } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/SimpleNode.java 0000664 0001750 0001750 00000014430 11671435474 033000 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.parser; import org.apache.commons.jexl.JexlContext; import org.apache.commons.jexl.util.introspection.Uberspect; /** * A Useful implementation of {@link Node}. Mostly autogenerated by javacc * * @author Geir Magnusson Jr. * @version $Id: SimpleNode.java 548229 2007-06-18 06:11:32Z dion $ */ public class SimpleNode implements Node { /** parent node. */ protected Node parent; /** children of this node. */ protected Node[] children; /** id of the node. */ protected int id; /** parser that created the node. */ protected Parser parser; /** * Create the node given an id. * * @param i node id. */ public SimpleNode(int i) { id = i; } /** * Create a node with the given parser and id. * * @param p a parser. * @param i node id. */ public SimpleNode(Parser p, int i) { this(i); parser = p; } /** * Start of the node. */ public void jjtOpen() { } /** * End of the node. */ public void jjtClose() { } /** {@inheritDoc} */ public void jjtSetParent(Node n) { parent = n; } /** {@inheritDoc} */ public Node jjtGetParent() { return parent; } /** {@inheritDoc} */ public void jjtAddChild(Node n, int i) { if (children == null) { children = new Node[i + 1]; } else if (i >= children.length) { Node[] c = new Node[i + 1]; System.arraycopy(children, 0, c, 0, children.length); children = c; } children[i] = n; } /** {@inheritDoc} */ public Node jjtGetChild(int i) { return children[i]; } /** {@inheritDoc} */ public int jjtGetNumChildren() { return (children == null) ? 0 : children.length; } /** * Accept the visitor. * * @param visitor a {@link ParserVisitor}. * @param data data to be passed along to the visitor. * @return the value from visiting. * @see ParserVisitor#visit */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } /** * Visit all children. * * @param visitor a {@link ParserVisitor}. * @param data data to be passed along to the visitor. * @return the value from visiting. * @see ParserVisitor#visit */ public Object childrenAccept(ParserVisitor visitor, Object data) { if (children != null) { for (int i = 0; i < children.length; ++i) { children[i].jjtAccept(visitor, data); } } return data; } /** * Gets a string representation of the node. * @return the node name. */ public String toString() { return ParserTreeConstants.jjtNodeName[id]; } /** * Used during dumping to output the node with a prefix. * @param prefix text to prefix {@link #toString()} * @return text. */ public String toString(String prefix) { return prefix + toString(); } /** * Dump the node and all children. * @param prefix text to prefix the node output. */ public void dump(String prefix) { System.out.println(toString(prefix)); if (children != null) { for (int i = 0; i < children.length; ++i) { SimpleNode n = (SimpleNode) children[i]; if (n != null) { n.dump(prefix + " "); } } } } /** * basic interpret - just invoke interpret on all children. * @param pc the {@link JexlContext context} to interpret against. * @return true if interpretation worked. * @throws Exception on any error. */ public boolean interpret(JexlContext pc) throws Exception { for (int i = 0; i < jjtGetNumChildren(); i++) { SimpleNode node = (SimpleNode) jjtGetChild(i); if (!node.interpret(pc)) { return false; } } return true; } /** * Gets the value of this node. * * @param context the context to retrieve values from. * @return the value of the node. * @throws Exception when evaluating the operands fails. */ public Object value(JexlContext context) throws Exception { return null; } /** * Sets the value for the node - again, only makes sense for some nodes but * lazyness tempts me to put it here. Keeps things simple. * * @param context the context to retrieve values from. * @param value the value. * @return the result. * @throws Exception when evaluating the operands fails. */ public Object setValue(JexlContext context, Object value) throws Exception { return null; } /** * Used to let a node calcuate it's value.. * @param o the object to calculate with. * @param ctx the context to retrieve values from. * @throws Exception when calculating the value fails. * @return the result of the calculation. */ public Object execute(Object o, JexlContext ctx) throws Exception { return null; } protected Uberspect getUberspect() { return parser.getUberspect(); } } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTReference.java 0000664 0001750 0001750 00000010705 11671435474 033210 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.parser; import org.apache.commons.jexl.JexlContext; /** * reference - any variable expression. * * @author Geir Magnusson Jr. * @version $Id: ASTReference.java 480412 2006-11-29 05:11:23Z bayard $ */ public class ASTReference extends SimpleNode { /** first variable in the expression. */ protected SimpleNode root; /** * Create the node given an id. * * @param id node id. */ public ASTReference(int id) { super(id); } /** * Create a node with the given parser and id. * * @param p a parser. * @param id node id. */ public ASTReference(Parser p, int id) { super(p, id); } /** {@inheritDoc} */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } /** {@inheritDoc} */ public Object value(JexlContext jc) throws Exception { return execute(null, jc); } /** Store the first child as {@link ASTReference#root root}. */ public void jjtClose() { root = (SimpleNode) jjtGetChild(0); } /** * evaluate each piece of the reference. * * e.g. foo.bar.woogie[2].name, foo is our 'root', and we need to * evaluate 'bar.woogie[2].name' relative to foo. * * @param jc the {@link JexlContext} to evaluate against. * @param obj not used. root.value(jc) is used instead. * @return the value of the array expression. * @throws Exception on any error */ public Object execute(Object obj, JexlContext jc) throws Exception { Object o = root.value(jc); /* * ignore the first child - it's our identifier */ for (int i = 1; i < jjtGetNumChildren(); i++) { o = ((SimpleNode) jjtGetChild(i)).execute(o, jc); // check for a variable in the context named // child0.child1.child2 etc if (o == null) { String varName = getIdentifierToDepth(i); o = jc.getVars().get(varName); } } return o; } /** * This method returns a variable from this identifier and it's children. * For an expression like 'a.b.c', a is child zero, b is child 1 and c is * child 2. * * @param i the depth of the child nodes to go to * @return the a dotted variable from this identifier and it's child nodes. */ private String getIdentifierToDepth(int i) { StringBuffer varName = new StringBuffer(); for (int j = 0; j <= i; j++) { SimpleNode node = (SimpleNode) jjtGetChild(j); if (node instanceof ASTIdentifier) { varName.append(((ASTIdentifier) node).getIdentifierString()); if (j != i) { varName.append('.'); } } } return varName.toString(); } /** * Gets the variable name of {@link ASTReference#root root}. * @return the identifier. * @throws Exception on any error * @see ASTIdentifier#getIdentifierString() * @see ASTArrayAccess#getIdentifierString() */ public String getRootString() throws Exception { if (root instanceof ASTIdentifier) { return ((ASTIdentifier) root).getIdentifierString(); } if (root instanceof ASTArrayAccess) { return ((ASTArrayAccess) root).getIdentifierString(); } throw new Exception("programmer error : ASTReference : root not known" + root); } } ././@LongLink 0000000 0000000 0000000 00000000157 00000000000 011570 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTExpressionExpression.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTExpressionExpre0000664 0001750 0001750 00000003561 11671435474 033537 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.parser; import org.apache.commons.jexl.JexlContext; /** * represents equality between integers - use .equals() for strings. * * @author Geir Magnusson Jr. * @version $Id: ASTExpressionExpression.java 480412 2006-11-29 05:11:23Z bayard $ */ public class ASTExpressionExpression extends SimpleNode { /** * Create the node given an id. * * @param id node id. */ public ASTExpressionExpression(int id) { super(id); } /** * Create a node with the given parser and id. * * @param p a parser. * @param id node id. */ public ASTExpressionExpression(Parser p, int id) { super(p, id); } /** {@inheritDoc} */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } /** {@inheritDoc} */ public Object value(JexlContext context) throws Exception { return ((SimpleNode) jjtGetChild(0)).value(context); } } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTSizeMethod.java0000664 0001750 0001750 00000004202 11671435474 033360 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.parser; import org.apache.commons.jexl.JexlContext; /** * Size Method, e.g. size(). * * @author Mark H. Wilkinson * @version $Id: ASTSizeMethod.java 548229 2007-06-18 06:11:32Z dion $ */ public class ASTSizeMethod extends SimpleNode { /** * Create the node given an id. * * @param id node id. */ public ASTSizeMethod(int id) { super(id); } /** * Create a node with the given parser and id. * * @param p a parser. * @param id node id. */ public ASTSizeMethod(Parser p, int id) { super(p, id); } /** {@inheritDoc} */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } /** * evaluate size as part of an expression on a base object. * * foo.bar.size * * @param jc the {@link JexlContext} to evaluate against. * @param obj not used. * @return the value of the array expression. * @throws Exception on any error */ public Object execute(Object obj, JexlContext jc) throws Exception { if (null == obj) { return null; } return new Integer(ASTSizeFunction.sizeOf(obj, getUberspect())); } } ././@LongLink 0000000 0000000 0000000 00000000151 00000000000 011562 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTIntegerLiteral.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTIntegerLiteral.0000664 0001750 0001750 00000004522 11671435474 033362 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.parser; import org.apache.commons.jexl.JexlContext; /** * represents an integer. * * @author Geir Magnusson Jr. * @version $Id: ASTIntegerLiteral.java 548229 2007-06-18 06:11:32Z dion $ */ public class ASTIntegerLiteral extends SimpleNode { /** literal value. */ protected Integer val; /** * Create the node given an id. * * @param id node id. */ public ASTIntegerLiteral(int id) { super(id); } /** * Create a node with the given parser and id. * * @param p a parser. * @param id node id. */ public ASTIntegerLiteral(Parser p, int id) { super(p, id); } /** {@inheritDoc} */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } /** * Part of reference resolution - wierd... in JSTL EL you can have foo.2 * which is equiv to foo[2] it appears... * * @param obj the object to evaluate against. * @param ctx the {@link JexlContext}. * @throws Exception on any error. * @return the resulting value. * @see ASTArrayAccess#evaluateExpr(Object, Object, Uberspect) */ public Object execute(Object obj, JexlContext ctx) throws Exception { return ASTArrayAccess.evaluateExpr(obj, val, getUberspect()); } /** {@inheritDoc} */ public Object value(JexlContext jc) throws Exception { return val; } } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTJexlScript.java0000664 0001750 0001750 00000003564 11671435474 033406 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.parser; import org.apache.commons.jexl.JexlContext; /** * Top of the syntax tree - parsed Jexl code. * * @since 1.1 */ public class ASTJexlScript extends SimpleNode { /** * Create the node given an id. * * @param id node id. */ public ASTJexlScript(int id) { super(id); } /** * Create a node with the given parser and id. * * @param p a parser. * @param id node id. */ public ASTJexlScript(Parser p, int id) { super(p, id); } /** {@inheritDoc} */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } /** {@inheritDoc} */ public Object value(JexlContext jc) throws Exception { int numChildren = jjtGetNumChildren(); Object result = null; for (int i = 0; i < numChildren; i++) { SimpleNode child = (SimpleNode) jjtGetChild(i); result = child.value(jc); } return result; } } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTDivNode.java 0000664 0001750 0001750 00000004534 11671435474 032645 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.parser; import org.apache.commons.jexl.util.Coercion; import org.apache.commons.jexl.JexlContext; /** * a / b, mathematical divide. * * @author Geir Magnusson Jr. * @version $Id: ASTDivNode.java 480412 2006-11-29 05:11:23Z bayard $ */ public class ASTDivNode extends SimpleNode { /** * Create the node given an id. * * @param id node id. */ public ASTDivNode(int id) { super(id); } /** * Create a node with the given parser and id. * * @param p a parser. * @param id node id. */ public ASTDivNode(Parser p, int id) { super(p, id); } /** {@inheritDoc} */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } /** {@inheritDoc} */ public Object value(JexlContext jc) throws Exception { Object left = ((SimpleNode) jjtGetChild(0)).value(jc); Object right = ((SimpleNode) jjtGetChild(1)).value(jc); /* * the spec says 'and', I think 'or' */ if (left == null && right == null) { return new Byte((byte) 0); } Double l = Coercion.coerceDouble(left); Double r = Coercion.coerceDouble(right); /* * catch div/0 */ if (r.doubleValue() == 0.0) { return new Double(0.0); } return new Double(l.doubleValue() / r.doubleValue()); } } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTExpression.java0000664 0001750 0001750 00000003436 11671435474 033454 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.parser; import org.apache.commons.jexl.JexlContext; /** * AST node for expression. * * @author Geir Magnusson Jr. * @version $Id: ASTExpression.java 480412 2006-11-29 05:11:23Z bayard $ */ public class ASTExpression extends SimpleNode { /** * Create the node given an id. * * @param id node id. */ public ASTExpression(int id) { super(id); } /** * Create a node with the given parser and id. * * @param p a parser. * @param id node id. */ public ASTExpression(Parser p, int id) { super(p, id); } /** {@inheritDoc} */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } /** {@inheritDoc} */ public Object value(JexlContext context) throws Exception { return ((SimpleNode) jjtGetChild(0)).value(context); } } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTAndNode.java 0000664 0001750 0001750 00000004142 11671435474 032620 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.parser; import org.apache.commons.jexl.JexlContext; import org.apache.commons.jexl.util.Coercion; /** * && and 'and'. * * @author Geir Magnusson Jr. * @version $Id: ASTAndNode.java 480412 2006-11-29 05:11:23Z bayard $ */ public class ASTAndNode extends SimpleNode { /** * Create the node given an id. * * @param id node id. */ public ASTAndNode(int id) { super(id); } /** * Create a node with the given parser and id. * * @param p a parser. * @param id node id. */ public ASTAndNode(Parser p, int id) { super(p, id); } /** {@inheritDoc} */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } /** {@inheritDoc} */ public Object value(JexlContext jc) throws Exception { Object left = ((SimpleNode) jjtGetChild(0)).value(jc); boolean leftValue = Coercion.coerceBoolean(left).booleanValue(); /* * coercion rules */ return (leftValue && Coercion.coerceBoolean( ((SimpleNode) jjtGetChild(1)).value(jc)).booleanValue()) ? Boolean.TRUE : Boolean.FALSE; } } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTAddNode.java 0000664 0001750 0001750 00000010103 11671435474 032600 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.parser; import org.apache.commons.jexl.JexlContext; import org.apache.commons.jexl.util.Coercion; /** * Addition : either integer addition or string concatenation. * * @author Geir Magnusson Jr. * @version $Id: ASTAddNode.java 480412 2006-11-29 05:11:23Z bayard $ */ public class ASTAddNode extends SimpleNode { /** * Create the node given an id. * * @param id node id. */ public ASTAddNode(int id) { super(id); } /** * Create a node with the given parser and id. * * @param p a parser. * @param id node id. */ public ASTAddNode(Parser p, int id) { super(p, id); } /** * {@inheritDoc} */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } /** * {@inheritDoc} */ public Object value(JexlContext context) throws Exception { Object left = ((SimpleNode) jjtGetChild(0)).value(context); Object right = ((SimpleNode) jjtGetChild(1)).value(context); /* * the spec says 'and' */ if (left == null && right == null) { return new Long(0); } // Kohsuke addition - handle null gracefully if (left == null) return right; if (right == null) return left; // Kohsuke addition until here /* * if anything is float, double or string with ( "." | "E" | "e") * coerce all to doubles and do it */ if (left instanceof Float || left instanceof Double || right instanceof Float || right instanceof Double || (left instanceof String && (((String) left).indexOf(".") != -1 || ((String) left).indexOf("e") != -1 || ((String) left).indexOf("E") != -1) ) || (right instanceof String && (((String) right).indexOf(".") != -1 || ((String) right).indexOf("e") != -1 || ((String) right).indexOf("E") != -1) ) ) { /* * in the event that either is null and not both, then just make the * null a 0 */ try { Double l = Coercion.coerceDouble(left); Double r = Coercion.coerceDouble(right); return new Double(l.doubleValue() + r.doubleValue()); } catch (java.lang.NumberFormatException nfe) { /* * Well, use strings! */ return left.toString().concat(right.toString()); } } /* * attempt to use Longs */ try { Long l = Coercion.coerceLong(left); Long r = Coercion.coerceLong(right); return new Long(l.longValue() + r.longValue()); } catch (java.lang.NumberFormatException nfe) { /* * Well, use strings! */ return left.toString().concat(right.toString()); } } } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTMethod.java 0000664 0001750 0001750 00000012303 11671435474 032526 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.parser; import java.lang.reflect.InvocationTargetException; import java.math.BigDecimal; import java.math.BigInteger; import org.apache.commons.jexl.JexlContext; import org.apache.commons.jexl.util.introspection.Info; import org.apache.commons.jexl.util.introspection.VelMethod; /** * Method execution. */ public class ASTMethod extends SimpleNode { /** dummy velocity info. */ private static final Info DUMMY = new Info("", 1, 1); /** * Create the node given an id. * * @param id node id. */ public ASTMethod(int id) { super(id); } /** * Create a node with the given parser and id. * * @param p a parser. * @param id node id. */ public ASTMethod(Parser p, int id) { super(p, id); } /** {@inheritDoc} */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } /** * evaluate a method invocation upon a base object. * * foo.bar(2) * * @param jc the {@link JexlContext} to evaluate against. * @param obj The object to have the method invoked. * @return the value of the method invocation. * @throws Exception on any error */ public Object execute(Object obj, JexlContext jc) throws Exception { String methodName = ((ASTIdentifier) jjtGetChild(0)).val; int paramCount = jjtGetNumChildren() - 1; /* * get our params */ Object[] params = new Object[paramCount]; try { for (int i = 0; i < paramCount; i++) { params[i] = ((SimpleNode) jjtGetChild(i + 1)).value(jc); } VelMethod vm = getUberspect().getMethod(obj, methodName, params, DUMMY); /* * DG: If we can't find an exact match, narrow the parameters and * try again! */ if (vm == null) { // replace all numbers with the smallest type that will fit for (int i = 0; i < params.length; i++) { Object param = params[i]; if (param instanceof Number) { params[i] = narrow((Number) param); } } vm = getUberspect().getMethod(obj, methodName, params, DUMMY); if (vm == null) { return null; } } return vm.invoke(obj, params); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof Exception) { throw (Exception) t; } throw e; } } /** * Given a Number, return back the value using the smallest type the result * will fit into. This works hand in hand with parameter 'widening' in java * method calls, e.g. a call to substring(int,int) with an int and a long * will fail, but a call to substring(int,int) with an int and a short will * succeed. * * @param original the original number. * @return a value of the smallest type the original number will fit into. * @since 1.1 */ private Number narrow(Number original) { if (original == null || original instanceof BigDecimal || original instanceof BigInteger) { return original; } Number result = original; if (original instanceof Double || original instanceof Float) { double value = original.doubleValue(); if (value <= Float.MAX_VALUE && value >= Float.MIN_VALUE) { result = new Float(result.floatValue()); } // else it was already a double } else { long value = original.longValue(); if (value <= Byte.MAX_VALUE && value >= Byte.MIN_VALUE) { // it will fit in a byte result = new Byte((byte) value); } else if (value <= Short.MAX_VALUE && value >= Short.MIN_VALUE) { result = new Short((short) value); } else if (value <= Integer.MAX_VALUE && value >= Integer.MIN_VALUE) { result = new Integer((int) value); } // else it was already a long } return result; } } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTTrueNode.java 0000664 0001750 0001750 00000003361 11671435474 033037 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.parser; import org.apache.commons.jexl.JexlContext; /** * represents Boolean true. * * @author Geir Magnusson Jr. * @version $Id: ASTTrueNode.java 480412 2006-11-29 05:11:23Z bayard $ */ public class ASTTrueNode extends SimpleNode { /** * Create the node given an id. * * @param id node id. */ public ASTTrueNode(int id) { super(id); } /** * Create a node with the given parser and id. * * @param p a parser. * @param id node id. */ public ASTTrueNode(Parser p, int id) { super(p, id); } /** {@inheritDoc} */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } /** {@inheritDoc} */ public Object value(JexlContext jc) throws Exception { return Boolean.TRUE; } } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTAssignment.java0000664 0001750 0001750 00000004457 11671435474 033431 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.parser; import org.apache.commons.jexl.JexlContext; /** * x = y, assigns a value to a variable in the context. * * @author Dion Gillard * */ public class ASTAssignment extends SimpleNode { /** * Create the node given an id. * * @param id node id. */ public ASTAssignment(int id) { super(id); } /** * Create a node with the given parser and id. * * @param p a parser. * @param id node id. */ public ASTAssignment(Parser p, int id) { super(p, id); } /** {@inheritDoc} */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } /** {@inheritDoc} */ public Object value(JexlContext context) throws Exception { // left should be the variable (reference) to assign to SimpleNode left = (SimpleNode) jjtGetChild(0); // right should be the expression to evaluate Object right = ((SimpleNode) jjtGetChild(1)).value(context); if (left instanceof ASTReference) { ASTReference reference = (ASTReference) left; left = (SimpleNode) reference.jjtGetChild(0); if (left instanceof ASTIdentifier) { String identifier = ((ASTIdentifier) left) .getIdentifierString(); context.getVars().put(identifier, right); } } return right; } } ././@LongLink 0000000 0000000 0000000 00000000147 00000000000 011567 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTFloatLiteral.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTFloatLiteral.ja0000664 0001750 0001750 00000003502 11671435474 033342 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.parser; import org.apache.commons.jexl.JexlContext; /** * represents a float point number. * * @author Geir Magnusson Jr. * @version $Id: ASTFloatLiteral.java 480412 2006-11-29 05:11:23Z bayard $ */ public class ASTFloatLiteral extends SimpleNode { /** the value of the literal. */ protected Float val; /** * Create the node given an id. * * @param id node id. */ public ASTFloatLiteral(int id) { super(id); } /** * Create a node with the given parser and id. * * @param p a parser. * @param id node id. */ public ASTFloatLiteral(Parser p, int id) { super(p, id); } /** {@inheritDoc} */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } /** {@inheritDoc} */ public Object value(JexlContext jc) throws Exception { return val; } } ././@LongLink 0000000 0000000 0000000 00000000151 00000000000 011562 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTBitwiseXorNode.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTBitwiseXorNode.0000664 0001750 0001750 00000004100 11671435474 033345 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.parser; import org.apache.commons.jexl.JexlContext; import org.apache.commons.jexl.util.Coercion; /** * Bitwise Or. Syntax: a ^ b Result is a Long * * @author Dion Gillard * @since 1.1 */ public class ASTBitwiseXorNode extends SimpleNode { /** * Create the node given an id. * * @param id node id. */ public ASTBitwiseXorNode(int id) { super(id); } /** * Create a node with the given parser and id. * * @param p a parser. * @param id node id. */ public ASTBitwiseXorNode(Parser p, int id) { super(p, id); } /** * {@inheritDoc} */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } /** * {@inheritDoc} */ public Object value(JexlContext context) throws Exception { Object left = ((SimpleNode) jjtGetChild(0)).value(context); Object right = ((SimpleNode) jjtGetChild(1)).value(context); Long l = left == null ? new Long(0) : Coercion.coerceLong(left); Long r = right == null ? new Long(0) : Coercion.coerceLong(right); return new Long(l.longValue() ^ r.longValue()); } } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTElvisNode.java 0000664 0001750 0001750 00000001636 11671435474 033205 0 ustar jamespage jamespage package org.apache.commons.jexl.parser; import org.apache.commons.jexl.JexlContext; /** * "x?:y" operator. * * @author Kohsuke Kawaguchi */ public class ASTElvisNode extends SimpleNode { /** * Create the node given an id. * * @param id node id. */ public ASTElvisNode(int id) { super(id); } /** * Create a node with the given parser and id. * * @param p a parser. * @param id node id. */ public ASTElvisNode(Parser p, int id) { super(p, id); } /** {@inheritDoc} */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } /** {@inheritDoc} */ public Object value(JexlContext jc) throws Exception { Object cond = ((SimpleNode) jjtGetChild(0)).value(jc); if(cond!=null) return cond; return ((SimpleNode) jjtGetChild(1)).value(jc); } } ././@LongLink 0000000 0000000 0000000 00000000150 00000000000 011561 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/SimpleCharStream.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/SimpleCharStream.j0000664 0001750 0001750 00000030223 11671435474 033452 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 3.0 */ package org.apache.commons.jexl.parser; /** * An implementation of interface CharStream, where the stream is assumed to * contain only ASCII characters (without unicode processing). */ public class SimpleCharStream { public static final boolean staticFlag = false; int bufsize; int available; int tokenBegin; public int bufpos = -1; protected int bufline[]; protected int bufcolumn[]; protected int column = 0; protected int line = 1; protected boolean prevCharIsCR = false; protected boolean prevCharIsLF = false; protected java.io.Reader inputStream; protected char[] buffer; protected int maxNextCharInd = 0; protected int inBuf = 0; protected int tabSize = 8; protected void setTabSize(int i) { tabSize = i; } protected int getTabSize(int i) { return tabSize; } protected void ExpandBuff(boolean wrapAround) { char[] newbuffer = new char[bufsize + 2048]; int newbufline[] = new int[bufsize + 2048]; int newbufcolumn[] = new int[bufsize + 2048]; try { if (wrapAround) { System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos); buffer = newbuffer; System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); bufline = newbufline; System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); bufcolumn = newbufcolumn; maxNextCharInd = (bufpos += (bufsize - tokenBegin)); } else { System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); buffer = newbuffer; System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); bufline = newbufline; System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); bufcolumn = newbufcolumn; maxNextCharInd = (bufpos -= tokenBegin); } } catch (Throwable t) { throw new Error(t.getMessage()); } bufsize += 2048; available = bufsize; tokenBegin = 0; } protected void FillBuff() throws java.io.IOException { if (maxNextCharInd == available) { if (available == bufsize) { if (tokenBegin > 2048) { bufpos = maxNextCharInd = 0; available = tokenBegin; } else if (tokenBegin < 0) bufpos = maxNextCharInd = 0; else ExpandBuff(false); } else if (available > tokenBegin) available = bufsize; else if ((tokenBegin - available) < 2048) ExpandBuff(true); else available = tokenBegin; } int i; try { if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1) { inputStream.close(); throw new java.io.IOException(); } else maxNextCharInd += i; return; } catch(java.io.IOException e) { --bufpos; backup(0); if (tokenBegin == -1) tokenBegin = bufpos; throw e; } } public char BeginToken() throws java.io.IOException { tokenBegin = -1; char c = readChar(); tokenBegin = bufpos; return c; } protected void UpdateLineColumn(char c) { column++; if (prevCharIsLF) { prevCharIsLF = false; line += (column = 1); } else if (prevCharIsCR) { prevCharIsCR = false; if (c == '\n') { prevCharIsLF = true; } else line += (column = 1); } switch (c) { case '\r' : prevCharIsCR = true; break; case '\n' : prevCharIsLF = true; break; case '\t' : column--; column += (tabSize - (column % tabSize)); break; default : break; } bufline[bufpos] = line; bufcolumn[bufpos] = column; } public char readChar() throws java.io.IOException { if (inBuf > 0) { --inBuf; if (++bufpos == bufsize) bufpos = 0; return buffer[bufpos]; } if (++bufpos >= maxNextCharInd) FillBuff(); char c = buffer[bufpos]; UpdateLineColumn(c); return (c); } /** * @deprecated * @see #getEndColumn */ public int getColumn() { return bufcolumn[bufpos]; } /** * @deprecated * @see #getEndLine */ public int getLine() { return bufline[bufpos]; } public int getEndColumn() { return bufcolumn[bufpos]; } public int getEndLine() { return bufline[bufpos]; } public int getBeginColumn() { return bufcolumn[tokenBegin]; } public int getBeginLine() { return bufline[tokenBegin]; } public void backup(int amount) { inBuf += amount; if ((bufpos -= amount) < 0) bufpos += bufsize; } public SimpleCharStream(java.io.Reader dstream, int startline, int startcolumn, int buffersize) { inputStream = dstream; line = startline; column = startcolumn - 1; available = bufsize = buffersize; buffer = new char[buffersize]; bufline = new int[buffersize]; bufcolumn = new int[buffersize]; } public SimpleCharStream(java.io.Reader dstream, int startline, int startcolumn) { this(dstream, startline, startcolumn, 4096); } public SimpleCharStream(java.io.Reader dstream) { this(dstream, 1, 1, 4096); } public void ReInit(java.io.Reader dstream, int startline, int startcolumn, int buffersize) { inputStream = dstream; line = startline; column = startcolumn - 1; if (buffer == null || buffersize != buffer.length) { available = bufsize = buffersize; buffer = new char[buffersize]; bufline = new int[buffersize]; bufcolumn = new int[buffersize]; } prevCharIsLF = prevCharIsCR = false; tokenBegin = inBuf = maxNextCharInd = 0; bufpos = -1; } public void ReInit(java.io.Reader dstream, int startline, int startcolumn) { ReInit(dstream, startline, startcolumn, 4096); } public void ReInit(java.io.Reader dstream) { ReInit(dstream, 1, 1, 4096); } public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException { this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); } public SimpleCharStream(java.io.InputStream dstream, int startline, int startcolumn, int buffersize) { this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); } public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, int startcolumn) throws java.io.UnsupportedEncodingException { this(dstream, encoding, startline, startcolumn, 4096); } public SimpleCharStream(java.io.InputStream dstream, int startline, int startcolumn) { this(dstream, startline, startcolumn, 4096); } public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException { this(dstream, encoding, 1, 1, 4096); } public SimpleCharStream(java.io.InputStream dstream) { this(dstream, 1, 1, 4096); } public void ReInit(java.io.InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException { ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); } public void ReInit(java.io.InputStream dstream, int startline, int startcolumn, int buffersize) { ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); } public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException { ReInit(dstream, encoding, 1, 1, 4096); } public void ReInit(java.io.InputStream dstream) { ReInit(dstream, 1, 1, 4096); } public void ReInit(java.io.InputStream dstream, String encoding, int startline, int startcolumn) throws java.io.UnsupportedEncodingException { ReInit(dstream, encoding, startline, startcolumn, 4096); } public void ReInit(java.io.InputStream dstream, int startline, int startcolumn) { ReInit(dstream, startline, startcolumn, 4096); } public String GetImage() { if (bufpos >= tokenBegin) return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); else return new String(buffer, tokenBegin, bufsize - tokenBegin) + new String(buffer, 0, bufpos + 1); } public char[] GetSuffix(int len) { char[] ret = new char[len]; if ((bufpos + 1) >= len) System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); else { System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, len - bufpos - 1); System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); } return ret; } public void Done() { buffer = null; bufline = null; bufcolumn = null; } /** * Method to adjust line and column numbers for the start of a token. */ public void adjustBeginLineColumn(int newLine, int newCol) { int start = tokenBegin; int len; if (bufpos >= tokenBegin) { len = bufpos - tokenBegin + inBuf + 1; } else { len = bufsize - tokenBegin + bufpos + 1 + inBuf; } int i = 0, j = 0, k = 0; int nextColDiff = 0, columnDiff = 0; while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) { bufline[j] = newLine; nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; bufcolumn[j] = newCol + columnDiff; columnDiff = nextColDiff; i++; } if (i < len) { bufline[j] = newLine++; bufcolumn[j] = newCol + columnDiff; while (i++ < len) { if (bufline[j = start % bufsize] != bufline[++start % bufsize]) bufline[j] = newLine++; else bufline[j] = newLine; } } line = bufline[j]; column = bufcolumn[j]; } } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTOrNode.java 0000664 0001750 0001750 00000004125 11671435474 032477 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.parser; import org.apache.commons.jexl.util.Coercion; import org.apache.commons.jexl.JexlContext; /** * || and 'or'. * * @author Geir Magnusson Jr. * @version $Id: ASTOrNode.java 480412 2006-11-29 05:11:23Z bayard $ */ public class ASTOrNode extends SimpleNode { /** * Create the node given an id. * * @param id node id. */ public ASTOrNode(int id) { super(id); } /** * Create a node with the given parser and id. * * @param p a parser. * @param id node id. */ public ASTOrNode(Parser p, int id) { super(p, id); } /** {@inheritDoc} */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } /** {@inheritDoc} */ public Object value(JexlContext jc) throws Exception { Object left = ((SimpleNode) jjtGetChild(0)).value(jc); boolean leftValue = Coercion.coerceBoolean(left).booleanValue(); /* * coercion rules */ return (leftValue || Coercion.coerceBoolean(((SimpleNode) jjtGetChild(1)).value(jc)).booleanValue()) ? Boolean.TRUE : Boolean.FALSE; } } ././@LongLink 0000000 0000000 0000000 00000000151 00000000000 011562 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTBitwiseAndNode.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTBitwiseAndNode.0000664 0001750 0001750 00000004053 11671435474 033306 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.parser; import org.apache.commons.jexl.JexlContext; import org.apache.commons.jexl.util.Coercion; /** * Bitwise And. Syntax: a & b Result is a {@link Long} * * @author Dion Gillard * @since 1.1 */ public class ASTBitwiseAndNode extends SimpleNode { /** * Create the node given an id. * * @param id node id. */ public ASTBitwiseAndNode(int id) { super(id); } /** * Create a node with the given parser and id. * * @param p a parser. * @param id node id. */ public ASTBitwiseAndNode(Parser p, int id) { super(p, id); } /** {@inheritDoc} */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } /** {@inheritDoc} */ public Object value(JexlContext context) throws Exception { Object left = ((SimpleNode) jjtGetChild(0)).value(context); Object right = ((SimpleNode) jjtGetChild(1)).value(context); Long l = left == null ? new Long(0) : Coercion.coerceLong(left); Long r = right == null ? new Long(0) : Coercion.coerceLong(right); return new Long(l.longValue() & r.longValue()); } } ././@LongLink 0000000 0000000 0000000 00000000156 00000000000 011567 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTReferenceExpression.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTReferenceExpres0000664 0001750 0001750 00000003253 11671435474 033457 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.parser; import org.apache.commons.jexl.JexlContext; /** * variable; A reference by itself. */ public class ASTReferenceExpression extends SimpleNode { /** * Create the node given an id. * * @param id node id. */ public ASTReferenceExpression(int id) { super(id); } /** * Create a node with the given parser and id. * * @param p a parser. * @param id node id. */ public ASTReferenceExpression(Parser p, int id) { super(p, id); } /** {@inheritDoc} */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } /** {@inheritDoc} */ public Object value(JexlContext context) throws Exception { return ((SimpleNode) jjtGetChild(0)).value(context); } } jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTModNode.java 0000664 0001750 0001750 00000006703 11671435474 032642 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.parser; import org.apache.commons.jexl.JexlContext; import org.apache.commons.jexl.util.Coercion; /** * % (mod). * * @author Geir Magnusson Jr. * @version $Id: ASTModNode.java 480412 2006-11-29 05:11:23Z bayard $ */ public class ASTModNode extends SimpleNode { /** * Create the node given an id. * * @param id node id. */ public ASTModNode(int id) { super(id); } /** * Create a node with the given parser and id. * * @param p a parser. * @param id node id. */ public ASTModNode(Parser p, int id) { super(p, id); } /** {@inheritDoc} */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } /** {@inheritDoc} */ public Object value(JexlContext jc) throws Exception { Object left = ((SimpleNode) jjtGetChild(0)).value(jc); Object right = ((SimpleNode) jjtGetChild(1)).value(jc); /* * the spec says 'and', I think 'or' */ if (left == null && right == null) { return new Byte((byte) 0); } /* * if anything is float, double or string with ( "." | "E" | "e") coerce * all to doubles and do it */ if (left instanceof Float || left instanceof Double || right instanceof Float || right instanceof Double || (left instanceof String && (((String) left).indexOf(".") != -1 || ((String) left).indexOf("e") != -1 || ((String) left).indexOf("E") != -1)) || (right instanceof String && (((String) right).indexOf(".") != -1 || ((String) right).indexOf("e") != -1 || ((String) right).indexOf("E") != -1))) { Double l = Coercion.coerceDouble(left); Double r = Coercion.coerceDouble(right); /* * catch div/0 */ if (r.doubleValue() == 0.0) { return new Double(0.0); } return new Double(l.doubleValue() % r.doubleValue()); } /* * otherwise to longs with thee! */ Long l = Coercion.coerceLong(left); Long r = Coercion.coerceLong(right); /* * catch the div/0 */ if (r.longValue() == 0) { return new Long(0); } return new Long(l.longValue() % r.longValue()); } } ././@LongLink 0000000 0000000 0000000 00000000150 00000000000 011561 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTBitwiseOrNode.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ASTBitwiseOrNode.j0000664 0001750 0001750 00000004041 11671435474 033333 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jexl.parser; import org.apache.commons.jexl.JexlContext; import org.apache.commons.jexl.util.Coercion; /** * Bitwise Or. Syntax: a | b Result is a Long * * @author Dion Gillard * @since 1.1 */ public class ASTBitwiseOrNode extends SimpleNode { /** * Create the node given an id. * * @param id node id. */ public ASTBitwiseOrNode(int id) { super(id); } /** * Create a node with the given parser and id. * * @param p a parser. * @param id node id. */ public ASTBitwiseOrNode(Parser p, int id) { super(p, id); } /** {@inheritDoc} */ public Object jjtAccept(ParserVisitor visitor, Object data) { return visitor.visit(this, data); } /** {@inheritDoc} */ public Object value(JexlContext context) throws Exception { Object left = ((SimpleNode) jjtGetChild(0)).value(context); Object right = ((SimpleNode) jjtGetChild(1)).value(context); Long l = left == null ? new Long(0) : Coercion.coerceLong(left); Long r = right == null ? new Long(0) : Coercion.coerceLong(right); return new Long(l.longValue() | r.longValue()); } } ././@LongLink 0000000 0000000 0000000 00000000146 00000000000 011566 L ustar root root jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ParseException.java jenkins-commons-jexl-1.1-jenkins-20111212/src/java/org/apache/commons/jexl/parser/ParseException.jav0000664 0001750 0001750 00000016425 11671435474 033537 0 ustar jamespage jamespage /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */ package org.apache.commons.jexl.parser; /** * This exception is thrown when parse errors are encountered. * You can explicitly create objects of this exception type by * calling the method generateParseException in the generated * parser. * * You can modify this class to customize your error reporting * mechanisms so long as you retain the public fields. */ public class ParseException extends Exception { /** * This constructor is used by the method "generateParseException" * in the generated parser. Calling this constructor generates * a new object of this type with the fields "currentToken", * "expectedTokenSequences", and "tokenImage" set. The boolean * flag "specialConstructor" is also set to true to indicate that * this constructor was used to create this object. * This constructor calls its super class with the empty string * to force the "toString" method of parent class "Throwable" to * print the error message in the form: * ParseException:Commons JEXL uses ASF JIRA for tracking issues. Issues for Commons JEXL are tracked at http://issues.apache.org/jira/browse/JEXL
To create a new issue you will need to sign up for a new account, unless you had previously used the Commons product in Bugzilla in which case your username is your email address and you will need to use the Forgot Password page to get a new password.
Bugs and enhancements should be filed under the "Commons JEXL" project in JIRA. If you would like to report a bug, or raise an enhancement request with Commons JEXL please do the following:
Please also remember these points:
You may also find these links useful:
Apache Commons JEXL is hosted on the Apache subversion repository.
The project URL is:
http://svn.apache.org/repos/asf/commons/proper/jexl/trunk
The best way to view the repository is via the subversion viewer.
The alternative is to use the native subversion display.
Latest Stable Release
Nightly Builds
Archived Releases
Older releases are retained by the Apache Software Foundation but are
moved into a
special archive area.
Commons JEXL uses Maven or Ant as a build system. The source is here.
To build a jar file, change into JEXL's root directory (see source link above) and run "maven jar". The result will be in the "target" subdirectory.
To build the Javadocs, run "maven javadoc". The result will be in "target/docs/apidocs".
To build the full website, run "maven site". The result will be in "target/docs".
To build the site, you need Maven 1.0.2 and version 1.9.2 of the maven-xdoc-plugin installed.
To build a jar file, change into JEXL's root directory and run "ant jar". The result will be in the "target" subdirectory.
To build the Javadocs, run "ant javadoc". The result will be in "dist/docs".