You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2006/04/29 17:40:37 UTC
svn commit: r398180 - in
/jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser:
ASTAddNode.java ASTAndNode.java ASTArrayAccess.java
Author: dion
Date: Sat Apr 29 08:40:35 2006
New Revision: 398180
URL: http://svn.apache.org/viewcvs?rev=398180&view=rev
Log:
Checkstyle
Modified:
jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTAddNode.java
jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTAndNode.java
jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTArrayAccess.java
Modified: jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTAddNode.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTAddNode.java?rev=398180&r1=398179&r2=398180&view=diff
==============================================================================
--- jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTAddNode.java (original)
+++ jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTAddNode.java Sat Apr 29 08:40:35 2006
@@ -27,12 +27,19 @@
*/
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);
Modified: jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTAndNode.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTAndNode.java?rev=398180&r1=398179&r2=398180&view=diff
==============================================================================
--- jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTAndNode.java (original)
+++ jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTAndNode.java Sat Apr 29 08:40:35 2006
@@ -25,19 +25,31 @@
* @version $Id$
*/
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);
}
- /** Accept the visitor. * */
+ /** {@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();
Modified: jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTArrayAccess.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTArrayAccess.java?rev=398180&r1=398179&r2=398180&view=diff
==============================================================================
--- jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTArrayAccess.java (original)
+++ jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTArrayAccess.java Sat Apr 29 08:40:35 2006
@@ -38,25 +38,40 @@
/** 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);
}
- /** Accept the visitor. * */
+ /** {@inheritDoc} */
public Object jjtAccept(ParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
- /*
- * evaluate array access upon a base object
+ /**
+ * 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);
@@ -79,9 +94,7 @@
return result;
}
- /**
- * return the value of this node
- */
+ /** {@inheritDoc} */
public Object value(JexlContext jc) throws Exception {
/*
* get the base ASTIdentifier
@@ -107,6 +120,21 @@
return o;
}
+ /**
+ * Evaluate the Array expression 'loc' on the given object, o.
+ * e.g. in 'a[2]', <code>2</code> is 'loc' and <code>a</code> 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.
+ * @return the resulting value.
+ * @throws Exception on any error.
+ */
public static Object evaluateExpr(Object o, Object loc) throws Exception {
/*
* following the JSTL EL rules
@@ -149,8 +177,7 @@
String s = loc.toString();
- VelPropertyGet vg = Introspector.getUberspect().getPropertyGet(o,
- s, DUMMY);
+ VelPropertyGet vg = Introspector.getUberspect().getPropertyGet(o, s, DUMMY);
if (vg != null) {
return vg.invoke(o);
@@ -160,6 +187,11 @@
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();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org