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 [4/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/ASTChain.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTChain.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTChain.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTChain.java Thu Jan 22 22:32:36 2009
@@ -36,174 +36,169 @@
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTChain extends SimpleNode
-{
- public ASTChain(int id) {
- super(id);
- }
-
- public ASTChain(OgnlParser p, int id) {
- super(p, id);
- }
-
- public void jjtClose() {
- flattenTree();
- }
-
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
- {
- Object result = source;
-
- for ( int i = 0, ilast = children.length - 1; i <= ilast; ++i ) {
- boolean handled = false;
-
- if (i < ilast) {
- if (children[i] instanceof ASTProperty) {
- ASTProperty propertyNode = (ASTProperty)children[i];
- int indexType = propertyNode.getIndexedPropertyType(context, result);
-
- if ((indexType != OgnlRuntime.INDEXED_PROPERTY_NONE) && (children[i + 1] instanceof ASTProperty)) {
- ASTProperty indexNode = (ASTProperty)children[i + 1];
-
- if (indexNode.isIndexedAccess()) {
- Object index = indexNode.getProperty(context, result);
-
- if (index instanceof DynamicSubscript) {
- if (indexType == OgnlRuntime.INDEXED_PROPERTY_INT) {
- Object array = propertyNode.getValue(context, result);
- int len = Array.getLength(array);
-
- switch (((DynamicSubscript)index).getFlag()) {
- case DynamicSubscript.ALL:
- result = Array.newInstance( array.getClass().getComponentType(), len );
- System.arraycopy( array, 0, result, 0, len );
- handled = true;
- i++;
- 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;
- }
- } else {
- if (indexType == OgnlRuntime.INDEXED_PROPERTY_OBJECT) {
- throw new OgnlException("DynamicSubscript '" + indexNode + "' not allowed for object indexed property '" + propertyNode + "'");
- }
- }
- }
- if (!handled) {
- result = OgnlRuntime.getIndexedProperty(context, result, propertyNode.getProperty(context, result).toString(), index);
- handled = true;
- i++;
- }
- }
- }
+class ASTChain extends SimpleNode {
+ public ASTChain(int id) {
+ super(id);
+ }
+
+ public ASTChain(OgnlParser p, int id) {
+ super(p, id);
+ }
+
+ public void jjtClose() {
+ flattenTree();
+ }
+
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ Object result = source;
+
+ for (int i = 0, ilast = children.length - 1; i <= ilast; ++i) {
+ boolean handled = false;
+
+ if (i < ilast) {
+ if (children[i] instanceof ASTProperty) {
+ ASTProperty propertyNode = (ASTProperty) children[i];
+ int indexType = propertyNode.getIndexedPropertyType(context, result);
+
+ if ((indexType != OgnlRuntime.INDEXED_PROPERTY_NONE) && (children[i + 1] instanceof ASTProperty)) {
+ ASTProperty indexNode = (ASTProperty) children[i + 1];
+
+ if (indexNode.isIndexedAccess()) {
+ Object index = indexNode.getProperty(context, result);
+
+ if (index instanceof DynamicSubscript) {
+ if (indexType == OgnlRuntime.INDEXED_PROPERTY_INT) {
+ Object array = propertyNode.getValue(context, result);
+ int len = Array.getLength(array);
+
+ switch (((DynamicSubscript) index).getFlag()) {
+ case DynamicSubscript.ALL:
+ result = Array.newInstance(array.getClass().getComponentType(), len);
+ System.arraycopy(array, 0, result, 0, len);
+ handled = true;
+ i++;
+ 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;
+ }
+ } else {
+ if (indexType == OgnlRuntime.INDEXED_PROPERTY_OBJECT) {
+ throw new OgnlException("DynamicSubscript '" + indexNode + "' not allowed for object indexed property '" + propertyNode + "'");
+ }
}
+ }
+ if (!handled) {
+ result = OgnlRuntime.getIndexedProperty(context, result, propertyNode.getProperty(context, result).toString(), index);
+ handled = true;
+ i++;
+ }
}
- if (!handled) {
- result = children[i].getValue( context, result );
- }
+ }
}
- return result;
- }
-
- protected void setValueBody( OgnlContext context, Object target, Object value ) throws OgnlException
- {
- boolean handled = false;
-
- for ( int i = 0, ilast = children.length - 2; i <= ilast; ++i ) {
- if (i == ilast) {
- if (children[i] instanceof ASTProperty) {
- ASTProperty propertyNode = (ASTProperty)children[i];
- int indexType = propertyNode.getIndexedPropertyType(context, target);
-
- if ((indexType != OgnlRuntime.INDEXED_PROPERTY_NONE) && (children[i + 1] instanceof ASTProperty)) {
- ASTProperty indexNode = (ASTProperty)children[i + 1];
-
- if (indexNode.isIndexedAccess()) {
- Object index = indexNode.getProperty(context, target);
-
- if (index instanceof DynamicSubscript) {
- if (indexType == OgnlRuntime.INDEXED_PROPERTY_INT) {
- Object array = propertyNode.getValue(context, target);
- int len = Array.getLength(array);
-
- switch (((DynamicSubscript)index).getFlag()) {
- case DynamicSubscript.ALL:
- System.arraycopy(target, 0, value, 0, len);
- handled = true;
- i++;
- 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;
- }
- } else {
- if (indexType == OgnlRuntime.INDEXED_PROPERTY_OBJECT) {
- throw new OgnlException("DynamicSubscript '" + indexNode + "' not allowed for object indexed property '" + propertyNode + "'");
- }
- }
- }
- if (!handled) {
- OgnlRuntime.setIndexedProperty(context, target, propertyNode.getProperty(context, target).toString(), index, value);
- handled = true;
- i++;
- }
- }
- }
+ }
+ if (!handled) {
+ result = children[i].getValue(context, result);
+ }
+ }
+ return result;
+ }
+
+ protected void setValueBody(OgnlContext context, Object target, Object value) throws OgnlException {
+ boolean handled = false;
+
+ for (int i = 0, ilast = children.length - 2; i <= ilast; ++i) {
+ if (i == ilast) {
+ if (children[i] instanceof ASTProperty) {
+ ASTProperty propertyNode = (ASTProperty) children[i];
+ int indexType = propertyNode.getIndexedPropertyType(context, target);
+
+ if ((indexType != OgnlRuntime.INDEXED_PROPERTY_NONE) && (children[i + 1] instanceof ASTProperty)) {
+ ASTProperty indexNode = (ASTProperty) children[i + 1];
+
+ if (indexNode.isIndexedAccess()) {
+ Object index = indexNode.getProperty(context, target);
+
+ if (index instanceof DynamicSubscript) {
+ if (indexType == OgnlRuntime.INDEXED_PROPERTY_INT) {
+ Object array = propertyNode.getValue(context, target);
+ int len = Array.getLength(array);
+
+ switch (((DynamicSubscript) index).getFlag()) {
+ case DynamicSubscript.ALL:
+ System.arraycopy(target, 0, value, 0, len);
+ handled = true;
+ i++;
+ 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;
+ }
+ } else {
+ if (indexType == OgnlRuntime.INDEXED_PROPERTY_OBJECT) {
+ throw new OgnlException("DynamicSubscript '" + indexNode + "' not allowed for object indexed property '" + propertyNode + "'");
+ }
}
+ }
+ if (!handled) {
+ OgnlRuntime.setIndexedProperty(context, target, propertyNode.getProperty(context, target).toString(), index, value);
+ handled = true;
+ i++;
+ }
}
- if (!handled) {
- target = children[i].getValue( context, target );
- }
+ }
}
- if (!handled) {
- children[children.length - 1].setValue( context, target, value );
+ }
+ if (!handled) {
+ target = children[i].getValue(context, target);
+ }
+ }
+ if (!handled) {
+ children[children.length - 1].setValue(context, target, value);
+ }
+ }
+
+ public boolean isSimpleNavigationChain(OgnlContext context) throws OgnlException {
+ boolean result = false;
+
+ if ((children != null) && (children.length > 0)) {
+ result = true;
+ for (int i = 0; result && (i < children.length); i++) {
+ if (children[i] instanceof SimpleNode) {
+ result = ((SimpleNode) children[i]).isSimpleProperty(context);
+ } else {
+ result = false;
}
+ }
}
+ return result;
+ }
- public boolean isSimpleNavigationChain( OgnlContext context ) throws OgnlException
- {
- boolean result = false;
-
- if ((children != null) && (children.length > 0)) {
- result = true;
- for (int i = 0; result && (i < children.length); i++) {
- if (children[i] instanceof SimpleNode) {
- result = ((SimpleNode)children[i]).isSimpleProperty(context);
- } else {
- result = false;
- }
- }
- }
- return result;
- }
+ public String toString() {
+ String result = "";
- public String toString()
- {
- String result = "";
-
- if ((children != null) && (children.length > 0)) {
- for (int i = 0; i < children.length; i++) {
- if (i > 0) {
- if (!(children[i] instanceof ASTProperty) || !((ASTProperty)children[i]).isIndexedAccess()) {
- result = result + ".";
- }
- }
- result += children[i].toString();
- }
+ if ((children != null) && (children.length > 0)) {
+ for (int i = 0; i < children.length; i++) {
+ if (i > 0) {
+ if (!(children[i] instanceof ASTProperty) || !((ASTProperty) children[i]).isIndexedAccess()) {
+ result = result + ".";
+ }
}
- return result;
+ result += children[i].toString();
+ }
}
+ return result;
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTConst.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTConst.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTConst.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTConst.java Thu Jan 22 22:32:36 2009
@@ -30,140 +30,138 @@
//--------------------------------------------------------------------------
package org.apache.ibatis.ognl;
-import java.math.*;
+import java.math.BigDecimal;
+import java.math.BigInteger;
/**
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTConst extends SimpleNode
-{
- private Object value;
+class ASTConst extends SimpleNode {
+ private Object value;
- public ASTConst(int id) {
- super(id);
- }
-
- public ASTConst(OgnlParser p, int id) {
- super(p, id);
- }
-
- /** Called from parser actions. */
- void setValue( Object value ) {
- this.value = value;
- }
-
- public Object getValue() {
- return value;
- }
-
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException {
- return this.value;
- }
-
- public boolean isNodeConstant( OgnlContext context ) throws OgnlException
- {
- return true;
- }
-
- public String getEscapedChar(char ch)
- {
- String result;
-
- switch(ch) {
- case '\b':
- result = "\b";
- break;
- case '\t':
- result = "\\t";
- break;
- case '\n':
- result = "\\n";
- break;
- case '\f':
- result = "\\f";
- break;
- case '\r':
- result = "\\r";
- break;
- case '\"':
- result = "\\\"";
- break;
- case '\'':
- result = "\\\'";
- break;
- case '\\':
- result = "\\\\";
- break;
- default:
- if (Character.isISOControl(ch) || (ch > 255)) {
- String hc = Integer.toString((int)ch, 16);
- int hcl = hc.length();
-
- result = "\\u";
- if (hcl < 4) {
- if (hcl == 3) {
- result = result + "0";
- } else {
- if (hcl == 2) {
- result = result + "00";
- } else {
- result = result + "000";
- }
- }
- }
-
- result = result + hc;
- } else {
- result = new String(ch + "");
- }
- break;
- }
- return result;
- }
-
- public String getEscapedString(String value)
- {
- StringBuffer result = new StringBuffer();
+ public ASTConst(int id) {
+ super(id);
+ }
+
+ public ASTConst(OgnlParser p, int id) {
+ super(p, id);
+ }
+
+ /**
+ * Called from parser actions.
+ */
+ void setValue(Object value) {
+ this.value = value;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ return this.value;
+ }
+
+ public boolean isNodeConstant(OgnlContext context) throws OgnlException {
+ return true;
+ }
+
+ public String getEscapedChar(char ch) {
+ String result;
+
+ switch (ch) {
+ case '\b':
+ result = "\b";
+ break;
+ case '\t':
+ result = "\\t";
+ break;
+ case '\n':
+ result = "\\n";
+ break;
+ case '\f':
+ result = "\\f";
+ break;
+ case '\r':
+ result = "\\r";
+ break;
+ case '\"':
+ result = "\\\"";
+ break;
+ case '\'':
+ result = "\\\'";
+ break;
+ case '\\':
+ result = "\\\\";
+ break;
+ default:
+ if (Character.isISOControl(ch) || (ch > 255)) {
+ String hc = Integer.toString((int) ch, 16);
+ int hcl = hc.length();
+
+ result = "\\u";
+ if (hcl < 4) {
+ if (hcl == 3) {
+ result = result + "0";
+ } else {
+ if (hcl == 2) {
+ result = result + "00";
+ } else {
+ result = result + "000";
+ }
+ }
+ }
- for (int i = 0, icount = value.length(); i < icount; i++) {
- result.append(getEscapedChar(value.charAt(i)));
+ result = result + hc;
+ } else {
+ result = new String(ch + "");
}
- return new String(result);
+ break;
}
+ return result;
+ }
- public String toString()
- {
- String result;
+ public String getEscapedString(String value) {
+ StringBuffer result = new StringBuffer();
- if (value == null) {
- result = "null";
+ for (int i = 0, icount = value.length(); i < icount; i++) {
+ result.append(getEscapedChar(value.charAt(i)));
+ }
+ return new String(result);
+ }
+
+ public String toString() {
+ String result;
+
+ if (value == null) {
+ result = "null";
+ } else {
+ if (value instanceof String) {
+ result = '\"' + getEscapedString(value.toString()) + '\"';
+ } else {
+ if (value instanceof Character) {
+ result = '\'' + getEscapedChar(((Character) value).charValue()) + '\'';
} else {
- if (value instanceof String) {
- result = '\"' + getEscapedString(value.toString()) + '\"';
+ result = value.toString();
+ if (value instanceof Long) {
+ result = result + "L";
+ } else {
+ if (value instanceof BigDecimal) {
+ result = result + "B";
} else {
- if (value instanceof Character) {
- result = '\'' + getEscapedChar(((Character)value).charValue()) + '\'';
- } else {
- result = value.toString();
- if (value instanceof Long) {
- result = result + "L";
- } else {
- if (value instanceof BigDecimal) {
- result = result + "B";
- } else {
- if (value instanceof BigInteger) {
- result = result + "H";
- } else {
- if (value instanceof Node) {
- result = ":[ " + result + " ]";
- }
- }
- }
- }
+ if (value instanceof BigInteger) {
+ result = result + "H";
+ } else {
+ if (value instanceof Node) {
+ result = ":[ " + result + " ]";
}
+ }
}
+ }
}
- return result;
+ }
}
+ return result;
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTCtor.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTCtor.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTCtor.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTCtor.java Thu Jan 22 22:32:36 2009
@@ -30,111 +30,110 @@
//--------------------------------------------------------------------------
package org.apache.ibatis.ognl;
-import java.lang.reflect.*;
-import java.util.*;
+import java.lang.reflect.Array;
+import java.util.List;
/**
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTCtor extends SimpleNode
-{
- private String className;
- private boolean isArray;
-
- public ASTCtor(int id) {
- super(id);
- }
-
- public ASTCtor(OgnlParser p, int id) {
- super(p, id);
- }
-
- /** Called from parser action. */
- void setClassName( String className ) {
- this.className = className;
- }
-
- void setArray(boolean value) {
- isArray = value;
- }
-
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
- {
- Object result,
- root = context.getRoot();
- int count = jjtGetNumChildren();
- Object[] args = OgnlRuntime.getObjectArrayPool().create(count);
-
- try {
- for ( int i=0; i < count; ++i ) {
- args[i] = children[i].getValue(context, root);
- }
- if (isArray) {
- if (args.length == 1) {
- try {
- Class componentClass = OgnlRuntime.classForName(context, className);
- List sourceList = null;
- int size;
-
- if (args[0] instanceof List) {
- sourceList = (List)args[0];
- size = sourceList.size();
- } else {
- size = (int)OgnlOps.longValue(args[0]);
- }
- result = Array.newInstance(componentClass, size);
- if (sourceList != null) {
- TypeConverter converter = context.getTypeConverter();
-
- for (int i = 0, icount = sourceList.size(); i < icount; i++) {
- Object o = sourceList.get(i);
-
- if ((o == null) || componentClass.isInstance(o)) {
- Array.set(result, i, o);
- } else {
- Array.set(result, i, converter.convertValue(context, null, null, null, o, componentClass));
- }
- }
- }
- } catch (ClassNotFoundException ex) {
- throw new OgnlException("array component class '" + className + "' not found", ex);
- }
- } else {
- throw new OgnlException("only expect array size or fixed initializer list");
- }
+class ASTCtor extends SimpleNode {
+ private String className;
+ private boolean isArray;
+
+ public ASTCtor(int id) {
+ super(id);
+ }
+
+ public ASTCtor(OgnlParser p, int id) {
+ super(p, id);
+ }
+
+ /**
+ * Called from parser action.
+ */
+ void setClassName(String className) {
+ this.className = className;
+ }
+
+ void setArray(boolean value) {
+ isArray = value;
+ }
+
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ Object result,
+ root = context.getRoot();
+ int count = jjtGetNumChildren();
+ Object[] args = OgnlRuntime.getObjectArrayPool().create(count);
+
+ try {
+ for (int i = 0; i < count; ++i) {
+ args[i] = children[i].getValue(context, root);
+ }
+ if (isArray) {
+ if (args.length == 1) {
+ try {
+ Class componentClass = OgnlRuntime.classForName(context, className);
+ List sourceList = null;
+ int size;
+
+ if (args[0] instanceof List) {
+ sourceList = (List) args[0];
+ size = sourceList.size();
} else {
- result = OgnlRuntime.callConstructor( context, className, args );
+ size = (int) OgnlOps.longValue(args[0]);
}
+ result = Array.newInstance(componentClass, size);
+ if (sourceList != null) {
+ TypeConverter converter = context.getTypeConverter();
- return result;
- } finally {
- OgnlRuntime.getObjectArrayPool().recycle(args);
- }
- }
+ for (int i = 0, icount = sourceList.size(); i < icount; i++) {
+ Object o = sourceList.get(i);
- public String toString()
- {
- String result = "new " + className;
-
- if (isArray) {
- if (children[0] instanceof ASTConst) {
- result = result + "[" + children[0] + "]";
- } else {
- result = result + "[] " + children[0];
- }
- } else {
- 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];
+ if ((o == null) || componentClass.isInstance(o)) {
+ Array.set(result, i, o);
+ } else {
+ Array.set(result, i, converter.convertValue(context, null, null, null, o, componentClass));
}
+ }
}
- result = result + ")";
+ } catch (ClassNotFoundException ex) {
+ throw new OgnlException("array component class '" + className + "' not found", ex);
+ }
+ } else {
+ throw new OgnlException("only expect array size or fixed initializer list");
+ }
+ } else {
+ result = OgnlRuntime.callConstructor(context, className, args);
+ }
+
+ return result;
+ } finally {
+ OgnlRuntime.getObjectArrayPool().recycle(args);
+ }
+ }
+
+ public String toString() {
+ String result = "new " + className;
+
+ if (isArray) {
+ if (children[0] instanceof ASTConst) {
+ result = result + "[" + children[0] + "]";
+ } else {
+ result = result + "[] " + children[0];
+ }
+ } else {
+ 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];
}
- return result;
+ }
+ result = result + ")";
}
+ return result;
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTDivide.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTDivide.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTDivide.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTDivide.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 ASTDivide extends ExpressionNode
-{
- public ASTDivide(int id) {
- super(id);
- }
+class ASTDivide extends ExpressionNode {
+ public ASTDivide(int id) {
+ super(id);
+ }
- public ASTDivide(OgnlParser p, int id) {
- super(p, id);
- }
+ public ASTDivide(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.divide( 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.divide(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/ASTEq.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTEq.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTEq.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTEq.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 ASTEq extends ExpressionNode
-{
- public ASTEq(int id) {
- super(id);
- }
+class ASTEq extends ExpressionNode {
+ public ASTEq(int id) {
+ super(id);
+ }
- public ASTEq(OgnlParser p, int id) {
- super(p, id);
- }
+ public ASTEq(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.equal( v1, v2 )? Boolean.TRUE : Boolean.FALSE;
- }
+ 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.equal(v1, v2) ? Boolean.TRUE : Boolean.FALSE;
+ }
- 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/ASTEval.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTEval.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTEval.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTEval.java Thu Jan 22 22:32:36 2009
@@ -34,52 +34,48 @@
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTEval extends SimpleNode
-{
- public ASTEval(int id) {
- super(id);
+class ASTEval extends SimpleNode {
+ public ASTEval(int id) {
+ super(id);
+ }
+
+ public ASTEval(OgnlParser p, int id) {
+ super(p, id);
+ }
+
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ Object result,
+ expr = children[0].getValue(context, source),
+ previousRoot = context.getRoot();
+ Node node;
+
+ source = children[1].getValue(context, source);
+ node = (expr instanceof Node) ? (Node) expr : (Node) Ognl.parseExpression(expr.toString());
+ try {
+ context.setRoot(source);
+ result = node.getValue(context, source);
+ } finally {
+ context.setRoot(previousRoot);
}
+ return result;
+ }
- public ASTEval(OgnlParser p, int id) {
- super(p, id);
+ protected void setValueBody(OgnlContext context, Object target, Object value) throws OgnlException {
+ Object expr = children[0].getValue(context, target),
+ previousRoot = context.getRoot();
+ Node node;
+
+ target = children[1].getValue(context, target);
+ node = (expr instanceof Node) ? (Node) expr : (Node) Ognl.parseExpression(expr.toString());
+ try {
+ context.setRoot(target);
+ node.setValue(context, target, value);
+ } finally {
+ context.setRoot(previousRoot);
}
+ }
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
- {
- Object result,
- expr = children[0].getValue( context, source ),
- previousRoot = context.getRoot();
- Node node;
-
- source = children[1].getValue( context, source );
- node = (expr instanceof Node) ? (Node) expr : (Node) Ognl.parseExpression( expr.toString() );
- try {
- context.setRoot( source );
- result = node.getValue( context, source );
- } finally {
- context.setRoot( previousRoot );
- }
- return result;
- }
-
- protected void setValueBody( OgnlContext context, Object target, Object value ) throws OgnlException
- {
- Object expr = children[0].getValue(context, target),
- previousRoot = context.getRoot();
- Node node;
-
- target = children[1].getValue( context, target );
- node = (expr instanceof Node) ? (Node) expr : (Node) Ognl.parseExpression( expr.toString() );
- try {
- context.setRoot( target );
- node.setValue( context, target, value );
- } finally {
- context.setRoot( previousRoot );
- }
- }
-
- public String toString()
- {
- return "(" + children[0] + ")(" + children[1] + ")";
- }
+ public String toString() {
+ return "(" + children[0] + ")(" + children[1] + ")";
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTGreater.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTGreater.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTGreater.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTGreater.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 ASTGreater extends ExpressionNode
-{
- public ASTGreater(int id) {
- super(id);
- }
+class ASTGreater extends ExpressionNode {
+ public ASTGreater(int id) {
+ super(id);
+ }
- public ASTGreater(OgnlParser p, int id) {
- super(p, id);
- }
+ public ASTGreater(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.greater( v1, v2 )? Boolean.TRUE : Boolean.FALSE;
- }
+ 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.greater(v1, v2) ? Boolean.TRUE : Boolean.FALSE;
+ }
- 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/ASTGreaterEq.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTGreaterEq.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTGreaterEq.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTGreaterEq.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 ASTGreaterEq extends ExpressionNode
-{
- public ASTGreaterEq(int id) {
- super(id);
- }
+class ASTGreaterEq extends ExpressionNode {
+ public ASTGreaterEq(int id) {
+ super(id);
+ }
- public ASTGreaterEq(OgnlParser p, int id) {
- super(p, id);
- }
+ public ASTGreaterEq(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.less( v1, v2 )? Boolean.FALSE : Boolean.TRUE;
- }
+ 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.less(v1, v2) ? Boolean.FALSE : Boolean.TRUE;
+ }
- 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/ASTIn.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTIn.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTIn.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTIn.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 ASTIn extends SimpleNode
-{
- public ASTIn(int id) {
- super(id);
- }
+class ASTIn extends SimpleNode {
+ public ASTIn(int id) {
+ super(id);
+ }
- public ASTIn(OgnlParser p, int id) {
- super(p, id);
- }
+ public ASTIn(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.in( v1, v2 )? Boolean.TRUE : Boolean.FALSE;
- }
+ 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.in(v1, v2) ? Boolean.TRUE : Boolean.FALSE;
+ }
- public String toString()
- {
- return children[0] + " in " + children[1];
- }
+ public String toString() {
+ return children[0] + " in " + children[1];
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTInstanceof.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTInstanceof.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTInstanceof.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTInstanceof.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 ASTInstanceof extends SimpleNode
-{
- private String targetType;
+class ASTInstanceof extends SimpleNode {
+ private String targetType;
- public ASTInstanceof(int id) {
- super(id);
- }
+ public ASTInstanceof(int id) {
+ super(id);
+ }
- public ASTInstanceof(OgnlParser p, int id) {
- super(p, id);
- }
+ public ASTInstanceof(OgnlParser p, int id) {
+ super(p, id);
+ }
- void setTargetType( String targetType ) {
- this.targetType = targetType;
- }
+ void setTargetType(String targetType) {
+ this.targetType = targetType;
+ }
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
- {
- Object value = children[0].getValue( context, source );
- return OgnlRuntime.isInstance(context, value, targetType)? Boolean.TRUE : Boolean.FALSE;
- }
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ Object value = children[0].getValue(context, source);
+ return OgnlRuntime.isInstance(context, value, targetType) ? Boolean.TRUE : Boolean.FALSE;
+ }
- public String toString()
- {
- return children[0] + " instanceof " + targetType;
- }
+ public String toString() {
+ return children[0] + " instanceof " + targetType;
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTKeyValue.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTKeyValue.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTKeyValue.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTKeyValue.java Thu Jan 22 22:32:36 2009
@@ -34,36 +34,31 @@
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTKeyValue extends SimpleNode
-{
- public ASTKeyValue(int id) {
- super(id);
- }
+class ASTKeyValue extends SimpleNode {
+ public ASTKeyValue(int id) {
+ super(id);
+ }
- public ASTKeyValue(OgnlParser p, int id) {
- super(p, id);
- }
+ public ASTKeyValue(OgnlParser p, int id) {
+ super(p, id);
+ }
- protected Node getKey()
- {
- return children[0];
- }
+ protected Node getKey() {
+ return children[0];
+ }
- protected Node getValue()
- {
- return (jjtGetNumChildren() > 1) ? children[1] : null;
- }
+ protected Node getValue() {
+ return (jjtGetNumChildren() > 1) ? children[1] : null;
+ }
- /**
- Returns null because this is a parser construct and does not evaluate
- */
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
- {
- return null;
- }
+ /**
+ * Returns null because this is a parser construct and does not evaluate
+ */
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ return null;
+ }
- public String toString()
- {
- return getKey() + " -> " + getValue();
- }
+ public String toString() {
+ return getKey() + " -> " + getValue();
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTLess.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTLess.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTLess.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTLess.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 ASTLess extends ExpressionNode
-{
- public ASTLess(int id) {
- super(id);
- }
+class ASTLess extends ExpressionNode {
+ public ASTLess(int id) {
+ super(id);
+ }
- public ASTLess(OgnlParser p, int id) {
- super(p, id);
- }
+ public ASTLess(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.less( v1, v2 )? Boolean.TRUE : Boolean.FALSE;
- }
+ 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.less(v1, v2) ? Boolean.TRUE : Boolean.FALSE;
+ }
- 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/ASTLessEq.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTLessEq.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTLessEq.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTLessEq.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 ASTLessEq extends ExpressionNode
-{
- public ASTLessEq(int id) {
- super(id);
- }
+class ASTLessEq extends ExpressionNode {
+ public ASTLessEq(int id) {
+ super(id);
+ }
- public ASTLessEq(OgnlParser p, int id) {
- super(p, id);
- }
+ public ASTLessEq(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.greater( v1, v2 )? Boolean.FALSE : Boolean.TRUE;
- }
+ 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.greater(v1, v2) ? Boolean.FALSE : Boolean.TRUE;
+ }
- 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/ASTList.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTList.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTList.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTList.java Thu Jan 22 22:32:36 2009
@@ -30,41 +30,39 @@
//--------------------------------------------------------------------------
package org.apache.ibatis.ognl;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
/**
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTList extends SimpleNode
-{
- public ASTList(int id) {
- super(id);
- }
-
- public ASTList(OgnlParser p, int id) {
- super(p, id);
- }
-
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
- {
- List answer = new ArrayList( jjtGetNumChildren() );
- for ( int i=0; i < jjtGetNumChildren(); ++i )
- answer.add( children[i].getValue(context, source) );
- return answer;
- }
-
- public String toString()
- {
- String result = "{ ";
-
-
- for ( int i=0; i < jjtGetNumChildren(); ++i ) {
- if (i > 0) {
- result = result + ", ";
- }
- result = result + children[i].toString();
- }
- return result + " }";
+class ASTList extends SimpleNode {
+ public ASTList(int id) {
+ super(id);
+ }
+
+ public ASTList(OgnlParser p, int id) {
+ super(p, id);
+ }
+
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ List answer = new ArrayList(jjtGetNumChildren());
+ for (int i = 0; i < jjtGetNumChildren(); ++i)
+ answer.add(children[i].getValue(context, source));
+ return answer;
+ }
+
+ public String toString() {
+ String result = "{ ";
+
+
+ for (int i = 0; i < jjtGetNumChildren(); ++i) {
+ if (i > 0) {
+ result = result + ", ";
+ }
+ result = result + children[i].toString();
}
+ return result + " }";
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTMap.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTMap.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTMap.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTMap.java Thu Jan 22 22:32:36 2009
@@ -30,84 +30,81 @@
//--------------------------------------------------------------------------
package org.apache.ibatis.ognl;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
/**
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTMap extends SimpleNode
-{
- private static Class DEFAULT_MAP_CLASS;
- private String className;
-
- static {
- /* Try to get LinkedHashMap; if older JDK than 1.4 use HashMap */
- try {
- DEFAULT_MAP_CLASS = Class.forName("java.util.LinkedHashMap");
- } catch (ClassNotFoundException ex) {
- DEFAULT_MAP_CLASS = HashMap.class;
- }
- }
-
- public ASTMap(int id) {
- super(id);
- }
-
- public ASTMap(OgnlParser p, int id) {
- super(p, id);
- }
-
- protected void setClassName(String value)
- {
- className = value;
- }
-
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
- {
- Map answer;
-
- if (className == null) {
- try {
- answer = (Map)DEFAULT_MAP_CLASS.newInstance();
- } catch (Exception ex) {
- /* This should never happen */
- throw new OgnlException("Default Map class '" + DEFAULT_MAP_CLASS.getName() + "' instantiation error", ex);
- }
- } else {
- try {
- answer = (Map)OgnlRuntime.classForName(context, className).newInstance();
- } catch (Exception ex) {
- throw new OgnlException("Map implementor '" + className + "' not found", ex);
- }
- }
-
- for ( int i=0; i < jjtGetNumChildren(); ++i ) {
- ASTKeyValue kv = (ASTKeyValue)children[i];
- Node k = kv.getKey(),
- v = kv.getValue();
-
- answer.put( k.getValue(context, source), (v == null) ? null : v.getValue(context, source) );
- }
- return answer;
- }
-
- public String toString()
- {
- String result = "#";
-
- if (className != null) {
- result = result + "@" + className + "@";
- }
- result = result + "{ ";
- for ( int i = 0; i < jjtGetNumChildren(); ++i ) {
- ASTKeyValue kv = (ASTKeyValue)children[i];
-
- if (i > 0) {
- result = result + ", ";
- }
- result = result + kv.getKey() + " : " + kv.getValue();
- }
- return result + " }";
+class ASTMap extends SimpleNode {
+ private static Class DEFAULT_MAP_CLASS;
+ private String className;
+
+ static {
+ /* Try to get LinkedHashMap; if older JDK than 1.4 use HashMap */
+ try {
+ DEFAULT_MAP_CLASS = Class.forName("java.util.LinkedHashMap");
+ } catch (ClassNotFoundException ex) {
+ DEFAULT_MAP_CLASS = HashMap.class;
+ }
+ }
+
+ public ASTMap(int id) {
+ super(id);
+ }
+
+ public ASTMap(OgnlParser p, int id) {
+ super(p, id);
+ }
+
+ protected void setClassName(String value) {
+ className = value;
+ }
+
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ Map answer;
+
+ if (className == null) {
+ try {
+ answer = (Map) DEFAULT_MAP_CLASS.newInstance();
+ } catch (Exception ex) {
+ /* This should never happen */
+ throw new OgnlException("Default Map class '" + DEFAULT_MAP_CLASS.getName() + "' instantiation error", ex);
+ }
+ } else {
+ try {
+ answer = (Map) OgnlRuntime.classForName(context, className).newInstance();
+ } catch (Exception ex) {
+ throw new OgnlException("Map implementor '" + className + "' not found", ex);
+ }
+ }
+
+ for (int i = 0; i < jjtGetNumChildren(); ++i) {
+ ASTKeyValue kv = (ASTKeyValue) children[i];
+ Node k = kv.getKey(),
+ v = kv.getValue();
+
+ answer.put(k.getValue(context, source), (v == null) ? null : v.getValue(context, source));
+ }
+ return answer;
+ }
+
+ public String toString() {
+ String result = "#";
+
+ if (className != null) {
+ result = result + "@" + className + "@";
+ }
+ result = result + "{ ";
+ for (int i = 0; i < jjtGetNumChildren(); ++i) {
+ ASTKeyValue kv = (ASTKeyValue) children[i];
+
+ if (i > 0) {
+ result = result + ", ";
+ }
+ result = result + kv.getKey() + " : " + kv.getValue();
}
+ return result + " }";
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTMethod.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTMethod.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTMethod.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTMethod.java Thu Jan 22 22:32:36 2009
@@ -34,68 +34,66 @@
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTMethod extends SimpleNode
-{
- private String methodName;
+class ASTMethod extends SimpleNode {
+ private String methodName;
- public ASTMethod(int id) {
- super(id);
- }
-
- public ASTMethod(OgnlParser p, int id) {
- super(p, id);
- }
-
- /** Called from parser action. */
- void setMethodName( String methodName ) {
- this.methodName = methodName;
- }
-
- /**
- Returns the method name that this node will call.
- */
- public String getMethodName()
- {
- return methodName;
- }
-
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
- {
- Object[] args = OgnlRuntime.getObjectArrayPool().create(jjtGetNumChildren());
-
- try {
- Object result,
- root = context.getRoot();
-
- for ( int i = 0, icount = args.length; i < icount; ++i ) {
- args[i] = children[i].getValue(context, root);
- }
- result = OgnlRuntime.callMethod( context, source, methodName, null, args);
- if (result == null) {
- NullHandler nh = OgnlRuntime.getNullHandler(OgnlRuntime.getTargetClass(source));
-
- result = nh.nullMethodResult(context, source, methodName, args);
- }
- return result;
- } finally {
- OgnlRuntime.getObjectArrayPool().recycle(args);
- }
- }
-
- public String toString()
- {
- String result = 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];
- }
+ public ASTMethod(int id) {
+ super(id);
+ }
+
+ public ASTMethod(OgnlParser p, int id) {
+ super(p, id);
+ }
+
+ /**
+ * Called from parser action.
+ */
+ void setMethodName(String methodName) {
+ this.methodName = methodName;
+ }
+
+ /**
+ * Returns the method name that this node will call.
+ */
+ public String getMethodName() {
+ return methodName;
+ }
+
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ Object[] args = OgnlRuntime.getObjectArrayPool().create(jjtGetNumChildren());
+
+ try {
+ Object result,
+ root = context.getRoot();
+
+ for (int i = 0, icount = args.length; i < icount; ++i) {
+ args[i] = children[i].getValue(context, root);
+ }
+ result = OgnlRuntime.callMethod(context, source, methodName, null, args);
+ if (result == null) {
+ NullHandler nh = OgnlRuntime.getNullHandler(OgnlRuntime.getTargetClass(source));
+
+ result = nh.nullMethodResult(context, source, methodName, args);
+ }
+ return result;
+ } finally {
+ OgnlRuntime.getObjectArrayPool().recycle(args);
+ }
+ }
+
+ public String toString() {
+ String result = methodName;
+
+ 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/ASTMultiply.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTMultiply.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTMultiply.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTMultiply.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 ASTMultiply extends ExpressionNode
-{
- public ASTMultiply(int id) {
- super(id);
- }
+class ASTMultiply extends ExpressionNode {
+ public ASTMultiply(int id) {
+ super(id);
+ }
- public ASTMultiply(OgnlParser p, int id) {
- super(p, id);
- }
+ public ASTMultiply(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.multiply( 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.multiply(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/ASTNegate.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTNegate.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTNegate.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTNegate.java Thu Jan 22 22:32:36 2009
@@ -34,23 +34,20 @@
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTNegate extends ExpressionNode
-{
- public ASTNegate(int id) {
- super(id);
- }
+class ASTNegate extends ExpressionNode {
+ public ASTNegate(int id) {
+ super(id);
+ }
- public ASTNegate(OgnlParser p, int id) {
- super(p, id);
- }
+ public ASTNegate(OgnlParser p, int id) {
+ super(p, id);
+ }
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
- {
- return OgnlOps.negate( children[0].getValue(context, source) );
- }
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ return OgnlOps.negate(children[0].getValue(context, source));
+ }
- 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/ASTNot.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTNot.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTNot.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTNot.java Thu Jan 22 22:32:36 2009
@@ -34,23 +34,20 @@
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTNot extends ExpressionNode
-{
- public ASTNot(int id) {
- super(id);
- }
+class ASTNot extends ExpressionNode {
+ public ASTNot(int id) {
+ super(id);
+ }
- public ASTNot(OgnlParser p, int id) {
- super(p, id);
- }
+ public ASTNot(OgnlParser p, int id) {
+ super(p, id);
+ }
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
- {
- return OgnlOps.booleanValue( children[0].getValue(context, source) )? Boolean.FALSE : Boolean.TRUE;
- }
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ return OgnlOps.booleanValue(children[0].getValue(context, source)) ? Boolean.FALSE : Boolean.TRUE;
+ }
- 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/ASTNotEq.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTNotEq.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTNotEq.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTNotEq.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 ASTNotEq extends ExpressionNode
-{
- public ASTNotEq(int id) {
- super(id);
- }
+class ASTNotEq extends ExpressionNode {
+ public ASTNotEq(int id) {
+ super(id);
+ }
- public ASTNotEq(OgnlParser p, int id) {
- super(p, id);
- }
+ public ASTNotEq(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.equal( v1, v2 )? Boolean.FALSE : Boolean.TRUE;
- }
+ 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.equal(v1, v2) ? Boolean.FALSE : Boolean.TRUE;
+ }
- 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/ASTNotIn.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTNotIn.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTNotIn.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTNotIn.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 ASTNotIn extends SimpleNode
-{
- public ASTNotIn(int id) {
- super(id);
- }
+class ASTNotIn extends SimpleNode {
+ public ASTNotIn(int id) {
+ super(id);
+ }
- public ASTNotIn(OgnlParser p, int id) {
- super(p, id);
- }
+ public ASTNotIn(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.in( v1, v2 )? Boolean.FALSE : Boolean.TRUE;
- }
+ 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.in(v1, v2) ? Boolean.FALSE : Boolean.TRUE;
+ }
- public String toString()
- {
- return children[0] + " not in " + children[1];
- }
+ public String toString() {
+ return children[0] + " not in " + children[1];
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTOr.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTOr.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTOr.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTOr.java Thu Jan 22 22:32:36 2009
@@ -34,45 +34,41 @@
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTOr extends ExpressionNode
-{
- public ASTOr(int id) {
- super(id);
- }
+class ASTOr extends ExpressionNode {
+ public ASTOr(int id) {
+ super(id);
+ }
- public ASTOr(OgnlParser p, int id) {
- super(p, id);
- }
+ public ASTOr(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 = null;
- int last = children.length - 1;
- for ( int i=0; i <= last; ++i ) {
- result = children[i].getValue( context, source );
- if ( i != last && OgnlOps.booleanValue(result) )
- break;
- }
- return result;
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ Object result = null;
+ int last = children.length - 1;
+ for (int i = 0; i <= last; ++i) {
+ result = children[i].getValue(context, source);
+ if (i != last && OgnlOps.booleanValue(result))
+ break;
}
+ return result;
+ }
- protected void setValueBody( OgnlContext context, Object target, Object value ) throws OgnlException
- {
- int last = children.length - 1;
- for ( int i=0; i < last; ++i ) {
- Object v = children[i].getValue( context, target );
- if ( OgnlOps.booleanValue(v) )
- return;
- }
- children[last].setValue( context, target, value );
+ protected void setValueBody(OgnlContext context, Object target, Object value) throws OgnlException {
+ int last = children.length - 1;
+ for (int i = 0; i < last; ++i) {
+ Object v = children[i].getValue(context, target);
+ if (OgnlOps.booleanValue(v))
+ return;
}
+ children[last].setValue(context, target, value);
+ }
- 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/ASTProject.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTProject.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTProject.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTProject.java Thu Jan 22 22:32:36 2009
@@ -30,36 +30,35 @@
//--------------------------------------------------------------------------
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 ASTProject extends SimpleNode
-{
- public ASTProject(int id) {
- super(id);
- }
-
- public ASTProject(OgnlParser p, int id) {
- super(p, id);
- }
+class ASTProject extends SimpleNode {
+ public ASTProject(int id) {
+ super(id);
+ }
+
+ public ASTProject(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));
- 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();) {
- answer.add( expr.getValue(context, e.nextElement()) );
- }
- return answer;
+ for (Enumeration e = elementsAccessor.getElements(source); e.hasMoreElements();) {
+ answer.add(expr.getValue(context, e.nextElement()));
}
+ 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/ASTProperty.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTProperty.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTProperty.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTProperty.java Thu Jan 22 22:32:36 2009
@@ -34,87 +34,76 @@
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-class ASTProperty extends SimpleNode
-{
- private boolean indexedAccess = false;
-
- public ASTProperty(int id)
- {
- super(id);
- }
-
- public ASTProperty(OgnlParser p, int id)
- {
- super(p, id);
- }
-
- public void setIndexedAccess( boolean value )
- {
- indexedAccess = value;
- }
-
- /**
- Returns true iff this property is itself an index reference.
- */
- public boolean isIndexedAccess()
- {
- return indexedAccess;
- }
-
- /**
- Returns true if this property is described by an IndexedPropertyDescriptor
- and that if followed by an index specifier it will call the index get/set
- methods rather than go through property accessors.
- */
- public int getIndexedPropertyType(OgnlContext context, Object source) throws OgnlException
- {
- if (!isIndexedAccess()) {
- Object property = getProperty(context, source);
-
- if (property instanceof String) {
- return OgnlRuntime.getIndexedPropertyType(context, (source == null) ? null : source.getClass(), (String)property);
- }
- }
- return OgnlRuntime.INDEXED_PROPERTY_NONE;
- }
-
- public Object getProperty( OgnlContext context, Object source ) throws OgnlException
- {
- return children[0].getValue( context, context.getRoot() );
- }
-
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
- {
- Object result,
- property = getProperty(context, source);
- Node indexSibling;
-
- result = OgnlRuntime.getProperty( context, source, property );
- if (result == null) {
- result = OgnlRuntime.getNullHandler(OgnlRuntime.getTargetClass(source)).nullPropertyValue(context, source, property);
- }
- return result;
- }
-
- protected void setValueBody( OgnlContext context, Object target, Object value ) throws OgnlException
- {
- OgnlRuntime.setProperty( context, target, getProperty( context, target), value );
- }
-
- public boolean isNodeSimpleProperty( OgnlContext context ) throws OgnlException
- {
- return (children != null) && (children.length == 1) && ((SimpleNode)children[0]).isConstant(context);
- }
+class ASTProperty extends SimpleNode {
+ private boolean indexedAccess = false;
- public String toString()
- {
- String result;
-
- if (isIndexedAccess()) {
- result = "[" + children[0] + "]";
- } else {
- result = ((ASTConst)children[0]).getValue().toString();
- }
- return result;
+ public ASTProperty(int id) {
+ super(id);
+ }
+
+ public ASTProperty(OgnlParser p, int id) {
+ super(p, id);
+ }
+
+ public void setIndexedAccess(boolean value) {
+ indexedAccess = value;
+ }
+
+ /**
+ * Returns true iff this property is itself an index reference.
+ */
+ public boolean isIndexedAccess() {
+ return indexedAccess;
+ }
+
+ /**
+ * Returns true if this property is described by an IndexedPropertyDescriptor
+ * and that if followed by an index specifier it will call the index get/set
+ * methods rather than go through property accessors.
+ */
+ public int getIndexedPropertyType(OgnlContext context, Object source) throws OgnlException {
+ if (!isIndexedAccess()) {
+ Object property = getProperty(context, source);
+
+ if (property instanceof String) {
+ return OgnlRuntime.getIndexedPropertyType(context, (source == null) ? null : source.getClass(), (String) property);
+ }
+ }
+ return OgnlRuntime.INDEXED_PROPERTY_NONE;
+ }
+
+ public Object getProperty(OgnlContext context, Object source) throws OgnlException {
+ return children[0].getValue(context, context.getRoot());
+ }
+
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ Object result,
+ property = getProperty(context, source);
+ Node indexSibling;
+
+ result = OgnlRuntime.getProperty(context, source, property);
+ if (result == null) {
+ result = OgnlRuntime.getNullHandler(OgnlRuntime.getTargetClass(source)).nullPropertyValue(context, source, property);
+ }
+ return result;
+ }
+
+ protected void setValueBody(OgnlContext context, Object target, Object value) throws OgnlException {
+ OgnlRuntime.setProperty(context, target, getProperty(context, target), value);
+ }
+
+ public boolean isNodeSimpleProperty(OgnlContext context) throws OgnlException {
+ return (children != null) && (children.length == 1) && ((SimpleNode) children[0]).isConstant(context);
+ }
+
+ public String toString() {
+ String result;
+
+ if (isIndexedAccess()) {
+ result = "[" + children[0] + "]";
+ } else {
+ result = ((ASTConst) children[0]).getValue().toString();
}
+ return result;
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTRemainder.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTRemainder.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTRemainder.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTRemainder.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 ASTRemainder extends ExpressionNode
-{
- public ASTRemainder(int id) {
- super(id);
- }
+class ASTRemainder extends ExpressionNode {
+ public ASTRemainder(int id) {
+ super(id);
+ }
- public ASTRemainder(OgnlParser p, int id) {
- super(p, id);
- }
+ public ASTRemainder(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.remainder( 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.remainder(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/ASTRootVarRef.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTRootVarRef.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTRootVarRef.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTRootVarRef.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 ASTRootVarRef extends ASTVarRef
-{
- private String name;
+class ASTRootVarRef extends ASTVarRef {
+ private String name;
- public ASTRootVarRef(int id) {
- super(id);
- }
+ public ASTRootVarRef(int id) {
+ super(id);
+ }
- public ASTRootVarRef(OgnlParser p, int id) {
- super(p, id);
- }
+ public ASTRootVarRef(OgnlParser p, int id) {
+ super(p, id);
+ }
- protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException {
- return context.getRoot();
- }
+ protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
+ return context.getRoot();
+ }
- protected void setValueBody( OgnlContext context, Object target, Object value ) throws OgnlException {
- context.setRoot( value );
- }
+ protected void setValueBody(OgnlContext context, Object target, Object value) throws OgnlException {
+ context.setRoot(value);
+ }
- public String toString()
- {
- return "#root";
- }
+ public String toString() {
+ return "#root";
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTSelect.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTSelect.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTSelect.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ASTSelect.java Thu Jan 22 22:32:36 2009
@@ -30,39 +30,38 @@
//--------------------------------------------------------------------------
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 ASTSelect extends SimpleNode
-{
- public ASTSelect(int id) {
- super(id);
- }
+class ASTSelect extends SimpleNode {
+ public ASTSelect(int id) {
+ super(id);
+ }
+
+ public ASTSelect(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));
- public ASTSelect(OgnlParser p, int id) {
- super(p, id);
- }
+ for (Enumeration e = elementsAccessor.getElements(source); e.hasMoreElements();) {
+ Object next = e.nextElement();
- 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);
- }
- return answer;
+ if (OgnlOps.booleanValue(expr.getValue(context, next)))
+ answer.add(next);
}
+ return answer;
+ }
- public String toString()
- {
- return "{? " + children[0] + " }";
- }
+ public String toString() {
+ return "{? " + children[0] + " }";
+ }
}