Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 73459 invoked from network); 12 Oct 2009 16:48:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 12 Oct 2009 16:48:06 -0000 Received: (qmail 62392 invoked by uid 500); 12 Oct 2009 16:48:05 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 62283 invoked by uid 500); 12 Oct 2009 16:48:05 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 62274 invoked by uid 99); 12 Oct 2009 16:48:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Oct 2009 16:48:05 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00 X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Oct 2009 16:48:00 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 9C33423888E2; Mon, 12 Oct 2009 16:47:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r824415 - in /commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl: ./ scripting/ util/introspection/ Date: Mon, 12 Oct 2009 16:47:40 -0000 To: commits@commons.apache.org From: henrib@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091012164740.9C33423888E2@eris.apache.org> Author: henrib Date: Mon Oct 12 16:47:39 2009 New Revision: 824415 URL: http://svn.apache.org/viewvc?rev=824415&view=rev Log: Fixed various Javadoc / checkstyle issues Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/ExpressionImpl.java commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Interpreter.java commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/JexlArithmetic.java commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Main.java commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Script.java commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/ScriptFactory.java commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/UnifiedJEXL.java commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/scripting/Main.java commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/util/introspection/JexlMethod.java commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/util/introspection/JexlPropertyGet.java commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/util/introspection/JexlPropertySet.java Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/ExpressionImpl.java URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/ExpressionImpl.java?rev=824415&r1=824414&r2=824415&view=diff ============================================================================== --- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/ExpressionImpl.java (original) +++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/ExpressionImpl.java Mon Oct 12 16:47:39 2009 @@ -101,7 +101,7 @@ /** * {@inheritDoc} */ - public Object execute(JexlContext context) throws Exception { + public Object execute(JexlContext context) { Interpreter interpreter = jexl.createInterpreter(context); return interpreter.interpret(script); } Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Interpreter.java URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Interpreter.java?rev=824415&r1=824414&r2=824415&view=diff ============================================================================== --- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Interpreter.java (original) +++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Interpreter.java Mon Oct 12 16:47:39 2009 @@ -444,7 +444,7 @@ long l = arithmetic.toLong(left); n = 1; long r = arithmetic.toLong(right); - return new Long(l & r); + return Long.valueOf(l & r); } catch (RuntimeException xrt) { throw new JexlException(node.jjtGetChild(n), "long coercion error", xrt); } @@ -455,7 +455,7 @@ Object left = node.jjtGetChild(0).jjtAccept(this, data); try { long l = arithmetic.toLong(left); - return new Long(~l); + return Long.valueOf(~l); } catch (RuntimeException xrt) { throw new JexlException(node.jjtGetChild(0), "long coercion error", xrt); } @@ -471,7 +471,7 @@ long l = arithmetic.toLong(left); n = 1; long r = arithmetic.toLong(right); - return new Long(l | r); + return Long.valueOf(l | r); } catch (RuntimeException xrt) { throw new JexlException(node.jjtGetChild(n), "long coercion error", xrt); } @@ -487,7 +487,7 @@ long l = arithmetic.toLong(left); n = 1; long r = arithmetic.toLong(right); - return new Long(l ^ r); + return Long.valueOf(l ^ r); } catch (RuntimeException xrt) { throw new JexlException(node.jjtGetChild(n), "long coercion error", xrt); } @@ -1081,10 +1081,10 @@ return Long.valueOf(-valueAsLong); } else if (val instanceof Float) { float valueAsFloat = ((Float) val).floatValue(); - return Float.valueOf(-valueAsFloat); + return new Float(-valueAsFloat); } else if (val instanceof Double) { double valueAsDouble = ((Double) val).doubleValue(); - return Double.valueOf(-valueAsDouble); + return new Double(-valueAsDouble); } else if (val instanceof BigDecimal) { BigDecimal valueAsBigD = (BigDecimal) val; return valueAsBigD.negate(); Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/JexlArithmetic.java URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/JexlArithmetic.java?rev=824415&r1=824414&r2=824415&view=diff ============================================================================== --- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/JexlArithmetic.java (original) +++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/JexlArithmetic.java Mon Oct 12 16:47:39 2009 @@ -160,7 +160,6 @@ * @param lhs the left hand side operand that lead to the bigi result * @param rhs the right hand side operand that lead to the bigi result * @param bigi the BigInteger to narrow - * @param narrowInt whether we should try narrowing to int (@see mayNarrowToInt) * @return an Integer or Long if narrowing is possible, the original BigInteger otherwise */ protected Number narrowBigInteger(Object lhs, Object rhs, BigInteger bigi) { @@ -174,9 +173,9 @@ if (!(lhs instanceof Long || rhs instanceof Long) && l <= Integer.MAX_VALUE && l >= Integer.MIN_VALUE) { - return new Integer((int) l); + return Integer.valueOf((int) l); } - return new Long(l); + return Long.valueOf(l); } return bigi; } @@ -185,7 +184,7 @@ * Add two values together. *

