You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/08/30 14:56:58 UTC
[commons-ognl] branch master updated: Remove Subversion key substitution noise "$Id$"
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-ognl.git
The following commit(s) were added to refs/heads/master by this push:
new dae75d8 Remove Subversion key substitution noise "$Id$"
dae75d8 is described below
commit dae75d86114db06535a7796791fd7b56577f0300
Author: Gary Gregory <gg...@rocketsoftware.com>
AuthorDate: Tue Aug 30 10:56:52 2022 -0400
Remove Subversion key substitution noise "$Id$"
---
.../performance/PerformanceCommonsOgnlTest.java | 97 +-
.../ognl/performance/PerformanceOldOgnlTest.java | 97 +-
.../performance/invocation/CompilerInvocation.java | 91 +-
.../performance/invocation/FieldInvocation.java | 105 +-
.../invocation/FindParameterTypesInvocation.java | 117 +-
.../invocation/GetConstructorsInvocation.java | 105 +-
.../invocation/GetDeclaredMethodsInvocation.java | 109 +-
.../invocation/GetMethodsInvocation.java | 109 +-
.../invocation/InvokeMethodInvocation.java | 115 +-
.../invocation/MethodParameterTypesInvocation.java | 125 +-
.../invocation/PermissionInvocation.java | 121 +-
.../invocation/PrimitiveDefaultInvocation.java | 103 +-
.../invocation/RepeatableInvocation.java | 317 +-
.../performance/runtime/CommonsRuntimeWrapper.java | 235 +-
.../performance/runtime/OldOgnlRuntimeWrapper.java | 233 +-
.../ognl/performance/runtime/RuntimeWrapper.java | 133 +-
src/main/java/org/apache/commons/ognl/ASTAdd.java | 703 ++--
src/main/java/org/apache/commons/ognl/ASTAnd.java | 1 -
.../java/org/apache/commons/ognl/ASTAssign.java | 301 +-
.../java/org/apache/commons/ognl/ASTBitAnd.java | 137 +-
.../java/org/apache/commons/ognl/ASTBitNegate.java | 119 +-
.../java/org/apache/commons/ognl/ASTBitOr.java | 127 +-
.../java/org/apache/commons/ognl/ASTChain.java | 979 +++--
.../java/org/apache/commons/ognl/ASTConst.java | 341 +-
src/main/java/org/apache/commons/ognl/ASTCtor.java | 723 ++--
.../java/org/apache/commons/ognl/ASTDivide.java | 113 +-
src/main/java/org/apache/commons/ognl/ASTEq.java | 121 +-
src/main/java/org/apache/commons/ognl/ASTEval.java | 203 +-
.../java/org/apache/commons/ognl/ASTGreater.java | 123 +-
.../java/org/apache/commons/ognl/ASTGreaterEq.java | 121 +-
src/main/java/org/apache/commons/ognl/ASTIn.java | 199 +-
.../org/apache/commons/ognl/ASTInstanceof.java | 207 +-
.../java/org/apache/commons/ognl/ASTKeyValue.java | 123 +-
src/main/java/org/apache/commons/ognl/ASTLess.java | 123 +-
.../java/org/apache/commons/ognl/ASTLessEq.java | 123 +-
src/main/java/org/apache/commons/ognl/ASTList.java | 443 +-
src/main/java/org/apache/commons/ognl/ASTMap.java | 269 +-
.../java/org/apache/commons/ognl/ASTMethod.java | 823 ++--
.../org/apache/commons/ognl/ASTMethodUtil.java | 245 +-
.../java/org/apache/commons/ognl/ASTMultiply.java | 129 +-
.../java/org/apache/commons/ognl/ASTNegate.java | 119 +-
src/main/java/org/apache/commons/ognl/ASTNot.java | 153 +-
.../java/org/apache/commons/ognl/ASTNotEq.java | 123 +-
.../java/org/apache/commons/ognl/ASTNotIn.java | 187 +-
src/main/java/org/apache/commons/ognl/ASTOr.java | 411 +-
.../java/org/apache/commons/ognl/ASTProject.java | 153 +-
.../java/org/apache/commons/ognl/ASTProperty.java | 1297 +++---
.../java/org/apache/commons/ognl/ASTRemainder.java | 111 +-
.../org/apache/commons/ognl/ASTRootVarRef.java | 171 +-
.../java/org/apache/commons/ognl/ASTSelect.java | 161 +-
.../org/apache/commons/ognl/ASTSelectFirst.java | 157 +-
.../org/apache/commons/ognl/ASTSelectLast.java | 157 +-
.../java/org/apache/commons/ognl/ASTSequence.java | 331 +-
.../java/org/apache/commons/ognl/ASTShiftLeft.java | 111 +-
.../org/apache/commons/ognl/ASTShiftRight.java | 111 +-
.../org/apache/commons/ognl/ASTStaticField.java | 441 +-
.../org/apache/commons/ognl/ASTStaticMethod.java | 459 ++-
.../java/org/apache/commons/ognl/ASTSubtract.java | 111 +-
src/main/java/org/apache/commons/ognl/ASTTest.java | 305 +-
.../org/apache/commons/ognl/ASTThisVarRef.java | 135 +-
.../apache/commons/ognl/ASTUnsignedShiftRight.java | 183 +-
.../java/org/apache/commons/ognl/ASTVarRef.java | 295 +-
src/main/java/org/apache/commons/ognl/ASTXor.java | 127 +-
.../apache/commons/ognl/JJTOgnlParserState.java | 345 +-
.../apache/commons/ognl/MapPropertyAccessor.java | 339 +-
.../commons/ognl/OgnlParserTreeConstants.java | 259 +-
.../java/org/apache/commons/ognl/OgnlRuntime.java | 4233 ++++++++++----------
.../org/apache/commons/ognl/internal/Cache.java | 71 +-
.../commons/ognl/internal/CacheException.java | 63 +-
.../apache/commons/ognl/internal/ClassCache.java | 67 +-
.../commons/ognl/internal/ClassCacheHandler.java | 171 +-
.../commons/ognl/internal/ClassCacheImpl.java | 321 +-
.../ognl/internal/ConcurrentHashMapCache.java | 171 +-
.../internal/ConcurrentHashMapCacheFactory.java | 93 +-
.../ognl/internal/ConcurrentHashMapClassCache.java | 107 +-
.../org/apache/commons/ognl/internal/Entry.java | 147 +-
.../apache/commons/ognl/internal/HashMapCache.java | 195 +-
.../commons/ognl/internal/HashMapCacheFactory.java | 91 +-
.../commons/ognl/internal/HashMapClassCache.java | 107 +-
.../ognl/internal/ReentrantReadWriteLockCache.java | 259 +-
.../ReentrantReadWriteLockCacheFactory.java | 91 +-
.../internal/ReentrantReadWriteLockClassCache.java | 107 +-
.../commons/ognl/internal/entry/CacheEntry.java | 55 +-
.../ognl/internal/entry/CacheEntryFactory.java | 63 +-
.../internal/entry/ClassCacheEntryFactory.java | 57 +-
.../internal/entry/DeclaredMethodCacheEntry.java | 151 +-
.../entry/DeclaredMethodCacheEntryFactory.java | 103 +-
.../GenericMethodParameterTypeCacheEntry.java | 131 +-
.../entry/GenericMethodParameterTypeFactory.java | 213 +-
.../entry/MethodAccessCacheEntryFactory.java | 111 +-
.../internal/entry/MethodAccessEntryValue.java | 103 +-
.../ognl/internal/entry/MethodCacheEntry.java | 117 +-
.../internal/entry/MethodCacheEntryFactory.java | 137 +-
.../entry/MethodPermCacheEntryFactory.java | 119 +-
.../entry/ParametrizedCacheEntryFactory.java | 57 +-
.../ognl/internal/entry/PermissionCacheEntry.java | 121 +-
.../entry/PermissionCacheEntryFactory.java | 83 +-
.../entry/PropertyDescriptorCacheEntryFactory.java | 435 +-
.../java/org/apache/commons/ognl/package-info.java | 77 +-
.../org/apache/commons/ognl/InExpressionTest.java | 85 +-
.../org/apache/commons/ognl/TestOgnlException.java | 113 +-
.../org/apache/commons/ognl/TestOgnlRuntime.java | 843 ++--
.../ognl/internal/ConcurrentHashMapCacheTest.java | 201 +-
.../ognl/internal/ConstructorCacheTest.java | 113 +-
.../ognl/internal/DeclaredMethodCacheTest.java | 127 +-
.../commons/ognl/internal/FieldCacheTest.java | 119 +-
.../GenericMethodParameterTypeCacheTest.java | 109 +-
.../ognl/internal/MethodAccessCacheTest.java | 145 +-
.../commons/ognl/internal/MethodPermCacheTest.java | 165 +-
.../commons/ognl/internal/PermissionCacheTest.java | 115 +-
.../ognl/internal/PropertyDescriptorCacheTest.java | 121 +-
.../org/apache/commons/ognl/test/ASTChainTest.java | 87 +-
.../apache/commons/ognl/test/ASTMethodTest.java | 169 +-
.../apache/commons/ognl/test/ASTPropertyTest.java | 663 ++-
.../test/ArithmeticAndLogicalOperatorsTest.java | 363 +-
.../commons/ognl/test/ArrayCreationTest.java | 227 +-
.../commons/ognl/test/ArrayElementsTest.java | 259 +-
.../apache/commons/ognl/test/ClassMethodTest.java | 177 +-
.../ognl/test/CollectionDirectPropertyTest.java | 209 +-
.../ognl/test/CompilingPropertyAccessor.java | 537 ++-
.../org/apache/commons/ognl/test/ConstantTest.java | 217 +-
.../apache/commons/ognl/test/ConstantTreeTest.java | 185 +-
.../commons/ognl/test/ContextVariableTest.java | 149 +-
.../ognl/test/CorrectedObjectNullHandler.java | 123 +-
.../org/apache/commons/ognl/test/GenericsTest.java | 147 +-
.../apache/commons/ognl/test/IndexAccessTest.java | 195 +-
.../commons/ognl/test/IndexedPropertyTest.java | 213 +-
.../commons/ognl/test/InheritedMethodsTest.java | 121 +-
.../ognl/test/InterfaceInheritanceTest.java | 277 +-
.../commons/ognl/test/LambdaExpressionTest.java | 177 +-
.../apache/commons/ognl/test/MapCreationTest.java | 247 +-
.../apache/commons/ognl/test/MemberAccessTest.java | 241 +-
.../org/apache/commons/ognl/test/MethodTest.java | 215 +-
.../ognl/test/MethodWithConversionTest.java | 209 +-
.../apache/commons/ognl/test/NestedMethodTest.java | 207 +-
.../apache/commons/ognl/test/NullHandlerTest.java | 231 +-
.../ognl/test/NullStringCatenationTest.java | 183 +-
.../ognl/test/NumberFormatExceptionTest.java | 223 +-
.../commons/ognl/test/NumericConversionTest.java | 449 ++-
.../ognl/test/ObjectIndexedPropertyTest.java | 231 +-
.../commons/ognl/test/ObjectIndexedTest.java | 521 ++-
.../org/apache/commons/ognl/test/OgnlTestCase.java | 497 ++-
.../org/apache/commons/ognl/test/OperatorTest.java | 183 +-
.../org/apache/commons/ognl/test/Performance.java | 953 +++--
.../commons/ognl/test/PrimitiveArrayTest.java | 201 +-
.../ognl/test/PrimitiveNullHandlingTest.java | 217 +-
.../commons/ognl/test/PrivateAccessorTest.java | 247 +-
.../commons/ognl/test/PrivateMemberTest.java | 179 +-
.../commons/ognl/test/ProjectionSelectionTest.java | 157 +-
.../PropertyArithmeticAndLogicalOperatorsTest.java | 211 +-
.../commons/ognl/test/PropertyNotFoundTest.java | 323 +-
.../commons/ognl/test/PropertySetterTest.java | 231 +-
.../org/apache/commons/ognl/test/PropertyTest.java | 343 +-
.../commons/ognl/test/ProtectedInnerClassTest.java | 145 +-
.../org/apache/commons/ognl/test/QuotingTest.java | 197 +-
.../org/apache/commons/ognl/test/SetterTest.java | 237 +-
.../ognl/test/SetterWithConversionTest.java | 201 +-
.../ognl/test/ShortCircuitingExpressionTest.java | 143 +-
.../ognl/test/SimpleNavigationChainTreeTest.java | 167 +-
.../commons/ognl/test/SimplePropertyTreeTest.java | 167 +-
.../ognl/test/StaticsAndConstructorsTest.java | 385 +-
.../test/accessors/ListPropertyAccessorTest.java | 199 +-
.../ognl/test/enhance/TestExpressionCompiler.java | 505 ++-
.../apache/commons/ognl/test/objects/BaseBean.java | 113 +-
.../commons/ognl/test/objects/BaseGeneric.java | 139 +-
.../commons/ognl/test/objects/BaseIndexed.java | 63 +-
.../ognl/test/objects/BaseObjectIndexed.java | 127 +-
.../ognl/test/objects/BaseSyntheticObject.java | 69 +-
.../apache/commons/ognl/test/objects/Bean1.java | 59 +-
.../apache/commons/ognl/test/objects/Bean2.java | 159 +-
.../apache/commons/ognl/test/objects/Bean3.java | 1 -
.../commons/ognl/test/objects/BeanProvider.java | 91 +-
.../ognl/test/objects/BeanProviderAccessor.java | 185 +-
.../ognl/test/objects/BeanProviderImpl.java | 99 +-
.../commons/ognl/test/objects/Component.java | 153 +-
.../commons/ognl/test/objects/ComponentImpl.java | 103 +-
.../ognl/test/objects/ComponentSubclass.java | 79 +-
.../org/apache/commons/ognl/test/objects/Copy.java | 63 +-
.../commons/ognl/test/objects/CorrectedObject.java | 89 +-
.../apache/commons/ognl/test/objects/Cracker.java | 65 +-
.../apache/commons/ognl/test/objects/Entry.java | 109 +-
.../apache/commons/ognl/test/objects/EvenOdd.java | 111 +-
.../commons/ognl/test/objects/FirstBean.java | 71 +-
.../ognl/test/objects/FormComponentImpl.java | 81 +-
.../apache/commons/ognl/test/objects/FormImpl.java | 59 +-
.../commons/ognl/test/objects/GameGeneric.java | 65 +-
.../ognl/test/objects/GameGenericObject.java | 93 +-
.../commons/ognl/test/objects/GenericCracker.java | 79 +-
.../commons/ognl/test/objects/GenericObject.java | 61 +-
.../commons/ognl/test/objects/GenericRoot.java | 101 +-
.../commons/ognl/test/objects/GenericService.java | 61 +-
.../ognl/test/objects/GenericServiceImpl.java | 79 +-
.../commons/ognl/test/objects/GetterMethods.java | 87 +-
.../commons/ognl/test/objects/IComponent.java | 69 +-
.../ognl/test/objects/IContentProvider.java | 61 +-
.../apache/commons/ognl/test/objects/IForm.java | 57 +-
.../commons/ognl/test/objects/IFormComponent.java | 67 +-
.../ognl/test/objects/ITreeContentProvider.java | 67 +-
.../apache/commons/ognl/test/objects/Indexed.java | 209 +-
.../ognl/test/objects/IndexedMapObject.java | 77 +-
.../ognl/test/objects/IndexedSetObject.java | 131 +-
.../commons/ognl/test/objects/Inherited.java | 57 +-
.../commons/ognl/test/objects/ListSource.java | 65 +-
.../commons/ognl/test/objects/ListSourceImpl.java | 99 +-
.../apache/commons/ognl/test/objects/MenuItem.java | 149 +-
.../apache/commons/ognl/test/objects/Messages.java | 121 +-
.../apache/commons/ognl/test/objects/Model.java | 63 +-
.../apache/commons/ognl/test/objects/MyMap.java | 63 +-
.../commons/ognl/test/objects/MyMapImpl.java | 215 +-
.../commons/ognl/test/objects/ObjectIndexed.java | 61 +-
.../ognl/test/objects/OtherObjectIndexed.java | 59 +-
.../ognl/test/objects/PersonGenericObject.java | 75 +-
.../commons/ognl/test/objects/PropertyHolder.java | 119 +-
.../org/apache/commons/ognl/test/objects/Root.java | 1181 +++---
.../commons/ognl/test/objects/SearchCriteria.java | 77 +-
.../commons/ognl/test/objects/SearchTab.java | 169 +-
.../commons/ognl/test/objects/SecondBean.java | 69 +-
.../commons/ognl/test/objects/SetterReturns.java | 79 +-
.../apache/commons/ognl/test/objects/Simple.java | 465 ++-
.../commons/ognl/test/objects/SimpleEnum.java | 81 +-
.../commons/ognl/test/objects/SimpleNumeric.java | 83 +-
.../ognl/test/objects/SubclassSyntheticObject.java | 69 +-
.../commons/ognl/test/objects/TestClass.java | 55 +-
.../apache/commons/ognl/test/objects/TestImpl.java | 75 +-
.../commons/ognl/test/objects/TestInherited1.java | 65 +-
.../commons/ognl/test/objects/TestInherited2.java | 65 +-
.../commons/ognl/test/objects/TestModel.java | 93 +-
.../ognl/test/objects/TreeContentProvider.java | 93 +-
.../org/apache/commons/ognl/test/objects/Two.java | 73 +-
.../commons/ognl/test/util/ContextClassLoader.java | 105 +-
.../ognl/test/util/EnhancedClassLoader.java | 83 +-
.../apache/commons/ognl/test/util/NameFactory.java | 111 +-
232 files changed, 23720 insertions(+), 23952 deletions(-)
diff --git a/src/benchmarks/java/org/apache/commons/ognl/performance/PerformanceCommonsOgnlTest.java b/src/benchmarks/java/org/apache/commons/ognl/performance/PerformanceCommonsOgnlTest.java
index a5c5f57..eee2ea5 100644
--- a/src/benchmarks/java/org/apache/commons/ognl/performance/PerformanceCommonsOgnlTest.java
+++ b/src/benchmarks/java/org/apache/commons/ognl/performance/PerformanceCommonsOgnlTest.java
@@ -1,49 +1,48 @@
-/*
- * $Id$
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.commons.ognl.performance;
-
-import com.carrotsearch.junitbenchmarks.annotation.BenchmarkMethodChart;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-
-/**
- * User: Maurizio Cucchiara
- * Date: 10/22/11
- * Time: 12:49 AM
- */
-
-@BenchmarkMethodChart( filePrefix = "benchmark" )
-public class PerformanceCommonsOgnlTest
- extends BasePerformanceTest
-{
- @BeforeClass
- public static void before()
- {
- runtimeWrapper = COMMONS_RUNTIME_WRAPPER;
- }
-
- @AfterClass
- public static void after()
- {
- runtimeWrapper.clearCache();
- }
-}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.ognl.performance;
+
+import com.carrotsearch.junitbenchmarks.annotation.BenchmarkMethodChart;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+/**
+ * User: Maurizio Cucchiara
+ * Date: 10/22/11
+ * Time: 12:49 AM
+ */
+
+@BenchmarkMethodChart( filePrefix = "benchmark" )
+public class PerformanceCommonsOgnlTest
+ extends BasePerformanceTest
+{
+ @BeforeClass
+ public static void before()
+ {
+ runtimeWrapper = COMMONS_RUNTIME_WRAPPER;
+ }
+
+ @AfterClass
+ public static void after()
+ {
+ runtimeWrapper.clearCache();
+ }
+}
diff --git a/src/benchmarks/java/org/apache/commons/ognl/performance/PerformanceOldOgnlTest.java b/src/benchmarks/java/org/apache/commons/ognl/performance/PerformanceOldOgnlTest.java
index 3fa620d..353a4d2 100644
--- a/src/benchmarks/java/org/apache/commons/ognl/performance/PerformanceOldOgnlTest.java
+++ b/src/benchmarks/java/org/apache/commons/ognl/performance/PerformanceOldOgnlTest.java
@@ -1,49 +1,48 @@
-/*
- * $Id$
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.commons.ognl.performance;
-
-import com.carrotsearch.junitbenchmarks.annotation.BenchmarkMethodChart;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-
-/**
- * User: Maurizio Cucchiara
- * Date: 10/22/11
- * Time: 12:49 AM
- */
-
-@BenchmarkMethodChart( filePrefix = "benchmark-legacy" )
-public class PerformanceOldOgnlTest
- extends BasePerformanceTest
-{
- @BeforeClass
- public static void before()
- {
- runtimeWrapper = OLD_RUNTIME_WRAPPER;
- }
-
- @AfterClass
- public static void after()
- {
- runtimeWrapper.clearCache();
- }
-}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.ognl.performance;
+
+import com.carrotsearch.junitbenchmarks.annotation.BenchmarkMethodChart;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+/**
+ * User: Maurizio Cucchiara
+ * Date: 10/22/11
+ * Time: 12:49 AM
+ */
+
+@BenchmarkMethodChart( filePrefix = "benchmark-legacy" )
+public class PerformanceOldOgnlTest
+ extends BasePerformanceTest
+{
+ @BeforeClass
+ public static void before()
+ {
+ runtimeWrapper = OLD_RUNTIME_WRAPPER;
+ }
+
+ @AfterClass
+ public static void after()
+ {
+ runtimeWrapper.clearCache();
+ }
+}
diff --git a/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/CompilerInvocation.java b/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/CompilerInvocation.java
index 92a7fc9..09d2b2d 100644
--- a/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/CompilerInvocation.java
+++ b/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/CompilerInvocation.java
@@ -1,46 +1,45 @@
-/*
- * $Id$
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.ognl.performance.invocation;
-
-import org.apache.commons.ognl.performance.runtime.RuntimeWrapper;
-
-/**
- * User: mcucchiara
- * Date: 28/10/11
- * Time: 18.42
- */
-public class CompilerInvocation
- extends RepeatableInvocation
-{
- public CompilerInvocation( RuntimeWrapper runtimeWrapper, int times )
- throws Exception
- {
- super( runtimeWrapper, times );
-
- }
-
- @Override
- protected void invoke( Class<?> c )
- throws Exception
- {
- getRuntime().getCompiler();
- }
-}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.ognl.performance.invocation;
+
+import org.apache.commons.ognl.performance.runtime.RuntimeWrapper;
+
+/**
+ * User: mcucchiara
+ * Date: 28/10/11
+ * Time: 18.42
+ */
+public class CompilerInvocation
+ extends RepeatableInvocation
+{
+ public CompilerInvocation( RuntimeWrapper runtimeWrapper, int times )
+ throws Exception
+ {
+ super( runtimeWrapper, times );
+
+ }
+
+ @Override
+ protected void invoke( Class<?> c )
+ throws Exception
+ {
+ getRuntime().getCompiler();
+ }
+}
diff --git a/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/FieldInvocation.java b/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/FieldInvocation.java
index 346fdad..6f0be0b 100644
--- a/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/FieldInvocation.java
+++ b/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/FieldInvocation.java
@@ -1,53 +1,52 @@
-/*
- * $Id$
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.commons.ognl.performance.invocation;
-
-import org.apache.commons.ognl.performance.runtime.RuntimeWrapper;
-
-/**
- * User: mcucchiara
- * Date: 18/10/11
- * Time: 16.28
- */
-public class FieldInvocation
- extends RepeatableInvocation
-{
- public FieldInvocation( RuntimeWrapper runtimeWrapper )
- throws Exception
- {
- super( runtimeWrapper );
- }
-
- public FieldInvocation( RuntimeWrapper runtimeWrapper, int times )
- throws Exception
- {
- super( runtimeWrapper, times );
- }
-
- @Override
- protected void invoke( Class<?> c )
- throws Exception
- {
- getRuntime().getFields( c );
- }
-
-}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.ognl.performance.invocation;
+
+import org.apache.commons.ognl.performance.runtime.RuntimeWrapper;
+
+/**
+ * User: mcucchiara
+ * Date: 18/10/11
+ * Time: 16.28
+ */
+public class FieldInvocation
+ extends RepeatableInvocation
+{
+ public FieldInvocation( RuntimeWrapper runtimeWrapper )
+ throws Exception
+ {
+ super( runtimeWrapper );
+ }
+
+ public FieldInvocation( RuntimeWrapper runtimeWrapper, int times )
+ throws Exception
+ {
+ super( runtimeWrapper, times );
+ }
+
+ @Override
+ protected void invoke( Class<?> c )
+ throws Exception
+ {
+ getRuntime().getFields( c );
+ }
+
+}
diff --git a/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/FindParameterTypesInvocation.java b/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/FindParameterTypesInvocation.java
index 65de2f9..39084ed 100644
--- a/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/FindParameterTypesInvocation.java
+++ b/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/FindParameterTypesInvocation.java
@@ -1,59 +1,58 @@
-/*
- * $Id$
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.commons.ognl.performance.invocation;
-
-
-import org.apache.commons.ognl.performance.runtime.RuntimeWrapper;
-
-import java.lang.reflect.Method;
-
-/**
- * User: mcucchiara
- * Date: 18/10/11
- * Time: 16.37
- */
-public class FindParameterTypesInvocation
- extends RepeatableInvocation
-{
-
- public FindParameterTypesInvocation( RuntimeWrapper runtimeWrapper, int times )
- throws Exception
- {
- super( runtimeWrapper, times );
- }
-
- public FindParameterTypesInvocation( RuntimeWrapper runtimeWrapper )
- throws Exception
- {
- super( runtimeWrapper );
- }
-
- @Override
- protected void invoke( Class<?> c )
- throws Exception
- {
- for ( Method method : c.getMethods() )
- {
- getRuntime().findParameterTypes( String.class, method );
- }
- }
-}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.ognl.performance.invocation;
+
+
+import org.apache.commons.ognl.performance.runtime.RuntimeWrapper;
+
+import java.lang.reflect.Method;
+
+/**
+ * User: mcucchiara
+ * Date: 18/10/11
+ * Time: 16.37
+ */
+public class FindParameterTypesInvocation
+ extends RepeatableInvocation
+{
+
+ public FindParameterTypesInvocation( RuntimeWrapper runtimeWrapper, int times )
+ throws Exception
+ {
+ super( runtimeWrapper, times );
+ }
+
+ public FindParameterTypesInvocation( RuntimeWrapper runtimeWrapper )
+ throws Exception
+ {
+ super( runtimeWrapper );
+ }
+
+ @Override
+ protected void invoke( Class<?> c )
+ throws Exception
+ {
+ for ( Method method : c.getMethods() )
+ {
+ getRuntime().findParameterTypes( String.class, method );
+ }
+ }
+}
diff --git a/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/GetConstructorsInvocation.java b/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/GetConstructorsInvocation.java
index b6d0c6f..e6b35e4 100644
--- a/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/GetConstructorsInvocation.java
+++ b/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/GetConstructorsInvocation.java
@@ -1,53 +1,52 @@
-/*
- * $Id$
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.commons.ognl.performance.invocation;
-
-
-import org.apache.commons.ognl.performance.runtime.RuntimeWrapper;
-
-/**
- * User: mcucchiara
- * Date: 18/10/11
- * Time: 16.21
- */
-public class GetConstructorsInvocation
- extends RepeatableInvocation
-{
- public GetConstructorsInvocation( RuntimeWrapper runtimeWrapper )
- throws Exception
- {
- super( runtimeWrapper );
- }
-
- public GetConstructorsInvocation( RuntimeWrapper runtimeWrapper, int times )
- throws Exception
- {
- super( runtimeWrapper, times );
- }
-
- @Override
- protected void invoke( Class<?> c )
- throws Exception
- {
- getRuntime().getConstructors( c );
- }
-}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.ognl.performance.invocation;
+
+
+import org.apache.commons.ognl.performance.runtime.RuntimeWrapper;
+
+/**
+ * User: mcucchiara
+ * Date: 18/10/11
+ * Time: 16.21
+ */
+public class GetConstructorsInvocation
+ extends RepeatableInvocation
+{
+ public GetConstructorsInvocation( RuntimeWrapper runtimeWrapper )
+ throws Exception
+ {
+ super( runtimeWrapper );
+ }
+
+ public GetConstructorsInvocation( RuntimeWrapper runtimeWrapper, int times )
+ throws Exception
+ {
+ super( runtimeWrapper, times );
+ }
+
+ @Override
+ protected void invoke( Class<?> c )
+ throws Exception
+ {
+ getRuntime().getConstructors( c );
+ }
+}
diff --git a/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/GetDeclaredMethodsInvocation.java b/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/GetDeclaredMethodsInvocation.java
index 1dfbff9..1325a7a 100644
--- a/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/GetDeclaredMethodsInvocation.java
+++ b/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/GetDeclaredMethodsInvocation.java
@@ -1,55 +1,54 @@
-/*
- * $Id$
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.commons.ognl.performance.invocation;
-
-import org.apache.commons.ognl.performance.runtime.RuntimeWrapper;
-
-/**
- * User: mcucchiara
- * Date: 18/10/11
- * Time: 15.57
- */
-public class GetDeclaredMethodsInvocation
- extends RepeatableInvocation
-{
-
- public GetDeclaredMethodsInvocation( RuntimeWrapper runtimeWrapper )
- throws Exception
- {
- super( runtimeWrapper );
- }
-
- public GetDeclaredMethodsInvocation( RuntimeWrapper runtimeWrapper, int times )
- throws Exception
- {
- super( runtimeWrapper, times );
- }
-
- @Override
- protected void invoke( Class<?> c )
- throws Exception
- {
- getRuntime().getDeclaredMethods( c, "class", false );
- getRuntime().getDeclaredMethods( c, "class", true );
- }
-
-}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.ognl.performance.invocation;
+
+import org.apache.commons.ognl.performance.runtime.RuntimeWrapper;
+
+/**
+ * User: mcucchiara
+ * Date: 18/10/11
+ * Time: 15.57
+ */
+public class GetDeclaredMethodsInvocation
+ extends RepeatableInvocation
+{
+
+ public GetDeclaredMethodsInvocation( RuntimeWrapper runtimeWrapper )
+ throws Exception
+ {
+ super( runtimeWrapper );
+ }
+
+ public GetDeclaredMethodsInvocation( RuntimeWrapper runtimeWrapper, int times )
+ throws Exception
+ {
+ super( runtimeWrapper, times );
+ }
+
+ @Override
+ protected void invoke( Class<?> c )
+ throws Exception
+ {
+ getRuntime().getDeclaredMethods( c, "class", false );
+ getRuntime().getDeclaredMethods( c, "class", true );
+ }
+
+}
diff --git a/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/GetMethodsInvocation.java b/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/GetMethodsInvocation.java
index d0b5dd6..ba00493 100644
--- a/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/GetMethodsInvocation.java
+++ b/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/GetMethodsInvocation.java
@@ -1,55 +1,54 @@
-/*
- * $Id$
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.commons.ognl.performance.invocation;
-
-import org.apache.commons.ognl.performance.runtime.RuntimeWrapper;
-
-/**
- * User: mcucchiara
- * Date: 18/10/11
- * Time: 15.57
- */
-public class GetMethodsInvocation
- extends RepeatableInvocation
-{
-
- public GetMethodsInvocation( RuntimeWrapper runtimeWrapper )
- throws Exception
- {
- super( runtimeWrapper );
- }
-
- public GetMethodsInvocation( RuntimeWrapper runtimeWrapper, int times )
- throws Exception
- {
- super( runtimeWrapper, times );
- }
-
- @Override
- protected void invoke( Class<?> c )
- throws Exception
- {
- getRuntime().getMethods( c, false );
- getRuntime().getMethods( c, true );
- }
-
-}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.ognl.performance.invocation;
+
+import org.apache.commons.ognl.performance.runtime.RuntimeWrapper;
+
+/**
+ * User: mcucchiara
+ * Date: 18/10/11
+ * Time: 15.57
+ */
+public class GetMethodsInvocation
+ extends RepeatableInvocation
+{
+
+ public GetMethodsInvocation( RuntimeWrapper runtimeWrapper )
+ throws Exception
+ {
+ super( runtimeWrapper );
+ }
+
+ public GetMethodsInvocation( RuntimeWrapper runtimeWrapper, int times )
+ throws Exception
+ {
+ super( runtimeWrapper, times );
+ }
+
+ @Override
+ protected void invoke( Class<?> c )
+ throws Exception
+ {
+ getRuntime().getMethods( c, false );
+ getRuntime().getMethods( c, true );
+ }
+
+}
diff --git a/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/InvokeMethodInvocation.java b/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/InvokeMethodInvocation.java
index da6c64c..8c68c49 100644
--- a/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/InvokeMethodInvocation.java
+++ b/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/InvokeMethodInvocation.java
@@ -1,58 +1,57 @@
-/*
- * $Id$
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.commons.ognl.performance.invocation;
-
-import org.apache.commons.ognl.performance.runtime.RuntimeWrapper;
-
-import java.lang.reflect.Method;
-
-/**
- * User: mcucchiara
- * Date: 18/10/11
- * Time: 16.45
- */
-public class InvokeMethodInvocation
- extends RepeatableInvocation
-{
- public InvokeMethodInvocation( RuntimeWrapper runtimeWrapper )
- throws Exception
- {
- super( runtimeWrapper );
- }
-
- public InvokeMethodInvocation( RuntimeWrapper runtimeWrapper, int times )
- throws Exception
- {
- super( runtimeWrapper, times );
- }
-
- @Override
- protected void invoke( Class<?> c )
- throws Exception
- {
- Object o;
- o = c.newInstance();
-
- Method toString = c.getMethod( "toString" );
- getRuntime().invokeMethod( o, toString, new Object[0] );
- }
-}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.ognl.performance.invocation;
+
+import org.apache.commons.ognl.performance.runtime.RuntimeWrapper;
+
+import java.lang.reflect.Method;
+
+/**
+ * User: mcucchiara
+ * Date: 18/10/11
+ * Time: 16.45
+ */
+public class InvokeMethodInvocation
+ extends RepeatableInvocation
+{
+ public InvokeMethodInvocation( RuntimeWrapper runtimeWrapper )
+ throws Exception
+ {
+ super( runtimeWrapper );
+ }
+
+ public InvokeMethodInvocation( RuntimeWrapper runtimeWrapper, int times )
+ throws Exception
+ {
+ super( runtimeWrapper, times );
+ }
+
+ @Override
+ protected void invoke( Class<?> c )
+ throws Exception
+ {
+ Object o;
+ o = c.newInstance();
+
+ Method toString = c.getMethod( "toString" );
+ getRuntime().invokeMethod( o, toString, new Object[0] );
+ }
+}
diff --git a/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/MethodParameterTypesInvocation.java b/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/MethodParameterTypesInvocation.java
index be759da..e05f0bc 100644
--- a/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/MethodParameterTypesInvocation.java
+++ b/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/MethodParameterTypesInvocation.java
@@ -1,63 +1,62 @@
-/*
- * $Id$
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.commons.ognl.performance.invocation;
-
-import org.apache.commons.ognl.performance.runtime.RuntimeWrapper;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-
-/**
- * User: mcucchiara
- * Date: 18/10/11
- * Time: 16.35
- */
-public class MethodParameterTypesInvocation
- extends RepeatableInvocation
-{
-
- public MethodParameterTypesInvocation( RuntimeWrapper runtimeWrapper )
- throws Exception
- {
- super( runtimeWrapper );
- }
-
- public MethodParameterTypesInvocation( RuntimeWrapper runtimeWrapper, int times )
- throws Exception
- {
- super( runtimeWrapper, times );
- }
-
- @Override
- protected void invoke( Class<?> c )
- throws Exception
- {
- for ( Method method : c.getMethods() )
- {
- getRuntime().getParameterTypes( method );
- }
- for ( Constructor<?> constructor : c.getConstructors() )
- {
- getRuntime().getParameterTypes( constructor );
- }
- }
-}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.ognl.performance.invocation;
+
+import org.apache.commons.ognl.performance.runtime.RuntimeWrapper;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+
+/**
+ * User: mcucchiara
+ * Date: 18/10/11
+ * Time: 16.35
+ */
+public class MethodParameterTypesInvocation
+ extends RepeatableInvocation
+{
+
+ public MethodParameterTypesInvocation( RuntimeWrapper runtimeWrapper )
+ throws Exception
+ {
+ super( runtimeWrapper );
+ }
+
+ public MethodParameterTypesInvocation( RuntimeWrapper runtimeWrapper, int times )
+ throws Exception
+ {
+ super( runtimeWrapper, times );
+ }
+
+ @Override
+ protected void invoke( Class<?> c )
+ throws Exception
+ {
+ for ( Method method : c.getMethods() )
+ {
+ getRuntime().getParameterTypes( method );
+ }
+ for ( Constructor<?> constructor : c.getConstructors() )
+ {
+ getRuntime().getParameterTypes( constructor );
+ }
+ }
+}
diff --git a/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/PermissionInvocation.java b/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/PermissionInvocation.java
index b9a7688..17f5420 100644
--- a/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/PermissionInvocation.java
+++ b/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/PermissionInvocation.java
@@ -1,61 +1,60 @@
-/*
- * $Id$
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.commons.ognl.performance.invocation;
-
-
-import org.apache.commons.ognl.performance.runtime.RuntimeWrapper;
-
-import java.lang.reflect.Method;
-
-/**
- * User: mcucchiara
- * Date: 18/10/11
- * Time: 16.25
- */
-public class PermissionInvocation
- extends RepeatableInvocation
-{
-
- public PermissionInvocation( RuntimeWrapper runtimeWrapper )
- throws Exception
- {
- super( runtimeWrapper );
- }
-
- public PermissionInvocation( RuntimeWrapper runtimeWrapper, int times )
- throws Exception
- {
- super( runtimeWrapper, times );
- }
-
- @Override
- protected void invoke( Class<?> c )
- throws Exception
- {
- Method[] methods = c.getMethods();
- for ( Method method : methods )
- {
- getRuntime().getPermission( method );
- }
- }
-
-}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.ognl.performance.invocation;
+
+
+import org.apache.commons.ognl.performance.runtime.RuntimeWrapper;
+
+import java.lang.reflect.Method;
+
+/**
+ * User: mcucchiara
+ * Date: 18/10/11
+ * Time: 16.25
+ */
+public class PermissionInvocation
+ extends RepeatableInvocation
+{
+
+ public PermissionInvocation( RuntimeWrapper runtimeWrapper )
+ throws Exception
+ {
+ super( runtimeWrapper );
+ }
+
+ public PermissionInvocation( RuntimeWrapper runtimeWrapper, int times )
+ throws Exception
+ {
+ super( runtimeWrapper, times );
+ }
+
+ @Override
+ protected void invoke( Class<?> c )
+ throws Exception
+ {
+ Method[] methods = c.getMethods();
+ for ( Method method : methods )
+ {
+ getRuntime().getPermission( method );
+ }
+ }
+
+}
diff --git a/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/PrimitiveDefaultInvocation.java b/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/PrimitiveDefaultInvocation.java
index ada77c0..f449c2c 100644
--- a/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/PrimitiveDefaultInvocation.java
+++ b/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/PrimitiveDefaultInvocation.java
@@ -1,52 +1,51 @@
-/*
- * $Id$
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.commons.ognl.performance.invocation;
-
-import org.apache.commons.ognl.performance.runtime.RuntimeWrapper;
-
-/**
- * User: Maurizio Cucchiara
- * Date: 10/22/11
- * Time: 1:02 AM
- */
-public class PrimitiveDefaultInvocation
- extends RepeatableInvocation
-{
- public PrimitiveDefaultInvocation( RuntimeWrapper runtimeWrapper )
- throws Exception
- {
- super( runtimeWrapper );
- }
-
- public PrimitiveDefaultInvocation( RuntimeWrapper runtimeWrapper, int times )
- throws Exception
- {
- super( runtimeWrapper, times );
- }
-
- @Override
- protected void invoke( Class<?> c )
- throws Exception
- {
- getRuntime().getPrimitiveDefaultValue( c );
- }
-}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.ognl.performance.invocation;
+
+import org.apache.commons.ognl.performance.runtime.RuntimeWrapper;
+
+/**
+ * User: Maurizio Cucchiara
+ * Date: 10/22/11
+ * Time: 1:02 AM
+ */
+public class PrimitiveDefaultInvocation
+ extends RepeatableInvocation
+{
+ public PrimitiveDefaultInvocation( RuntimeWrapper runtimeWrapper )
+ throws Exception
+ {
+ super( runtimeWrapper );
+ }
+
+ public PrimitiveDefaultInvocation( RuntimeWrapper runtimeWrapper, int times )
+ throws Exception
+ {
+ super( runtimeWrapper, times );
+ }
+
+ @Override
+ protected void invoke( Class<?> c )
+ throws Exception
+ {
+ getRuntime().getPrimitiveDefaultValue( c );
+ }
+}
diff --git a/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/RepeatableInvocation.java b/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/RepeatableInvocation.java
index 255ebc4..72acdd7 100644
--- a/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/RepeatableInvocation.java
+++ b/src/benchmarks/java/org/apache/commons/ognl/performance/invocation/RepeatableInvocation.java
@@ -1,159 +1,158 @@
-/*
- * $Id$
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.commons.ognl.performance.invocation;
-
-import org.apache.commons.ognl.test.objects.BaseBean;
-import org.apache.commons.ognl.test.objects.BaseGeneric;
-import org.apache.commons.ognl.test.objects.BaseIndexed;
-import org.apache.commons.ognl.test.objects.BaseObjectIndexed;
-import org.apache.commons.ognl.test.objects.BaseSyntheticObject;
-import org.apache.commons.ognl.test.objects.Bean1;
-import org.apache.commons.ognl.test.objects.Bean2;
-import org.apache.commons.ognl.test.objects.Bean3;
-import org.apache.commons.ognl.test.objects.BeanProvider;
-import org.apache.commons.ognl.test.objects.BeanProviderAccessor;
-import org.apache.commons.ognl.test.objects.BeanProviderImpl;
-import org.apache.commons.ognl.test.objects.Component;
-import org.apache.commons.ognl.test.objects.ComponentImpl;
-import org.apache.commons.ognl.test.objects.ComponentSubclass;
-import org.apache.commons.ognl.test.objects.Copy;
-import org.apache.commons.ognl.test.objects.CorrectedObject;
-import org.apache.commons.ognl.test.objects.Cracker;
-import org.apache.commons.ognl.test.objects.Entry;
-import org.apache.commons.ognl.test.objects.EvenOdd;
-import org.apache.commons.ognl.test.objects.FirstBean;
-import org.apache.commons.ognl.test.objects.FormComponentImpl;
-import org.apache.commons.ognl.test.objects.FormImpl;
-import org.apache.commons.ognl.test.objects.GameGeneric;
-import org.apache.commons.ognl.test.objects.GameGenericObject;
-import org.apache.commons.ognl.test.objects.GenericCracker;
-import org.apache.commons.ognl.test.objects.GenericObject;
-import org.apache.commons.ognl.test.objects.GenericRoot;
-import org.apache.commons.ognl.test.objects.GenericService;
-import org.apache.commons.ognl.test.objects.GenericServiceImpl;
-import org.apache.commons.ognl.test.objects.GetterMethods;
-import org.apache.commons.ognl.test.objects.IComponent;
-import org.apache.commons.ognl.test.objects.IContentProvider;
-import org.apache.commons.ognl.test.objects.IForm;
-import org.apache.commons.ognl.test.objects.IFormComponent;
-import org.apache.commons.ognl.test.objects.ITreeContentProvider;
-import org.apache.commons.ognl.test.objects.Indexed;
-import org.apache.commons.ognl.test.objects.IndexedMapObject;
-import org.apache.commons.ognl.test.objects.IndexedSetObject;
-import org.apache.commons.ognl.test.objects.Inherited;
-import org.apache.commons.ognl.test.objects.ListSource;
-import org.apache.commons.ognl.test.objects.ListSourceImpl;
-import org.apache.commons.ognl.test.objects.MenuItem;
-import org.apache.commons.ognl.test.objects.Messages;
-import org.apache.commons.ognl.test.objects.Model;
-import org.apache.commons.ognl.test.objects.MyMap;
-import org.apache.commons.ognl.test.objects.MyMapImpl;
-import org.apache.commons.ognl.test.objects.ObjectIndexed;
-import org.apache.commons.ognl.test.objects.OtherObjectIndexed;
-import org.apache.commons.ognl.test.objects.PersonGenericObject;
-import org.apache.commons.ognl.test.objects.PropertyHolder;
-import org.apache.commons.ognl.test.objects.Root;
-import org.apache.commons.ognl.test.objects.SearchCriteria;
-import org.apache.commons.ognl.test.objects.SearchTab;
-import org.apache.commons.ognl.test.objects.SecondBean;
-import org.apache.commons.ognl.test.objects.SetterReturns;
-import org.apache.commons.ognl.test.objects.Simple;
-import org.apache.commons.ognl.test.objects.SimpleEnum;
-import org.apache.commons.ognl.test.objects.SimpleNumeric;
-import org.apache.commons.ognl.test.objects.SubclassSyntheticObject;
-import org.apache.commons.ognl.test.objects.TestClass;
-import org.apache.commons.ognl.test.objects.TestImpl;
-import org.apache.commons.ognl.test.objects.TestInherited1;
-import org.apache.commons.ognl.test.objects.TestInherited2;
-import org.apache.commons.ognl.test.objects.TestModel;
-import org.apache.commons.ognl.test.objects.TreeContentProvider;
-import org.apache.commons.ognl.test.objects.Two;
-import org.apache.commons.ognl.performance.runtime.RuntimeWrapper;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * User: Maurizio Cucchiara
- * Date: 10/22/11
- * Time: 12:20 AM
- */
-public abstract class RepeatableInvocation
-{
- private RuntimeWrapper runtimeWrapper;
-
- private int times = 1000;
-
- private List<Class<?>> classes =
- Arrays.asList( ComponentImpl.class, BaseObjectIndexed.class, TestInherited2.class, MenuItem.class,
- BaseIndexed.class, ListSourceImpl.class, GenericService.class, Copy.class, Inherited.class,
- MyMapImpl.class, GenericCracker.class, MyMap.class, SecondBean.class, SetterReturns.class,
- IContentProvider.class, FirstBean.class, CorrectedObject.class, BeanProviderImpl.class,
- TestClass.class, TestImpl.class, TreeContentProvider.class, Messages.class, Two.class,
- IndexedMapObject.class, SimpleNumeric.class, GameGeneric.class, Entry.class,
- SubclassSyntheticObject.class, SimpleEnum.class, Model.class, Simple.class,
- BaseSyntheticObject.class, ObjectIndexed.class, IComponent.class, SearchCriteria.class,
- FormImpl.class, TestInherited1.class, IndexedSetObject.class, SearchTab.class,
- GenericObject.class, GenericRoot.class, Bean1.class, FormComponentImpl.class,
- ComponentSubclass.class, IForm.class, OtherObjectIndexed.class, Cracker.class, Indexed.class,
- EvenOdd.class, PersonGenericObject.class, Bean2.class, GenericServiceImpl.class,
- IFormComponent.class, ListSource.class, PropertyHolder.class, Bean3.class, BaseGeneric.class,
- GetterMethods.class, BeanProviderAccessor.class, BeanProvider.class, GameGenericObject.class,
- ITreeContentProvider.class, TestModel.class, BaseBean.class, Component.class, Root.class );
-
- public RepeatableInvocation( RuntimeWrapper runtimeWrapper )
- throws Exception
- {
- this.runtimeWrapper = runtimeWrapper;
- invoke();
-
- }
-
- public RepeatableInvocation( RuntimeWrapper runtimeWrapper, int times )
- throws Exception
- {
-
- this.runtimeWrapper = runtimeWrapper;
- this.times = times;
- invoke();
- }
-
- private void invoke()
- throws Exception
- {
- for ( int i = 0; i < times; i++ )
- {
- for ( Class<?> c : classes )
- {
- invoke( c );
- }
- }
- }
-
- protected abstract void invoke( Class<?> c )
- throws Exception;
-
- protected RuntimeWrapper getRuntime()
- {
- return runtimeWrapper;
- }
-}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.ognl.performance.invocation;
+
+import org.apache.commons.ognl.test.objects.BaseBean;
+import org.apache.commons.ognl.test.objects.BaseGeneric;
+import org.apache.commons.ognl.test.objects.BaseIndexed;
+import org.apache.commons.ognl.test.objects.BaseObjectIndexed;
+import org.apache.commons.ognl.test.objects.BaseSyntheticObject;
+import org.apache.commons.ognl.test.objects.Bean1;
+import org.apache.commons.ognl.test.objects.Bean2;
+import org.apache.commons.ognl.test.objects.Bean3;
+import org.apache.commons.ognl.test.objects.BeanProvider;
+import org.apache.commons.ognl.test.objects.BeanProviderAccessor;
+import org.apache.commons.ognl.test.objects.BeanProviderImpl;
+import org.apache.commons.ognl.test.objects.Component;
+import org.apache.commons.ognl.test.objects.ComponentImpl;
+import org.apache.commons.ognl.test.objects.ComponentSubclass;
+import org.apache.commons.ognl.test.objects.Copy;
+import org.apache.commons.ognl.test.objects.CorrectedObject;
+import org.apache.commons.ognl.test.objects.Cracker;
+import org.apache.commons.ognl.test.objects.Entry;
+import org.apache.commons.ognl.test.objects.EvenOdd;
+import org.apache.commons.ognl.test.objects.FirstBean;
+import org.apache.commons.ognl.test.objects.FormComponentImpl;
+import org.apache.commons.ognl.test.objects.FormImpl;
+import org.apache.commons.ognl.test.objects.GameGeneric;
+import org.apache.commons.ognl.test.objects.GameGenericObject;
+import org.apache.commons.ognl.test.objects.GenericCracker;
+import org.apache.commons.ognl.test.objects.GenericObject;
+import org.apache.commons.ognl.test.objects.GenericRoot;
+import org.apache.commons.ognl.test.objects.GenericService;
+import org.apache.commons.ognl.test.objects.GenericServiceImpl;
+import org.apache.commons.ognl.test.objects.GetterMethods;
+import org.apache.commons.ognl.test.objects.IComponent;
+import org.apache.commons.ognl.test.objects.IContentProvider;
+import org.apache.commons.ognl.test.objects.IForm;
+import org.apache.commons.ognl.test.objects.IFormComponent;
+import org.apache.commons.ognl.test.objects.ITreeContentProvider;
+import org.apache.commons.ognl.test.objects.Indexed;
+import org.apache.commons.ognl.test.objects.IndexedMapObject;
+import org.apache.commons.ognl.test.objects.IndexedSetObject;
+import org.apache.commons.ognl.test.objects.Inherited;
+import org.apache.commons.ognl.test.objects.ListSource;
+import org.apache.commons.ognl.test.objects.ListSourceImpl;
+import org.apache.commons.ognl.test.objects.MenuItem;
+import org.apache.commons.ognl.test.objects.Messages;
+import org.apache.commons.ognl.test.objects.Model;
+import org.apache.commons.ognl.test.objects.MyMap;
+import org.apache.commons.ognl.test.objects.MyMapImpl;
+import org.apache.commons.ognl.test.objects.ObjectIndexed;
+import org.apache.commons.ognl.test.objects.OtherObjectIndexed;
+import org.apache.commons.ognl.test.objects.PersonGenericObject;
+import org.apache.commons.ognl.test.objects.PropertyHolder;
+import org.apache.commons.ognl.test.objects.Root;
+import org.apache.commons.ognl.test.objects.SearchCriteria;
+import org.apache.commons.ognl.test.objects.SearchTab;
+import org.apache.commons.ognl.test.objects.SecondBean;
+import org.apache.commons.ognl.test.objects.SetterReturns;
+import org.apache.commons.ognl.test.objects.Simple;
+import org.apache.commons.ognl.test.objects.SimpleEnum;
+import org.apache.commons.ognl.test.objects.SimpleNumeric;
+import org.apache.commons.ognl.test.objects.SubclassSyntheticObject;
+import org.apache.commons.ognl.test.objects.TestClass;
+import org.apache.commons.ognl.test.objects.TestImpl;
+import org.apache.commons.ognl.test.objects.TestInherited1;
+import org.apache.commons.ognl.test.objects.TestInherited2;
+import org.apache.commons.ognl.test.objects.TestModel;
+import org.apache.commons.ognl.test.objects.TreeContentProvider;
+import org.apache.commons.ognl.test.objects.Two;
+import org.apache.commons.ognl.performance.runtime.RuntimeWrapper;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * User: Maurizio Cucchiara
+ * Date: 10/22/11
+ * Time: 12:20 AM
+ */
+public abstract class RepeatableInvocation
+{
+ private RuntimeWrapper runtimeWrapper;
+
+ private int times = 1000;
+
+ private List<Class<?>> classes =
+ Arrays.asList( ComponentImpl.class, BaseObjectIndexed.class, TestInherited2.class, MenuItem.class,
+ BaseIndexed.class, ListSourceImpl.class, GenericService.class, Copy.class, Inherited.class,
+ MyMapImpl.class, GenericCracker.class, MyMap.class, SecondBean.class, SetterReturns.class,
+ IContentProvider.class, FirstBean.class, CorrectedObject.class, BeanProviderImpl.class,
+ TestClass.class, TestImpl.class, TreeContentProvider.class, Messages.class, Two.class,
+ IndexedMapObject.class, SimpleNumeric.class, GameGeneric.class, Entry.class,
+ SubclassSyntheticObject.class, SimpleEnum.class, Model.class, Simple.class,
+ BaseSyntheticObject.class, ObjectIndexed.class, IComponent.class, SearchCriteria.class,
+ FormImpl.class, TestInherited1.class, IndexedSetObject.class, SearchTab.class,
+ GenericObject.class, GenericRoot.class, Bean1.class, FormComponentImpl.class,
+ ComponentSubclass.class, IForm.class, OtherObjectIndexed.class, Cracker.class, Indexed.class,
+ EvenOdd.class, PersonGenericObject.class, Bean2.class, GenericServiceImpl.class,
+ IFormComponent.class, ListSource.class, PropertyHolder.class, Bean3.class, BaseGeneric.class,
+ GetterMethods.class, BeanProviderAccessor.class, BeanProvider.class, GameGenericObject.class,
+ ITreeContentProvider.class, TestModel.class, BaseBean.class, Component.class, Root.class );
+
+ public RepeatableInvocation( RuntimeWrapper runtimeWrapper )
+ throws Exception
+ {
+ this.runtimeWrapper = runtimeWrapper;
+ invoke();
+
+ }
+
+ public RepeatableInvocation( RuntimeWrapper runtimeWrapper, int times )
+ throws Exception
+ {
+
+ this.runtimeWrapper = runtimeWrapper;
+ this.times = times;
+ invoke();
+ }
+
+ private void invoke()
+ throws Exception
+ {
+ for ( int i = 0; i < times; i++ )
+ {
+ for ( Class<?> c : classes )
+ {
+ invoke( c );
+ }
+ }
+ }
+
+ protected abstract void invoke( Class<?> c )
+ throws Exception;
+
+ protected RuntimeWrapper getRuntime()
+ {
+ return runtimeWrapper;
+ }
+}
diff --git a/src/benchmarks/java/org/apache/commons/ognl/performance/runtime/CommonsRuntimeWrapper.java b/src/benchmarks/java/org/apache/commons/ognl/performance/runtime/CommonsRuntimeWrapper.java
index f0324c1..fbdcbfc 100644
--- a/src/benchmarks/java/org/apache/commons/ognl/performance/runtime/CommonsRuntimeWrapper.java
+++ b/src/benchmarks/java/org/apache/commons/ognl/performance/runtime/CommonsRuntimeWrapper.java
@@ -1,118 +1,117 @@
-/*
- * $Id$
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.commons.ognl.performance.runtime;
-
-import org.apache.commons.ognl.OgnlRuntime;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-
-/**
- * User: Maurizio Cucchiara
- * Date: 10/22/11
- * Time: 12:38 AM
- */
-public class CommonsRuntimeWrapper
- implements RuntimeWrapper
-{
-
-
- public void getFields( Class<?> c )
- throws Exception
- {
- OgnlRuntime.getFields( c );
- }
-
-
- public void findParameterTypes( Class<?> targetClass, Method method )
- throws Exception
- {
- OgnlRuntime.findParameterTypes( targetClass, method );
- }
-
-
- public void getConstructors( Class<?> c )
- throws Exception
- {
- OgnlRuntime.getConstructors( c );
- }
-
-
- public void getMethods( Class<?> c, boolean staticMethods )
- throws Exception
- {
- OgnlRuntime.getMethods( c, staticMethods );
- }
-
-
- public void getDeclaredMethods( Class<?> c, String propertyName, boolean setters )
- throws Exception
- {
- OgnlRuntime.getDeclaredMethods( c, propertyName, setters );
- }
-
-
- public void getParameterTypes( Method method )
- throws Exception
- {
- OgnlRuntime.getParameterTypes( method );
- }
-
-
- public void getParameterTypes( Constructor<?> constructor )
- throws Exception
- {
- OgnlRuntime.getParameterTypes( constructor );
- }
-
-
- public void getPermission( Method method )
- throws Exception
- {
- OgnlRuntime.getPermission( method );
- }
-
-
- public void getPrimitiveDefaultValue( Class<?> type )
- throws Exception
- {
- OgnlRuntime.getPrimitiveDefaultValue( type );
- }
-
-
- public void invokeMethod( Object o, Method method, Object[] args )
- throws Exception
- {
- OgnlRuntime.invokeMethod( o, method, args );
- }
-
-
- public void clearCache()
- {
- OgnlRuntime.clearCache();
- }
-
- public void getCompiler()
- {
- OgnlRuntime.getCompiler( null );
- }
-}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.ognl.performance.runtime;
+
+import org.apache.commons.ognl.OgnlRuntime;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+
+/**
+ * User: Maurizio Cucchiara
+ * Date: 10/22/11
+ * Time: 12:38 AM
+ */
+public class CommonsRuntimeWrapper
+ implements RuntimeWrapper
+{
+
+
+ public void getFields( Class<?> c )
+ throws Exception
+ {
+ OgnlRuntime.getFields( c );
+ }
+
+
+ public void findParameterTypes( Class<?> targetClass, Method method )
+ throws Exception
+ {
+ OgnlRuntime.findParameterTypes( targetClass, method );
+ }
+
+
+ public void getConstructors( Class<?> c )
+ throws Exception
+ {
+ OgnlRuntime.getConstructors( c );
+ }
+
+
+ public void getMethods( Class<?> c, boolean staticMethods )
+ throws Exception
+ {
+ OgnlRuntime.getMethods( c, staticMethods );
+ }
+
+
+ public void getDeclaredMethods( Class<?> c, String propertyName, boolean setters )
+ throws Exception
+ {
+ OgnlRuntime.getDeclaredMethods( c, propertyName, setters );
+ }
+
+
+ public void getParameterTypes( Method method )
+ throws Exception
+ {
+ OgnlRuntime.getParameterTypes( method );
+ }
+
+
+ public void getParameterTypes( Constructor<?> constructor )
+ throws Exception
+ {
+ OgnlRuntime.getParameterTypes( constructor );
+ }
+
+
+ public void getPermission( Method method )
+ throws Exception
+ {
+ OgnlRuntime.getPermission( method );
+ }
+
+
+ public void getPrimitiveDefaultValue( Class<?> type )
+ throws Exception
+ {
+ OgnlRuntime.getPrimitiveDefaultValue( type );
+ }
+
+
+ public void invokeMethod( Object o, Method method, Object[] args )
+ throws Exception
+ {
+ OgnlRuntime.invokeMethod( o, method, args );
+ }
+
+
+ public void clearCache()
+ {
+ OgnlRuntime.clearCache();
+ }
+
+ public void getCompiler()
+ {
+ OgnlRuntime.getCompiler( null );
+ }
+}
diff --git a/src/benchmarks/java/org/apache/commons/ognl/performance/runtime/OldOgnlRuntimeWrapper.java b/src/benchmarks/java/org/apache/commons/ognl/performance/runtime/OldOgnlRuntimeWrapper.java
index 5b1dc95..3335a30 100644
--- a/src/benchmarks/java/org/apache/commons/ognl/performance/runtime/OldOgnlRuntimeWrapper.java
+++ b/src/benchmarks/java/org/apache/commons/ognl/performance/runtime/OldOgnlRuntimeWrapper.java
@@ -1,117 +1,116 @@
-/*
- * $Id$
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.commons.ognl.performance.runtime;
-
-import ognl.OgnlRuntime;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-
-/**
- * User: Maurizio Cucchiara
- * Date: 10/22/11
- * Time: 12:46 AM
- */
-public class OldOgnlRuntimeWrapper
- implements RuntimeWrapper
-{
-
- public void getFields( Class<?> c )
- throws Exception
- {
- OgnlRuntime.getFields( c );
- }
-
-
- public void findParameterTypes( Class<?> targetClass, Method method )
- throws Exception
- {
- OgnlRuntime.findParameterTypes( targetClass, method );
- }
-
-
- public void getConstructors( Class<?> c )
- throws Exception
- {
- OgnlRuntime.getConstructors( c );
- }
-
-
- public void getMethods( Class<?> c, boolean staticMethods )
- throws Exception
- {
- OgnlRuntime.getMethods( c, staticMethods );
- }
-
-
- public void getDeclaredMethods( Class<?> c, String propertyName, boolean setters )
- throws Exception
- {
- OgnlRuntime.getDeclaredMethods( c, propertyName, setters );
- }
-
-
- public void getParameterTypes( Method method )
- throws Exception
- {
- OgnlRuntime.getParameterTypes( method );
- }
-
-
- public void getParameterTypes( Constructor<?> constructor )
- throws Exception
- {
- OgnlRuntime.getParameterTypes( constructor );
- }
-
-
- public void getPermission( Method method )
- throws Exception
- {
- OgnlRuntime.getPermission( method );
- }
-
-
- public void getPrimitiveDefaultValue( Class<?> type )
- throws Exception
- {
- OgnlRuntime.getPrimitiveDefaultValue( type );
- }
-
-
- public void invokeMethod( Object o, Method method, Object[] args )
- throws Exception
- {
- OgnlRuntime.invokeMethod( o, method, args );
- }
-
-
- public void clearCache()
- {
- OgnlRuntime.clearCache();
- }
-
- public void getCompiler()
- {
- OgnlRuntime.getCompiler();
- }
-}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.ognl.performance.runtime;
+
+import ognl.OgnlRuntime;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+
+/**
+ * User: Maurizio Cucchiara
+ * Date: 10/22/11
+ * Time: 12:46 AM
+ */
+public class OldOgnlRuntimeWrapper
+ implements RuntimeWrapper
+{
+
+ public void getFields( Class<?> c )
+ throws Exception
+ {
+ OgnlRuntime.getFields( c );
+ }
+
+
+ public void findParameterTypes( Class<?> targetClass, Method method )
+ throws Exception
+ {
+ OgnlRuntime.findParameterTypes( targetClass, method );
+ }
+
+
+ public void getConstructors( Class<?> c )
+ throws Exception
+ {
+ OgnlRuntime.getConstructors( c );
+ }
+
+
+ public void getMethods( Class<?> c, boolean staticMethods )
+ throws Exception
+ {
+ OgnlRuntime.getMethods( c, staticMethods );
+ }
+
+
+ public void getDeclaredMethods( Class<?> c, String propertyName, boolean setters )
+ throws Exception
+ {
+ OgnlRuntime.getDeclaredMethods( c, propertyName, setters );
+ }
+
+
+ public void getParameterTypes( Method method )
+ throws Exception
+ {
+ OgnlRuntime.getParameterTypes( method );
+ }
+
+
+ public void getParameterTypes( Constructor<?> constructor )
+ throws Exception
+ {
+ OgnlRuntime.getParameterTypes( constructor );
+ }
+
+
+ public void getPermission( Method method )
+ throws Exception
+ {
+ OgnlRuntime.getPermission( method );
+ }
+
+
+ public void getPrimitiveDefaultValue( Class<?> type )
+ throws Exception
+ {
+ OgnlRuntime.getPrimitiveDefaultValue( type );
+ }
+
+
+ public void invokeMethod( Object o, Method method, Object[] args )
+ throws Exception
+ {
+ OgnlRuntime.invokeMethod( o, method, args );
+ }
+
+
+ public void clearCache()
+ {
+ OgnlRuntime.clearCache();
+ }
+
+ public void getCompiler()
+ {
+ OgnlRuntime.getCompiler();
+ }
+}
diff --git a/src/benchmarks/java/org/apache/commons/ognl/performance/runtime/RuntimeWrapper.java b/src/benchmarks/java/org/apache/commons/ognl/performance/runtime/RuntimeWrapper.java
index c754fe6..b9339f1 100644
--- a/src/benchmarks/java/org/apache/commons/ognl/performance/runtime/RuntimeWrapper.java
+++ b/src/benchmarks/java/org/apache/commons/ognl/performance/runtime/RuntimeWrapper.java
@@ -1,67 +1,66 @@
-/*
- * $Id$
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.commons.ognl.performance.runtime;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-
-/**
- * User: mcucchiara
- * Date: 19/10/11
- * Time: 9.37
- */
-public interface RuntimeWrapper
-{
- void getFields( Class<?> c )
- throws Exception;
-
- void findParameterTypes( Class<?> targetClass, Method method )
- throws Exception;
-
- void getConstructors( Class<?> c )
- throws Exception;
-
- void getMethods( Class<?> c, boolean staticMethods )
- throws Exception;
-
- void getDeclaredMethods( Class<?> c, String propertyName, boolean setters )
- throws Exception;
-
- void getParameterTypes( Method method )
- throws Exception;
-
- void getParameterTypes( Constructor<?> constructor )
- throws Exception;
-
- void getPermission( Method method )
- throws Exception;
-
- void getPrimitiveDefaultValue( Class<?> type )
- throws Exception;
-
- void invokeMethod( Object o, Method method, Object[] args )
- throws Exception;
-
- void clearCache();
-
- void getCompiler();
-}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.ognl.performance.runtime;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+
+/**
+ * User: mcucchiara
+ * Date: 19/10/11
+ * Time: 9.37
+ */
+public interface RuntimeWrapper
+{
+ void getFields( Class<?> c )
+ throws Exception;
+
+ void findParameterTypes( Class<?> targetClass, Method method )
+ throws Exception;
+
+ void getConstructors( Class<?> c )
+ throws Exception;
+
+ void getMethods( Class<?> c, boolean staticMethods )
+ throws Exception;
+
+ void getDeclaredMethods( Class<?> c, String propertyName, boolean setters )
+ throws Exception;
+
+ void getParameterTypes( Method method )
+ throws Exception;
+
+ void getParameterTypes( Constructor<?> constructor )
+ throws Exception;
+
+ void getPermission( Method method )
+ throws Exception;
+
+ void getPrimitiveDefaultValue( Class<?> type )
+ throws Exception;
+
+ void invokeMethod( Object o, Method method, Object[] args )
+ throws Exception;
+
+ void clearCache();
+
+ void getCompiler();
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTAdd.java b/src/main/java/org/apache/commons/ognl/ASTAdd.java
index 04a4427..f926449 100644
--- a/src/main/java/org/apache/commons/ognl/ASTAdd.java
+++ b/src/main/java/org/apache/commons/ognl/ASTAdd.java
@@ -1,352 +1,351 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.ognl.enhance.ExpressionCompiler;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-import static java.lang.String.format;
-
-/**
- * $Id$
- */
-class ASTAdd
- extends NumericExpression
-{
- public ASTAdd( int id )
- {
- super( id );
- }
-
- public ASTAdd( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- 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.add( result, children[i].getValue( context, source ) );
- }
-
- return result;
- }
-
- public String getExpressionOperator( int index )
- {
- return "+";
- }
-
- boolean isWider( NodeType type, NodeType lastType )
- {
- if ( lastType == null )
- {
- return true;
- }
-
- // System.out.println("checking isWider(" + type.getGetterClass() + " , " + lastType.getGetterClass() + ")");
-
- if ( String.class.isAssignableFrom( lastType.getGetterClass() ) )
- {
- return false;
- }
-
- if ( String.class.isAssignableFrom( type.getGetterClass() ) )
- {
- return true;
- }
-
- if ( parent != null && String.class.isAssignableFrom( type.getGetterClass() ) )
- {
- return true;
- }
-
- if ( String.class.isAssignableFrom( lastType.getGetterClass() ) && Object.class == type.getGetterClass() )
- {
- return false;
- }
-
- if ( parent != null && String.class.isAssignableFrom( lastType.getGetterClass() ) )
- {
- return false;
- }
- if ( parent == null && String.class.isAssignableFrom( lastType.getGetterClass() ) )
- {
- return true;
- }
- if ( parent == null && String.class.isAssignableFrom( type.getGetterClass() ) )
- {
- return false;
- }
-
- if ( BigDecimal.class.isAssignableFrom( type.getGetterClass() )
- || BigInteger.class.isAssignableFrom( type.getGetterClass() ) )
- {
- return true;
- }
-
- if ( BigDecimal.class.isAssignableFrom( lastType.getGetterClass() )
- || BigInteger.class.isAssignableFrom( lastType.getGetterClass() ) )
- {
- return false;
- }
-
- if ( Double.class.isAssignableFrom( type.getGetterClass() ) )
- {
- return true;
- }
-
- if ( Integer.class.isAssignableFrom( type.getGetterClass() )
- && Double.class.isAssignableFrom( lastType.getGetterClass() ) )
- {
- return false;
- }
-
- if ( Float.class.isAssignableFrom( type.getGetterClass() )
- && Integer.class.isAssignableFrom( lastType.getGetterClass() ) )
- {
- return true;
- }
-
- return true;
- }
-
- public String toGetSourceString( OgnlContext context, Object target )
- {
- try
- {
- StringBuilder result = new StringBuilder();
- NodeType lastType = null;
-
- // go through once to determine the ultimate type
-
- if ( ( children != null ) && ( children.length > 0 ) )
- {
- Class currType = context.getCurrentType();
- Class currAccessor = context.getCurrentAccessor();
-
- Object cast = context.get( ExpressionCompiler.PRE_CAST );
-
- for ( Node aChildren : children )
- {
- aChildren.toGetSourceString( context, target );
-
- if ( aChildren instanceof NodeType && ( (NodeType) aChildren ).getGetterClass() != null
- && isWider( (NodeType) aChildren, lastType ) )
- {
- lastType = (NodeType) aChildren;
- }
- }
-
- context.put( ExpressionCompiler.PRE_CAST, cast );
-
- context.setCurrentType( currType );
- context.setCurrentAccessor( currAccessor );
- }
-
- // reset context since previous children loop would have changed it
-
- context.setCurrentObject( target );
-
- if ( ( children != null ) && ( children.length > 0 ) )
- {
-
- for ( int i = 0; i < children.length; ++i )
- {
- if ( i > 0 )
- {
- result.append(" ").append(getExpressionOperator(i)).append(" ");
- }
-
- String expr = children[i].toGetSourceString( context, target );
-
- if ( ( "null".equals( expr ) )
- || ( !(children[i] instanceof ASTConst)
- && ( expr == null || expr.trim().isEmpty() ) ) )
- {
- expr = "null";
- }
-
- // System.out.println("astadd child class: " + _children[i].getClass().getName() +
- // " and return expr: " + expr);
-
- if (children[i] instanceof ASTProperty)
- {
- expr = ExpressionCompiler.getRootExpression( children[i], context.getRoot(), context ) + expr;
- context.setCurrentAccessor( context.getRoot().getClass() );
- }
- else if (children[i] instanceof ASTMethod)
- {
- String chain = (String) context.get( "_currentChain" );
- String rootExpr =
- ExpressionCompiler.getRootExpression( children[i], context.getRoot(), context );
-
- // System.out.println("astadd chains is >>" + chain + "<< and rootExpr is >>" + rootExpr +
- // "<<");
-
- // dirty fix for overly aggressive casting dot operations
- if ( rootExpr.endsWith( "." ) && chain != null && chain.startsWith( ")." ) )
- {
- chain = chain.substring( 1 );
- }
-
- expr = rootExpr + ( chain != null ? chain + "." : "" ) + expr;
- context.setCurrentAccessor( context.getRoot().getClass() );
-
- }
- else if (children[i] instanceof ExpressionNode)
- {
- expr = "(" + expr + ")";
- }
- else if ( ( parent == null || !(parent instanceof ASTChain))
- && children[i] instanceof ASTChain)
- {
- String rootExpr =
- ExpressionCompiler.getRootExpression( children[i], context.getRoot(), context );
-
- if ( !(children[i].jjtGetChild(0) instanceof ASTProperty) && rootExpr.endsWith( ")" )
- && expr.startsWith( ")" ) )
- {
- expr = expr.substring( 1 );
- }
-
- expr = rootExpr + expr;
- context.setCurrentAccessor( context.getRoot().getClass() );
-
- String cast = (String) context.remove( ExpressionCompiler.PRE_CAST );
- if ( cast == null )
- {
- cast = "";
- }
-
- expr = cast + expr;
- }
-
- // turn quoted characters into quoted strings
-
- if ( context.getCurrentType() != null && context.getCurrentType() == Character.class
- && children[i] instanceof ASTConst)
- {
- expr = expr.replace( "'", "\"" );
- context.setCurrentType( String.class );
- }
- else
- {
-
- if ( !ASTVarRef.class.isAssignableFrom( children[i].getClass() )
- && !(children[i] instanceof ASTProperty)
- && !(children[i] instanceof ASTMethod)
- && !(children[i] instanceof ASTSequence)
- && !(children[i] instanceof ASTChain)
- && !NumericExpression.class.isAssignableFrom( children[i].getClass() )
- && !(children[i] instanceof ASTStaticField)
- && !(children[i] instanceof ASTStaticMethod)
- && !(children[i] instanceof ASTTest))
- {
- if ( lastType != null && String.class.isAssignableFrom( lastType.getGetterClass() ) )
- {
- // System.out.println("Input expr >>" + expr + "<<");
- expr = expr.replace( """, "\"" );
- expr = expr.replace( "\"", "'" );
- expr = format( "\"%s\"", expr );
- // System.out.println("Expr now >>" + expr + "<<");
- }
- }
- }
-
- result.append(expr);
-
- // hanlde addition for numeric types when applicable or just string concatenation
-
- if ( ( lastType == null || !String.class.isAssignableFrom( lastType.getGetterClass() ) )
- && !ASTConst.class.isAssignableFrom( children[i].getClass() )
- && !NumericExpression.class.isAssignableFrom( children[i].getClass() ) )
- {
- if ( context.getCurrentType() != null
- && Number.class.isAssignableFrom( context.getCurrentType() )
- && !(children[i] instanceof ASTMethod))
- {
- if ( children[i] instanceof ASTVarRef
- || children[i] instanceof ASTProperty
- || children[i] instanceof ASTChain)
- {
- result.append(".");
- }
-
- result.append(OgnlRuntime.getNumericValueGetter(context.getCurrentType()));
- context.setCurrentType( OgnlRuntime.getPrimitiveWrapperClass( context.getCurrentType() ) );
- }
- }
-
- if ( lastType != null )
- {
- context.setCurrentAccessor( lastType.getGetterClass() );
- }
- }
- }
-
- if ( parent == null || ASTSequence.class.isAssignableFrom( parent.getClass() ) )
- {
- if ( getterClass != null && String.class.isAssignableFrom( getterClass ) )
- {
- getterClass = Object.class;
- }
- }
- else
- {
- context.setCurrentType( getterClass );
- }
-
- try
- {
- Object contextObj = getValueBody( context, target );
- context.setCurrentObject( contextObj );
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
-
- return result.toString();
-
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.ognl.enhance.ExpressionCompiler;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import static java.lang.String.format;
+
+/**
+ */
+class ASTAdd
+ extends NumericExpression
+{
+ public ASTAdd( int id )
+ {
+ super( id );
+ }
+
+ public ASTAdd( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ 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.add( result, children[i].getValue( context, source ) );
+ }
+
+ return result;
+ }
+
+ public String getExpressionOperator( int index )
+ {
+ return "+";
+ }
+
+ boolean isWider( NodeType type, NodeType lastType )
+ {
+ if ( lastType == null )
+ {
+ return true;
+ }
+
+ // System.out.println("checking isWider(" + type.getGetterClass() + " , " + lastType.getGetterClass() + ")");
+
+ if ( String.class.isAssignableFrom( lastType.getGetterClass() ) )
+ {
+ return false;
+ }
+
+ if ( String.class.isAssignableFrom( type.getGetterClass() ) )
+ {
+ return true;
+ }
+
+ if ( parent != null && String.class.isAssignableFrom( type.getGetterClass() ) )
+ {
+ return true;
+ }
+
+ if ( String.class.isAssignableFrom( lastType.getGetterClass() ) && Object.class == type.getGetterClass() )
+ {
+ return false;
+ }
+
+ if ( parent != null && String.class.isAssignableFrom( lastType.getGetterClass() ) )
+ {
+ return false;
+ }
+ if ( parent == null && String.class.isAssignableFrom( lastType.getGetterClass() ) )
+ {
+ return true;
+ }
+ if ( parent == null && String.class.isAssignableFrom( type.getGetterClass() ) )
+ {
+ return false;
+ }
+
+ if ( BigDecimal.class.isAssignableFrom( type.getGetterClass() )
+ || BigInteger.class.isAssignableFrom( type.getGetterClass() ) )
+ {
+ return true;
+ }
+
+ if ( BigDecimal.class.isAssignableFrom( lastType.getGetterClass() )
+ || BigInteger.class.isAssignableFrom( lastType.getGetterClass() ) )
+ {
+ return false;
+ }
+
+ if ( Double.class.isAssignableFrom( type.getGetterClass() ) )
+ {
+ return true;
+ }
+
+ if ( Integer.class.isAssignableFrom( type.getGetterClass() )
+ && Double.class.isAssignableFrom( lastType.getGetterClass() ) )
+ {
+ return false;
+ }
+
+ if ( Float.class.isAssignableFrom( type.getGetterClass() )
+ && Integer.class.isAssignableFrom( lastType.getGetterClass() ) )
+ {
+ return true;
+ }
+
+ return true;
+ }
+
+ public String toGetSourceString( OgnlContext context, Object target )
+ {
+ try
+ {
+ StringBuilder result = new StringBuilder();
+ NodeType lastType = null;
+
+ // go through once to determine the ultimate type
+
+ if ( ( children != null ) && ( children.length > 0 ) )
+ {
+ Class currType = context.getCurrentType();
+ Class currAccessor = context.getCurrentAccessor();
+
+ Object cast = context.get( ExpressionCompiler.PRE_CAST );
+
+ for ( Node aChildren : children )
+ {
+ aChildren.toGetSourceString( context, target );
+
+ if ( aChildren instanceof NodeType && ( (NodeType) aChildren ).getGetterClass() != null
+ && isWider( (NodeType) aChildren, lastType ) )
+ {
+ lastType = (NodeType) aChildren;
+ }
+ }
+
+ context.put( ExpressionCompiler.PRE_CAST, cast );
+
+ context.setCurrentType( currType );
+ context.setCurrentAccessor( currAccessor );
+ }
+
+ // reset context since previous children loop would have changed it
+
+ context.setCurrentObject( target );
+
+ if ( ( children != null ) && ( children.length > 0 ) )
+ {
+
+ for ( int i = 0; i < children.length; ++i )
+ {
+ if ( i > 0 )
+ {
+ result.append(" ").append(getExpressionOperator(i)).append(" ");
+ }
+
+ String expr = children[i].toGetSourceString( context, target );
+
+ if ( ( "null".equals( expr ) )
+ || ( !(children[i] instanceof ASTConst)
+ && ( expr == null || expr.trim().isEmpty() ) ) )
+ {
+ expr = "null";
+ }
+
+ // System.out.println("astadd child class: " + _children[i].getClass().getName() +
+ // " and return expr: " + expr);
+
+ if (children[i] instanceof ASTProperty)
+ {
+ expr = ExpressionCompiler.getRootExpression( children[i], context.getRoot(), context ) + expr;
+ context.setCurrentAccessor( context.getRoot().getClass() );
+ }
+ else if (children[i] instanceof ASTMethod)
+ {
+ String chain = (String) context.get( "_currentChain" );
+ String rootExpr =
+ ExpressionCompiler.getRootExpression( children[i], context.getRoot(), context );
+
+ // System.out.println("astadd chains is >>" + chain + "<< and rootExpr is >>" + rootExpr +
+ // "<<");
+
+ // dirty fix for overly aggressive casting dot operations
+ if ( rootExpr.endsWith( "." ) && chain != null && chain.startsWith( ")." ) )
+ {
+ chain = chain.substring( 1 );
+ }
+
+ expr = rootExpr + ( chain != null ? chain + "." : "" ) + expr;
+ context.setCurrentAccessor( context.getRoot().getClass() );
+
+ }
+ else if (children[i] instanceof ExpressionNode)
+ {
+ expr = "(" + expr + ")";
+ }
+ else if ( ( parent == null || !(parent instanceof ASTChain))
+ && children[i] instanceof ASTChain)
+ {
+ String rootExpr =
+ ExpressionCompiler.getRootExpression( children[i], context.getRoot(), context );
+
+ if ( !(children[i].jjtGetChild(0) instanceof ASTProperty) && rootExpr.endsWith( ")" )
+ && expr.startsWith( ")" ) )
+ {
+ expr = expr.substring( 1 );
+ }
+
+ expr = rootExpr + expr;
+ context.setCurrentAccessor( context.getRoot().getClass() );
+
+ String cast = (String) context.remove( ExpressionCompiler.PRE_CAST );
+ if ( cast == null )
+ {
+ cast = "";
+ }
+
+ expr = cast + expr;
+ }
+
+ // turn quoted characters into quoted strings
+
+ if ( context.getCurrentType() != null && context.getCurrentType() == Character.class
+ && children[i] instanceof ASTConst)
+ {
+ expr = expr.replace( "'", "\"" );
+ context.setCurrentType( String.class );
+ }
+ else
+ {
+
+ if ( !ASTVarRef.class.isAssignableFrom( children[i].getClass() )
+ && !(children[i] instanceof ASTProperty)
+ && !(children[i] instanceof ASTMethod)
+ && !(children[i] instanceof ASTSequence)
+ && !(children[i] instanceof ASTChain)
+ && !NumericExpression.class.isAssignableFrom( children[i].getClass() )
+ && !(children[i] instanceof ASTStaticField)
+ && !(children[i] instanceof ASTStaticMethod)
+ && !(children[i] instanceof ASTTest))
+ {
+ if ( lastType != null && String.class.isAssignableFrom( lastType.getGetterClass() ) )
+ {
+ // System.out.println("Input expr >>" + expr + "<<");
+ expr = expr.replace( """, "\"" );
+ expr = expr.replace( "\"", "'" );
+ expr = format( "\"%s\"", expr );
+ // System.out.println("Expr now >>" + expr + "<<");
+ }
+ }
+ }
+
+ result.append(expr);
+
+ // hanlde addition for numeric types when applicable or just string concatenation
+
+ if ( ( lastType == null || !String.class.isAssignableFrom( lastType.getGetterClass() ) )
+ && !ASTConst.class.isAssignableFrom( children[i].getClass() )
+ && !NumericExpression.class.isAssignableFrom( children[i].getClass() ) )
+ {
+ if ( context.getCurrentType() != null
+ && Number.class.isAssignableFrom( context.getCurrentType() )
+ && !(children[i] instanceof ASTMethod))
+ {
+ if ( children[i] instanceof ASTVarRef
+ || children[i] instanceof ASTProperty
+ || children[i] instanceof ASTChain)
+ {
+ result.append(".");
+ }
+
+ result.append(OgnlRuntime.getNumericValueGetter(context.getCurrentType()));
+ context.setCurrentType( OgnlRuntime.getPrimitiveWrapperClass( context.getCurrentType() ) );
+ }
+ }
+
+ if ( lastType != null )
+ {
+ context.setCurrentAccessor( lastType.getGetterClass() );
+ }
+ }
+ }
+
+ if ( parent == null || ASTSequence.class.isAssignableFrom( parent.getClass() ) )
+ {
+ if ( getterClass != null && String.class.isAssignableFrom( getterClass ) )
+ {
+ getterClass = Object.class;
+ }
+ }
+ else
+ {
+ context.setCurrentType( getterClass );
+ }
+
+ try
+ {
+ Object contextObj = getValueBody( context, target );
+ context.setCurrentObject( contextObj );
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+
+ return result.toString();
+
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTAnd.java b/src/main/java/org/apache/commons/ognl/ASTAnd.java
index a9dbd75..077069c 100644
--- a/src/main/java/org/apache/commons/ognl/ASTAnd.java
+++ b/src/main/java/org/apache/commons/ognl/ASTAnd.java
@@ -25,7 +25,6 @@ import org.apache.commons.ognl.enhance.UnsupportedCompilationException;
import static java.lang.String.format;
/**
- * $Id$
*/
public class ASTAnd
extends BooleanExpression
diff --git a/src/main/java/org/apache/commons/ognl/ASTAssign.java b/src/main/java/org/apache/commons/ognl/ASTAssign.java
index 7a6d3aa..b85ca21 100644
--- a/src/main/java/org/apache/commons/ognl/ASTAssign.java
+++ b/src/main/java/org/apache/commons/ognl/ASTAssign.java
@@ -1,151 +1,150 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.ognl.enhance.OrderedReturn;
-import org.apache.commons.ognl.enhance.UnsupportedCompilationException;
-
-/**
- * $Id$
- */
-class ASTAssign
- extends SimpleNode
-{
- public ASTAssign( int id )
- {
- super( id );
- }
-
- public ASTAssign( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- protected Object getValueBody( OgnlContext context, Object source )
- throws OgnlException
- {
- Object result = children[1].getValue( context, source );
- children[0].setValue( context, source, result );
- return result;
- }
-
- public String toGetSourceString( OgnlContext context, Object target )
- {
- String result = "";
-
- String first = children[0].toGetSourceString( context, target );
- String second = "";
-
- if (children[1] instanceof ASTProperty)
- {
- second += "((" + OgnlRuntime.getCompiler( context ).getClassName( target.getClass() ) + ")$2).";
- }
-
- second += children[1].toGetSourceString( context, target );
-
- if ( ASTSequence.class.isAssignableFrom( children[1].getClass() ) )
- {
- ASTSequence seq = (ASTSequence) children[1];
-
- context.setCurrentType( Object.class );
-
- String core = seq.getCoreExpression();
- if ( core.endsWith( ";" ) )
- {
- core = core.substring( 0, core.lastIndexOf( ";" ) );
- }
-
- second =
- OgnlRuntime.getCompiler( context ).createLocalReference( context,
- "org.apache.commons.ognl.OgnlOps.returnValue(($w)"
- + core + ", ($w) " + seq.getLastExpression() + ")",
- Object.class );
- }
-
- if ( children[1] instanceof NodeType && !(children[1] instanceof ASTProperty)
- && ( (NodeType) children[1] ).getGetterClass() != null && !(children[1] instanceof OrderedReturn))
- {
-
- second = "new " + ( (NodeType) children[1] ).getGetterClass().getName() + "(" + second + ")";
- }
-
- if ( OrderedReturn.class.isAssignableFrom( children[0].getClass() )
- && ( (OrderedReturn) children[0] ).getCoreExpression() != null )
- {
- context.setCurrentType( Object.class );
-
- result = first + second + ")";
-
- // System.out.println("building ordered ret from child[0] with result of:" + result);
-
- result =
- OgnlRuntime
- .getCompiler( context )
- .createLocalReference( context,
- "org.apache.commons.ognl.OgnlOps.returnValue(($w)" + result + ", ($w)"
- + ( (OrderedReturn) children[0] ).getLastExpression() + ")",
- Object.class );
- }
-
- return result;
- }
-
- public String toSetSourceString( OgnlContext context, Object target )
- {
- String result = "";
-
- result += children[0].toSetSourceString( context, target );
-
- if (children[1] instanceof ASTProperty)
- {
- result += "((" + OgnlRuntime.getCompiler( context ).getClassName( target.getClass() ) + ")$2).";
- }
-
- String value = children[1].toSetSourceString( context, target );
-
- if ( value == null )
- {
- throw new UnsupportedCompilationException(
- "Value for assignment is null, can't enhance statement to bytecode." );
- }
-
- if ( ASTSequence.class.isAssignableFrom( children[1].getClass() ) )
- {
- ASTSequence seq = (ASTSequence) children[1];
- result = seq.getCoreExpression() + result;
- value = seq.getLastExpression();
- }
-
- if ( children[1] instanceof NodeType && !(children[1] instanceof ASTProperty)
- && ( (NodeType) children[1] ).getGetterClass() != null )
- {
-
- value = "new " + ( (NodeType) children[1] ).getGetterClass().getName() + "(" + value + ")";
- }
-
- return result + value + ")";
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.ognl.enhance.OrderedReturn;
+import org.apache.commons.ognl.enhance.UnsupportedCompilationException;
+
+/**
+ */
+class ASTAssign
+ extends SimpleNode
+{
+ public ASTAssign( int id )
+ {
+ super( id );
+ }
+
+ public ASTAssign( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ protected Object getValueBody( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ Object result = children[1].getValue( context, source );
+ children[0].setValue( context, source, result );
+ return result;
+ }
+
+ public String toGetSourceString( OgnlContext context, Object target )
+ {
+ String result = "";
+
+ String first = children[0].toGetSourceString( context, target );
+ String second = "";
+
+ if (children[1] instanceof ASTProperty)
+ {
+ second += "((" + OgnlRuntime.getCompiler( context ).getClassName( target.getClass() ) + ")$2).";
+ }
+
+ second += children[1].toGetSourceString( context, target );
+
+ if ( ASTSequence.class.isAssignableFrom( children[1].getClass() ) )
+ {
+ ASTSequence seq = (ASTSequence) children[1];
+
+ context.setCurrentType( Object.class );
+
+ String core = seq.getCoreExpression();
+ if ( core.endsWith( ";" ) )
+ {
+ core = core.substring( 0, core.lastIndexOf( ";" ) );
+ }
+
+ second =
+ OgnlRuntime.getCompiler( context ).createLocalReference( context,
+ "org.apache.commons.ognl.OgnlOps.returnValue(($w)"
+ + core + ", ($w) " + seq.getLastExpression() + ")",
+ Object.class );
+ }
+
+ if ( children[1] instanceof NodeType && !(children[1] instanceof ASTProperty)
+ && ( (NodeType) children[1] ).getGetterClass() != null && !(children[1] instanceof OrderedReturn))
+ {
+
+ second = "new " + ( (NodeType) children[1] ).getGetterClass().getName() + "(" + second + ")";
+ }
+
+ if ( OrderedReturn.class.isAssignableFrom( children[0].getClass() )
+ && ( (OrderedReturn) children[0] ).getCoreExpression() != null )
+ {
+ context.setCurrentType( Object.class );
+
+ result = first + second + ")";
+
+ // System.out.println("building ordered ret from child[0] with result of:" + result);
+
+ result =
+ OgnlRuntime
+ .getCompiler( context )
+ .createLocalReference( context,
+ "org.apache.commons.ognl.OgnlOps.returnValue(($w)" + result + ", ($w)"
+ + ( (OrderedReturn) children[0] ).getLastExpression() + ")",
+ Object.class );
+ }
+
+ return result;
+ }
+
+ public String toSetSourceString( OgnlContext context, Object target )
+ {
+ String result = "";
+
+ result += children[0].toSetSourceString( context, target );
+
+ if (children[1] instanceof ASTProperty)
+ {
+ result += "((" + OgnlRuntime.getCompiler( context ).getClassName( target.getClass() ) + ")$2).";
+ }
+
+ String value = children[1].toSetSourceString( context, target );
+
+ if ( value == null )
+ {
+ throw new UnsupportedCompilationException(
+ "Value for assignment is null, can't enhance statement to bytecode." );
+ }
+
+ if ( ASTSequence.class.isAssignableFrom( children[1].getClass() ) )
+ {
+ ASTSequence seq = (ASTSequence) children[1];
+ result = seq.getCoreExpression() + result;
+ value = seq.getLastExpression();
+ }
+
+ if ( children[1] instanceof NodeType && !(children[1] instanceof ASTProperty)
+ && ( (NodeType) children[1] ).getGetterClass() != null )
+ {
+
+ value = "new " + ( (NodeType) children[1] ).getGetterClass().getName() + "(" + value + ")";
+ }
+
+ return result + value + ")";
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTBitAnd.java b/src/main/java/org/apache/commons/ognl/ASTBitAnd.java
index ea83d4f..2e5bbc0 100644
--- a/src/main/java/org/apache/commons/ognl/ASTBitAnd.java
+++ b/src/main/java/org/apache/commons/ognl/ASTBitAnd.java
@@ -1,69 +1,68 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * $Id$
- */
-class ASTBitAnd
- extends NumericExpression
-{
- public ASTBitAnd( int id )
- {
- super( id );
- }
-
- public ASTBitAnd( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- 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.binaryAnd( result, children[i].getValue( context, source ) );
- }
- return result;
- }
-
- public String getExpressionOperator( int index )
- {
- return "&";
- }
-
- public String coerceToNumeric( String source, OgnlContext context, Node child )
- {
- return "(long)" + super.coerceToNumeric( source, context, child );
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ */
+class ASTBitAnd
+ extends NumericExpression
+{
+ public ASTBitAnd( int id )
+ {
+ super( id );
+ }
+
+ public ASTBitAnd( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ 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.binaryAnd( result, children[i].getValue( context, source ) );
+ }
+ return result;
+ }
+
+ public String getExpressionOperator( int index )
+ {
+ return "&";
+ }
+
+ public String coerceToNumeric( String source, OgnlContext context, Node child )
+ {
+ return "(long)" + super.coerceToNumeric( source, context, child );
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTBitNegate.java b/src/main/java/org/apache/commons/ognl/ASTBitNegate.java
index f612e45..cfcc299 100644
--- a/src/main/java/org/apache/commons/ognl/ASTBitNegate.java
+++ b/src/main/java/org/apache/commons/ognl/ASTBitNegate.java
@@ -1,60 +1,59 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * $Id$
- */
-class ASTBitNegate
- extends NumericExpression
-{
- public ASTBitNegate( int id )
- {
- super( id );
- }
-
- public ASTBitNegate( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- protected Object getValueBody( OgnlContext context, Object source )
- throws OgnlException
- {
- return OgnlOps.bitNegate( children[0].getValue( context, source ) );
- }
-
- public String toGetSourceString( OgnlContext context, Object target )
- {
- String source = children[0].toGetSourceString( context, target );
-
- if ( !(children[0] instanceof ASTBitNegate))
- {
- return "~(" + super.coerceToNumeric( source, context, children[0] ) + ")";
- }
- return "~(" + source + ")";
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ */
+class ASTBitNegate
+ extends NumericExpression
+{
+ public ASTBitNegate( int id )
+ {
+ super( id );
+ }
+
+ public ASTBitNegate( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ protected Object getValueBody( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ return OgnlOps.bitNegate( children[0].getValue( context, source ) );
+ }
+
+ public String toGetSourceString( OgnlContext context, Object target )
+ {
+ String source = children[0].toGetSourceString( context, target );
+
+ if ( !(children[0] instanceof ASTBitNegate))
+ {
+ return "~(" + super.coerceToNumeric( source, context, children[0] ) + ")";
+ }
+ return "~(" + source + ")";
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTBitOr.java b/src/main/java/org/apache/commons/ognl/ASTBitOr.java
index 7eb3a42..d3128b6 100644
--- a/src/main/java/org/apache/commons/ognl/ASTBitOr.java
+++ b/src/main/java/org/apache/commons/ognl/ASTBitOr.java
@@ -1,64 +1,63 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * $Id$
- */
-class ASTBitOr
- extends NumericExpression
-{
- public ASTBitOr( int id )
- {
- super( id );
- }
-
- public ASTBitOr( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- 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.binaryOr( result, children[i].getValue( context, source ) );
- }
- return result;
- }
-
- public String getExpressionOperator( int index )
- {
- return "|";
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ */
+class ASTBitOr
+ extends NumericExpression
+{
+ public ASTBitOr( int id )
+ {
+ super( id );
+ }
+
+ public ASTBitOr( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ 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.binaryOr( result, children[i].getValue( context, source ) );
+ }
+ return result;
+ }
+
+ public String getExpressionOperator( int index )
+ {
+ return "|";
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTChain.java b/src/main/java/org/apache/commons/ognl/ASTChain.java
index 8344376..242a823 100644
--- a/src/main/java/org/apache/commons/ognl/ASTChain.java
+++ b/src/main/java/org/apache/commons/ognl/ASTChain.java
@@ -1,490 +1,489 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.ognl.enhance.ExpressionCompiler;
-import org.apache.commons.ognl.enhance.OrderedReturn;
-import org.apache.commons.ognl.enhance.UnsupportedCompilationException;
-
-import java.lang.reflect.Array;
-
-/**
- * $Id$
- */
-public class ASTChain
- extends SimpleNode
- implements NodeType, OrderedReturn
-{
-
- private Class getterClass;
-
- private Class setterClass;
-
- private String lastExpression;
-
- private String coreExpression;
-
- public ASTChain( int id )
- {
- super( id );
- }
-
- public ASTChain( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- public String getLastExpression()
- {
- return lastExpression;
- }
-
- public String getCoreExpression()
- {
- return coreExpression;
- }
-
- 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) && (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 = ( len > 0 ) ? 0 : -1;
- break;
- case DynamicSubscript.MID:
- index = ( len > 0 ) ? ( len / 2 ) : -1;
- break;
- case DynamicSubscript.LAST:
- index = ( len > 0 ) ? ( len - 1 ) : -1;
- break;
- default:
- 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) && (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 = ( len > 0 ) ? 0 : -1;
- break;
- case DynamicSubscript.MID:
- index = ( len > 0 ) ? ( len / 2 ) : -1;
- break;
- case DynamicSubscript.LAST:
- index = ( len > 0 ) ? ( len - 1 ) : -1;
- break;
- default:
- break;
- }
- }
- else
- {
- if ( indexType == OgnlRuntime.INDEXED_PROPERTY_OBJECT )
- {
- throw new OgnlException( "DynamicSubscript '" + indexNode
- + "' not allowed for object indexed property '" + propertyNode + "'" );
- }
- }
- }
- if ( !handled && i == ilast )
- {
- OgnlRuntime.setIndexedProperty( context, target,
- propertyNode.getProperty( context, target ).toString(),
- index, value );
- handled = true;
- i++;
- }
- else if ( !handled )
- {
- target =
- OgnlRuntime.getIndexedProperty(
- context,
- target,
- propertyNode.getProperty( context, target ).toString(),
- index );
- i++;
- continue;
- }
- }
- }
- }
- 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++ )
- {
- result =
- children[i] instanceof SimpleNode && ( (SimpleNode) children[i] ).isSimpleProperty( context );
- }
- }
- return result;
- }
-
- public Class getGetterClass()
- {
- return getterClass;
- }
-
- public Class getSetterClass()
- {
- return setterClass;
- }
-
- public String toGetSourceString( OgnlContext context, Object target )
- {
- String prevChain = (String) context.get( "_currentChain" );
-
- if ( target != null )
- {
- context.setCurrentObject( target );
- context.setCurrentType( target.getClass() );
- }
-
- String result = "";
- NodeType lastType = null;
- boolean ordered = false;
- boolean constructor = false;
- try
- {
- if ( ( children != null ) && ( children.length > 0 ) )
- {
- for ( Node child : children )
- {
- /*
- * System.out.println("astchain child: " + _children[i].getClass().getName() +
- * " with current object target " + context.getCurrentObject() + " current type: " +
- * context.getCurrentType());
- */
-
- String value = child.toGetSourceString( context, context.getCurrentObject() );
-
- // System.out.println("astchain child returned >> " + value + " <<");
-
- if (child instanceof ASTCtor)
- {
- constructor = true;
- }
-
- if ( child instanceof NodeType && ( (NodeType) child ).getGetterClass() != null )
- {
- lastType = (NodeType) child;
- }
-
- // System.out.println("Astchain i: " + i + " currentobj : " + context.getCurrentObject() +
- // " and root: " + context.getRoot());
- if ( !(child instanceof ASTVarRef) && !constructor && !(
- child instanceof OrderedReturn
- && ( (OrderedReturn) child ).getLastExpression() != null ) && ( parent == null
- || !(parent instanceof ASTSequence)) )
- {
- value = OgnlRuntime.getCompiler( context ).castExpression( context, child, value );
- }
-
- /*
- * System.out.println("astchain value now : " + value + " with index " + i + " current type " +
- * context.getCurrentType() + " current accessor " + context.getCurrentAccessor() + " prev type " +
- * context.getPreviousType() + " prev accessor " + context.getPreviousAccessor());
- */
-
- if ( child instanceof OrderedReturn
- && ( (OrderedReturn) child ).getLastExpression() != null )
- {
- ordered = true;
- OrderedReturn or = (OrderedReturn) child;
-
- if ( or.getCoreExpression() == null || or.getCoreExpression().trim().isEmpty() )
- {
- result = "";
- }
- else
- {
- result += or.getCoreExpression();
- }
-
- lastExpression = or.getLastExpression();
-
- if ( context.get( ExpressionCompiler.PRE_CAST ) != null )
- {
- lastExpression = context.remove( ExpressionCompiler.PRE_CAST ) + lastExpression;
- }
- }
- else if ( child instanceof ASTOr || child instanceof ASTAnd
- || child instanceof ASTCtor || ( child instanceof ASTStaticField
- && parent == null ) )
- {
- context.put( "_noRoot", "true" );
- result = value;
- }
- else
- {
- result += value;
- }
-
- context.put( "_currentChain", result );
- }
- }
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
-
- if ( lastType != null )
- {
- getterClass = lastType.getGetterClass();
- setterClass = lastType.getSetterClass();
- }
-
- if ( ordered )
- {
- coreExpression = result;
- }
-
- context.put( "_currentChain", prevChain );
-
- return result;
- }
-
- public String toSetSourceString( OgnlContext context, Object target )
- {
- String prevChain = (String) context.get( "_currentChain" );
- String prevChild = (String) context.get( "_lastChild" );
-
- if ( prevChain != null )
- {
- throw new UnsupportedCompilationException( "Can't compile nested chain expressions." );
- }
-
- if ( target != null )
- {
- context.setCurrentObject( target );
- context.setCurrentType( target.getClass() );
- }
-
- String result = "";
- NodeType lastType = null;
- boolean constructor = false;
- try
- {
- if ( ( children != null ) && ( children.length > 0 ) )
- {
- if (children[0] instanceof ASTConst)
- {
- throw new UnsupportedCompilationException( "Can't modify constant values." );
- }
-
- for ( int i = 0; i < children.length; i++ )
- {
- // System.out.println("astchain setsource child[" + i + "] : " + _children[i].getClass().getName());
-
- if ( i == ( children.length - 1 ) )
- {
- context.put( "_lastChild", "true" );
- }
-
- String value = children[i].toSetSourceString( context, context.getCurrentObject() );
- // if (value == null || value.trim().isEmpty())
- // return "";
-
- // System.out.println("astchain setter child returned >> " + value + " <<");
-
- if (children[i] instanceof ASTCtor)
- {
- constructor = true;
- }
-
- if ( children[i] instanceof NodeType
- && ( (NodeType) children[i] ).getGetterClass() != null )
- {
- lastType = (NodeType) children[i];
- }
-
- if ( !(children[i] instanceof ASTVarRef)
- && !constructor
- && !( children[i] instanceof OrderedReturn
- && ( (OrderedReturn) children[i] ).getLastExpression() != null )
- && ( parent == null || !(parent instanceof ASTSequence)) )
- {
- value = OgnlRuntime.getCompiler( context ).castExpression( context, children[i], value );
- }
-
- // System.out.println("astchain setter after cast value is: " + value);
-
- /*
- * if (!constructor && !OrderedReturn.class.isInstance(_children[i]) && (_parent == null ||
- * !ASTSequence.class.isInstance(_parent))) { value =
- * OgnlRuntime.getCompiler().castExpression(context, _children[i], value); }
- */
-
- if ( children[i] instanceof ASTOr || children[i] instanceof ASTAnd
- || children[i] instanceof ASTCtor || children[i] instanceof ASTStaticField)
- {
- context.put( "_noRoot", "true" );
- result = value;
- }
- else
- {
- result += value;
- }
-
- context.put( "_currentChain", result );
- }
- }
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
-
- context.put( "_lastChild", prevChild );
- context.put( "_currentChain", prevChain );
-
- if ( lastType != null )
- {
- setterClass = lastType.getSetterClass();
- }
-
- return result;
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.ognl.enhance.ExpressionCompiler;
+import org.apache.commons.ognl.enhance.OrderedReturn;
+import org.apache.commons.ognl.enhance.UnsupportedCompilationException;
+
+import java.lang.reflect.Array;
+
+/**
+ */
+public class ASTChain
+ extends SimpleNode
+ implements NodeType, OrderedReturn
+{
+
+ private Class getterClass;
+
+ private Class setterClass;
+
+ private String lastExpression;
+
+ private String coreExpression;
+
+ public ASTChain( int id )
+ {
+ super( id );
+ }
+
+ public ASTChain( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ public String getLastExpression()
+ {
+ return lastExpression;
+ }
+
+ public String getCoreExpression()
+ {
+ return coreExpression;
+ }
+
+ 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) && (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 = ( len > 0 ) ? 0 : -1;
+ break;
+ case DynamicSubscript.MID:
+ index = ( len > 0 ) ? ( len / 2 ) : -1;
+ break;
+ case DynamicSubscript.LAST:
+ index = ( len > 0 ) ? ( len - 1 ) : -1;
+ break;
+ default:
+ 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) && (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 = ( len > 0 ) ? 0 : -1;
+ break;
+ case DynamicSubscript.MID:
+ index = ( len > 0 ) ? ( len / 2 ) : -1;
+ break;
+ case DynamicSubscript.LAST:
+ index = ( len > 0 ) ? ( len - 1 ) : -1;
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ if ( indexType == OgnlRuntime.INDEXED_PROPERTY_OBJECT )
+ {
+ throw new OgnlException( "DynamicSubscript '" + indexNode
+ + "' not allowed for object indexed property '" + propertyNode + "'" );
+ }
+ }
+ }
+ if ( !handled && i == ilast )
+ {
+ OgnlRuntime.setIndexedProperty( context, target,
+ propertyNode.getProperty( context, target ).toString(),
+ index, value );
+ handled = true;
+ i++;
+ }
+ else if ( !handled )
+ {
+ target =
+ OgnlRuntime.getIndexedProperty(
+ context,
+ target,
+ propertyNode.getProperty( context, target ).toString(),
+ index );
+ i++;
+ continue;
+ }
+ }
+ }
+ }
+ 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++ )
+ {
+ result =
+ children[i] instanceof SimpleNode && ( (SimpleNode) children[i] ).isSimpleProperty( context );
+ }
+ }
+ return result;
+ }
+
+ public Class getGetterClass()
+ {
+ return getterClass;
+ }
+
+ public Class getSetterClass()
+ {
+ return setterClass;
+ }
+
+ public String toGetSourceString( OgnlContext context, Object target )
+ {
+ String prevChain = (String) context.get( "_currentChain" );
+
+ if ( target != null )
+ {
+ context.setCurrentObject( target );
+ context.setCurrentType( target.getClass() );
+ }
+
+ String result = "";
+ NodeType lastType = null;
+ boolean ordered = false;
+ boolean constructor = false;
+ try
+ {
+ if ( ( children != null ) && ( children.length > 0 ) )
+ {
+ for ( Node child : children )
+ {
+ /*
+ * System.out.println("astchain child: " + _children[i].getClass().getName() +
+ * " with current object target " + context.getCurrentObject() + " current type: " +
+ * context.getCurrentType());
+ */
+
+ String value = child.toGetSourceString( context, context.getCurrentObject() );
+
+ // System.out.println("astchain child returned >> " + value + " <<");
+
+ if (child instanceof ASTCtor)
+ {
+ constructor = true;
+ }
+
+ if ( child instanceof NodeType && ( (NodeType) child ).getGetterClass() != null )
+ {
+ lastType = (NodeType) child;
+ }
+
+ // System.out.println("Astchain i: " + i + " currentobj : " + context.getCurrentObject() +
+ // " and root: " + context.getRoot());
+ if ( !(child instanceof ASTVarRef) && !constructor && !(
+ child instanceof OrderedReturn
+ && ( (OrderedReturn) child ).getLastExpression() != null ) && ( parent == null
+ || !(parent instanceof ASTSequence)) )
+ {
+ value = OgnlRuntime.getCompiler( context ).castExpression( context, child, value );
+ }
+
+ /*
+ * System.out.println("astchain value now : " + value + " with index " + i + " current type " +
+ * context.getCurrentType() + " current accessor " + context.getCurrentAccessor() + " prev type " +
+ * context.getPreviousType() + " prev accessor " + context.getPreviousAccessor());
+ */
+
+ if ( child instanceof OrderedReturn
+ && ( (OrderedReturn) child ).getLastExpression() != null )
+ {
+ ordered = true;
+ OrderedReturn or = (OrderedReturn) child;
+
+ if ( or.getCoreExpression() == null || or.getCoreExpression().trim().isEmpty() )
+ {
+ result = "";
+ }
+ else
+ {
+ result += or.getCoreExpression();
+ }
+
+ lastExpression = or.getLastExpression();
+
+ if ( context.get( ExpressionCompiler.PRE_CAST ) != null )
+ {
+ lastExpression = context.remove( ExpressionCompiler.PRE_CAST ) + lastExpression;
+ }
+ }
+ else if ( child instanceof ASTOr || child instanceof ASTAnd
+ || child instanceof ASTCtor || ( child instanceof ASTStaticField
+ && parent == null ) )
+ {
+ context.put( "_noRoot", "true" );
+ result = value;
+ }
+ else
+ {
+ result += value;
+ }
+
+ context.put( "_currentChain", result );
+ }
+ }
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+
+ if ( lastType != null )
+ {
+ getterClass = lastType.getGetterClass();
+ setterClass = lastType.getSetterClass();
+ }
+
+ if ( ordered )
+ {
+ coreExpression = result;
+ }
+
+ context.put( "_currentChain", prevChain );
+
+ return result;
+ }
+
+ public String toSetSourceString( OgnlContext context, Object target )
+ {
+ String prevChain = (String) context.get( "_currentChain" );
+ String prevChild = (String) context.get( "_lastChild" );
+
+ if ( prevChain != null )
+ {
+ throw new UnsupportedCompilationException( "Can't compile nested chain expressions." );
+ }
+
+ if ( target != null )
+ {
+ context.setCurrentObject( target );
+ context.setCurrentType( target.getClass() );
+ }
+
+ String result = "";
+ NodeType lastType = null;
+ boolean constructor = false;
+ try
+ {
+ if ( ( children != null ) && ( children.length > 0 ) )
+ {
+ if (children[0] instanceof ASTConst)
+ {
+ throw new UnsupportedCompilationException( "Can't modify constant values." );
+ }
+
+ for ( int i = 0; i < children.length; i++ )
+ {
+ // System.out.println("astchain setsource child[" + i + "] : " + _children[i].getClass().getName());
+
+ if ( i == ( children.length - 1 ) )
+ {
+ context.put( "_lastChild", "true" );
+ }
+
+ String value = children[i].toSetSourceString( context, context.getCurrentObject() );
+ // if (value == null || value.trim().isEmpty())
+ // return "";
+
+ // System.out.println("astchain setter child returned >> " + value + " <<");
+
+ if (children[i] instanceof ASTCtor)
+ {
+ constructor = true;
+ }
+
+ if ( children[i] instanceof NodeType
+ && ( (NodeType) children[i] ).getGetterClass() != null )
+ {
+ lastType = (NodeType) children[i];
+ }
+
+ if ( !(children[i] instanceof ASTVarRef)
+ && !constructor
+ && !( children[i] instanceof OrderedReturn
+ && ( (OrderedReturn) children[i] ).getLastExpression() != null )
+ && ( parent == null || !(parent instanceof ASTSequence)) )
+ {
+ value = OgnlRuntime.getCompiler( context ).castExpression( context, children[i], value );
+ }
+
+ // System.out.println("astchain setter after cast value is: " + value);
+
+ /*
+ * if (!constructor && !OrderedReturn.class.isInstance(_children[i]) && (_parent == null ||
+ * !ASTSequence.class.isInstance(_parent))) { value =
+ * OgnlRuntime.getCompiler().castExpression(context, _children[i], value); }
+ */
+
+ if ( children[i] instanceof ASTOr || children[i] instanceof ASTAnd
+ || children[i] instanceof ASTCtor || children[i] instanceof ASTStaticField)
+ {
+ context.put( "_noRoot", "true" );
+ result = value;
+ }
+ else
+ {
+ result += value;
+ }
+
+ context.put( "_currentChain", result );
+ }
+ }
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+
+ context.put( "_lastChild", prevChild );
+ context.put( "_currentChain", prevChain );
+
+ if ( lastType != null )
+ {
+ setterClass = lastType.getSetterClass();
+ }
+
+ return result;
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTConst.java b/src/main/java/org/apache/commons/ognl/ASTConst.java
index 9813f3a..590208a 100644
--- a/src/main/java/org/apache/commons/ognl/ASTConst.java
+++ b/src/main/java/org/apache/commons/ognl/ASTConst.java
@@ -1,171 +1,170 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.ognl.enhance.UnsupportedCompilationException;
-
-/**
- * $Id$
- */
-public class ASTConst
- extends SimpleNode
- implements NodeType
-{
-
- private Object value;
-
- private Class getterClass;
-
- public ASTConst( int id )
- {
- super( id );
- }
-
- public ASTConst( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- /**
- * Called from parser actions.
- * @param value the value to set
- */
- public 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 Class getGetterClass()
- {
- return getterClass;
- }
-
- public Class getSetterClass()
- {
- return null;
- }
-
- public String toGetSourceString( OgnlContext context, Object target )
- {
- if ( value == null && parent != null && parent instanceof ExpressionNode)
- {
- context.setCurrentType( null );
- return "null";
- }
- if ( value == null )
- {
- context.setCurrentType( null );
- return "";
- }
-
- getterClass = value.getClass();
-
- Object retval = value;
- if ( parent != null && parent instanceof ASTProperty)
- {
- context.setCurrentObject( value );
-
- return value.toString();
- }
- if ( value != null && Number.class.isAssignableFrom( value.getClass() ) )
- {
- context.setCurrentType( OgnlRuntime.getPrimitiveWrapperClass( value.getClass() ) );
- context.setCurrentObject( value );
-
- return value.toString();
- }
- if ( !( parent != null
- && value != null
- && NumericExpression.class.isAssignableFrom( parent.getClass() ) )
- && String.class.isAssignableFrom( value.getClass() ) )
- {
- context.setCurrentType( String.class );
-
- retval = '\"' + OgnlOps.getEscapeString( value.toString() ) + '\"';
-
- context.setCurrentObject( retval.toString() );
-
- return retval.toString();
- }
- if (value instanceof Character)
- {
- Character val = (Character) value;
-
- context.setCurrentType( Character.class );
-
- if ( Character.isLetterOrDigit( val.charValue() ) )
- {
- retval = "'" + ( (Character) value ).charValue() + "'";
- }
- else
- {
- retval = "'" + OgnlOps.getEscapedChar( ( (Character) value ).charValue() ) + "'";
- }
-
- context.setCurrentObject( retval );
- return retval.toString();
- }
-
- if ( Boolean.class.isAssignableFrom( value.getClass() ) )
- {
- getterClass = Boolean.TYPE;
-
- context.setCurrentType( Boolean.TYPE );
- context.setCurrentObject( value );
-
- return value.toString();
- }
-
- return value.toString();
- }
-
- public String toSetSourceString( OgnlContext context, Object target )
- {
- if ( parent == null )
- {
- throw new UnsupportedCompilationException( "Can't modify constant values." );
- }
-
- return toGetSourceString( context, target );
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.ognl.enhance.UnsupportedCompilationException;
+
+/**
+ */
+public class ASTConst
+ extends SimpleNode
+ implements NodeType
+{
+
+ private Object value;
+
+ private Class getterClass;
+
+ public ASTConst( int id )
+ {
+ super( id );
+ }
+
+ public ASTConst( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ /**
+ * Called from parser actions.
+ * @param value the value to set
+ */
+ public 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 Class getGetterClass()
+ {
+ return getterClass;
+ }
+
+ public Class getSetterClass()
+ {
+ return null;
+ }
+
+ public String toGetSourceString( OgnlContext context, Object target )
+ {
+ if ( value == null && parent != null && parent instanceof ExpressionNode)
+ {
+ context.setCurrentType( null );
+ return "null";
+ }
+ if ( value == null )
+ {
+ context.setCurrentType( null );
+ return "";
+ }
+
+ getterClass = value.getClass();
+
+ Object retval = value;
+ if ( parent != null && parent instanceof ASTProperty)
+ {
+ context.setCurrentObject( value );
+
+ return value.toString();
+ }
+ if ( value != null && Number.class.isAssignableFrom( value.getClass() ) )
+ {
+ context.setCurrentType( OgnlRuntime.getPrimitiveWrapperClass( value.getClass() ) );
+ context.setCurrentObject( value );
+
+ return value.toString();
+ }
+ if ( !( parent != null
+ && value != null
+ && NumericExpression.class.isAssignableFrom( parent.getClass() ) )
+ && String.class.isAssignableFrom( value.getClass() ) )
+ {
+ context.setCurrentType( String.class );
+
+ retval = '\"' + OgnlOps.getEscapeString( value.toString() ) + '\"';
+
+ context.setCurrentObject( retval.toString() );
+
+ return retval.toString();
+ }
+ if (value instanceof Character)
+ {
+ Character val = (Character) value;
+
+ context.setCurrentType( Character.class );
+
+ if ( Character.isLetterOrDigit( val.charValue() ) )
+ {
+ retval = "'" + ( (Character) value ).charValue() + "'";
+ }
+ else
+ {
+ retval = "'" + OgnlOps.getEscapedChar( ( (Character) value ).charValue() ) + "'";
+ }
+
+ context.setCurrentObject( retval );
+ return retval.toString();
+ }
+
+ if ( Boolean.class.isAssignableFrom( value.getClass() ) )
+ {
+ getterClass = Boolean.TYPE;
+
+ context.setCurrentType( Boolean.TYPE );
+ context.setCurrentObject( value );
+
+ return value.toString();
+ }
+
+ return value.toString();
+ }
+
+ public String toSetSourceString( OgnlContext context, Object target )
+ {
+ if ( parent == null )
+ {
+ throw new UnsupportedCompilationException( "Can't modify constant values." );
+ }
+
+ return toGetSourceString( context, target );
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTCtor.java b/src/main/java/org/apache/commons/ognl/ASTCtor.java
index 5ac44a6..8d3b594 100644
--- a/src/main/java/org/apache/commons/ognl/ASTCtor.java
+++ b/src/main/java/org/apache/commons/ognl/ASTCtor.java
@@ -1,362 +1,361 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.ognl.enhance.ExpressionCompiler;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.Constructor;
-import java.util.List;
-
-/**
- * $Id$
- */
-public 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;
- }
-
- /**
- * Get the class name for this constructor.
- *
- * @return the class name.
- * @since 4.0
- */
- String getClassName()
- {
- return className;
- }
-
-
- void setArray( boolean value )
- {
- isArray = value;
- }
-
- public boolean isArray()
- {
- return isArray;
- }
-
- protected Object getValueBody( OgnlContext context, Object source )
- throws OgnlException
- {
- Object result, root = context.getRoot();
- int count = jjtGetNumChildren();
- Object[] args = new Object[count];
-
- for ( int i = 0; i < count; ++i )
- {
- args[i] = children[i].getValue( context, root );
- }
- if ( isArray )
- {
- if ( args.length != 1 ) {
- throw new OgnlException( "only expect array size or fixed initializer list" );
- }
- 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
- {
- result = OgnlRuntime.callConstructor( context, className, args );
- }
-
- return result;
- }
-
-
- public String toGetSourceString( OgnlContext context, Object target )
- {
- StringBuilder result = new StringBuilder("new " + className);
-
- Class clazz = null;
- Object ctorValue = null;
- try
- {
-
- clazz = OgnlRuntime.classForName( context, className );
-
- ctorValue = this.getValueBody( context, target );
- context.setCurrentObject( ctorValue );
-
- if ( ctorValue != null )
- {
-
- context.setCurrentType( ctorValue.getClass() );
- context.setCurrentAccessor( ctorValue.getClass() );
- }
-
- if ( isArray )
- {
- context.put( "_ctorClass", clazz );
- }
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
-
- try
- {
-
- if ( isArray )
- {
- if ( children[0] instanceof ASTConst )
- {
-
- result.append("[").append(children[0].toGetSourceString(context, target)).append("]");
- }
- else if (children[0] instanceof ASTProperty)
- {
-
- result.append("[").append(ExpressionCompiler.getRootExpression(children[0], target, context)).append(children[0].toGetSourceString(context, target)).append("]");
- }
- else if (children[0] instanceof ASTChain)
- {
-
- result.append("[").append(children[0].toGetSourceString(context, target)).append("]");
- }
- else
- {
-
- result.append("[] ").append(children[0].toGetSourceString(context, target));
- }
-
- }
- else
- {
- result.append("(");
-
- if ( ( children != null ) && ( children.length > 0 ) )
- {
-
- Object[] values = new Object[children.length];
- String[] expressions = new String[children.length];
- Class[] types = new Class[children.length];
-
- // first populate arrays with child values
-
- for ( int i = 0; i < children.length; i++ )
- {
-
- Object objValue = children[i].getValue( context, context.getRoot() );
- String value = children[i].toGetSourceString( context, target );
-
- if ( !(children[i] instanceof ASTRootVarRef))
- {
- value = ExpressionCompiler.getRootExpression( children[i], target, context ) + value;
- }
-
- String cast = "";
- if ( ExpressionCompiler.shouldCast( children[i] ) )
- {
-
- cast = (String) context.remove( ExpressionCompiler.PRE_CAST );
- }
- if ( cast == null )
- {
- cast = "";
- }
-
- if ( !(children[i] instanceof ASTConst))
- {
- value = cast + value;
- }
-
- values[i] = objValue;
- expressions[i] = value;
- types[i] = context.getCurrentType();
- }
-
- // now try and find a matching constructor
-
- Constructor[] cons = clazz.getConstructors();
- Constructor ctor = null;
- Class[] ctorParamTypes = null;
-
- for ( int i = 0; i < cons.length; i++ )
- {
- Class[] ctorTypes = cons[i].getParameterTypes();
-
- if ( OgnlRuntime.areArgsCompatible( values, ctorTypes )
- && ( ctor == null || OgnlRuntime.isMoreSpecific( ctorTypes, ctorParamTypes ) ) )
- {
- ctor = cons[i];
- ctorParamTypes = ctorTypes;
- }
- }
-
- if ( ctor == null )
- {
- ctor =
- OgnlRuntime.getConvertedConstructorAndArgs( context, clazz,
- OgnlRuntime.getConstructors( clazz ), values,
- new Object[values.length] );
- }
-
- if ( ctor == null )
- {
- throw new NoSuchMethodException(
- "Unable to find constructor appropriate for arguments in class: " + clazz );
- }
- ctorParamTypes = ctor.getParameterTypes();
-
- // now loop over child values again and build up the actual source string
-
- for ( int i = 0; i < children.length; i++ )
- {
- if ( i > 0 )
- {
- result.append(", ");
- }
-
- String value = expressions[i];
-
- if ( types[i].isPrimitive() )
- {
-
- String literal = OgnlRuntime.getNumericLiteral( types[i] );
- if ( literal != null )
- {
- value += literal;
- }
- }
-
- if ( ctorParamTypes[i] != types[i] )
- {
-
- if ( values[i] != null && !types[i].isPrimitive() && !values[i].getClass().isArray()
- && !(children[i] instanceof ASTConst))
- {
-
- value =
- "(" + OgnlRuntime.getCompiler( context ).getInterfaceClass( values[i].getClass() ).getName()
- + ")" + value;
- }
- else if ( !(children[i] instanceof ASTConst)
- || ( children[i] instanceof ASTConst && !types[i].isPrimitive() ) )
- {
-
- if ( !types[i].isArray() && types[i].isPrimitive() && !ctorParamTypes[i].isPrimitive() )
- {
- value =
- "new "
- + ExpressionCompiler.getCastString(
- OgnlRuntime.getPrimitiveWrapperClass( types[i] ) )
- + "(" + value + ")";
- }
- else
- {
- value = " ($w) " + value;
- }
- }
- }
-
- result.append(value);
- }
-
- }
- result.append(")");
- }
-
- context.setCurrentType( ctorValue != null ? ctorValue.getClass() : clazz );
- context.setCurrentAccessor( clazz );
- context.setCurrentObject( ctorValue );
-
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
-
- context.remove( "_ctorClass" );
-
- return result.toString();
- }
-
- public String toSetSourceString( OgnlContext context, Object target )
- {
- return "";
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.ognl.enhance.ExpressionCompiler;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Constructor;
+import java.util.List;
+
+/**
+ */
+public 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;
+ }
+
+ /**
+ * Get the class name for this constructor.
+ *
+ * @return the class name.
+ * @since 4.0
+ */
+ String getClassName()
+ {
+ return className;
+ }
+
+
+ void setArray( boolean value )
+ {
+ isArray = value;
+ }
+
+ public boolean isArray()
+ {
+ return isArray;
+ }
+
+ protected Object getValueBody( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ Object result, root = context.getRoot();
+ int count = jjtGetNumChildren();
+ Object[] args = new Object[count];
+
+ for ( int i = 0; i < count; ++i )
+ {
+ args[i] = children[i].getValue( context, root );
+ }
+ if ( isArray )
+ {
+ if ( args.length != 1 ) {
+ throw new OgnlException( "only expect array size or fixed initializer list" );
+ }
+ 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
+ {
+ result = OgnlRuntime.callConstructor( context, className, args );
+ }
+
+ return result;
+ }
+
+
+ public String toGetSourceString( OgnlContext context, Object target )
+ {
+ StringBuilder result = new StringBuilder("new " + className);
+
+ Class clazz = null;
+ Object ctorValue = null;
+ try
+ {
+
+ clazz = OgnlRuntime.classForName( context, className );
+
+ ctorValue = this.getValueBody( context, target );
+ context.setCurrentObject( ctorValue );
+
+ if ( ctorValue != null )
+ {
+
+ context.setCurrentType( ctorValue.getClass() );
+ context.setCurrentAccessor( ctorValue.getClass() );
+ }
+
+ if ( isArray )
+ {
+ context.put( "_ctorClass", clazz );
+ }
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+
+ try
+ {
+
+ if ( isArray )
+ {
+ if ( children[0] instanceof ASTConst )
+ {
+
+ result.append("[").append(children[0].toGetSourceString(context, target)).append("]");
+ }
+ else if (children[0] instanceof ASTProperty)
+ {
+
+ result.append("[").append(ExpressionCompiler.getRootExpression(children[0], target, context)).append(children[0].toGetSourceString(context, target)).append("]");
+ }
+ else if (children[0] instanceof ASTChain)
+ {
+
+ result.append("[").append(children[0].toGetSourceString(context, target)).append("]");
+ }
+ else
+ {
+
+ result.append("[] ").append(children[0].toGetSourceString(context, target));
+ }
+
+ }
+ else
+ {
+ result.append("(");
+
+ if ( ( children != null ) && ( children.length > 0 ) )
+ {
+
+ Object[] values = new Object[children.length];
+ String[] expressions = new String[children.length];
+ Class[] types = new Class[children.length];
+
+ // first populate arrays with child values
+
+ for ( int i = 0; i < children.length; i++ )
+ {
+
+ Object objValue = children[i].getValue( context, context.getRoot() );
+ String value = children[i].toGetSourceString( context, target );
+
+ if ( !(children[i] instanceof ASTRootVarRef))
+ {
+ value = ExpressionCompiler.getRootExpression( children[i], target, context ) + value;
+ }
+
+ String cast = "";
+ if ( ExpressionCompiler.shouldCast( children[i] ) )
+ {
+
+ cast = (String) context.remove( ExpressionCompiler.PRE_CAST );
+ }
+ if ( cast == null )
+ {
+ cast = "";
+ }
+
+ if ( !(children[i] instanceof ASTConst))
+ {
+ value = cast + value;
+ }
+
+ values[i] = objValue;
+ expressions[i] = value;
+ types[i] = context.getCurrentType();
+ }
+
+ // now try and find a matching constructor
+
+ Constructor[] cons = clazz.getConstructors();
+ Constructor ctor = null;
+ Class[] ctorParamTypes = null;
+
+ for ( int i = 0; i < cons.length; i++ )
+ {
+ Class[] ctorTypes = cons[i].getParameterTypes();
+
+ if ( OgnlRuntime.areArgsCompatible( values, ctorTypes )
+ && ( ctor == null || OgnlRuntime.isMoreSpecific( ctorTypes, ctorParamTypes ) ) )
+ {
+ ctor = cons[i];
+ ctorParamTypes = ctorTypes;
+ }
+ }
+
+ if ( ctor == null )
+ {
+ ctor =
+ OgnlRuntime.getConvertedConstructorAndArgs( context, clazz,
+ OgnlRuntime.getConstructors( clazz ), values,
+ new Object[values.length] );
+ }
+
+ if ( ctor == null )
+ {
+ throw new NoSuchMethodException(
+ "Unable to find constructor appropriate for arguments in class: " + clazz );
+ }
+ ctorParamTypes = ctor.getParameterTypes();
+
+ // now loop over child values again and build up the actual source string
+
+ for ( int i = 0; i < children.length; i++ )
+ {
+ if ( i > 0 )
+ {
+ result.append(", ");
+ }
+
+ String value = expressions[i];
+
+ if ( types[i].isPrimitive() )
+ {
+
+ String literal = OgnlRuntime.getNumericLiteral( types[i] );
+ if ( literal != null )
+ {
+ value += literal;
+ }
+ }
+
+ if ( ctorParamTypes[i] != types[i] )
+ {
+
+ if ( values[i] != null && !types[i].isPrimitive() && !values[i].getClass().isArray()
+ && !(children[i] instanceof ASTConst))
+ {
+
+ value =
+ "(" + OgnlRuntime.getCompiler( context ).getInterfaceClass( values[i].getClass() ).getName()
+ + ")" + value;
+ }
+ else if ( !(children[i] instanceof ASTConst)
+ || ( children[i] instanceof ASTConst && !types[i].isPrimitive() ) )
+ {
+
+ if ( !types[i].isArray() && types[i].isPrimitive() && !ctorParamTypes[i].isPrimitive() )
+ {
+ value =
+ "new "
+ + ExpressionCompiler.getCastString(
+ OgnlRuntime.getPrimitiveWrapperClass( types[i] ) )
+ + "(" + value + ")";
+ }
+ else
+ {
+ value = " ($w) " + value;
+ }
+ }
+ }
+
+ result.append(value);
+ }
+
+ }
+ result.append(")");
+ }
+
+ context.setCurrentType( ctorValue != null ? ctorValue.getClass() : clazz );
+ context.setCurrentAccessor( clazz );
+ context.setCurrentObject( ctorValue );
+
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+
+ context.remove( "_ctorClass" );
+
+ return result.toString();
+ }
+
+ public String toSetSourceString( OgnlContext context, Object target )
+ {
+ return "";
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTDivide.java b/src/main/java/org/apache/commons/ognl/ASTDivide.java
index b74948e..7b37606 100644
--- a/src/main/java/org/apache/commons/ognl/ASTDivide.java
+++ b/src/main/java/org/apache/commons/ognl/ASTDivide.java
@@ -1,57 +1,56 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * $Id$
- */
-class ASTDivide
- extends NumericExpression
-{
- public ASTDivide( int id )
- {
- super( 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 );
- }
-
- public String getExpressionOperator( int index )
- {
- return "/";
- }
-
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ */
+class ASTDivide
+ extends NumericExpression
+{
+ public ASTDivide( int id )
+ {
+ super( 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 );
+ }
+
+ public String getExpressionOperator( int index )
+ {
+ return "/";
+ }
+
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTEq.java b/src/main/java/org/apache/commons/ognl/ASTEq.java
index 1479110..319432d 100644
--- a/src/main/java/org/apache/commons/ognl/ASTEq.java
+++ b/src/main/java/org/apache/commons/ognl/ASTEq.java
@@ -1,61 +1,60 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * $Id$
- */
-class ASTEq
- extends ComparisonExpression
-{
- public ASTEq( int id )
- {
- super( 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;
- }
-
- public String getExpressionOperator( int index )
- {
- return "==";
- }
-
- public String getComparisonFunction()
- {
- return "org.apache.commons.ognl.OgnlOps.equal";
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ */
+class ASTEq
+ extends ComparisonExpression
+{
+ public ASTEq( int id )
+ {
+ super( 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;
+ }
+
+ public String getExpressionOperator( int index )
+ {
+ return "==";
+ }
+
+ public String getComparisonFunction()
+ {
+ return "org.apache.commons.ognl.OgnlOps.equal";
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTEval.java b/src/main/java/org/apache/commons/ognl/ASTEval.java
index f098a5a..b27cc33 100644
--- a/src/main/java/org/apache/commons/ognl/ASTEval.java
+++ b/src/main/java/org/apache/commons/ognl/ASTEval.java
@@ -1,102 +1,101 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.ognl.enhance.UnsupportedCompilationException;
-
-/**
- * $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;
- }
-
- 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 toGetSourceString( OgnlContext context, Object target )
- {
- throw new UnsupportedCompilationException( "Eval expressions not supported as native java yet." );
- }
-
- public String toSetSourceString( OgnlContext context, Object target )
- {
- throw new UnsupportedCompilationException( "Map expressions not supported as native java yet." );
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-
- @Override
- public boolean isEvalChain( OgnlContext context )
- throws OgnlException
- {
- return true;
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.ognl.enhance.UnsupportedCompilationException;
+
+/**
+ */
+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;
+ }
+
+ 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 toGetSourceString( OgnlContext context, Object target )
+ {
+ throw new UnsupportedCompilationException( "Eval expressions not supported as native java yet." );
+ }
+
+ public String toSetSourceString( OgnlContext context, Object target )
+ {
+ throw new UnsupportedCompilationException( "Map expressions not supported as native java yet." );
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+
+ @Override
+ public boolean isEvalChain( OgnlContext context )
+ throws OgnlException
+ {
+ return true;
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTGreater.java b/src/main/java/org/apache/commons/ognl/ASTGreater.java
index 00c9968..8c44352 100644
--- a/src/main/java/org/apache/commons/ognl/ASTGreater.java
+++ b/src/main/java/org/apache/commons/ognl/ASTGreater.java
@@ -1,62 +1,61 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * $Id$
- */
-class ASTGreater
- extends ComparisonExpression
-{
- public ASTGreater( int id )
- {
- super( 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;
- }
-
- public String getExpressionOperator( int index )
- {
- return ">";
- }
-
- public String getComparisonFunction()
- {
- return "org.apache.commons.ognl.OgnlOps.greater";
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ */
+class ASTGreater
+ extends ComparisonExpression
+{
+ public ASTGreater( int id )
+ {
+ super( 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;
+ }
+
+ public String getExpressionOperator( int index )
+ {
+ return ">";
+ }
+
+ public String getComparisonFunction()
+ {
+ return "org.apache.commons.ognl.OgnlOps.greater";
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTGreaterEq.java b/src/main/java/org/apache/commons/ognl/ASTGreaterEq.java
index fb3b606..156e0b1 100644
--- a/src/main/java/org/apache/commons/ognl/ASTGreaterEq.java
+++ b/src/main/java/org/apache/commons/ognl/ASTGreaterEq.java
@@ -1,61 +1,60 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * $Id$
- */
-class ASTGreaterEq
- extends ComparisonExpression
-{
- public ASTGreaterEq( int id )
- {
- super( 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;
- }
-
- public String getExpressionOperator( int index )
- {
- return ">=";
- }
-
- public String getComparisonFunction()
- {
- return "!org.apache.commons.ognl.OgnlOps.less";
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ */
+class ASTGreaterEq
+ extends ComparisonExpression
+{
+ public ASTGreaterEq( int id )
+ {
+ super( 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;
+ }
+
+ public String getExpressionOperator( int index )
+ {
+ return ">=";
+ }
+
+ public String getComparisonFunction()
+ {
+ return "!org.apache.commons.ognl.OgnlOps.less";
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTIn.java b/src/main/java/org/apache/commons/ognl/ASTIn.java
index 4c990b8..e26bcfb 100644
--- a/src/main/java/org/apache/commons/ognl/ASTIn.java
+++ b/src/main/java/org/apache/commons/ognl/ASTIn.java
@@ -1,100 +1,99 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.ognl.enhance.UnsupportedCompilationException;
-
-/**
- * $Id$
- */
-class ASTIn
- extends SimpleNode
- implements NodeType
-{
- public ASTIn( int id )
- {
- super( 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;
- }
-
- public Class getGetterClass()
- {
- return Boolean.TYPE;
- }
-
- public Class getSetterClass()
- {
- return null;
- }
-
- public String toGetSourceString( OgnlContext context, Object target )
- {
- try
- {
- String result = "org.apache.commons.ognl.OgnlOps.in( ($w) ";
-
- result +=
- OgnlRuntime.getChildSource( context, target, children[0] ) + ", ($w) "
- + OgnlRuntime.getChildSource( context, target, children[1] );
-
- result += ")";
-
- context.setCurrentType( Boolean.TYPE );
-
- return result;
- }
- catch ( NullPointerException e )
- {
-
- // expected to happen in some instances
- e.printStackTrace();
-
- throw new UnsupportedCompilationException( "evaluation resulted in null expression." );
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
- }
-
- public String toSetSourceString( OgnlContext context, Object target )
- {
- throw new UnsupportedCompilationException( "Map expressions not supported as native java yet." );
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.ognl.enhance.UnsupportedCompilationException;
+
+/**
+ */
+class ASTIn
+ extends SimpleNode
+ implements NodeType
+{
+ public ASTIn( int id )
+ {
+ super( 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;
+ }
+
+ public Class getGetterClass()
+ {
+ return Boolean.TYPE;
+ }
+
+ public Class getSetterClass()
+ {
+ return null;
+ }
+
+ public String toGetSourceString( OgnlContext context, Object target )
+ {
+ try
+ {
+ String result = "org.apache.commons.ognl.OgnlOps.in( ($w) ";
+
+ result +=
+ OgnlRuntime.getChildSource( context, target, children[0] ) + ", ($w) "
+ + OgnlRuntime.getChildSource( context, target, children[1] );
+
+ result += ")";
+
+ context.setCurrentType( Boolean.TYPE );
+
+ return result;
+ }
+ catch ( NullPointerException e )
+ {
+
+ // expected to happen in some instances
+ e.printStackTrace();
+
+ throw new UnsupportedCompilationException( "evaluation resulted in null expression." );
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+ }
+
+ public String toSetSourceString( OgnlContext context, Object target )
+ {
+ throw new UnsupportedCompilationException( "Map expressions not supported as native java yet." );
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTInstanceof.java b/src/main/java/org/apache/commons/ognl/ASTInstanceof.java
index 9eb4b5d..10540ae 100644
--- a/src/main/java/org/apache/commons/ognl/ASTInstanceof.java
+++ b/src/main/java/org/apache/commons/ognl/ASTInstanceof.java
@@ -1,104 +1,103 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * $Id$
- */
-public class ASTInstanceof
- extends SimpleNode
- implements NodeType
-{
- private String targetType;
-
- public ASTInstanceof( int id )
- {
- super( id );
- }
-
- public ASTInstanceof( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- void setTargetType( String targetType )
- {
- this.targetType = targetType;
- }
-
- String getTargetType()
- {
- return 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;
- }
-
- public Class getGetterClass()
- {
- return boolean.class;
- }
-
- public Class getSetterClass()
- {
- return null;
- }
-
- public String toGetSourceString( OgnlContext context, Object target )
- {
- try
- {
-
- String ret = "";
-
- if (children[0] instanceof ASTConst)
- {
- ret = ( (Boolean) getValueBody( context, target ) ).toString();
- }
- else
- {
- ret = children[0].toGetSourceString( context, target ) + " instanceof " + targetType;
- }
- context.setCurrentType( Boolean.TYPE );
-
- return ret;
-
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
- }
-
- public String toSetSourceString( OgnlContext context, Object target )
- {
- return toGetSourceString( context, target );
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ */
+public class ASTInstanceof
+ extends SimpleNode
+ implements NodeType
+{
+ private String targetType;
+
+ public ASTInstanceof( int id )
+ {
+ super( id );
+ }
+
+ public ASTInstanceof( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ void setTargetType( String targetType )
+ {
+ this.targetType = targetType;
+ }
+
+ String getTargetType()
+ {
+ return 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;
+ }
+
+ public Class getGetterClass()
+ {
+ return boolean.class;
+ }
+
+ public Class getSetterClass()
+ {
+ return null;
+ }
+
+ public String toGetSourceString( OgnlContext context, Object target )
+ {
+ try
+ {
+
+ String ret = "";
+
+ if (children[0] instanceof ASTConst)
+ {
+ ret = ( (Boolean) getValueBody( context, target ) ).toString();
+ }
+ else
+ {
+ ret = children[0].toGetSourceString( context, target ) + " instanceof " + targetType;
+ }
+ context.setCurrentType( Boolean.TYPE );
+
+ return ret;
+
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+ }
+
+ public String toSetSourceString( OgnlContext context, Object target )
+ {
+ return toGetSourceString( context, target );
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTKeyValue.java b/src/main/java/org/apache/commons/ognl/ASTKeyValue.java
index 134e264..8248b32 100644
--- a/src/main/java/org/apache/commons/ognl/ASTKeyValue.java
+++ b/src/main/java/org/apache/commons/ognl/ASTKeyValue.java
@@ -1,62 +1,61 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * $Id$
- */
-class ASTKeyValue
- extends SimpleNode
-{
- public ASTKeyValue( int id )
- {
- super( id );
- }
-
- public ASTKeyValue( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- protected Node getKey()
- {
- return children[0];
- }
-
- 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;
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ */
+class ASTKeyValue
+ extends SimpleNode
+{
+ public ASTKeyValue( int id )
+ {
+ super( id );
+ }
+
+ public ASTKeyValue( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ protected Node getKey()
+ {
+ return children[0];
+ }
+
+ 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;
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTLess.java b/src/main/java/org/apache/commons/ognl/ASTLess.java
index fb8c8a4..1bec541 100644
--- a/src/main/java/org/apache/commons/ognl/ASTLess.java
+++ b/src/main/java/org/apache/commons/ognl/ASTLess.java
@@ -1,62 +1,61 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * $Id$
- */
-class ASTLess
- extends ComparisonExpression
-{
- public ASTLess( int id )
- {
- super( 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;
- }
-
- public String getExpressionOperator( int index )
- {
- return "<";
- }
-
- public String getComparisonFunction()
- {
- return "org.apache.commons.ognl.OgnlOps.less";
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ */
+class ASTLess
+ extends ComparisonExpression
+{
+ public ASTLess( int id )
+ {
+ super( 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;
+ }
+
+ public String getExpressionOperator( int index )
+ {
+ return "<";
+ }
+
+ public String getComparisonFunction()
+ {
+ return "org.apache.commons.ognl.OgnlOps.less";
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTLessEq.java b/src/main/java/org/apache/commons/ognl/ASTLessEq.java
index 2fd093b..5e93a1a 100644
--- a/src/main/java/org/apache/commons/ognl/ASTLessEq.java
+++ b/src/main/java/org/apache/commons/ognl/ASTLessEq.java
@@ -1,62 +1,61 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * $Id$
- */
-class ASTLessEq
- extends ComparisonExpression
-{
- public ASTLessEq( int id )
- {
- super( 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;
- }
-
- public String getExpressionOperator( int index )
- {
- return "<=";
- }
-
- public String getComparisonFunction()
- {
- return "!org.apache.commons.ognl.OgnlOps.greater";
- }
-
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ */
+class ASTLessEq
+ extends ComparisonExpression
+{
+ public ASTLessEq( int id )
+ {
+ super( 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;
+ }
+
+ public String getExpressionOperator( int index )
+ {
+ return "<=";
+ }
+
+ public String getComparisonFunction()
+ {
+ return "!org.apache.commons.ognl.OgnlOps.greater";
+ }
+
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTList.java b/src/main/java/org/apache/commons/ognl/ASTList.java
index eb019a7..19296da 100644
--- a/src/main/java/org/apache/commons/ognl/ASTList.java
+++ b/src/main/java/org/apache/commons/ognl/ASTList.java
@@ -1,222 +1,221 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.ognl.enhance.ExpressionCompiler;
-import org.apache.commons.ognl.enhance.OgnlExpressionCompiler;
-import org.apache.commons.ognl.enhance.UnsupportedCompilationException;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * $Id$
- */
-public class ASTList
- extends SimpleNode
- implements NodeType
-{
- 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 Class getGetterClass()
- {
- return null;
- }
-
- public Class getSetterClass()
- {
- return null;
- }
-
- public String toGetSourceString( OgnlContext context, Object target )
- {
- StringBuilder result = new StringBuilder();
- boolean array = parent instanceof ASTCtor && ((ASTCtor) parent).isArray();
-
- context.setCurrentType( List.class );
- context.setCurrentAccessor( List.class );
-
- if ( !array )
- {
- if ( jjtGetNumChildren() < 1 )
- {
- return "java.util.Arrays.asList( new Object[0])";
- }
- result.append("java.util.Arrays.asList( new Object[] ");
- }
-
- result.append("{ ");
-
- try
- {
-
- for ( int i = 0; i < jjtGetNumChildren(); ++i )
- {
- if ( i > 0 )
- {
- result.append(", ");
- }
-
- Class prevType = context.getCurrentType();
-
- Object objValue = children[i].getValue( context, context.getRoot() );
- String value = children[i].toGetSourceString( context, target );
-
- // to undo type setting of constants when used as method parameters
- if (children[i] instanceof ASTConst)
- {
-
- context.setCurrentType( prevType );
- }
-
- value = ExpressionCompiler.getRootExpression( children[i], target, context ) + value;
-
- String cast = "";
- if ( ExpressionCompiler.shouldCast( children[i] ) )
- {
-
- cast = (String) context.remove( ExpressionCompiler.PRE_CAST );
- }
- if ( cast == null )
- {
- cast = "";
- }
-
- if ( !(children[i] instanceof ASTConst))
- {
- value = cast + value;
- }
- Class ctorClass = (Class) context.get( "_ctorClass" );
- if ( array && ctorClass != null && !ctorClass.isPrimitive() )
- {
-
- Class valueClass = value != null ? value.getClass() : null;
- if ( NodeType.class.isAssignableFrom( children[i].getClass() ) )
- {
- valueClass = ( (NodeType) children[i] ).getGetterClass();
- }
- final OgnlExpressionCompiler compiler = OgnlRuntime.getCompiler( context );
- if ( valueClass != null && ctorClass.isArray() )
- {
-
- value =
- compiler
- .createLocalReference( context, "(" + ExpressionCompiler.getCastString( ctorClass )
- + ")org.apache.commons.ognl.OgnlOps.toArray(" + value + ", "
- + ctorClass.getComponentType().getName() + ".class, true)", ctorClass );
-
- }
- else if ( ctorClass.isPrimitive() )
- {
-
- Class wrapClass = OgnlRuntime.getPrimitiveWrapperClass( ctorClass );
-
- value =
- compiler
- .createLocalReference( context, "((" + wrapClass.getName()
- + ")org.apache.commons.ognl.OgnlOps.convertValue(" + value + ","
- + wrapClass.getName() + ".class, true))." + OgnlRuntime.getNumericValueGetter(
- wrapClass ), ctorClass );
- }
- else if ( ctorClass != Object.class )
- {
-
- value =
- compiler
- .createLocalReference( context, "(" + ctorClass.getName()
- + ")org.apache.commons.ognl.OgnlOps.convertValue(" + value + ","
- + ctorClass.getName() + ".class)", ctorClass );
-
- }
- else if ( ( children[i] instanceof NodeType
- && ( (NodeType) children[i] ).getGetterClass() != null
- && Number.class.isAssignableFrom( ( (NodeType) children[i] ).getGetterClass() ) )
- || valueClass.isPrimitive() )
- {
-
- value = " ($w) (" + value + ")";
- }
- else if ( valueClass.isPrimitive() )
- {
- value = "($w) (" + value + ")";
- }
-
- }
- else if ( ctorClass == null || !ctorClass.isPrimitive() )
- {
-
- value = " ($w) (" + value + ")";
- }
-
- if ( objValue == null || value.isEmpty() )
- {
- value = "null";
- }
- result.append(value);
- }
-
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
-
- context.setCurrentType( List.class );
- context.setCurrentAccessor( List.class );
-
- result.append("}");
-
- if ( !array )
- {
- result.append(")");
- }
- return result.toString();
- }
-
- public String toSetSourceString( OgnlContext context, Object target )
- {
- throw new UnsupportedCompilationException( "Can't generate setter for ASTList." );
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.ognl.enhance.ExpressionCompiler;
+import org.apache.commons.ognl.enhance.OgnlExpressionCompiler;
+import org.apache.commons.ognl.enhance.UnsupportedCompilationException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ */
+public class ASTList
+ extends SimpleNode
+ implements NodeType
+{
+ 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 Class getGetterClass()
+ {
+ return null;
+ }
+
+ public Class getSetterClass()
+ {
+ return null;
+ }
+
+ public String toGetSourceString( OgnlContext context, Object target )
+ {
+ StringBuilder result = new StringBuilder();
+ boolean array = parent instanceof ASTCtor && ((ASTCtor) parent).isArray();
+
+ context.setCurrentType( List.class );
+ context.setCurrentAccessor( List.class );
+
+ if ( !array )
+ {
+ if ( jjtGetNumChildren() < 1 )
+ {
+ return "java.util.Arrays.asList( new Object[0])";
+ }
+ result.append("java.util.Arrays.asList( new Object[] ");
+ }
+
+ result.append("{ ");
+
+ try
+ {
+
+ for ( int i = 0; i < jjtGetNumChildren(); ++i )
+ {
+ if ( i > 0 )
+ {
+ result.append(", ");
+ }
+
+ Class prevType = context.getCurrentType();
+
+ Object objValue = children[i].getValue( context, context.getRoot() );
+ String value = children[i].toGetSourceString( context, target );
+
+ // to undo type setting of constants when used as method parameters
+ if (children[i] instanceof ASTConst)
+ {
+
+ context.setCurrentType( prevType );
+ }
+
+ value = ExpressionCompiler.getRootExpression( children[i], target, context ) + value;
+
+ String cast = "";
+ if ( ExpressionCompiler.shouldCast( children[i] ) )
+ {
+
+ cast = (String) context.remove( ExpressionCompiler.PRE_CAST );
+ }
+ if ( cast == null )
+ {
+ cast = "";
+ }
+
+ if ( !(children[i] instanceof ASTConst))
+ {
+ value = cast + value;
+ }
+ Class ctorClass = (Class) context.get( "_ctorClass" );
+ if ( array && ctorClass != null && !ctorClass.isPrimitive() )
+ {
+
+ Class valueClass = value != null ? value.getClass() : null;
+ if ( NodeType.class.isAssignableFrom( children[i].getClass() ) )
+ {
+ valueClass = ( (NodeType) children[i] ).getGetterClass();
+ }
+ final OgnlExpressionCompiler compiler = OgnlRuntime.getCompiler( context );
+ if ( valueClass != null && ctorClass.isArray() )
+ {
+
+ value =
+ compiler
+ .createLocalReference( context, "(" + ExpressionCompiler.getCastString( ctorClass )
+ + ")org.apache.commons.ognl.OgnlOps.toArray(" + value + ", "
+ + ctorClass.getComponentType().getName() + ".class, true)", ctorClass );
+
+ }
+ else if ( ctorClass.isPrimitive() )
+ {
+
+ Class wrapClass = OgnlRuntime.getPrimitiveWrapperClass( ctorClass );
+
+ value =
+ compiler
+ .createLocalReference( context, "((" + wrapClass.getName()
+ + ")org.apache.commons.ognl.OgnlOps.convertValue(" + value + ","
+ + wrapClass.getName() + ".class, true))." + OgnlRuntime.getNumericValueGetter(
+ wrapClass ), ctorClass );
+ }
+ else if ( ctorClass != Object.class )
+ {
+
+ value =
+ compiler
+ .createLocalReference( context, "(" + ctorClass.getName()
+ + ")org.apache.commons.ognl.OgnlOps.convertValue(" + value + ","
+ + ctorClass.getName() + ".class)", ctorClass );
+
+ }
+ else if ( ( children[i] instanceof NodeType
+ && ( (NodeType) children[i] ).getGetterClass() != null
+ && Number.class.isAssignableFrom( ( (NodeType) children[i] ).getGetterClass() ) )
+ || valueClass.isPrimitive() )
+ {
+
+ value = " ($w) (" + value + ")";
+ }
+ else if ( valueClass.isPrimitive() )
+ {
+ value = "($w) (" + value + ")";
+ }
+
+ }
+ else if ( ctorClass == null || !ctorClass.isPrimitive() )
+ {
+
+ value = " ($w) (" + value + ")";
+ }
+
+ if ( objValue == null || value.isEmpty() )
+ {
+ value = "null";
+ }
+ result.append(value);
+ }
+
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+
+ context.setCurrentType( List.class );
+ context.setCurrentAccessor( List.class );
+
+ result.append("}");
+
+ if ( !array )
+ {
+ result.append(")");
+ }
+ return result.toString();
+ }
+
+ public String toSetSourceString( OgnlContext context, Object target )
+ {
+ throw new UnsupportedCompilationException( "Can't generate setter for ASTList." );
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTMap.java b/src/main/java/org/apache/commons/ognl/ASTMap.java
index be5964d..fbaaf09 100644
--- a/src/main/java/org/apache/commons/ognl/ASTMap.java
+++ b/src/main/java/org/apache/commons/ognl/ASTMap.java
@@ -1,135 +1,134 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.ognl.enhance.UnsupportedCompilationException;
-
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * $Id$
- */
-class ASTMap
- extends SimpleNode
-{
- private String className;
-
- private final Map<OgnlContext, Class> defaultMapClassMap = new HashMap<OgnlContext, Class>();
-
- public ASTMap( int id )
- {
- super( id );
- }
-
- public ASTMap( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- protected void setClassName( String value )
- {
- className = value;
- }
-
- /**
- * Get the class name for this map.
- *
- * @return the class name.
- * @since 4.0
- */
- String getClassName()
- {
- return className;
- }
-
- protected Object getValueBody( OgnlContext context, Object source )
- throws OgnlException
- {
- Map answer;
-
- if ( className == null )
- {
- Class defaultMapClass = getDefaultMapClass( context );
- try
- {
- answer = (Map) defaultMapClass.newInstance();
- }
- catch ( Exception ex )
- {
- /* This should never happen */
- throw new OgnlException( "Default Map class '" + defaultMapClass.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 toGetSourceString( OgnlContext context, Object target )
- {
- throw new UnsupportedCompilationException( "Map expressions not supported as native java yet." );
- }
-
- public String toSetSourceString( OgnlContext context, Object target )
- {
- throw new UnsupportedCompilationException( "Map expressions not supported as native java yet." );
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-
- private Class getDefaultMapClass( OgnlContext context )
- {
- Class defaultMapClass = defaultMapClassMap.get( context );
- if ( defaultMapClass != null )
- {
- return defaultMapClass;
- }
-
- defaultMapClass = LinkedHashMap.class;
-
- defaultMapClassMap.put( context, defaultMapClass );
- return defaultMapClass;
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.ognl.enhance.UnsupportedCompilationException;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ */
+class ASTMap
+ extends SimpleNode
+{
+ private String className;
+
+ private final Map<OgnlContext, Class> defaultMapClassMap = new HashMap<OgnlContext, Class>();
+
+ public ASTMap( int id )
+ {
+ super( id );
+ }
+
+ public ASTMap( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ protected void setClassName( String value )
+ {
+ className = value;
+ }
+
+ /**
+ * Get the class name for this map.
+ *
+ * @return the class name.
+ * @since 4.0
+ */
+ String getClassName()
+ {
+ return className;
+ }
+
+ protected Object getValueBody( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ Map answer;
+
+ if ( className == null )
+ {
+ Class defaultMapClass = getDefaultMapClass( context );
+ try
+ {
+ answer = (Map) defaultMapClass.newInstance();
+ }
+ catch ( Exception ex )
+ {
+ /* This should never happen */
+ throw new OgnlException( "Default Map class '" + defaultMapClass.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 toGetSourceString( OgnlContext context, Object target )
+ {
+ throw new UnsupportedCompilationException( "Map expressions not supported as native java yet." );
+ }
+
+ public String toSetSourceString( OgnlContext context, Object target )
+ {
+ throw new UnsupportedCompilationException( "Map expressions not supported as native java yet." );
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+
+ private Class getDefaultMapClass( OgnlContext context )
+ {
+ Class defaultMapClass = defaultMapClassMap.get( context );
+ if ( defaultMapClass != null )
+ {
+ return defaultMapClass;
+ }
+
+ defaultMapClass = LinkedHashMap.class;
+
+ defaultMapClassMap.put( context, defaultMapClass );
+ return defaultMapClass;
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTMethod.java b/src/main/java/org/apache/commons/ognl/ASTMethod.java
index 0a52322..5c4761e 100644
--- a/src/main/java/org/apache/commons/ognl/ASTMethod.java
+++ b/src/main/java/org/apache/commons/ognl/ASTMethod.java
@@ -1,412 +1,411 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.ognl.enhance.ExpressionCompiler;
-import org.apache.commons.ognl.enhance.OgnlExpressionCompiler;
-import org.apache.commons.ognl.enhance.OrderedReturn;
-import org.apache.commons.ognl.enhance.UnsupportedCompilationException;
-
-import java.lang.reflect.Method;
-
-/**
- * $Id$
- */
-public class ASTMethod
- extends SimpleNode
- implements OrderedReturn, NodeType
-{
-
- private String methodName;
-
- private String lastExpression;
-
- private String coreExpression;
-
- private Class getterClass;
-
- public ASTMethod( int id )
- {
- super( id );
- }
-
- public ASTMethod( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- /**
- * Called from parser action.
- *
- * @param methodName sets the name of the method
- */
- public void setMethodName( String methodName )
- {
- this.methodName = methodName;
- }
-
- /**
- * Returns the method name that this node will call.
- *
- * @return the method name
- */
- public String getMethodName()
- {
- return methodName;
- }
-
- protected Object getValueBody( OgnlContext context, Object source )
- throws OgnlException
- {
- Object[] args = new Object[jjtGetNumChildren()];
-
- Object result, root = context.getRoot();
-
- for ( int i = 0; i < args.length; ++i )
- {
- args[i] = children[i].getValue( context, root );
- }
-
- result = OgnlRuntime.callMethod( context, source, methodName, args );
-
- if ( result == null )
- {
- NullHandler nullHandler = OgnlRuntime.getNullHandler( OgnlRuntime.getTargetClass( source ) );
- result = nullHandler.nullMethodResult( context, source, methodName, args );
- }
-
- return result;
- }
-
- public String getLastExpression()
- {
- return lastExpression;
- }
-
- public String getCoreExpression()
- {
- return coreExpression;
- }
-
- public Class getGetterClass()
- {
- return getterClass;
- }
-
- public Class getSetterClass()
- {
- return getterClass;
- }
-
- public String toGetSourceString( OgnlContext context, Object target )
- {
- /*
- * System.out.println("methodName is " + methodName + " for target " + target + " target class: " + (target !=
- * null ? target.getClass() : null) + " current type: " + context.getCurrentType());
- */
- if ( target == null )
- {
- throw new UnsupportedCompilationException( "Target object is null." );
- }
-
- String post = "";
- StringBuilder sourceStringBuilder;
- Method method;
-
- OgnlExpressionCompiler compiler = OgnlRuntime.getCompiler( context );
- try
- {
-
- method = OgnlRuntime.getMethod( context, context.getCurrentType() != null
- ? context.getCurrentType()
- : target.getClass(), methodName, children, false );
- if ( method == null )
- {
- method = OgnlRuntime.getReadMethod( target.getClass(), methodName,
- children != null ? children.length : -1 );
- }
-
- if ( method == null )
- {
- method = OgnlRuntime.getWriteMethod( target.getClass(), methodName,
- children != null ? children.length : -1 );
-
- if ( method != null )
- {
-
- context.setCurrentType( method.getReturnType() );
- context.setCurrentAccessor(
- compiler.getSuperOrInterfaceClass( method, method.getDeclaringClass() ) );
-
- coreExpression = toSetSourceString( context, target );
- if ( coreExpression == null || coreExpression.length() < 1 )
- {
- throw new UnsupportedCompilationException( "can't find suitable getter method" );
- }
-
- coreExpression += ";";
- lastExpression = "null";
-
- return coreExpression;
- }
-
- return "";
- }
- getterClass = method.getReturnType();
-
- // TODO: This is a hacky workaround until javassist supports varargs method invocations
- boolean varArgs = method.isVarArgs();
-
- if ( varArgs )
- {
- throw new UnsupportedCompilationException(
- "Javassist does not currently support varargs method calls" );
- }
-
- sourceStringBuilder = new StringBuilder().append( "." ).append( method.getName() ).append( "(" );
-
- if ( ( children != null ) && ( children.length > 0 ) )
- {
- Class[] parms = method.getParameterTypes();
- String prevCast = (String) context.remove( ExpressionCompiler.PRE_CAST );
- /*
- * System.out.println("before children methodName is " + methodName + " for target " + target +
- * " target class: " + (target != null ? target.getClass() : null) + " current type: " +
- * context.getCurrentType() + " and previous type: " + context.getPreviousType());
- */
-
- for ( int i = 0; i < children.length; i++ )
- {
- if ( i > 0 )
- {
- sourceStringBuilder.append( ", " );
- }
-
- Class prevType = context.getCurrentType();
-
- Object root = context.getRoot();
- context.setCurrentObject( root );
- context.setCurrentType( root != null ? root.getClass() : null );
- context.setCurrentAccessor( null );
- context.setPreviousType( null );
-
- Node child = children[i];
-
- String parmString = ASTMethodUtil.getParmString( context, root, child, prevType );
-
- Class valueClass = ASTMethodUtil.getValueClass( context, root, child );
-
- if ( ( !varArgs || varArgs && ( i + 1 ) < parms.length ) && valueClass != parms[i] )
- {
- parmString = ASTMethodUtil.getParmString( context, parms[i], parmString, child, valueClass,
- ".class, true)" );
- }
-
- sourceStringBuilder.append( parmString );
- }
-
- if ( prevCast != null )
- {
- context.put( ExpressionCompiler.PRE_CAST, prevCast );
- }
- }
-
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
-
- try
- {
- Object contextObj = getValueBody( context, target );
- context.setCurrentObject( contextObj );
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
-
- sourceStringBuilder.append( ")" ).append( post );
-
- if ( method.getReturnType() == void.class )
- {
- coreExpression = sourceStringBuilder.toString() + ";";
- lastExpression = "null";
- }
-
- context.setCurrentType( method.getReturnType() );
- context.setCurrentAccessor( compiler.getSuperOrInterfaceClass( method, method.getDeclaringClass() ) );
-
- return sourceStringBuilder.toString();
- }
-
- public String toSetSourceString( OgnlContext context, Object target )
- {
- /*
- * System.out.println("current type: " + context.getCurrentType() + " target:" + target + " " +
- * context.getCurrentObject() + " last child? " + lastChild(context));
- */
- Method method =
- OgnlRuntime.getWriteMethod( context.getCurrentType() != null ? context.getCurrentType() : target.getClass(),
- methodName, children != null ? children.length : -1 );
- if ( method == null )
- {
- throw new UnsupportedCompilationException(
- "Unable to determine setter method generation for " + methodName );
- }
-
- String post = "";
- StringBuilder result = new StringBuilder("." + method.getName() + "(");
-
- if ( method.getReturnType() != void.class && method.getReturnType().isPrimitive() && ( parent == null
- || !(parent instanceof ASTTest)) )
- {
- Class wrapper = OgnlRuntime.getPrimitiveWrapperClass( method.getReturnType() );
-
- ExpressionCompiler.addCastString( context, "new " + wrapper.getName() + "(" );
- post = ")";
- getterClass = wrapper;
- }
-
- boolean varArgs = method.isVarArgs();
-
- if ( varArgs )
- {
- throw new UnsupportedCompilationException( "Javassist does not currently support varargs method calls" );
- }
-
- OgnlExpressionCompiler compiler = OgnlRuntime.getCompiler( context );
- try
- {
- /*
- * if (lastChild(context) && method.getParameterTypes().length > 0 && _children.length <= 0) throw new
- * UnsupportedCompilationException("Unable to determine setter method generation for " + method);
- */
-
- if ( ( children != null ) && ( children.length > 0 ) )
- {
- Class[] parms = method.getParameterTypes();
- String prevCast = (String) context.remove( ExpressionCompiler.PRE_CAST );
-
- for ( int i = 0; i < children.length; i++ )
- {
- if ( i > 0 )
- {
- result.append(", ");
- }
-
- Class prevType = context.getCurrentType();
-
- context.setCurrentObject( context.getRoot() );
- context.setCurrentType( context.getRoot() != null ? context.getRoot().getClass() : null );
- context.setCurrentAccessor( null );
- context.setPreviousType( null );
-
- Node child = children[i];
- Object value = child.getValue( context, context.getRoot() );
- String parmString = child.toSetSourceString( context, context.getRoot() );
-
- if ( context.getCurrentType() == Void.TYPE || context.getCurrentType() == void.class )
- {
- throw new UnsupportedCompilationException( "Method argument can't be a void type." );
- }
-
- if ( parmString == null || parmString.trim().length() < 1 )
- {
- if ( child instanceof ASTProperty || child instanceof ASTMethod
- || child instanceof ASTStaticMethod || child instanceof ASTChain)
- {
- throw new UnsupportedCompilationException(
- "ASTMethod setter child returned null from a sub property expression." );
- }
- parmString = "null";
- }
-
- // to undo type setting of constants when used as method parameters
- if (child instanceof ASTConst)
- {
- context.setCurrentType( prevType );
- }
-
- parmString = ExpressionCompiler.getRootExpression( child, context.getRoot(), context ) + parmString;
-
- String cast = "";
- if ( ExpressionCompiler.shouldCast( child ) )
- {
- cast = (String) context.remove( ExpressionCompiler.PRE_CAST );
- }
-
- if ( cast == null )
- {
- cast = "";
- }
-
- parmString = cast + parmString;
-
- Class valueClass = value != null ? value.getClass() : null;
- if ( NodeType.class.isAssignableFrom( child.getClass() ) )
- {
- valueClass = ( (NodeType) child ).getGetterClass();
- }
-
- if ( valueClass != parms[i] )
- {
- parmString =
- ASTMethodUtil.getParmString( context, parms[i], parmString, child, valueClass, ".class)" );
- }
-
- result.append(parmString);
- }
-
- if ( prevCast != null )
- {
- context.put( ExpressionCompiler.PRE_CAST, prevCast );
- }
- }
-
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
-
- try
- {
- Object contextObj = getValueBody( context, target );
- context.setCurrentObject( contextObj );
- }
- catch ( Throwable t )
- {
- // ignore
- }
-
- context.setCurrentType( method.getReturnType() );
- context.setCurrentAccessor( compiler.getSuperOrInterfaceClass( method, method.getDeclaringClass() ) );
-
- return result + ")" + post;
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.ognl.enhance.ExpressionCompiler;
+import org.apache.commons.ognl.enhance.OgnlExpressionCompiler;
+import org.apache.commons.ognl.enhance.OrderedReturn;
+import org.apache.commons.ognl.enhance.UnsupportedCompilationException;
+
+import java.lang.reflect.Method;
+
+/**
+ */
+public class ASTMethod
+ extends SimpleNode
+ implements OrderedReturn, NodeType
+{
+
+ private String methodName;
+
+ private String lastExpression;
+
+ private String coreExpression;
+
+ private Class getterClass;
+
+ public ASTMethod( int id )
+ {
+ super( id );
+ }
+
+ public ASTMethod( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ /**
+ * Called from parser action.
+ *
+ * @param methodName sets the name of the method
+ */
+ public void setMethodName( String methodName )
+ {
+ this.methodName = methodName;
+ }
+
+ /**
+ * Returns the method name that this node will call.
+ *
+ * @return the method name
+ */
+ public String getMethodName()
+ {
+ return methodName;
+ }
+
+ protected Object getValueBody( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ Object[] args = new Object[jjtGetNumChildren()];
+
+ Object result, root = context.getRoot();
+
+ for ( int i = 0; i < args.length; ++i )
+ {
+ args[i] = children[i].getValue( context, root );
+ }
+
+ result = OgnlRuntime.callMethod( context, source, methodName, args );
+
+ if ( result == null )
+ {
+ NullHandler nullHandler = OgnlRuntime.getNullHandler( OgnlRuntime.getTargetClass( source ) );
+ result = nullHandler.nullMethodResult( context, source, methodName, args );
+ }
+
+ return result;
+ }
+
+ public String getLastExpression()
+ {
+ return lastExpression;
+ }
+
+ public String getCoreExpression()
+ {
+ return coreExpression;
+ }
+
+ public Class getGetterClass()
+ {
+ return getterClass;
+ }
+
+ public Class getSetterClass()
+ {
+ return getterClass;
+ }
+
+ public String toGetSourceString( OgnlContext context, Object target )
+ {
+ /*
+ * System.out.println("methodName is " + methodName + " for target " + target + " target class: " + (target !=
+ * null ? target.getClass() : null) + " current type: " + context.getCurrentType());
+ */
+ if ( target == null )
+ {
+ throw new UnsupportedCompilationException( "Target object is null." );
+ }
+
+ String post = "";
+ StringBuilder sourceStringBuilder;
+ Method method;
+
+ OgnlExpressionCompiler compiler = OgnlRuntime.getCompiler( context );
+ try
+ {
+
+ method = OgnlRuntime.getMethod( context, context.getCurrentType() != null
+ ? context.getCurrentType()
+ : target.getClass(), methodName, children, false );
+ if ( method == null )
+ {
+ method = OgnlRuntime.getReadMethod( target.getClass(), methodName,
+ children != null ? children.length : -1 );
+ }
+
+ if ( method == null )
+ {
+ method = OgnlRuntime.getWriteMethod( target.getClass(), methodName,
+ children != null ? children.length : -1 );
+
+ if ( method != null )
+ {
+
+ context.setCurrentType( method.getReturnType() );
+ context.setCurrentAccessor(
+ compiler.getSuperOrInterfaceClass( method, method.getDeclaringClass() ) );
+
+ coreExpression = toSetSourceString( context, target );
+ if ( coreExpression == null || coreExpression.length() < 1 )
+ {
+ throw new UnsupportedCompilationException( "can't find suitable getter method" );
+ }
+
+ coreExpression += ";";
+ lastExpression = "null";
+
+ return coreExpression;
+ }
+
+ return "";
+ }
+ getterClass = method.getReturnType();
+
+ // TODO: This is a hacky workaround until javassist supports varargs method invocations
+ boolean varArgs = method.isVarArgs();
+
+ if ( varArgs )
+ {
+ throw new UnsupportedCompilationException(
+ "Javassist does not currently support varargs method calls" );
+ }
+
+ sourceStringBuilder = new StringBuilder().append( "." ).append( method.getName() ).append( "(" );
+
+ if ( ( children != null ) && ( children.length > 0 ) )
+ {
+ Class[] parms = method.getParameterTypes();
+ String prevCast = (String) context.remove( ExpressionCompiler.PRE_CAST );
+ /*
+ * System.out.println("before children methodName is " + methodName + " for target " + target +
+ * " target class: " + (target != null ? target.getClass() : null) + " current type: " +
+ * context.getCurrentType() + " and previous type: " + context.getPreviousType());
+ */
+
+ for ( int i = 0; i < children.length; i++ )
+ {
+ if ( i > 0 )
+ {
+ sourceStringBuilder.append( ", " );
+ }
+
+ Class prevType = context.getCurrentType();
+
+ Object root = context.getRoot();
+ context.setCurrentObject( root );
+ context.setCurrentType( root != null ? root.getClass() : null );
+ context.setCurrentAccessor( null );
+ context.setPreviousType( null );
+
+ Node child = children[i];
+
+ String parmString = ASTMethodUtil.getParmString( context, root, child, prevType );
+
+ Class valueClass = ASTMethodUtil.getValueClass( context, root, child );
+
+ if ( ( !varArgs || varArgs && ( i + 1 ) < parms.length ) && valueClass != parms[i] )
+ {
+ parmString = ASTMethodUtil.getParmString( context, parms[i], parmString, child, valueClass,
+ ".class, true)" );
+ }
+
+ sourceStringBuilder.append( parmString );
+ }
+
+ if ( prevCast != null )
+ {
+ context.put( ExpressionCompiler.PRE_CAST, prevCast );
+ }
+ }
+
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+
+ try
+ {
+ Object contextObj = getValueBody( context, target );
+ context.setCurrentObject( contextObj );
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+
+ sourceStringBuilder.append( ")" ).append( post );
+
+ if ( method.getReturnType() == void.class )
+ {
+ coreExpression = sourceStringBuilder.toString() + ";";
+ lastExpression = "null";
+ }
+
+ context.setCurrentType( method.getReturnType() );
+ context.setCurrentAccessor( compiler.getSuperOrInterfaceClass( method, method.getDeclaringClass() ) );
+
+ return sourceStringBuilder.toString();
+ }
+
+ public String toSetSourceString( OgnlContext context, Object target )
+ {
+ /*
+ * System.out.println("current type: " + context.getCurrentType() + " target:" + target + " " +
+ * context.getCurrentObject() + " last child? " + lastChild(context));
+ */
+ Method method =
+ OgnlRuntime.getWriteMethod( context.getCurrentType() != null ? context.getCurrentType() : target.getClass(),
+ methodName, children != null ? children.length : -1 );
+ if ( method == null )
+ {
+ throw new UnsupportedCompilationException(
+ "Unable to determine setter method generation for " + methodName );
+ }
+
+ String post = "";
+ StringBuilder result = new StringBuilder("." + method.getName() + "(");
+
+ if ( method.getReturnType() != void.class && method.getReturnType().isPrimitive() && ( parent == null
+ || !(parent instanceof ASTTest)) )
+ {
+ Class wrapper = OgnlRuntime.getPrimitiveWrapperClass( method.getReturnType() );
+
+ ExpressionCompiler.addCastString( context, "new " + wrapper.getName() + "(" );
+ post = ")";
+ getterClass = wrapper;
+ }
+
+ boolean varArgs = method.isVarArgs();
+
+ if ( varArgs )
+ {
+ throw new UnsupportedCompilationException( "Javassist does not currently support varargs method calls" );
+ }
+
+ OgnlExpressionCompiler compiler = OgnlRuntime.getCompiler( context );
+ try
+ {
+ /*
+ * if (lastChild(context) && method.getParameterTypes().length > 0 && _children.length <= 0) throw new
+ * UnsupportedCompilationException("Unable to determine setter method generation for " + method);
+ */
+
+ if ( ( children != null ) && ( children.length > 0 ) )
+ {
+ Class[] parms = method.getParameterTypes();
+ String prevCast = (String) context.remove( ExpressionCompiler.PRE_CAST );
+
+ for ( int i = 0; i < children.length; i++ )
+ {
+ if ( i > 0 )
+ {
+ result.append(", ");
+ }
+
+ Class prevType = context.getCurrentType();
+
+ context.setCurrentObject( context.getRoot() );
+ context.setCurrentType( context.getRoot() != null ? context.getRoot().getClass() : null );
+ context.setCurrentAccessor( null );
+ context.setPreviousType( null );
+
+ Node child = children[i];
+ Object value = child.getValue( context, context.getRoot() );
+ String parmString = child.toSetSourceString( context, context.getRoot() );
+
+ if ( context.getCurrentType() == Void.TYPE || context.getCurrentType() == void.class )
+ {
+ throw new UnsupportedCompilationException( "Method argument can't be a void type." );
+ }
+
+ if ( parmString == null || parmString.trim().length() < 1 )
+ {
+ if ( child instanceof ASTProperty || child instanceof ASTMethod
+ || child instanceof ASTStaticMethod || child instanceof ASTChain)
+ {
+ throw new UnsupportedCompilationException(
+ "ASTMethod setter child returned null from a sub property expression." );
+ }
+ parmString = "null";
+ }
+
+ // to undo type setting of constants when used as method parameters
+ if (child instanceof ASTConst)
+ {
+ context.setCurrentType( prevType );
+ }
+
+ parmString = ExpressionCompiler.getRootExpression( child, context.getRoot(), context ) + parmString;
+
+ String cast = "";
+ if ( ExpressionCompiler.shouldCast( child ) )
+ {
+ cast = (String) context.remove( ExpressionCompiler.PRE_CAST );
+ }
+
+ if ( cast == null )
+ {
+ cast = "";
+ }
+
+ parmString = cast + parmString;
+
+ Class valueClass = value != null ? value.getClass() : null;
+ if ( NodeType.class.isAssignableFrom( child.getClass() ) )
+ {
+ valueClass = ( (NodeType) child ).getGetterClass();
+ }
+
+ if ( valueClass != parms[i] )
+ {
+ parmString =
+ ASTMethodUtil.getParmString( context, parms[i], parmString, child, valueClass, ".class)" );
+ }
+
+ result.append(parmString);
+ }
+
+ if ( prevCast != null )
+ {
+ context.put( ExpressionCompiler.PRE_CAST, prevCast );
+ }
+ }
+
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+
+ try
+ {
+ Object contextObj = getValueBody( context, target );
+ context.setCurrentObject( contextObj );
+ }
+ catch ( Throwable t )
+ {
+ // ignore
+ }
+
+ context.setCurrentType( method.getReturnType() );
+ context.setCurrentAccessor( compiler.getSuperOrInterfaceClass( method, method.getDeclaringClass() ) );
+
+ return result + ")" + post;
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTMethodUtil.java b/src/main/java/org/apache/commons/ognl/ASTMethodUtil.java
index 55e9eab..ef09927 100644
--- a/src/main/java/org/apache/commons/ognl/ASTMethodUtil.java
+++ b/src/main/java/org/apache/commons/ognl/ASTMethodUtil.java
@@ -1,123 +1,122 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.ognl.enhance.ExpressionCompiler;
-import org.apache.commons.ognl.enhance.OgnlExpressionCompiler;
-
-
-/**
- * $Id$
- */
-class ASTMethodUtil
-{
-
- private ASTMethodUtil()
- {
- }
-
- static String getParmString( OgnlContext context, Object root, Node child, Class prevType )
- throws OgnlException
- {
- String parmString = child.toGetSourceString( context, root );
-
- if ( parmString == null || parmString.trim().length() < 1 )
- {
- parmString = "null";
- }
-
- // to undo type setting of constants when used as method parameters
- if (child instanceof ASTConst)
- {
- context.setCurrentType( prevType );
- }
-
- parmString = ExpressionCompiler.getRootExpression( child, root, context ) + parmString;
-
- String cast = "";
- if ( ExpressionCompiler.shouldCast( child ) )
- {
- cast = (String) context.remove( ExpressionCompiler.PRE_CAST );
- }
-
- if ( cast == null )
- {
- cast = "";
- }
-
- if ( !(child instanceof ASTConst))
- {
- parmString = cast + parmString;
- }
- return parmString;
- }
-
- static Class getValueClass( OgnlContext context, Object root, Node child )
- throws OgnlException
- {
- Object value = child.getValue( context, root );
- Class valueClass = value != null ? value.getClass() : null;
- if ( NodeType.class.isAssignableFrom( child.getClass() ) )
- {
- valueClass = ( (NodeType) child ).getGetterClass();
- }
- return valueClass;
- }
-
- static String getParmString( OgnlContext context, Class parm, String parmString, Node child, Class valueClass,
- String endParam )
- {
- OgnlExpressionCompiler compiler = OgnlRuntime.getCompiler( context );
- if ( parm.isArray() )
- {
- parmString = compiler.createLocalReference( context, "(" + ExpressionCompiler.getCastString( parm )
- + ")org.apache.commons.ognl.OgnlOps#toArray(" + parmString + ", " + parm.getComponentType().getName()
- + endParam, parm );
-
- }
- else if ( parm.isPrimitive() )
- {
- Class wrapClass = OgnlRuntime.getPrimitiveWrapperClass( parm );
-
- parmString = compiler.createLocalReference( context, "((" + wrapClass.getName()
- + ")org.apache.commons.ognl.OgnlOps#convertValue(" + parmString + "," + wrapClass.getName()
- + ".class, true))." + OgnlRuntime.getNumericValueGetter( wrapClass ), parm );
-
- }
- else if ( parm != Object.class )
- {
- parmString = compiler.createLocalReference( context, "(" + parm.getName()
- + ")org.apache.commons.ognl.OgnlOps#convertValue(" + parmString + "," + parm.getName() + ".class)",
- parm );
-
- }
- else if ( ( child instanceof NodeType && ( (NodeType) child ).getGetterClass() != null
- && Number.class.isAssignableFrom( ( (NodeType) child ).getGetterClass() ) ) || ( valueClass != null
- && valueClass.isPrimitive() ) )
- {
- parmString = " ($w) " + parmString;
- }
- else if ( valueClass != null && valueClass.isPrimitive() )
- {
- parmString = "($w) " + parmString;
- }
- return parmString;
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.ognl.enhance.ExpressionCompiler;
+import org.apache.commons.ognl.enhance.OgnlExpressionCompiler;
+
+
+/**
+ */
+class ASTMethodUtil
+{
+
+ private ASTMethodUtil()
+ {
+ }
+
+ static String getParmString( OgnlContext context, Object root, Node child, Class prevType )
+ throws OgnlException
+ {
+ String parmString = child.toGetSourceString( context, root );
+
+ if ( parmString == null || parmString.trim().length() < 1 )
+ {
+ parmString = "null";
+ }
+
+ // to undo type setting of constants when used as method parameters
+ if (child instanceof ASTConst)
+ {
+ context.setCurrentType( prevType );
+ }
+
+ parmString = ExpressionCompiler.getRootExpression( child, root, context ) + parmString;
+
+ String cast = "";
+ if ( ExpressionCompiler.shouldCast( child ) )
+ {
+ cast = (String) context.remove( ExpressionCompiler.PRE_CAST );
+ }
+
+ if ( cast == null )
+ {
+ cast = "";
+ }
+
+ if ( !(child instanceof ASTConst))
+ {
+ parmString = cast + parmString;
+ }
+ return parmString;
+ }
+
+ static Class getValueClass( OgnlContext context, Object root, Node child )
+ throws OgnlException
+ {
+ Object value = child.getValue( context, root );
+ Class valueClass = value != null ? value.getClass() : null;
+ if ( NodeType.class.isAssignableFrom( child.getClass() ) )
+ {
+ valueClass = ( (NodeType) child ).getGetterClass();
+ }
+ return valueClass;
+ }
+
+ static String getParmString( OgnlContext context, Class parm, String parmString, Node child, Class valueClass,
+ String endParam )
+ {
+ OgnlExpressionCompiler compiler = OgnlRuntime.getCompiler( context );
+ if ( parm.isArray() )
+ {
+ parmString = compiler.createLocalReference( context, "(" + ExpressionCompiler.getCastString( parm )
+ + ")org.apache.commons.ognl.OgnlOps#toArray(" + parmString + ", " + parm.getComponentType().getName()
+ + endParam, parm );
+
+ }
+ else if ( parm.isPrimitive() )
+ {
+ Class wrapClass = OgnlRuntime.getPrimitiveWrapperClass( parm );
+
+ parmString = compiler.createLocalReference( context, "((" + wrapClass.getName()
+ + ")org.apache.commons.ognl.OgnlOps#convertValue(" + parmString + "," + wrapClass.getName()
+ + ".class, true))." + OgnlRuntime.getNumericValueGetter( wrapClass ), parm );
+
+ }
+ else if ( parm != Object.class )
+ {
+ parmString = compiler.createLocalReference( context, "(" + parm.getName()
+ + ")org.apache.commons.ognl.OgnlOps#convertValue(" + parmString + "," + parm.getName() + ".class)",
+ parm );
+
+ }
+ else if ( ( child instanceof NodeType && ( (NodeType) child ).getGetterClass() != null
+ && Number.class.isAssignableFrom( ( (NodeType) child ).getGetterClass() ) ) || ( valueClass != null
+ && valueClass.isPrimitive() ) )
+ {
+ parmString = " ($w) " + parmString;
+ }
+ else if ( valueClass != null && valueClass.isPrimitive() )
+ {
+ parmString = "($w) " + parmString;
+ }
+ return parmString;
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTMultiply.java b/src/main/java/org/apache/commons/ognl/ASTMultiply.java
index ce7c986..b21d305 100644
--- a/src/main/java/org/apache/commons/ognl/ASTMultiply.java
+++ b/src/main/java/org/apache/commons/ognl/ASTMultiply.java
@@ -1,65 +1,64 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * $Id$
- */
-class ASTMultiply
- extends NumericExpression
-{
-
- public ASTMultiply( int id )
- {
- super( id );
- }
-
- public ASTMultiply( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- 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;
- }
-
- public String getExpressionOperator( int index )
- {
- return "*";
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ */
+class ASTMultiply
+ extends NumericExpression
+{
+
+ public ASTMultiply( int id )
+ {
+ super( id );
+ }
+
+ public ASTMultiply( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ 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;
+ }
+
+ public String getExpressionOperator( int index )
+ {
+ return "*";
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTNegate.java b/src/main/java/org/apache/commons/ognl/ASTNegate.java
index d40322c..d8d7954 100644
--- a/src/main/java/org/apache/commons/ognl/ASTNegate.java
+++ b/src/main/java/org/apache/commons/ognl/ASTNegate.java
@@ -1,60 +1,59 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * $Id$
- */
-class ASTNegate
- extends NumericExpression
-{
- public ASTNegate( int id )
- {
- super( 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 ) );
- }
-
- public String toGetSourceString( OgnlContext context, Object target )
- {
- String source = children[0].toGetSourceString( context, target );
-
- if ( !(children[0] instanceof ASTNegate))
- {
- return "-" + source;
- }
- return "-(" + source + ")";
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ */
+class ASTNegate
+ extends NumericExpression
+{
+ public ASTNegate( int id )
+ {
+ super( 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 ) );
+ }
+
+ public String toGetSourceString( OgnlContext context, Object target )
+ {
+ String source = children[0].toGetSourceString( context, target );
+
+ if ( !(children[0] instanceof ASTNegate))
+ {
+ return "-" + source;
+ }
+ return "-(" + source + ")";
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTNot.java b/src/main/java/org/apache/commons/ognl/ASTNot.java
index 52b6f1a..f1cf48f 100644
--- a/src/main/java/org/apache/commons/ognl/ASTNot.java
+++ b/src/main/java/org/apache/commons/ognl/ASTNot.java
@@ -1,77 +1,76 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * $Id$
- */
-class ASTNot
- extends BooleanExpression
-{
- public ASTNot( int id )
- {
- super( 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;
- }
-
- public String getExpressionOperator( int index )
- {
- return "!";
- }
-
- public String toGetSourceString( OgnlContext context, Object target )
- {
- try
- {
-
- String srcString = super.toGetSourceString( context, target );
-
- if ( srcString == null || srcString.trim().length() < 1 )
- {
- srcString = "null";
- }
-
- context.setCurrentType( Boolean.TYPE );
-
- return "(! org.apache.commons.ognl.OgnlOps.booleanValue(" + srcString + ") )";
-
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ */
+class ASTNot
+ extends BooleanExpression
+{
+ public ASTNot( int id )
+ {
+ super( 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;
+ }
+
+ public String getExpressionOperator( int index )
+ {
+ return "!";
+ }
+
+ public String toGetSourceString( OgnlContext context, Object target )
+ {
+ try
+ {
+
+ String srcString = super.toGetSourceString( context, target );
+
+ if ( srcString == null || srcString.trim().length() < 1 )
+ {
+ srcString = "null";
+ }
+
+ context.setCurrentType( Boolean.TYPE );
+
+ return "(! org.apache.commons.ognl.OgnlOps.booleanValue(" + srcString + ") )";
+
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTNotEq.java b/src/main/java/org/apache/commons/ognl/ASTNotEq.java
index e09dc7d..f230f37 100644
--- a/src/main/java/org/apache/commons/ognl/ASTNotEq.java
+++ b/src/main/java/org/apache/commons/ognl/ASTNotEq.java
@@ -1,62 +1,61 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * $Id$
- */
-class ASTNotEq
- extends ComparisonExpression
-{
- public ASTNotEq( int id )
- {
- super( 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;
- }
-
- public String getExpressionOperator( int index )
- {
- return "!=";
- }
-
- public String getComparisonFunction()
- {
- return "!org.apache.commons.ognl.OgnlOps.equal";
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ */
+class ASTNotEq
+ extends ComparisonExpression
+{
+ public ASTNotEq( int id )
+ {
+ super( 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;
+ }
+
+ public String getExpressionOperator( int index )
+ {
+ return "!=";
+ }
+
+ public String getComparisonFunction()
+ {
+ return "!org.apache.commons.ognl.OgnlOps.equal";
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTNotIn.java b/src/main/java/org/apache/commons/ognl/ASTNotIn.java
index d96e390..6b8da58 100644
--- a/src/main/java/org/apache/commons/ognl/ASTNotIn.java
+++ b/src/main/java/org/apache/commons/ognl/ASTNotIn.java
@@ -1,94 +1,93 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.ognl.enhance.UnsupportedCompilationException;
-
-/**
- * $Id$
- */
-class ASTNotIn
- extends SimpleNode
- implements NodeType
-{
- public ASTNotIn( int id )
- {
- super( 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;
- }
-
- public Class getGetterClass()
- {
- return Boolean.TYPE;
- }
-
- public Class getSetterClass()
- {
- return null;
- }
-
- public String toGetSourceString( OgnlContext context, Object target )
- {
- try
- {
- String result = "(! org.apache.commons.ognl.OgnlOps.in( ($w) ";
-
- result +=
- OgnlRuntime.getChildSource( context, target, children[0] ) + ", ($w) "
- + OgnlRuntime.getChildSource( context, target, children[1] );
-
- result += ") )";
-
- context.setCurrentType( Boolean.TYPE );
-
- return result;
- }
- catch ( NullPointerException e )
- {
-
- // expected to happen in some instances
- e.printStackTrace();
-
- throw new UnsupportedCompilationException( "evaluation resulted in null expression." );
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.ognl.enhance.UnsupportedCompilationException;
+
+/**
+ */
+class ASTNotIn
+ extends SimpleNode
+ implements NodeType
+{
+ public ASTNotIn( int id )
+ {
+ super( id );
+ }
... 39088 lines suppressed ...