You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by cb...@apache.org on 2009/01/23 07:32:46 UTC
svn commit: r736963 [5/21] - in /ibatis/trunk/java/ibatis-3:
ibatis-3-compat/src/main/java/com/ibatis/common/jdbc/
ibatis-3-compat/src/main/java/com/ibatis/common/resources/
ibatis-3-compat/src/main/java/com/ibatis/common/util/
ibatis-3-compat/src/main...
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTSelectFirst.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTSelectFirst.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTSelectFirst.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTSelectFirst.java Thu Jan 22 22:32:36 2009
@@ -30,41 +30,40 @@
//--------------------------------------------------------------------------
package org.apache.ibatis.ognl;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
/**
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTSelectFirst extends SimpleNode
-{
- public ASTSelectFirst(int id) {
- super(id);
+class ASTSelectFirst extends SimpleNode {
+ public ASTSelectFirst(int id) {
+ super(id);
+ }
+
+ public ASTSelectFirst(OgnlParser p, int id) {
+ super(p, id);
+ }
+
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ Node expr = children[0];
+ List answer = new ArrayList();
+ ElementsAccessor elementsAccessor = OgnlRuntime.getElementsAccessor(OgnlRuntime.getTargetClass(source));
+
+ for (Enumeration e = elementsAccessor.getElements(source); e.hasMoreElements();) {
+ Object next = e.nextElement();
+
+ if (OgnlOps.booleanValue(expr.getValue(context, next))) {
+ answer.add(next);
+ break;
+ }
}
+ return answer;
+ }
- public ASTSelectFirst(OgnlParser p, int id) {
- super(p, id);
- }
-
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
- {
- Node expr = children[0];
- List answer = new ArrayList();
- ElementsAccessor elementsAccessor = OgnlRuntime.getElementsAccessor( OgnlRuntime.getTargetClass(source) );
-
- for (Enumeration e = elementsAccessor.getElements(source); e.hasMoreElements(); ) {
- Object next = e.nextElement();
-
- if (OgnlOps.booleanValue(expr.getValue(context, next))) {
- answer.add(next);
- break;
- }
- }
- return answer;
- }
-
- public String toString()
- {
- return "{^ " + children[0] + " }";
- }
+ public String toString() {
+ return "{^ " + children[0] + " }";
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTSelectLast.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTSelectLast.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTSelectLast.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTSelectLast.java Thu Jan 22 22:32:36 2009
@@ -30,41 +30,40 @@
//--------------------------------------------------------------------------
package org.apache.ibatis.ognl;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
/**
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTSelectLast extends SimpleNode
-{
- public ASTSelectLast(int id) {
- super(id);
+class ASTSelectLast extends SimpleNode {
+ public ASTSelectLast(int id) {
+ super(id);
+ }
+
+ public ASTSelectLast(OgnlParser p, int id) {
+ super(p, id);
+ }
+
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ Node expr = children[0];
+ List answer = new ArrayList();
+ ElementsAccessor elementsAccessor = OgnlRuntime.getElementsAccessor(OgnlRuntime.getTargetClass(source));
+
+ for (Enumeration e = elementsAccessor.getElements(source); e.hasMoreElements();) {
+ Object next = e.nextElement();
+
+ if (OgnlOps.booleanValue(expr.getValue(context, next))) {
+ answer.clear();
+ answer.add(next);
+ }
}
+ return answer;
+ }
- public ASTSelectLast(OgnlParser p, int id) {
- super(p, id);
- }
-
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
- {
- Node expr = children[0];
- List answer = new ArrayList();
- ElementsAccessor elementsAccessor = OgnlRuntime.getElementsAccessor( OgnlRuntime.getTargetClass(source) );
-
- for ( Enumeration e = elementsAccessor.getElements(source); e.hasMoreElements(); ) {
- Object next = e.nextElement();
-
- if (OgnlOps.booleanValue(expr.getValue(context, next))) {
- answer.clear();
- answer.add(next);
- }
- }
- return answer;
- }
-
- public String toString()
- {
- return "{$ " + children[0] + " }";
- }
+ public String toString() {
+ return "{$ " + children[0] + " }";
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTSequence.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTSequence.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTSequence.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTSequence.java Thu Jan 22 22:32:36 2009
@@ -34,47 +34,44 @@
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTSequence extends SimpleNode
-{
- public ASTSequence(int id) {
- super(id);
- }
-
- public ASTSequence(OgnlParser p, int id) {
- super(p, id);
- }
-
- public void jjtClose() {
- flattenTree();
- }
-
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
- {
- Object result = null;
- for ( int i=0; i < children.length; ++i ) {
- result = children[i].getValue( context, source );
- }
- return result; // The result is just the last one we saw.
- }
-
- protected void setValueBody( OgnlContext context, Object target, Object value ) throws OgnlException {
- int last = children.length - 1;
- for ( int i=0; i < last; ++i ) {
- children[i].getValue( context, target );
- }
- children[last].setValue( context, target, value );
- }
-
- public String toString()
- {
- String result = "";
-
- for ( int i=0; i < children.length; ++i ) {
- if (i > 0) {
- result = result + ", ";
- }
- result = result + children[i];
- }
- return result;
+class ASTSequence extends SimpleNode {
+ public ASTSequence(int id) {
+ super(id);
+ }
+
+ public ASTSequence(OgnlParser p, int id) {
+ super(p, id);
+ }
+
+ public void jjtClose() {
+ flattenTree();
+ }
+
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ Object result = null;
+ for (int i = 0; i < children.length; ++i) {
+ result = children[i].getValue(context, source);
+ }
+ return result; // The result is just the last one we saw.
+ }
+
+ protected void setValueBody(OgnlContext context, Object target, Object value) throws OgnlException {
+ int last = children.length - 1;
+ for (int i = 0; i < last; ++i) {
+ children[i].getValue(context, target);
+ }
+ children[last].setValue(context, target, value);
+ }
+
+ public String toString() {
+ String result = "";
+
+ for (int i = 0; i < children.length; ++i) {
+ if (i > 0) {
+ result = result + ", ";
+ }
+ result = result + children[i];
}
+ return result;
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTShiftLeft.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTShiftLeft.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTShiftLeft.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTShiftLeft.java Thu Jan 22 22:32:36 2009
@@ -34,25 +34,22 @@
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTShiftLeft extends ExpressionNode
-{
- public ASTShiftLeft(int id) {
- super(id);
- }
+class ASTShiftLeft extends ExpressionNode {
+ public ASTShiftLeft(int id) {
+ super(id);
+ }
- public ASTShiftLeft(OgnlParser p, int id) {
- super(p, id);
- }
+ public ASTShiftLeft(OgnlParser p, int id) {
+ super(p, id);
+ }
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
- {
- Object v1 = children[0].getValue( context, source );
- Object v2 = children[1].getValue( context, source );
- return OgnlOps.shiftLeft( v1, v2 );
- }
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ Object v1 = children[0].getValue(context, source);
+ Object v2 = children[1].getValue(context, source);
+ return OgnlOps.shiftLeft(v1, v2);
+ }
- public String getExpressionOperator(int index)
- {
- return "<<";
- }
+ public String getExpressionOperator(int index) {
+ return "<<";
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTShiftRight.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTShiftRight.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTShiftRight.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTShiftRight.java Thu Jan 22 22:32:36 2009
@@ -34,25 +34,22 @@
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTShiftRight extends ExpressionNode
-{
- public ASTShiftRight(int id) {
- super(id);
- }
+class ASTShiftRight extends ExpressionNode {
+ public ASTShiftRight(int id) {
+ super(id);
+ }
- public ASTShiftRight(OgnlParser p, int id) {
- super(p, id);
- }
+ public ASTShiftRight(OgnlParser p, int id) {
+ super(p, id);
+ }
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
- {
- Object v1 = children[0].getValue( context, source );
- Object v2 = children[1].getValue( context, source );
- return OgnlOps.shiftRight( v1, v2 );
- }
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ Object v1 = children[0].getValue(context, source);
+ Object v2 = children[1].getValue(context, source);
+ return OgnlOps.shiftRight(v1, v2);
+ }
- public String getExpressionOperator(int index)
- {
- return ">>";
- }
+ public String getExpressionOperator(int index) {
+ return ">>";
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTStaticField.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTStaticField.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTStaticField.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTStaticField.java Thu Jan 22 22:32:36 2009
@@ -37,65 +37,69 @@
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTStaticField extends SimpleNode
-{
- private String className;
- private String fieldName;
+class ASTStaticField extends SimpleNode {
+ private String className;
+ private String fieldName;
+
+ public ASTStaticField(int id) {
+ super(id);
+ }
+
+ public ASTStaticField(OgnlParser p, int id) {
+ super(p, id);
+ }
+
+ /**
+ * Called from parser action.
+ */
+ void init(String className, String fieldName) {
+ this.className = className;
+ this.fieldName = fieldName;
+ }
+
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ return OgnlRuntime.getStaticField(context, className, fieldName);
+ }
+
+ public boolean isNodeConstant(OgnlContext context) throws OgnlException {
+ boolean result = false;
+ Exception reason = null;
+
+ try {
+ Class c = OgnlRuntime.classForName(context, className);
+
+ /*
+ Check for virtual static field "class"; this cannot interfere with
+ normal static fields because it is a reserved word. It is considered
+ constant.
+ */
+ if (fieldName.equals("class")) {
+ result = true;
+ } else {
+ Field f = c.getField(fieldName);
- public ASTStaticField(int id) {
- super(id);
- }
-
- public ASTStaticField(OgnlParser p, int id) {
- super(p, id);
+ if (!Modifier.isStatic(f.getModifiers())) {
+ throw new OgnlException("Field " + fieldName + " of class " + className + " is not static");
+ }
+ result = Modifier.isFinal(f.getModifiers());
+ }
+ } catch (ClassNotFoundException e) {
+ reason = e;
}
-
- /** Called from parser action. */
- void init( String className, String fieldName ) {
- this.className = className;
- this.fieldName = fieldName;
+ catch (NoSuchFieldException e) {
+ reason = e;
}
-
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
- {
- return OgnlRuntime.getStaticField( context, className, fieldName );
+ catch (SecurityException e) {
+ reason = e;
}
- public boolean isNodeConstant( OgnlContext context ) throws OgnlException
- {
- boolean result = false;
- Exception reason = null;
-
- try {
- Class c = OgnlRuntime.classForName(context, className);
-
- /*
- Check for virtual static field "class"; this cannot interfere with
- normal static fields because it is a reserved word. It is considered
- constant.
- */
- if (fieldName.equals("class")) {
- result = true;
- } else {
- Field f = c.getField(fieldName);
-
- if (!Modifier.isStatic(f.getModifiers())) {
- throw new OgnlException( "Field " + fieldName + " of class " + className + " is not static" );
- }
- result = Modifier.isFinal(f.getModifiers());
- }
- } catch (ClassNotFoundException e) { reason = e; }
- catch (NoSuchFieldException e) { reason = e; }
- catch (SecurityException e) { reason = e; }
-
- if (reason != null) {
- throw new OgnlException( "Could not get static field " + fieldName + " from class " + className, reason );
- }
- return result;
+ if (reason != null) {
+ throw new OgnlException("Could not get static field " + fieldName + " from class " + className, reason);
}
+ return result;
+ }
- public String toString()
- {
- return "@" + className + "@" + fieldName;
- }
+ public String toString() {
+ return "@" + className + "@" + fieldName;
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTStaticMethod.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTStaticMethod.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTStaticMethod.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTStaticMethod.java Thu Jan 22 22:32:36 2009
@@ -34,54 +34,53 @@
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTStaticMethod extends SimpleNode
-{
- private String className;
- private String methodName;
-
- public ASTStaticMethod(int id) {
- super(id);
- }
-
- public ASTStaticMethod(OgnlParser p, int id) {
- super(p, id);
+class ASTStaticMethod extends SimpleNode {
+ private String className;
+ private String methodName;
+
+ public ASTStaticMethod(int id) {
+ super(id);
+ }
+
+ public ASTStaticMethod(OgnlParser p, int id) {
+ super(p, id);
+ }
+
+ /**
+ * Called from parser action.
+ */
+ void init(String className, String methodName) {
+ this.className = className;
+ this.methodName = methodName;
+ }
+
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ Object[] args = OgnlRuntime.getObjectArrayPool().create(jjtGetNumChildren());
+ Object root = context.getRoot();
+
+ try {
+ for (int i = 0, icount = args.length; i < icount; ++i)
+ args[i] = children[i].getValue(context, root);
+
+ return OgnlRuntime.callStaticMethod(context, className, methodName, args);
+ } finally {
+ OgnlRuntime.getObjectArrayPool().recycle(args);
}
+ }
- /** Called from parser action. */
- void init( String className, String methodName ) {
- this.className = className;
- this.methodName = methodName;
- }
-
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
- {
- Object[] args = OgnlRuntime.getObjectArrayPool().create(jjtGetNumChildren());
- Object root = context.getRoot();
-
- try {
- for ( int i=0, icount = args.length; i < icount; ++i )
- args[i] = children[i].getValue(context, root);
-
- return OgnlRuntime.callStaticMethod( context, className, methodName, args );
- } finally {
- OgnlRuntime.getObjectArrayPool().recycle(args);
- }
- }
+ public String toString() {
+ String result = "@" + className + "@" + methodName;
- public String toString()
- {
- String result = "@" + className + "@" + methodName;
-
- result = result + "(";
- if ((children != null) && (children.length > 0)) {
- for (int i = 0; i < children.length; i++) {
- if (i > 0) {
- result = result + ", ";
- }
- result = result + children[i];
- }
+ result = result + "(";
+ if ((children != null) && (children.length > 0)) {
+ for (int i = 0; i < children.length; i++) {
+ if (i > 0) {
+ result = result + ", ";
}
- result = result + ")";
- return result;
+ result = result + children[i];
+ }
}
+ result = result + ")";
+ return result;
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTSubtract.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTSubtract.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTSubtract.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTSubtract.java Thu Jan 22 22:32:36 2009
@@ -34,25 +34,22 @@
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTSubtract extends ExpressionNode
-{
- public ASTSubtract(int id) {
- super(id);
- }
+class ASTSubtract extends ExpressionNode {
+ public ASTSubtract(int id) {
+ super(id);
+ }
- public ASTSubtract(OgnlParser p, int id) {
- super(p, id);
- }
+ public ASTSubtract(OgnlParser p, int id) {
+ super(p, id);
+ }
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
- {
- Object v1 = children[0].getValue( context, source );
- Object v2 = children[1].getValue( context, source );
- return OgnlOps.subtract( v1, v2 );
- }
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ Object v1 = children[0].getValue(context, source);
+ Object v2 = children[1].getValue(context, source);
+ return OgnlOps.subtract(v1, v2);
+ }
- public String getExpressionOperator(int index)
- {
- return "-";
- }
+ public String getExpressionOperator(int index) {
+ return "-";
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTTest.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTTest.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTTest.java Thu Jan 22 22:32:36 2009
@@ -34,32 +34,28 @@
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTTest extends ExpressionNode
-{
- public ASTTest(int id) {
- super(id);
- }
+class ASTTest extends ExpressionNode {
+ public ASTTest(int id) {
+ super(id);
+ }
- public ASTTest(OgnlParser p, int id) {
- super(p, id);
- }
+ public ASTTest(OgnlParser p, int id) {
+ super(p, id);
+ }
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
- {
- Object test = children[0].getValue( context, source );
- int branch = OgnlOps.booleanValue(test)? 1 : 2;
- return children[branch].getValue( context, source );
- }
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ Object test = children[0].getValue(context, source);
+ int branch = OgnlOps.booleanValue(test) ? 1 : 2;
+ return children[branch].getValue(context, source);
+ }
- protected void setValueBody( OgnlContext context, Object target, Object value ) throws OgnlException
- {
- Object test = children[0].getValue( context, target );
- int branch = OgnlOps.booleanValue(test)? 1 : 2;
- children[branch].setValue( context, target, value );
- }
+ protected void setValueBody(OgnlContext context, Object target, Object value) throws OgnlException {
+ Object test = children[0].getValue(context, target);
+ int branch = OgnlOps.booleanValue(test) ? 1 : 2;
+ children[branch].setValue(context, target, value);
+ }
- public String getExpressionOperator(int index)
- {
- return (index == 1) ? "?" : ":";
- }
+ public String getExpressionOperator(int index) {
+ return (index == 1) ? "?" : ":";
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTThisVarRef.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTThisVarRef.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTThisVarRef.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTThisVarRef.java Thu Jan 22 22:32:36 2009
@@ -34,28 +34,26 @@
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTThisVarRef extends ASTVarRef
-{
- private String name;
+class ASTThisVarRef extends ASTVarRef {
+ private String name;
- public ASTThisVarRef(int id) {
- super(id);
- }
+ public ASTThisVarRef(int id) {
+ super(id);
+ }
- public ASTThisVarRef(OgnlParser p, int id) {
- super(p, id);
- }
+ public ASTThisVarRef(OgnlParser p, int id) {
+ super(p, id);
+ }
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException {
- return context.getCurrentObject();
- }
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ return context.getCurrentObject();
+ }
- protected void setValueBody( OgnlContext context, Object target, Object value ) throws OgnlException {
- context.setCurrentObject( value );
- }
+ protected void setValueBody(OgnlContext context, Object target, Object value) throws OgnlException {
+ context.setCurrentObject(value);
+ }
- public String toString()
- {
- return "#this";
- }
+ public String toString() {
+ return "#this";
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTUnsignedShiftRight.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTUnsignedShiftRight.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTUnsignedShiftRight.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTUnsignedShiftRight.java Thu Jan 22 22:32:36 2009
@@ -34,25 +34,22 @@
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTUnsignedShiftRight extends ExpressionNode
-{
- public ASTUnsignedShiftRight(int id) {
- super(id);
- }
+class ASTUnsignedShiftRight extends ExpressionNode {
+ public ASTUnsignedShiftRight(int id) {
+ super(id);
+ }
- public ASTUnsignedShiftRight(OgnlParser p, int id) {
- super(p, id);
- }
+ public ASTUnsignedShiftRight(OgnlParser p, int id) {
+ super(p, id);
+ }
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
- {
- Object v1 = children[0].getValue( context, source );
- Object v2 = children[1].getValue( context, source );
- return OgnlOps.unsignedShiftRight( v1, v2 );
- }
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ Object v1 = children[0].getValue(context, source);
+ Object v2 = children[1].getValue(context, source);
+ return OgnlOps.unsignedShiftRight(v1, v2);
+ }
- public String getExpressionOperator(int index)
- {
- return ">>>";
- }
+ public String getExpressionOperator(int index) {
+ return ">>>";
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTVarRef.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTVarRef.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTVarRef.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTVarRef.java Thu Jan 22 22:32:36 2009
@@ -34,31 +34,30 @@
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTVarRef extends SimpleNode
-{
- private String name;
-
- public ASTVarRef(int id) {
- super(id);
- }
-
- public ASTVarRef(OgnlParser p, int id) {
- super(p, id);
- }
-
- void setName( String name ) {
- this.name = name;
- }
-
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException {
- return context.get(name);
- }
-
- protected void setValueBody( OgnlContext context, Object target, Object value ) throws OgnlException {
- context.put( name, value );
- }
-
- public String toString() {
- return "#" + name;
- }
+class ASTVarRef extends SimpleNode {
+ private String name;
+
+ public ASTVarRef(int id) {
+ super(id);
+ }
+
+ public ASTVarRef(OgnlParser p, int id) {
+ super(p, id);
+ }
+
+ void setName(String name) {
+ this.name = name;
+ }
+
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ return context.get(name);
+ }
+
+ protected void setValueBody(OgnlContext context, Object target, Object value) throws OgnlException {
+ context.put(name, value);
+ }
+
+ public String toString() {
+ return "#" + name;
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTXor.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTXor.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTXor.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTXor.java Thu Jan 22 22:32:36 2009
@@ -34,30 +34,27 @@
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTXor extends ExpressionNode
-{
- public ASTXor(int id) {
- super(id);
- }
+class ASTXor extends ExpressionNode {
+ public ASTXor(int id) {
+ super(id);
+ }
- public ASTXor(OgnlParser p, int id) {
- super(p, id);
- }
+ public ASTXor(OgnlParser p, int id) {
+ super(p, id);
+ }
- public void jjtClose() {
- flattenTree();
- }
+ public void jjtClose() {
+ flattenTree();
+ }
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
- {
- Object result = children[0].getValue( context, source );
- for ( int i=1; i < children.length; ++i )
- result = OgnlOps.binaryXor( result, children[i].getValue(context, source) );
- return result;
- }
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ Object result = children[0].getValue(context, source);
+ for (int i = 1; i < children.length; ++i)
+ result = OgnlOps.binaryXor(result, children[i].getValue(context, source));
+ return result;
+ }
- public String getExpressionOperator(int index)
- {
- return "^";
- }
+ public String getExpressionOperator(int index) {
+ return "^";
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ArrayElementsAccessor.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ArrayElementsAccessor.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ArrayElementsAccessor.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ArrayElementsAccessor.java Thu Jan 22 22:32:36 2009
@@ -35,22 +35,23 @@
/**
* Implementation of ElementsAccessor that returns an iterator over a Java array.
+ *
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-public class ArrayElementsAccessor implements ElementsAccessor
-{
- public Enumeration getElements( final Object target )
- {
- return new Enumeration() {
- private int count = Array.getLength( target );
- private int index = 0;
- public boolean hasMoreElements() {
- return index < count;
- }
- public Object nextElement() {
- return Array.get( target, index++ );
- }
- };
- }
+public class ArrayElementsAccessor implements ElementsAccessor {
+ public Enumeration getElements(final Object target) {
+ return new Enumeration() {
+ private int count = Array.getLength(target);
+ private int index = 0;
+
+ public boolean hasMoreElements() {
+ return index < count;
+ }
+
+ public Object nextElement() {
+ return Array.get(target, index++);
+ }
+ };
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ArrayPropertyAccessor.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ArrayPropertyAccessor.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ArrayPropertyAccessor.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ArrayPropertyAccessor.java Thu Jan 22 22:32:36 2009
@@ -36,97 +36,96 @@
/**
* Implementation of PropertyAccessor that uses numbers and dynamic subscripts as
* properties to index into Java arrays.
+ *
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
public class ArrayPropertyAccessor extends ObjectPropertyAccessor
implements PropertyAccessor // This is here to make javadoc show this class as an implementor
{
- public Object getProperty( Map context, Object target, Object name ) throws OgnlException
- {
- Object result = null;
-
- if (name instanceof String) {
- if (name.equals("length")) {
- result = new Integer( Array.getLength(target) );
- } else {
- result = super.getProperty( context, target, name );
- }
- } else {
- Object index = name;
+ public Object getProperty(Map context, Object target, Object name) throws OgnlException {
+ Object result = null;
- if (index instanceof DynamicSubscript) {
- int len = Array.getLength(target);
+ if (name instanceof String) {
+ if (name.equals("length")) {
+ result = new Integer(Array.getLength(target));
+ } else {
+ result = super.getProperty(context, target, name);
+ }
+ } else {
+ Object index = name;
+
+ if (index instanceof DynamicSubscript) {
+ int len = Array.getLength(target);
+
+ switch (((DynamicSubscript) index).getFlag()) {
+ case DynamicSubscript.ALL:
+ result = Array.newInstance(target.getClass().getComponentType(), len);
+ System.arraycopy(target, 0, result, 0, len);
+ break;
+ case DynamicSubscript.FIRST:
+ index = new Integer((len > 0) ? 0 : -1);
+ break;
+ case DynamicSubscript.MID:
+ index = new Integer((len > 0) ? (len / 2) : -1);
+ break;
+ case DynamicSubscript.LAST:
+ index = new Integer((len > 0) ? (len - 1) : -1);
+ break;
+ }
+ }
+ if (result == null) {
+ if (index instanceof Number) {
+ int i = ((Number) index).intValue();
- switch (((DynamicSubscript)index).getFlag()) {
- case DynamicSubscript.ALL:
- result = Array.newInstance( target.getClass().getComponentType(), len );
- System.arraycopy( target, 0, result, 0, len );
- break;
- case DynamicSubscript.FIRST:
- index = new Integer((len > 0) ? 0 : -1);
- break;
- case DynamicSubscript.MID:
- index = new Integer((len > 0) ? (len / 2) : -1);
- break;
- case DynamicSubscript.LAST:
- index = new Integer((len > 0) ? (len - 1) : -1);
- break;
- }
- }
- if (result == null) {
- if (index instanceof Number) {
- int i = ((Number)index).intValue();
-
- result = (i >= 0) ? Array.get(target, i) : null;
- } else {
- throw new NoSuchPropertyException(target, index);
- }
- }
+ result = (i >= 0) ? Array.get(target, i) : null;
+ } else {
+ throw new NoSuchPropertyException(target, index);
}
- return result;
+ }
}
+ return result;
+ }
- public void setProperty( Map context, Object target, Object name, Object value ) throws OgnlException
- {
- Object index = name;
- boolean isNumber = (index instanceof Number);
-
- if (isNumber || (index instanceof DynamicSubscript)) {
- TypeConverter converter = ((OgnlContext)context).getTypeConverter();
- Object convertedValue;
-
- convertedValue = converter.convertValue(context, target, null, name.toString(), value, target.getClass().getComponentType());
- if (isNumber) {
- int i = ((Number)index).intValue();
-
- if (i >= 0) {
- Array.set(target, i, convertedValue);
- }
- } else {
- int len = Array.getLength(target);
-
- switch ( ((DynamicSubscript)index).getFlag() ) {
- case DynamicSubscript.ALL:
- System.arraycopy(target, 0, convertedValue, 0, len);
- return;
- case DynamicSubscript.FIRST:
- index = new Integer((len > 0) ? 0 : -1);
- break;
- case DynamicSubscript.MID:
- index = new Integer((len > 0) ? (len / 2) : -1);
- break;
- case DynamicSubscript.LAST:
- index = new Integer((len > 0 ) ? (len - 1) : -1);
- break;
- }
- }
- } else {
- if (name instanceof String) {
- super.setProperty(context, target, name, value);
- } else {
- throw new NoSuchPropertyException(target, index);
- }
+ public void setProperty(Map context, Object target, Object name, Object value) throws OgnlException {
+ Object index = name;
+ boolean isNumber = (index instanceof Number);
+
+ if (isNumber || (index instanceof DynamicSubscript)) {
+ TypeConverter converter = ((OgnlContext) context).getTypeConverter();
+ Object convertedValue;
+
+ convertedValue = converter.convertValue(context, target, null, name.toString(), value, target.getClass().getComponentType());
+ if (isNumber) {
+ int i = ((Number) index).intValue();
+
+ if (i >= 0) {
+ Array.set(target, i, convertedValue);
+ }
+ } else {
+ int len = Array.getLength(target);
+
+ switch (((DynamicSubscript) index).getFlag()) {
+ case DynamicSubscript.ALL:
+ System.arraycopy(target, 0, convertedValue, 0, len);
+ return;
+ case DynamicSubscript.FIRST:
+ index = new Integer((len > 0) ? 0 : -1);
+ break;
+ case DynamicSubscript.MID:
+ index = new Integer((len > 0) ? (len / 2) : -1);
+ break;
+ case DynamicSubscript.LAST:
+ index = new Integer((len > 0) ? (len - 1) : -1);
+ break;
}
+ }
+ } else {
+ if (name instanceof String) {
+ super.setProperty(context, target, name, value);
+ } else {
+ throw new NoSuchPropertyException(target, index);
+ }
}
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ClassResolver.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ClassResolver.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ClassResolver.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ClassResolver.java Thu Jan 22 22:32:36 2009
@@ -35,10 +35,10 @@
/**
* This interface defines an object that will resolve a class from a string
* and a ognl context table.
+ *
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-public interface ClassResolver
-{
- public Class classForName(String className, Map context) throws ClassNotFoundException;
+public interface ClassResolver {
+ public Class classForName(String className, Map context) throws ClassNotFoundException;
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/CollectionElementsAccessor.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/CollectionElementsAccessor.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/CollectionElementsAccessor.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/CollectionElementsAccessor.java Thu Jan 22 22:32:36 2009
@@ -30,17 +30,17 @@
//--------------------------------------------------------------------------
package org.apache.ibatis.ognl;
-import java.util.*;
+import java.util.Collection;
+import java.util.Enumeration;
/**
* Implementation of ElementsAccessor that returns a collection's iterator.
+ *
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-public class CollectionElementsAccessor implements ElementsAccessor
-{
- public Enumeration getElements( Object target )
- {
- return new IteratorEnumeration( ((Collection)target).iterator() );
- }
+public class CollectionElementsAccessor implements ElementsAccessor {
+ public Enumeration getElements(Object target) {
+ return new IteratorEnumeration(((Collection) target).iterator());
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/DefaultClassResolver.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/DefaultClassResolver.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/DefaultClassResolver.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/DefaultClassResolver.java Thu Jan 22 22:32:36 2009
@@ -30,39 +30,38 @@
//--------------------------------------------------------------------------
package org.apache.ibatis.ognl;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
/**
* Default class resolution. Uses Class.forName() to look up classes by name.
* It also looks in the "java.lang" package if the class named does not give
* a package specifier, allowing easier usage of these classes.
+ *
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-public class DefaultClassResolver extends Object implements ClassResolver
-{
- private Map classes = new HashMap(101);
+public class DefaultClassResolver extends Object implements ClassResolver {
+ private Map classes = new HashMap(101);
- public DefaultClassResolver()
- {
- super();
- }
+ public DefaultClassResolver() {
+ super();
+ }
- public Class classForName(String className, Map context) throws ClassNotFoundException
- {
- Class result = null;
+ public Class classForName(String className, Map context) throws ClassNotFoundException {
+ Class result = null;
- if ((result = (Class)classes.get(className)) == null) {
- try {
- result = Class.forName(className);
- } catch (ClassNotFoundException ex) {
- if (className.indexOf('.') == -1) {
- result = Class.forName("java.lang." + className);
- classes.put("java.lang." + className, result);
- }
- }
- classes.put(className, result);
- }
- return result;
- }
+ if ((result = (Class) classes.get(className)) == null) {
+ try {
+ result = Class.forName(className);
+ } catch (ClassNotFoundException ex) {
+ if (className.indexOf('.') == -1) {
+ result = Class.forName("java.lang." + className);
+ classes.put("java.lang." + className, result);
+ }
+ }
+ classes.put(className, result);
+ }
+ return result;
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/DefaultMemberAccess.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/DefaultMemberAccess.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/DefaultMemberAccess.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/DefaultMemberAccess.java Thu Jan 22 22:32:36 2009
@@ -30,8 +30,10 @@
//--------------------------------------------------------------------------
package org.apache.ibatis.ognl;
-import java.lang.reflect.*;
-import java.util.*;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Member;
+import java.lang.reflect.Modifier;
+import java.util.Map;
/**
* This class provides methods for setting up and restoring
@@ -45,106 +47,94 @@
* @author Drew Davidson (drew@ognl.org)
* @version 15 October 1999
*/
-public class DefaultMemberAccess implements MemberAccess
-{
- public boolean allowPrivateAccess = false;
- public boolean allowProtectedAccess = false;
- public boolean allowPackageProtectedAccess = false;
-
- /*===================================================================
- Constructors
- ===================================================================*/
- public DefaultMemberAccess(boolean allowAllAccess)
- {
- this(allowAllAccess, allowAllAccess, allowAllAccess);
- }
-
- public DefaultMemberAccess(boolean allowPrivateAccess, boolean allowProtectedAccess, boolean allowPackageProtectedAccess)
- {
- super();
- this.allowPrivateAccess = allowPrivateAccess;
- this.allowProtectedAccess = allowProtectedAccess;
- this.allowPackageProtectedAccess = allowPackageProtectedAccess;
- }
-
- /*===================================================================
- Public methods
- ===================================================================*/
- public boolean getAllowPrivateAccess()
- {
- return allowPrivateAccess;
- }
-
- public void setAllowPrivateAccess(boolean value)
- {
- allowPrivateAccess = value;
- }
-
- public boolean getAllowProtectedAccess()
- {
- return allowProtectedAccess;
- }
-
- public void setAllowProtectedAccess(boolean value)
- {
- allowProtectedAccess = value;
- }
-
- public boolean getAllowPackageProtectedAccess()
- {
- return allowPackageProtectedAccess;
- }
-
- public void setAllowPackageProtectedAccess(boolean value)
- {
- allowPackageProtectedAccess = value;
- }
+public class DefaultMemberAccess implements MemberAccess {
+ public boolean allowPrivateAccess = false;
+ public boolean allowProtectedAccess = false;
+ public boolean allowPackageProtectedAccess = false;
+
+ /*===================================================================
+ Constructors
+ ===================================================================*/
+ public DefaultMemberAccess(boolean allowAllAccess) {
+ this(allowAllAccess, allowAllAccess, allowAllAccess);
+ }
+
+ public DefaultMemberAccess(boolean allowPrivateAccess, boolean allowProtectedAccess, boolean allowPackageProtectedAccess) {
+ super();
+ this.allowPrivateAccess = allowPrivateAccess;
+ this.allowProtectedAccess = allowProtectedAccess;
+ this.allowPackageProtectedAccess = allowPackageProtectedAccess;
+ }
+
+ /*===================================================================
+ Public methods
+ ===================================================================*/
+ public boolean getAllowPrivateAccess() {
+ return allowPrivateAccess;
+ }
+
+ public void setAllowPrivateAccess(boolean value) {
+ allowPrivateAccess = value;
+ }
+
+ public boolean getAllowProtectedAccess() {
+ return allowProtectedAccess;
+ }
+
+ public void setAllowProtectedAccess(boolean value) {
+ allowProtectedAccess = value;
+ }
+
+ public boolean getAllowPackageProtectedAccess() {
+ return allowPackageProtectedAccess;
+ }
+
+ public void setAllowPackageProtectedAccess(boolean value) {
+ allowPackageProtectedAccess = value;
+ }
+
+ /*===================================================================
+ MemberAccess interface
+ ===================================================================*/
+ public Object setup(Map context, Object target, Member member, String propertyName) {
+ Object result = null;
+
+ if (isAccessible(context, target, member, propertyName)) {
+ AccessibleObject accessible = (AccessibleObject) member;
+
+ if (!accessible.isAccessible()) {
+ result = Boolean.TRUE;
+ accessible.setAccessible(true);
+ }
+ }
+ return result;
+ }
- /*===================================================================
- MemberAccess interface
- ===================================================================*/
- public Object setup(Map context, Object target, Member member, String propertyName)
- {
- Object result = null;
-
- if (isAccessible(context, target, member, propertyName)) {
- AccessibleObject accessible = (AccessibleObject)member;
-
- if (!accessible.isAccessible()) {
- result = Boolean.TRUE;
- accessible.setAccessible(true);
- }
- }
- return result;
+ public void restore(Map context, Object target, Member member, String propertyName, Object state) {
+ if (state != null) {
+ ((AccessibleObject) member).setAccessible(((Boolean) state).booleanValue());
}
+ }
- public void restore(Map context, Object target, Member member, String propertyName, Object state)
- {
- if (state != null) {
- ((AccessibleObject)member).setAccessible(((Boolean)state).booleanValue());
+ /**
+ * Returns true if the given member is accessible or can be made accessible
+ * by this object.
+ */
+ public boolean isAccessible(Map context, Object target, Member member, String propertyName) {
+ int modifiers = member.getModifiers();
+ boolean result = Modifier.isPublic(modifiers);
+
+ if (!result) {
+ if (Modifier.isPrivate(modifiers)) {
+ result = getAllowPrivateAccess();
+ } else {
+ if (Modifier.isProtected(modifiers)) {
+ result = getAllowProtectedAccess();
+ } else {
+ result = getAllowPackageProtectedAccess();
}
+ }
}
-
- /**
- Returns true if the given member is accessible or can be made accessible
- by this object.
- */
- public boolean isAccessible(Map context, Object target, Member member, String propertyName)
- {
- int modifiers = member.getModifiers();
- boolean result = Modifier.isPublic(modifiers);
-
- if (!result) {
- if (Modifier.isPrivate(modifiers)) {
- result = getAllowPrivateAccess();
- } else {
- if (Modifier.isProtected(modifiers)) {
- result = getAllowProtectedAccess();
- } else {
- result = getAllowPackageProtectedAccess();
- }
- }
- }
- return result;
+ return result;
}
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/DefaultTypeConverter.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/DefaultTypeConverter.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/DefaultTypeConverter.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/DefaultTypeConverter.java Thu Jan 22 22:32:36 2009
@@ -35,24 +35,21 @@
/**
* Default type conversion. Converts among numeric types and also strings.
+ *
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-public class DefaultTypeConverter implements TypeConverter
-{
- public DefaultTypeConverter()
- {
- super();
- }
+public class DefaultTypeConverter implements TypeConverter {
+ public DefaultTypeConverter() {
+ super();
+ }
- public Object convertValue(Map context, Object value, Class toType)
- {
- return OgnlOps.convertValue(value, toType);
- }
+ public Object convertValue(Map context, Object value, Class toType) {
+ return OgnlOps.convertValue(value, toType);
+ }
- public Object convertValue(Map context, Object target, Member member, String propertyName, Object value, Class toType)
- {
- return convertValue(context, value, toType);
- }
+ public Object convertValue(Map context, Object target, Member member, String propertyName, Object value, Class toType) {
+ return convertValue(context, value, toType);
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/DynamicSubscript.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/DynamicSubscript.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/DynamicSubscript.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/DynamicSubscript.java Thu Jan 22 22:32:36 2009
@@ -36,42 +36,43 @@
* for getting at the first, middle, or last elements of a list. In OGNL expressions,
* these subscripts look like special kinds of array indexes: [^] means the first element,
* [$] means the last, [|] means the middle, and [*] means the whole list.
+ *
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-public class DynamicSubscript
-{
- public static final int FIRST = 0;
- public static final int MID = 1;
- public static final int LAST = 2;
- public static final int ALL = 3;
+public class DynamicSubscript {
+ public static final int FIRST = 0;
+ public static final int MID = 1;
+ public static final int LAST = 2;
+ public static final int ALL = 3;
- public static final DynamicSubscript first = new DynamicSubscript(FIRST);
- public static final DynamicSubscript mid = new DynamicSubscript(MID);
- public static final DynamicSubscript last = new DynamicSubscript(LAST);
- public static final DynamicSubscript all = new DynamicSubscript(ALL);
+ public static final DynamicSubscript first = new DynamicSubscript(FIRST);
+ public static final DynamicSubscript mid = new DynamicSubscript(MID);
+ public static final DynamicSubscript last = new DynamicSubscript(LAST);
+ public static final DynamicSubscript all = new DynamicSubscript(ALL);
- private int flag;
+ private int flag;
- private DynamicSubscript( int flag )
- {
- this.flag = flag;
- }
+ private DynamicSubscript(int flag) {
+ this.flag = flag;
+ }
- public int getFlag()
- {
- return flag;
- }
+ public int getFlag() {
+ return flag;
+ }
- public String toString()
- {
- switch (flag)
- {
- case FIRST: return "^";
- case MID: return "|";
- case LAST: return "$";
- case ALL: return "*";
- default: return "?"; // Won't happen
- }
+ public String toString() {
+ switch (flag) {
+ case FIRST:
+ return "^";
+ case MID:
+ return "|";
+ case LAST:
+ return "$";
+ case ALL:
+ return "*";
+ default:
+ return "?"; // Won't happen
}
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ElementsAccessor.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ElementsAccessor.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ElementsAccessor.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ElementsAccessor.java Thu Jan 22 22:32:36 2009
@@ -37,20 +37,21 @@
* any objects that naturally would be considered to be contained by the object. So for a
* collection, you would expect this method to return all the objects in that collection;
* while for an ordinary object you would expect this method to return just that object.
- *
+ * <p/>
* <p> An implementation of this interface will often require that its target objects all
* be of some particular type. For example, the MapElementsAccessor class requires that
* its targets all implement the Map interface.
+ *
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-public interface ElementsAccessor
-{
- /**
- * Returns an iterator over the elements of the given target object.
- * @param target the object to get the elements of
- * @return an iterator over the elements of the given object
- * @exception OgnlException if there is an error getting the given object's elements
- */
- public Enumeration getElements( Object target ) throws OgnlException;
+public interface ElementsAccessor {
+ /**
+ * Returns an iterator over the elements of the given target object.
+ *
+ * @param target the object to get the elements of
+ * @return an iterator over the elements of the given object
+ * @throws OgnlException if there is an error getting the given object's elements
+ */
+ public Enumeration getElements(Object target) throws OgnlException;
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/EnumerationElementsAccessor.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/EnumerationElementsAccessor.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/EnumerationElementsAccessor.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/EnumerationElementsAccessor.java Thu Jan 22 22:32:36 2009
@@ -36,13 +36,12 @@
/**
* Implementation of the ElementsAccessor interface for Enumerations, which returns an
* iterator that passes its calls through to the target Enumeration.
+ *
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-public class EnumerationElementsAccessor implements ElementsAccessor
-{
- public Enumeration getElements( Object target )
- {
- return (Enumeration)target;
- }
+public class EnumerationElementsAccessor implements ElementsAccessor {
+ public Enumeration getElements(Object target) {
+ return (Enumeration) target;
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/EnumerationIterator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/EnumerationIterator.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/EnumerationIterator.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/EnumerationIterator.java Thu Jan 22 22:32:36 2009
@@ -30,35 +30,32 @@
//--------------------------------------------------------------------------
package org.apache.ibatis.ognl;
-import java.util.*;
+import java.util.Enumeration;
+import java.util.Iterator;
/**
* Object that implements Iterator from an Enumeration
+ *
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-public class EnumerationIterator implements Iterator
-{
- private Enumeration e;
-
- public EnumerationIterator(Enumeration e)
- {
- super();
- this.e = e;
- }
-
- public boolean hasNext()
- {
- return e.hasMoreElements();
- }
-
- public Object next()
- {
- return e.nextElement();
- }
-
- public void remove()
- {
- throw new UnsupportedOperationException("remove() not supported by Enumeration");
- }
+public class EnumerationIterator implements Iterator {
+ private Enumeration e;
+
+ public EnumerationIterator(Enumeration e) {
+ super();
+ this.e = e;
+ }
+
+ public boolean hasNext() {
+ return e.hasMoreElements();
+ }
+
+ public Object next() {
+ return e.nextElement();
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException("remove() not supported by Enumeration");
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/EnumerationPropertyAccessor.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/EnumerationPropertyAccessor.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/EnumerationPropertyAccessor.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/EnumerationPropertyAccessor.java Thu Jan 22 22:32:36 2009
@@ -30,41 +30,41 @@
//--------------------------------------------------------------------------
package org.apache.ibatis.ognl;
-import java.util.*;
+import java.util.Enumeration;
+import java.util.Map;
/**
* Implementation of PropertyAccessor that provides "property" reference to
* "nextElement" (aliases to "next" also) and "hasMoreElements" (also aliased
* to "hasNext").
+ *
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
public class EnumerationPropertyAccessor extends ObjectPropertyAccessor
implements PropertyAccessor // This is here to make javadoc show this class as an implementor
{
- public Object getProperty( Map context, Object target, Object name ) throws OgnlException
- {
- Object result;
- Enumeration e = (Enumeration)target;
+ public Object getProperty(Map context, Object target, Object name) throws OgnlException {
+ Object result;
+ Enumeration e = (Enumeration) target;
- if ( name instanceof String ) {
- if (name.equals("next") || name.equals("nextElement")) {
- result = e.nextElement();
- } else {
- if (name.equals("hasNext") || name.equals("hasMoreElements")) {
- result = e.hasMoreElements() ? Boolean.TRUE : Boolean.FALSE;
- } else {
- result = super.getProperty( context, target, name );
- }
- }
+ if (name instanceof String) {
+ if (name.equals("next") || name.equals("nextElement")) {
+ result = e.nextElement();
+ } else {
+ if (name.equals("hasNext") || name.equals("hasMoreElements")) {
+ result = e.hasMoreElements() ? Boolean.TRUE : Boolean.FALSE;
} else {
- result = super.getProperty(context, target, name);
+ result = super.getProperty(context, target, name);
}
- return result;
+ }
+ } else {
+ result = super.getProperty(context, target, name);
}
+ return result;
+ }
- public void setProperty( Map context, Object target, Object name, Object value ) throws OgnlException
- {
- throw new IllegalArgumentException( "can't set property " + name + " on Enumeration" );
- }
+ public void setProperty(Map context, Object target, Object name, Object value) throws OgnlException {
+ throw new IllegalArgumentException("can't set property " + name + " on Enumeration");
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/Evaluation.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/Evaluation.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/Evaluation.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/Evaluation.java Thu Jan 22 22:32:36 2009
@@ -31,304 +31,278 @@
package org.apache.ibatis.ognl;
/**
- An <code>Evaluation</code> is and object that holds a node being evaluated
- and the source from which that node will take extract its
- value. It refers to child evaluations that occur as
- a result of the nodes' evaluation.
+ * An <code>Evaluation</code> is and object that holds a node being evaluated
+ * and the source from which that node will take extract its
+ * value. It refers to child evaluations that occur as
+ * a result of the nodes' evaluation.
*/
-public class Evaluation extends Object
-{
- private SimpleNode node;
- private Object source;
- private boolean setOperation;
- private Object result;
- private Throwable exception;
- private Evaluation parent;
- private Evaluation next;
- private Evaluation previous;
- private Evaluation firstChild;
- private Evaluation lastChild;
-
- /**
- Constructs a new "get" <code>Evaluation</code> from the node and source given.
- */
- public Evaluation(SimpleNode node, Object source)
- {
- super();
- this.node = node;
- this.source = source;
- }
-
- /**
- Constructs a new <code>Evaluation</code> from the node and source given.
- If <code>setOperation</code> is true this <code>Evaluation</code> represents
- a "set" as opposed to a "get".
- */
- public Evaluation(SimpleNode node, Object source, boolean setOperation)
- {
- this(node, source);
- this.setOperation = setOperation;
- }
-
- /**
- Returns the <code>SimpleNode</code> for this <code>Evaluation</code>
- */
- public SimpleNode getNode()
- {
- return node;
- }
-
- /**
- Sets the node of the evaluation. Normally applications do not need to
- set this. Notable exceptions to this rule are custom evaluators that
- choose between navigable objects (as in a multi-root evaluator where
- the navigable node is chosen at runtime).
- */
- public void setNode(SimpleNode value)
- {
- node = value;
- }
-
- /**
- Returns the source object on which this Evaluation operated.
- */
- public Object getSource()
- {
- return source;
- }
-
- /**
- Sets the source of the evaluation. Normally applications do not need to
- set this. Notable exceptions to this rule are custom evaluators that
- choose between navigable objects (as in a multi-root evaluator where
- the navigable node is chosen at runtime).
- */
- public void setSource(Object value)
- {
- source = value;
- }
-
- /**
- Returns true if this Evaluation represents a set operation.
- */
- public boolean isSetOperation()
- {
- return setOperation;
- }
-
- /**
- Marks the Evaluation as a set operation if the value is true, else
- marks it as a get operation.
- */
- public void setSetOperation(boolean value)
- {
- setOperation = value;
- }
-
- /**
- Returns the result of the Evaluation, or null if it was a set operation.
- */
- public Object getResult()
- {
- return result;
- }
-
- /**
- Sets the result of the Evaluation. This method is normally only used
- interally and should not be set without knowledge of what you are doing.
- */
- public void setResult(Object value)
- {
- result = value;
- }
-
- /**
- Returns the exception that occurred as a result of evaluating the
- Evaluation, or null if no exception occurred.
- */
- public Throwable getException()
- {
- return exception;
- }
-
- /**
- Sets the exception that occurred as a result of evaluating the
- Evaluation. This method is normally only used interally and
- should not be set without knowledge of what you are doing.
- */
- public void setException(Throwable value)
- {
- exception = value;
- }
-
- /**
- Returns the parent evaluation of this evaluation. If this returns
- null then it is is the root evaluation of a tree.
- */
- public Evaluation getParent()
- {
- return parent;
- }
-
- /**
- Returns the next sibling of this evaluation. Returns null if
- this is the last in a chain of evaluations.
- */
- public Evaluation getNext()
- {
- return next;
- }
-
- /**
- Returns the previous sibling of this evaluation. Returns null if
- this is the first in a chain of evaluations.
- */
- public Evaluation getPrevious()
- {
- return previous;
- }
-
- /**
- Returns the first child of this evaluation. Returns null if
- there are no children.
- */
- public Evaluation getFirstChild()
- {
- return firstChild;
- }
-
- /**
- Returns the last child of this evaluation. Returns null if
- there are no children.
- */
- public Evaluation getLastChild()
- {
- return lastChild;
- }
-
- /**
- Gets the first descendent. In any Evaluation tree this will the
- Evaluation that was first executed.
- */
- public Evaluation getFirstDescendant()
- {
- if (firstChild != null) {
- return firstChild.getFirstDescendant();
- }
- return this;
- }
-
- /**
- Gets the last descendent. In any Evaluation tree this will the
- Evaluation that was most recently executing.
- */
- public Evaluation getLastDescendant()
- {
- if (lastChild != null) {
- return lastChild.getLastDescendant();
- }
- return this;
- }
-
- /**
- Adds a child to the list of children of this evaluation. The
- parent of the child is set to the receiver and the children
- references are modified in the receiver to reflect the new child.
- The lastChild of the receiver is set to the child, and the
- firstChild is set also if child is the first (or only) child.
- */
- public void addChild(Evaluation child)
- {
- if (firstChild == null) {
- firstChild = lastChild = child;
- } else {
- if (firstChild == lastChild) {
- firstChild.next = child;
- lastChild = child;
- lastChild.previous = firstChild;
- } else {
- child.previous = lastChild;
- lastChild.next = child;
- lastChild = child;
- }
- }
- child.parent = this;
- }
-
- /**
- Reinitializes this Evaluation to the parameters specified.
- */
- public void init(SimpleNode node, Object source, boolean setOperation)
- {
- this.node = node;
- this.source = source;
- this.setOperation = setOperation;
- result = null;
- exception = null;
- parent = null;
- next = null;
- previous = null;
- firstChild = null;
- lastChild = null;
- }
-
- /**
- Resets this Evaluation to the initial state.
- */
- public void reset()
- {
- init(null, null, false);
- }
-
- /**
- Produces a String value for the Evaluation. If compact is
- true then a more compact form of the description only including
- the node type and unique identifier is shown, else a full
- description including source and result are shown. If showChildren
- is true the child evaluations are printed using the depth string
- given as a prefix.
- */
- public String toString(boolean compact, boolean showChildren, String depth)
- {
- String stringResult;
-
- if (compact) {
- stringResult = depth + "<" + node.getClass().getName() + " " + System.identityHashCode(this) + ">";
- } else {
- String ss = (source != null) ? source.getClass().getName() : "null",
- rs = (result != null) ? result.getClass().getName() : "null";
-
- stringResult = depth + "<" + node.getClass().getName() + ": [" + (setOperation ? "set" : "get") + "] source = " + ss + ", result = " + result + " [" + rs + "]>";
- }
- if (showChildren) {
- Evaluation child = firstChild;
-
- stringResult += "\n";
- while (child != null) {
- stringResult += child.toString(compact, depth + " ");
- child = child.next;
- }
- }
- return stringResult;
- }
-
- /**
- Produces a String value for the Evaluation. If compact is
- true then a more compact form of the description only including
- the node type and unique identifier is shown, else a full
- description including source and result are shown. Child
- evaluations are printed using the depth string given as a prefix.
- */
- public String toString(boolean compact, String depth)
- {
- return toString(compact, true, depth);
- }
-
- /**
- Returns a String description of the Evaluation.
- */
- public String toString()
- {
- return toString(false, "");
- }
+public class Evaluation extends Object {
+ private SimpleNode node;
+ private Object source;
+ private boolean setOperation;
+ private Object result;
+ private Throwable exception;
+ private Evaluation parent;
+ private Evaluation next;
+ private Evaluation previous;
+ private Evaluation firstChild;
+ private Evaluation lastChild;
+
+ /**
+ * Constructs a new "get" <code>Evaluation</code> from the node and source given.
+ */
+ public Evaluation(SimpleNode node, Object source) {
+ super();
+ this.node = node;
+ this.source = source;
+ }
+
+ /**
+ * Constructs a new <code>Evaluation</code> from the node and source given.
+ * If <code>setOperation</code> is true this <code>Evaluation</code> represents
+ * a "set" as opposed to a "get".
+ */
+ public Evaluation(SimpleNode node, Object source, boolean setOperation) {
+ this(node, source);
+ this.setOperation = setOperation;
+ }
+
+ /**
+ * Returns the <code>SimpleNode</code> for this <code>Evaluation</code>
+ */
+ public SimpleNode getNode() {
+ return node;
+ }
+
+ /**
+ * Sets the node of the evaluation. Normally applications do not need to
+ * set this. Notable exceptions to this rule are custom evaluators that
+ * choose between navigable objects (as in a multi-root evaluator where
+ * the navigable node is chosen at runtime).
+ */
+ public void setNode(SimpleNode value) {
+ node = value;
+ }
+
+ /**
+ * Returns the source object on which this Evaluation operated.
+ */
+ public Object getSource() {
+ return source;
+ }
+
+ /**
+ * Sets the source of the evaluation. Normally applications do not need to
+ * set this. Notable exceptions to this rule are custom evaluators that
+ * choose between navigable objects (as in a multi-root evaluator where
+ * the navigable node is chosen at runtime).
+ */
+ public void setSource(Object value) {
+ source = value;
+ }
+
+ /**
+ * Returns true if this Evaluation represents a set operation.
+ */
+ public boolean isSetOperation() {
+ return setOperation;
+ }
+
+ /**
+ * Marks the Evaluation as a set operation if the value is true, else
+ * marks it as a get operation.
+ */
+ public void setSetOperation(boolean value) {
+ setOperation = value;
+ }
+
+ /**
+ * Returns the result of the Evaluation, or null if it was a set operation.
+ */
+ public Object getResult() {
+ return result;
+ }
+
+ /**
+ * Sets the result of the Evaluation. This method is normally only used
+ * interally and should not be set without knowledge of what you are doing.
+ */
+ public void setResult(Object value) {
+ result = value;
+ }
+
+ /**
+ * Returns the exception that occurred as a result of evaluating the
+ * Evaluation, or null if no exception occurred.
+ */
+ public Throwable getException() {
+ return exception;
+ }
+
+ /**
+ * Sets the exception that occurred as a result of evaluating the
+ * Evaluation. This method is normally only used interally and
+ * should not be set without knowledge of what you are doing.
+ */
+ public void setException(Throwable value) {
+ exception = value;
+ }
+
+ /**
+ * Returns the parent evaluation of this evaluation. If this returns
+ * null then it is is the root evaluation of a tree.
+ */
+ public Evaluation getParent() {
+ return parent;
+ }
+
+ /**
+ * Returns the next sibling of this evaluation. Returns null if
+ * this is the last in a chain of evaluations.
+ */
+ public Evaluation getNext() {
+ return next;
+ }
+
+ /**
+ * Returns the previous sibling of this evaluation. Returns null if
+ * this is the first in a chain of evaluations.
+ */
+ public Evaluation getPrevious() {
+ return previous;
+ }
+
+ /**
+ * Returns the first child of this evaluation. Returns null if
+ * there are no children.
+ */
+ public Evaluation getFirstChild() {
+ return firstChild;
+ }
+
+ /**
+ * Returns the last child of this evaluation. Returns null if
+ * there are no children.
+ */
+ public Evaluation getLastChild() {
+ return lastChild;
+ }
+
+ /**
+ * Gets the first descendent. In any Evaluation tree this will the
+ * Evaluation that was first executed.
+ */
+ public Evaluation getFirstDescendant() {
+ if (firstChild != null) {
+ return firstChild.getFirstDescendant();
+ }
+ return this;
+ }
+
+ /**
+ * Gets the last descendent. In any Evaluation tree this will the
+ * Evaluation that was most recently executing.
+ */
+ public Evaluation getLastDescendant() {
+ if (lastChild != null) {
+ return lastChild.getLastDescendant();
+ }
+ return this;
+ }
+
+ /**
+ * Adds a child to the list of children of this evaluation. The
+ * parent of the child is set to the receiver and the children
+ * references are modified in the receiver to reflect the new child.
+ * The lastChild of the receiver is set to the child, and the
+ * firstChild is set also if child is the first (or only) child.
+ */
+ public void addChild(Evaluation child) {
+ if (firstChild == null) {
+ firstChild = lastChild = child;
+ } else {
+ if (firstChild == lastChild) {
+ firstChild.next = child;
+ lastChild = child;
+ lastChild.previous = firstChild;
+ } else {
+ child.previous = lastChild;
+ lastChild.next = child;
+ lastChild = child;
+ }
+ }
+ child.parent = this;
+ }
+
+ /**
+ * Reinitializes this Evaluation to the parameters specified.
+ */
+ public void init(SimpleNode node, Object source, boolean setOperation) {
+ this.node = node;
+ this.source = source;
+ this.setOperation = setOperation;
+ result = null;
+ exception = null;
+ parent = null;
+ next = null;
+ previous = null;
+ firstChild = null;
+ lastChild = null;
+ }
+
+ /**
+ * Resets this Evaluation to the initial state.
+ */
+ public void reset() {
+ init(null, null, false);
+ }
+
+ /**
+ * Produces a String value for the Evaluation. If compact is
+ * true then a more compact form of the description only including
+ * the node type and unique identifier is shown, else a full
+ * description including source and result are shown. If showChildren
+ * is true the child evaluations are printed using the depth string
+ * given as a prefix.
+ */
+ public String toString(boolean compact, boolean showChildren, String depth) {
+ String stringResult;
+
+ if (compact) {
+ stringResult = depth + "<" + node.getClass().getName() + " " + System.identityHashCode(this) + ">";
+ } else {
+ String ss = (source != null) ? source.getClass().getName() : "null",
+ rs = (result != null) ? result.getClass().getName() : "null";
+
+ stringResult = depth + "<" + node.getClass().getName() + ": [" + (setOperation ? "set" : "get") + "] source = " + ss + ", result = " + result + " [" + rs + "]>";
+ }
+ if (showChildren) {
+ Evaluation child = firstChild;
+
+ stringResult += "\n";
+ while (child != null) {
+ stringResult += child.toString(compact, depth + " ");
+ child = child.next;
+ }
+ }
+ return stringResult;
+ }
+
+ /**
+ * Produces a String value for the Evaluation. If compact is
+ * true then a more compact form of the description only including
+ * the node type and unique identifier is shown, else a full
+ * description including source and result are shown. Child
+ * evaluations are printed using the depth string given as a prefix.
+ */
+ public String toString(boolean compact, String depth) {
+ return toString(compact, true, depth);
+ }
+
+ /**
+ * Returns a String description of the Evaluation.
+ */
+ public String toString() {
+ return toString(false, "");
+ }
}