* If any numeric add fails on coercion to the appropriate type, - * treat as Strings and do concatenation + * treat as Strings and do concatenation. *

* @param left first value * @param right second value Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Main.java URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Main.java?rev=824415&r1=824414&r2=824415&view=diff ============================================================================== --- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Main.java (original) +++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Main.java Mon Oct 12 16:47:39 2009 @@ -6,14 +6,13 @@ * (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 + * 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; @@ -40,30 +39,30 @@ * * @param args (optional) filename to evaluate. Stored in the args variable. * - * @throws Exception + * @throws Exception if parsing or IO fail */ public static void main(String[] args) throws Exception { JexlEngine engine = new JexlEngine(); JexlContext context = new HashMapContext(); context.getVars().put("args", args); - if (args.length == 1){ - Script script = engine.createScript(new File(args[0])); - Object value = script.execute(context); - System.out.println("Return value: "+value); - } else { - BufferedReader console = new BufferedReader(new InputStreamReader(System.in)); - String line; - System.out.print("> "); - while(null != (line=console.readLine())){ - try { + try { + if (args.length == 1) { + Script script = engine.createScript(new File(args[0])); + Object value = script.execute(context); + System.out.println("Return value: " + value); + } else { + BufferedReader console = new BufferedReader(new InputStreamReader(System.in)); + String line; + System.out.print("> "); + while (null != (line = console.readLine())) { Expression expression = engine.createExpression(line); Object value = expression.evaluate(context); - System.out.println("Return value: "+value); + System.out.println("Return value: " + value); System.out.print("> "); - } catch (JexlException e) { - System.out.println(e.getLocalizedMessage()); } } + } catch (JexlException e) { + System.out.println(e.getLocalizedMessage()); } } } Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Script.java URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Script.java?rev=824415&r1=824414&r2=824415&view=diff ============================================================================== --- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Script.java (original) +++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Script.java Mon Oct 12 16:47:39 2009 @@ -35,9 +35,8 @@ * @param context A JexlContext containing variables. * @return The result of this script, usually the result of * the last statement. - * @throws Exception on any script parse or execution error. */ - Object execute(JexlContext context) throws Exception; + Object execute(JexlContext context); /** * Returns the text of this Script. Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/ScriptFactory.java URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/ScriptFactory.java?rev=824415&r1=824414&r2=824415&view=diff ============================================================================== --- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/ScriptFactory.java (original) +++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/ScriptFactory.java Mon Oct 12 16:47:39 2009 @@ -49,35 +49,46 @@ * Lazy JexlEngine singleton; since this class is deprecated, let's not create the shared * engine if it's not gonna be used. */ - private static volatile JexlEngine INSTANCE = null; + private static volatile JexlEngine jexl10 = null; + /** + * Default cache size. + */ + private static final int CACHE_SIZE = 256; /** * An interpreter made compatible with v1.1 behavior (at least Jelly's expectations). */ private static class LegacyInterpreter extends Interpreter { + /** + * Creates an instance. + * @param jexl the jexl engine + * @param aContext the jexl context + */ public LegacyInterpreter(JexlEngine jexl, JexlContext aContext) { super(jexl, aContext); } - + /**{@inheritDoc}*/ @Override public Object interpret(JexlNode node) { try { return node.jjtAccept(this, null); } catch (JexlException xjexl) { Throwable e = xjexl.getCause(); - if (e instanceof RuntimeException) - throw (RuntimeException)e; - if (e instanceof IllegalStateException) - throw (IllegalStateException )e; + if (e instanceof RuntimeException) { + throw (RuntimeException) e; + } + if (e instanceof IllegalStateException) { + throw (IllegalStateException) e; + } throw new IllegalStateException(e.getMessage(), e); } } - + /**{@inheritDoc}*/ @Override protected Object invocationFailed(JexlException xjexl) { throw xjexl; } - + /**{@inheritDoc}*/ @Override protected Object unknownVariable(JexlException xjexl) { return null; @@ -88,6 +99,7 @@ * An engine that uses a LegacyInterpreter. */ private static class LegacyEngine extends JexlEngine { + /**{@inheritDoc}*/ @Override protected Interpreter createInterpreter(JexlContext context) { if (context == null) { @@ -99,21 +111,24 @@ /** * Retrieves the static shared JexlEngine instance. + * @return the static "legacy" shared instance */ + // CSOFF: DoubleCheckedLocking static JexlEngine getInstance() { // Java5 memory model allows double-lock pattern - if (INSTANCE == null) { + if (jexl10 == null) { synchronized(ScriptFactory.class){ - if (INSTANCE == null) { + if (jexl10 == null) { JexlEngine jexl = new LegacyEngine(); - jexl.setCache(256); + jexl.setCache(CACHE_SIZE); jexl.setSilent(false); - INSTANCE = jexl; + jexl10 = jexl; } } } - return INSTANCE; + return jexl10; } + // CSON: DoubleCheckedLocking /** * Private constructor, ensure no instance. Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/UnifiedJEXL.java URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/UnifiedJEXL.java?rev=824415&r1=824414&r2=824415&view=diff ============================================================================== --- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/UnifiedJEXL.java (original) +++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/UnifiedJEXL.java Mon Oct 12 16:47:39 2009 @@ -233,7 +233,7 @@ * The abstract base class for all expressions, immediate '${...}' and deferred '#{...}'. */ public abstract class Expression { - /** The source of this expression (see {@link Expression#prepare}). */ + /** The source of this expression (see {@link UnifiedJEXL.Expression#prepare}). */ protected final Expression source; /** * Creates an expression. @@ -353,7 +353,7 @@ * Intreprets a sub-expression. * @param interpreter a JEXL interpreter * @return the result of interpretation - * @throws org.apache.commons.jexl.parser.ParseException (only for nested & composite) + * @throws ParseException (only for nested & composite) */ abstract Object evaluate(Interpreter interpreter) throws ParseException; } @@ -763,7 +763,7 @@ * @param context the JEXL context to use * @param expr the expression to prepare * @return a prepared expression - * @throws {@link UnifiedJEXL.Exception} if an error occurs and the {@link JexlEngine} is not silent + * @throws UnifiedJEXL.Exception if an error occurs and the {@link JexlEngine} is not silent */ Expression prepare(JexlContext context, Expression expr) { try { @@ -793,7 +793,7 @@ * @param context the JEXL context to use * @param expr the expression to prepare * @return the result of the evaluation - * @throws {@link UnifiedJEXL.Exception} if an error occurs and the {@link JexlEngine} is not silent + * @throws UnifiedJEXL.Exception if an error occurs and the {@link JexlEngine} is not silent */ Object evaluate(JexlContext context, Expression expr) { try { @@ -821,6 +821,7 @@ * Use the JEXL parser to create the AST for an expression. * @param expression the expression to parse * @return the AST + * @throws ParseException if an error occur during parsing */ private JexlNode toNode(CharSequence expression) throws ParseException { return jexl.parse(expression, null); @@ -831,6 +832,7 @@ * @param expression the expression to parse * @param info debug information * @return the AST + * @throws ParseException if an error occur during parsing */ private JexlNode toNode(CharSequence expression, Info info) throws ParseException { return jexl.parse(expression, info); @@ -841,7 +843,7 @@ * @param action parse, prepare, evaluate * @param expr the expression * @param xany the exception - * @return an exception contained an explicit error message + * @return an exception containing an explicit error message */ private Exception createException(String action, Expression expr, java.lang.Exception xany) { StringBuilder strb = new StringBuilder("failed to "); @@ -881,7 +883,7 @@ * Parses a unified expression. * @param expr the string expression * @return the expression instance - * @throws org.apache.commons.jexl.parser.ParseException if an error occur during parsing + * @throws ParseException if an error occur during parsing */ private Expression parseExpression(String expr) throws ParseException { final int size = expr.length(); Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/scripting/Main.java URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/scripting/Main.java?rev=824415&r1=824414&r2=824415&view=diff ============================================================================== --- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/scripting/Main.java (original) +++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/scripting/Main.java Mon Oct 12 16:47:39 2009 @@ -6,14 +6,13 @@ * (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 + * 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.scripting; @@ -41,7 +40,7 @@ * * @param args (optional) filename to evaluate. Stored in the args variable. * - * @throws Exception + * @throws Exception if parsing or IO fail */ public static void main(String[] args) throws Exception { JexlScriptEngineFactory fac = new JexlScriptEngineFactory(); Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/util/introspection/JexlMethod.java URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/util/introspection/JexlMethod.java?rev=824415&r1=824414&r2=824415&view=diff ============================================================================== --- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/util/introspection/JexlMethod.java (original) +++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/util/introspection/JexlMethod.java Mon Oct 12 16:47:39 2009 @@ -40,7 +40,7 @@ Object invoke(Object o, Object[] params) throws Exception; /** - * specifies if this VelMethod is cacheable and able to be reused for this + * specifies if this JexlMethod 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 Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/util/introspection/JexlPropertyGet.java URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/util/introspection/JexlPropertyGet.java?rev=824415&r1=824414&r2=824415&view=diff ============================================================================== --- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/util/introspection/JexlPropertyGet.java (original) +++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/util/introspection/JexlPropertyGet.java Mon Oct 12 16:47:39 2009 @@ -38,7 +38,7 @@ Object invoke(Object o) throws Exception; /** - * specifies if this VelPropertyGet is cacheable and able to be reused for + * Specifies if this JexlPropertyGet 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 Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/util/introspection/JexlPropertySet.java URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/util/introspection/JexlPropertySet.java?rev=824415&r1=824414&r2=824415&view=diff ============================================================================== --- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/util/introspection/JexlPropertySet.java (original) +++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/util/introspection/JexlPropertySet.java Mon Oct 12 16:47:39 2009 @@ -39,7 +39,7 @@ Object invoke(Object o, Object arg) throws Exception; /** - * specifies if this VelPropertySet is cacheable and able to be reused for + * specifies if this JexlPropertySet 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