Remove Subversion key substitution noise "$Id$"
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 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 );
+ }
+
+ 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 );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTOr.java b/src/main/java/org/apache/commons/ognl/ASTOr.java
index 304352d..23662e9 100644
--- a/src/main/java/org/apache/commons/ognl/ASTOr.java
+++ b/src/main/java/org/apache/commons/ognl/ASTOr.java
@@ -1,206 +1,205 @@
-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.UnsupportedCompilationException;
-
-/**
- * $Id$
- */
-public class ASTOr
- extends BooleanExpression
-{
- public ASTOr( int id )
- {
- super( id );
- }
-
- public ASTOr( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- public void jjtClose()
- {
- flattenTree();
- }
-
- protected Object getValueBody( OgnlContext context, Object source )
- throws OgnlException
- {
- Object result = null;
- int last = children.length - 1;
- for ( int i = 0; i <= last; ++i )
- {
- result = children[i].getValue( context, source );
- if ( i != last && OgnlOps.booleanValue( result ) )
- {
- break;
- }
- }
- return result;
- }
-
- protected void setValueBody( OgnlContext context, Object target, Object value )
- throws OgnlException
- {
- int last = children.length - 1;
- for ( int i = 0; i < last; ++i )
- {
- Object v = children[i].getValue( context, target );
- if ( OgnlOps.booleanValue( v ) )
- {
- return;
- }
- }
- children[last].setValue( context, target, value );
- }
-
- public String getExpressionOperator( int index )
- {
- return "||";
- }
-
- public Class getGetterClass()
- {
- return null;
- }
-
- public String toGetSourceString( OgnlContext context, Object target )
- {
- if ( children.length != 2 )
- {
- throw new UnsupportedCompilationException( "Can only compile boolean expressions with two children." );
- }
-
- String result = "(";
-
- try
- {
-
- String first = OgnlRuntime.getChildSource( context, target, children[0] );
- if ( !OgnlRuntime.isBoolean( first ) )
- {
- first = OgnlRuntime.getCompiler( context ).createLocalReference( context, first, context.getCurrentType() );
- }
-
- Class firstType = context.getCurrentType();
-
- String second = OgnlRuntime.getChildSource( context, target, children[1] );
- if ( !OgnlRuntime.isBoolean( second ) )
- {
- second = OgnlRuntime.getCompiler( context ).createLocalReference( context, second, context.getCurrentType() );
- }
-
- Class secondType = context.getCurrentType();
-
- boolean mismatched =
- ( firstType.isPrimitive( ) && !secondType.isPrimitive( ) ) || ( !firstType.isPrimitive( )
- && secondType.isPrimitive( ) );
-
- result += "org.apache.commons.ognl.OgnlOps.booleanValue(" + first + ")";
-
- result += " ? ";
-
- result += ( mismatched ? " ($w) " : "" ) + first;
-
- result += " : ";
-
- result += ( mismatched ? " ($w) " : "" ) + second;
-
- result += ")";
-
- context.setCurrentObject( target );
- context.setCurrentType( Boolean.TYPE );
-
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
-
- return result;
- }
-
- public String toSetSourceString( OgnlContext context, Object target )
- {
- if ( children.length != 2 )
- {
- throw new UnsupportedCompilationException( "Can only compile boolean expressions with two children." );
- }
-
- String pre = (String) context.get( "_currentChain" );
- if ( pre == null )
- {
- pre = "";
- }
-
- String result = "";
-
- try
- {
-
- children[0].getValue( context, target );
-
- String first =
- ExpressionCompiler.getRootExpression( children[0], context.getRoot(), context ) + pre
- + children[0].toGetSourceString( context, target );
- if ( !OgnlRuntime.isBoolean( first ) )
- {
- first = OgnlRuntime.getCompiler( context ).createLocalReference( context, first, Object.class );
- }
- children[1].getValue( context, target );
-
- String second =
- ExpressionCompiler.getRootExpression( children[1], context.getRoot(), context ) + pre
- + children[1].toSetSourceString( context, target );
- if ( !OgnlRuntime.isBoolean( second ) )
- {
- second = OgnlRuntime.getCompiler( context ).createLocalReference( context, second, context.getCurrentType() );
- }
- result += "org.apache.commons.ognl.OgnlOps.booleanValue(" + first + ")";
-
- result += " ? ";
-
- result += first;
- result += " : ";
-
- result += second;
-
- context.setCurrentObject( target );
-
- context.setCurrentType( Boolean.TYPE );
-
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
-
- 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.UnsupportedCompilationException;
+
+/**
+ */
+public class ASTOr
+ extends BooleanExpression
+{
+ public ASTOr( int id )
+ {
+ super( id );
+ }
+
+ public ASTOr( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ public void jjtClose()
+ {
+ flattenTree();
+ }
+
+ protected Object getValueBody( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ Object result = null;
+ int last = children.length - 1;
+ for ( int i = 0; i <= last; ++i )
+ {
+ result = children[i].getValue( context, source );
+ if ( i != last && OgnlOps.booleanValue( result ) )
+ {
+ break;
+ }
+ }
+ return result;
+ }
+
+ protected void setValueBody( OgnlContext context, Object target, Object value )
+ throws OgnlException
+ {
+ int last = children.length - 1;
+ for ( int i = 0; i < last; ++i )
+ {
+ Object v = children[i].getValue( context, target );
+ if ( OgnlOps.booleanValue( v ) )
+ {
+ return;
+ }
+ }
+ children[last].setValue( context, target, value );
+ }
+
+ public String getExpressionOperator( int index )
+ {
+ return "||";
+ }
+
+ public Class getGetterClass()
+ {
+ return null;
+ }
+
+ public String toGetSourceString( OgnlContext context, Object target )
+ {
+ if ( children.length != 2 )
+ {
+ throw new UnsupportedCompilationException( "Can only compile boolean expressions with two children." );
+ }
+
+ String result = "(";
+
+ try
+ {
+
+ String first = OgnlRuntime.getChildSource( context, target, children[0] );
+ if ( !OgnlRuntime.isBoolean( first ) )
+ {
+ first = OgnlRuntime.getCompiler( context ).createLocalReference( context, first, context.getCurrentType() );
+ }
+
+ Class firstType = context.getCurrentType();
+
+ String second = OgnlRuntime.getChildSource( context, target, children[1] );
+ if ( !OgnlRuntime.isBoolean( second ) )
+ {
+ second = OgnlRuntime.getCompiler( context ).createLocalReference( context, second, context.getCurrentType() );
+ }
+
+ Class secondType = context.getCurrentType();
+
+ boolean mismatched =
+ ( firstType.isPrimitive( ) && !secondType.isPrimitive( ) ) || ( !firstType.isPrimitive( )
+ && secondType.isPrimitive( ) );
+
+ result += "org.apache.commons.ognl.OgnlOps.booleanValue(" + first + ")";
+
+ result += " ? ";
+
+ result += ( mismatched ? " ($w) " : "" ) + first;
+
+ result += " : ";
+
+ result += ( mismatched ? " ($w) " : "" ) + second;
+
+ result += ")";
+
+ context.setCurrentObject( target );
+ context.setCurrentType( Boolean.TYPE );
+
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+
+ return result;
+ }
+
+ public String toSetSourceString( OgnlContext context, Object target )
+ {
+ if ( children.length != 2 )
+ {
+ throw new UnsupportedCompilationException( "Can only compile boolean expressions with two children." );
+ }
+
+ String pre = (String) context.get( "_currentChain" );
+ if ( pre == null )
+ {
+ pre = "";
+ }
+
+ String result = "";
+
+ try
+ {
+
+ children[0].getValue( context, target );
+
+ String first =
+ ExpressionCompiler.getRootExpression( children[0], context.getRoot(), context ) + pre
+ + children[0].toGetSourceString( context, target );
+ if ( !OgnlRuntime.isBoolean( first ) )
+ {
+ first = OgnlRuntime.getCompiler( context ).createLocalReference( context, first, Object.class );
+ }
+ children[1].getValue( context, target );
+
+ String second =
+ ExpressionCompiler.getRootExpression( children[1], context.getRoot(), context ) + pre
+ + children[1].toSetSourceString( context, target );
+ if ( !OgnlRuntime.isBoolean( second ) )
+ {
+ second = OgnlRuntime.getCompiler( context ).createLocalReference( context, second, context.getCurrentType() );
+ }
+ result += "org.apache.commons.ognl.OgnlOps.booleanValue(" + first + ")";
+
+ result += " ? ";
+
+ result += first;
+ result += " : ";
+
+ result += second;
+
+ context.setCurrentObject( target );
+
+ context.setCurrentType( Boolean.TYPE );
+
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+
+ 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/ASTProject.java b/src/main/java/org/apache/commons/ognl/ASTProject.java
index b0973e8..2bd622c 100644
--- a/src/main/java/org/apache/commons/ognl/ASTProject.java
+++ b/src/main/java/org/apache/commons/ognl/ASTProject.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.
- */
-
-import org.apache.commons.ognl.enhance.UnsupportedCompilationException;
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-
-/**
- * $Id$
- */
-class ASTProject
- extends SimpleNode
-{
-
- public ASTProject( int id )
- {
- super( id );
- }
-
- public ASTProject( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- protected Object getValueBody( OgnlContext context, Object source )
- throws OgnlException
- {
- Node expr = children[0];
- List answer = new ArrayList();
-
- ElementsAccessor elementsAccessor = OgnlRuntime.getElementsAccessor( OgnlRuntime.getTargetClass( source ) );
-
- for ( Enumeration e = elementsAccessor.getElements( source ); e.hasMoreElements(); )
- {
-
- answer.add( expr.getValue( context, e.nextElement() ) );
- }
-
- return answer;
- }
-
- public String toGetSourceString( OgnlContext context, Object target )
- {
- throw new UnsupportedCompilationException( "Projection expressions not supported as native java yet." );
- }
-
- public String toSetSourceString( OgnlContext context, Object target )
- {
- throw new UnsupportedCompilationException( "Projection 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;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+
+/**
+ */
+class ASTProject
+ extends SimpleNode
+{
+
+ public ASTProject( int id )
+ {
+ super( id );
+ }
+
+ public ASTProject( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ protected Object getValueBody( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ Node expr = children[0];
+ List answer = new ArrayList();
+
+ ElementsAccessor elementsAccessor = OgnlRuntime.getElementsAccessor( OgnlRuntime.getTargetClass( source ) );
+
+ for ( Enumeration e = elementsAccessor.getElements( source ); e.hasMoreElements(); )
+ {
+
+ answer.add( expr.getValue( context, e.nextElement() ) );
+ }
+
+ return answer;
+ }
+
+ public String toGetSourceString( OgnlContext context, Object target )
+ {
+ throw new UnsupportedCompilationException( "Projection expressions not supported as native java yet." );
+ }
+
+ public String toSetSourceString( OgnlContext context, Object target )
+ {
+ throw new UnsupportedCompilationException( "Projection 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/ASTProperty.java b/src/main/java/org/apache/commons/ognl/ASTProperty.java
index 8a5caf3..0560d53 100644
--- a/src/main/java/org/apache/commons/ognl/ASTProperty.java
+++ b/src/main/java/org/apache/commons/ognl/ASTProperty.java
@@ -1,649 +1,648 @@
-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.UnsupportedCompilationException;
-
-import java.beans.IndexedPropertyDescriptor;
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.Method;
-import java.util.Iterator;
-
-/**
- * $Id$
- */
-public class ASTProperty
- extends SimpleNode
- implements NodeType
-{
- private boolean indexedAccess = false;
-
- private Class getterClass;
-
- private Class setterClass;
-
- public ASTProperty( int id )
- {
- super( id );
- }
-
- public void setIndexedAccess( boolean value )
- {
- indexedAccess = value;
- }
-
- /**
- * Returns true if this property is itself an index reference.
- *
- * @return Returns true if this property is itself an index reference.
- */
- public boolean isIndexedAccess()
- {
- return indexedAccess;
- }
-
- /**
- * Returns true if this property is described by an IndexedPropertyDescriptor and that if followed by an index
- * specifier it will call the index get/set methods rather than go through property accessors.
- *
- * @param context The context
- * @param source The object source
- * @return true, if this property is described by an IndexedPropertyDescriptor
- * @throws OgnlException if an error occurs
- */
- public int getIndexedPropertyType( OgnlContext context, Object source )
- throws OgnlException
- {
- Class type = context.getCurrentType();
- Class prevType = context.getPreviousType();
- try
- {
- if ( !isIndexedAccess() )
- {
- Object property = getProperty( context, source );
-
- if ( property instanceof String )
- {
- return OgnlRuntime.getIndexedPropertyType( context, ( source == null )
- ? null
- : OgnlRuntime.getCompiler( context ).getInterfaceClass( source.getClass() ),
- (String) property );
- }
- }
-
- return OgnlRuntime.INDEXED_PROPERTY_NONE;
- }
- finally
- {
- context.setCurrentObject( source );
- context.setCurrentType( type );
- context.setPreviousType( prevType );
- }
- }
-
- public Object getProperty( OgnlContext context, Object source )
- throws OgnlException
- {
- return children[0].getValue( context, context.getRoot() );
- }
-
- protected Object getValueBody( OgnlContext context, Object source )
- throws OgnlException
- {
- Object property = getProperty( context, source );
-
- Object result = OgnlRuntime.getProperty( context, source, property );
-
- if ( result == null )
- {
- result =
- OgnlRuntime.getNullHandler( OgnlRuntime.getTargetClass( source ) ).nullPropertyValue( context, source,
- property );
- }
-
- return result;
- }
-
- protected void setValueBody( OgnlContext context, Object target, Object value )
- throws OgnlException
- {
- OgnlRuntime.setProperty( context, target, getProperty( context, target ), value );
- }
-
- public boolean isNodeSimpleProperty( OgnlContext context )
- throws OgnlException
- {
- return ( children != null ) && ( children.length == 1 ) && ( (SimpleNode) children[0] ).isConstant( context );
- }
-
- public Class getGetterClass()
- {
- return getterClass;
- }
-
- public Class getSetterClass()
- {
- return setterClass;
- }
-
- public String toGetSourceString( OgnlContext context, Object target )
- {
- if ( context.getCurrentObject() == null )
- {
- throw new UnsupportedCompilationException( "Current target is null." );
- }
- String result = "";
- Method m = null;
-
- try
- {
- /*
- * System.out.println("astproperty is indexed? : " + isIndexedAccess() + " child: " +
- * _children[0].getClass().getName() + " target: " + target.getClass().getName() + " current object: " +
- * context.getCurrentObject().getClass().getName());
- */
-
- Node child = children[0];
- if ( isIndexedAccess() )
- {
- Object value = child.getValue( context, context.getRoot() );
-
- if ( value == null || DynamicSubscript.class.isAssignableFrom( value.getClass() ) )
- {
- throw new UnsupportedCompilationException(
- "Value passed as indexed property was null or not supported." );
- }
- // Get root cast string if the child is a type that needs it (like a nested ASTProperty)
-
- String srcString = getSourceString( context, child );
-
- if ( context.get( "_indexedMethod" ) != null )
- {
- m = (Method) context.remove( "_indexedMethod" );
- getterClass = m.getReturnType();
-
- Object indexedValue = OgnlRuntime.callMethod( context, target, m.getName(), new Object[]{ value } );
-
- context.setCurrentType( getterClass );
- context.setCurrentObject( indexedValue );
- context.setCurrentAccessor(
- OgnlRuntime.getCompiler( context ).getSuperOrInterfaceClass( m, m.getDeclaringClass() ) );
-
- return "." + m.getName() + "(" + srcString + ")";
- }
- PropertyAccessor propertyAccessor = OgnlRuntime.getPropertyAccessor( target.getClass() );
-
- // System.out.println("child value : " + _children[0].getValue(context, context.getCurrentObject())
- // + " using propaccessor " + p.getClass().getName()
- // + " and srcString " + srcString + " on target: " + target);
-
- Object currentObject = context.getCurrentObject();
- if ( child instanceof ASTConst && currentObject instanceof Number)
- {
- context.setCurrentType( OgnlRuntime.getPrimitiveWrapperClass( currentObject.getClass() ) );
- }
- Object indexValue = propertyAccessor.getProperty( context, target, value );
- result = propertyAccessor.getSourceAccessor( context, target, srcString );
- getterClass = context.getCurrentType();
- context.setCurrentObject( indexValue );
-
- return result;
- }
-
- String name = ( (ASTConst) child ).getValue().toString();
-
- target = getTarget( context, target, name );
-
- PropertyDescriptor pd = OgnlRuntime.getPropertyDescriptor( context.getCurrentObject().getClass(), name );
-
- if ( pd != null && pd.getReadMethod() != null && !context.getMemberAccess().isAccessible( context,
- context.getCurrentObject(),
- pd.getReadMethod(),
- name ) )
- {
- throw new UnsupportedCompilationException( "Member access forbidden for property " + name + " on class "
- + context.getCurrentObject().getClass() );
- }
-
- if ( this.getIndexedPropertyType( context, context.getCurrentObject() ) > 0 && pd != null )
- {
- // if an indexed method accessor need to use special property descriptors to find methods
-
- if ( pd instanceof IndexedPropertyDescriptor )
- {
- m = ( (IndexedPropertyDescriptor) pd ).getIndexedReadMethod();
- }
- else
- {
- if ( !(pd instanceof ObjectIndexedPropertyDescriptor) ) {
- throw new OgnlException( "property '" + name + "' is not an indexed property" );
- }
- m = ( (ObjectIndexedPropertyDescriptor) pd ).getIndexedReadMethod();
- }
-
- if ( parent == null )
- {
- // the above pd will be the wrong result sometimes, such as methods like getValue(int) vs String[]
- // getValue()
- m = OgnlRuntime.getReadMethod( context.getCurrentObject().getClass(), name );
-
- result = m.getName() + "()";
- getterClass = m.getReturnType();
- }
- else
- {
- context.put( "_indexedMethod", m );
- }
- }
- else
- {
-
- /*
- * System.out.println("astproperty trying to get " + name + " on object target: " +
- * context.getCurrentObject().getClass().getName() + " current type " + context.getCurrentType() +
- * " current accessor " + context.getCurrentAccessor() + " prev type " + context.getPreviousType() +
- * " prev accessor " + context.getPreviousAccessor());
- */
-
- PropertyAccessor pa = OgnlRuntime.getPropertyAccessor( context.getCurrentObject().getClass() );
-
- if ( context.getCurrentObject().getClass().isArray() )
- {
- if ( pd == null )
- {
- pd = OgnlRuntime.getProperty( context.getCurrentObject().getClass(), name );
-
- if ( pd != null && pd.getReadMethod() != null )
- {
- m = pd.getReadMethod();
- result = pd.getName();
- }
- else
- {
- getterClass = int.class;
- context.setCurrentAccessor( context.getCurrentObject().getClass() );
- context.setCurrentType( int.class );
- result = "." + name;
- }
- }
- }
- else
- {
- if ( pd != null && pd.getReadMethod() != null )
- {
- m = pd.getReadMethod();
- result = "." + m.getName() + "()";
- }
- else if ( pa != null )
- {
- Object currObj = context.getCurrentObject();
- Class currType = context.getCurrentType();
- Class prevType = context.getPreviousType();
-
- String srcString = child.toGetSourceString( context, context.getRoot() );
-
- if ( child instanceof ASTConst && context.getCurrentObject() instanceof String)
- {
- srcString = "\"" + srcString + "\"";
- }
- context.setCurrentObject( currObj );
- context.setCurrentType( currType );
- context.setPreviousType( prevType );
-
- result = pa.getSourceAccessor( context, context.getCurrentObject(), srcString );
-
- getterClass = context.getCurrentType();
- }
- }
- }
-
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
-
- // set known property types for NodeType interface when possible
-
- if ( m != null )
- {
- getterClass = m.getReturnType();
-
- context.setCurrentType( m.getReturnType() );
- context.setCurrentAccessor(
- OgnlRuntime.getCompiler( context ).getSuperOrInterfaceClass( m, m.getDeclaringClass() ) );
- }
-
- context.setCurrentObject( target );
-
- return result;
- }
-
- Object getTarget( OgnlContext context, Object target, String name )
- throws OgnlException
- {
- Class<?> clazz = context.getCurrentObject().getClass();
- if ( !Iterator.class.isAssignableFrom( clazz ) || ( Iterator.class.isAssignableFrom( clazz ) && !name.contains(
- "next" ) ) )
- {
- Object currObj = target;
-
- try
- {
- target = getValue( context, context.getCurrentObject() );
- }
- catch ( NoSuchPropertyException e )
- {
- try
- {
- target = getValue( context, context.getRoot() );
- }
- catch ( NoSuchPropertyException ex )
- {
- // ignore
- }
- }
- finally
- {
- context.setCurrentObject( currObj );
- }
- }
- return target;
- }
-
- Method getIndexedWriteMethod( PropertyDescriptor pd )
- {
- if (pd instanceof IndexedPropertyDescriptor)
- {
- return ( (IndexedPropertyDescriptor) pd ).getIndexedWriteMethod();
- }
- if (pd instanceof ObjectIndexedPropertyDescriptor)
- {
- return ( (ObjectIndexedPropertyDescriptor) pd ).getIndexedWriteMethod();
- }
-
- return null;
- }
-
- public String toSetSourceString( OgnlContext context, Object target )
- {
- String result = "";
- Method m = null;
-
- if ( context.getCurrentObject() == null )
- {
- throw new UnsupportedCompilationException( "Current target is null." );
- }
- /*
- * System.out.println("astproperty(setter) is indexed? : " + isIndexedAccess() + " child: " +
- * _children[0].getClass().getName() + " target: " + target.getClass().getName() + " children length: " +
- * _children.length);
- */
-
- try
- {
-
- Node child = children[0];
- if ( isIndexedAccess() )
- {
- Object value = child.getValue( context, context.getRoot() );
-
- if ( value == null )
- {
- throw new UnsupportedCompilationException(
- "Value passed as indexed property is null, can't enhance statement to bytecode." );
- }
-
- String srcString = getSourceString( context, child );
-
- // System.out.println("astproperty setter using indexed value " + value + " and srcString: " +
- // srcString);
-
- if ( context.get( "_indexedMethod" ) == null ) {
- PropertyAccessor propertyAccessor = OgnlRuntime.getPropertyAccessor( target.getClass() );
-
- Object currentObject = context.getCurrentObject();
- if ( child instanceof ASTConst && currentObject instanceof Number)
- {
- context.setCurrentType( OgnlRuntime.getPrimitiveWrapperClass( currentObject.getClass() ) );
- }
- Object indexValue = propertyAccessor.getProperty( context, target, value );
- result = lastChild( context )
- ? propertyAccessor.getSourceSetter( context, target, srcString )
- : propertyAccessor.getSourceAccessor( context, target, srcString );
-
- /*
- * System.out.println("ASTProperty using propertyaccessor and isLastChild? " + lastChild(context) +
- * " generated source of: " + result + " using accessor class: " + p.getClass().getName());
- */
-
- // result = p.getSourceAccessor(context, target, srcString);
- getterClass = context.getCurrentType();
- context.setCurrentObject( indexValue );
-
- /*
- * PropertyAccessor p = OgnlRuntime.getPropertyAccessor(target.getClass()); if
- * (ASTConst.class.isInstance(_children[0]) && Number.class.isInstance(context.getCurrentObject()))
- * {
- * context.setCurrentType(OgnlRuntime.getPrimitiveWrapperClass(context.getCurrentObject().getClass(
- * ))); } result = p.getSourceSetter(context, target, srcString); context.setCurrentObject(value);
- * context.setCurrentType(getterClass);
- */
- return result;
- }
- m = (Method) context.remove( "_indexedMethod" );
- PropertyDescriptor pd = (PropertyDescriptor) context.remove( "_indexedDescriptor" );
-
- boolean lastChild = lastChild( context );
- if ( lastChild )
- {
- m = getIndexedWriteMethod( pd );
-
- if ( m == null )
- {
- throw new UnsupportedCompilationException(
- "Indexed property has no corresponding write method." );
- }
- }
-
- setterClass = m.getParameterTypes()[0];
-
- Object indexedValue = null;
- if ( !lastChild )
- {
- indexedValue = OgnlRuntime.callMethod( context, target, m.getName(), new Object[]{ value } );
- }
- context.setCurrentType( setterClass );
- context.setCurrentAccessor(
- OgnlRuntime.getCompiler( context ).getSuperOrInterfaceClass( m, m.getDeclaringClass() ) );
-
- if ( !lastChild )
- {
- context.setCurrentObject( indexedValue );
- return "." + m.getName() + "(" + srcString + ")";
- }
- return "." + m.getName() + "(" + srcString + ", $3)";
- }
-
- String name = ( (ASTConst) child ).getValue().toString();
-
- // System.out.println(" astprop(setter) : trying to set " + name + " on object target " +
- // context.getCurrentObject().getClass().getName());
-
- target = getTarget( context, target, name );
-
- PropertyDescriptor pd = OgnlRuntime.getPropertyDescriptor(
- OgnlRuntime.getCompiler( context ).getInterfaceClass( context.getCurrentObject().getClass() ), name );
-
- if ( pd != null )
- {
- Method pdMethod = lastChild( context ) ? pd.getWriteMethod() : pd.getReadMethod();
-
- if ( pdMethod != null && !context.getMemberAccess().isAccessible( context, context.getCurrentObject(),
- pdMethod, name ) )
- {
- throw new UnsupportedCompilationException(
- "Member access forbidden for property " + name + " on class "
- + context.getCurrentObject().getClass() );
- }
- }
-
- if ( pd != null && this.getIndexedPropertyType( context, context.getCurrentObject() ) > 0 )
- {
- // if an indexed method accessor need to use special property descriptors to find methods
-
- if ( pd instanceof IndexedPropertyDescriptor )
- {
- IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
- m = lastChild( context ) ? ipd.getIndexedWriteMethod() : ipd.getIndexedReadMethod();
- }
- else
- {
- if ( !(pd instanceof ObjectIndexedPropertyDescriptor) ) {
- throw new OgnlException( "property '" + name + "' is not an indexed property" );
- }
- ObjectIndexedPropertyDescriptor opd = (ObjectIndexedPropertyDescriptor) pd;
-
- m = lastChild( context ) ? opd.getIndexedWriteMethod() : opd.getIndexedReadMethod();
- }
-
- if ( parent == null )
- {
- // the above pd will be the wrong result sometimes, such as methods like getValue(int) vs String[]
- // getValue()
-
- m = OgnlRuntime.getWriteMethod( context.getCurrentObject().getClass(), name );
- Class parm = m.getParameterTypes()[0];
- String cast = parm.isArray() ? ExpressionCompiler.getCastString( parm ) : parm.getName();
-
- result = m.getName() + "((" + cast + ")$3)";
- setterClass = parm;
- }
- else
- {
- context.put( "_indexedMethod", m );
- context.put( "_indexedDescriptor", pd );
- }
-
- }
- else
- {
- PropertyAccessor pa = OgnlRuntime.getPropertyAccessor( context.getCurrentObject().getClass() );
-
- /*
- * System.out.println("astproperty trying to set " + name + " on object target: " +
- * context.getCurrentObject().getClass().getName() + " using propertyaccessor type: " + pa);
- */
-
- if ( target != null )
- {
- setterClass = target.getClass();
- }
- if ( parent != null && pd != null && pa == null )
- {
- m = pd.getReadMethod();
- result = m.getName() + "()";
- }
- else
- {
- if ( context.getCurrentObject().getClass().isArray() )
- {
- result = "";
- }
- else if ( pa != null )
- {
- Object currObj = context.getCurrentObject();
- // Class currType = context.getCurrentType();
- // Class prevType = context.getPreviousType();
-
- String srcString = child.toGetSourceString( context, context.getRoot() );
-
- if ( child instanceof ASTConst && context.getCurrentObject() instanceof String)
- {
- srcString = "\"" + srcString + "\"";
- }
-
- context.setCurrentObject( currObj );
- // context.setCurrentType(currType);
- // context.setPreviousType(prevType);
-
- if ( !lastChild( context ) )
- {
- result = pa.getSourceAccessor( context, context.getCurrentObject(), srcString );
- }
- else
- {
- result = pa.getSourceSetter( context, context.getCurrentObject(), srcString );
- }
-
- getterClass = context.getCurrentType();
- }
- }
- }
-
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
-
- context.setCurrentObject( target );
-
- if ( m != null )
- {
- context.setCurrentType( m.getReturnType() );
- context.setCurrentAccessor(
- OgnlRuntime.getCompiler( context ).getSuperOrInterfaceClass( m, m.getDeclaringClass() ) );
- }
-
- return result;
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-
- private static String getSourceString( OgnlContext context, Node child )
- {
- String srcString = child.toGetSourceString( context, context.getRoot() );
- srcString = ExpressionCompiler.getRootExpression( child, context.getRoot(), context ) + srcString;
-
- if (child instanceof ASTChain)
- {
- String cast = (String) context.remove( ExpressionCompiler.PRE_CAST );
- if ( cast != null )
- {
- srcString = cast + srcString;
- }
- }
-
- if ( child instanceof ASTConst && context.getCurrentObject() instanceof String)
- {
- srcString = "\"" + srcString + "\"";
- }
- // System.out.println("indexed getting with child srcString: " + srcString + " value class: " +
- // value.getClass() + " and child: " + _children[0].getClass());
- return srcString;
- }
-
-}
+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.UnsupportedCompilationException;
+
+import java.beans.IndexedPropertyDescriptor;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import java.util.Iterator;
+
+/**
+ */
+public class ASTProperty
+ extends SimpleNode
+ implements NodeType
+{
+ private boolean indexedAccess = false;
+
+ private Class getterClass;
+
+ private Class setterClass;
+
+ public ASTProperty( int id )
+ {
+ super( id );
+ }
+
+ public void setIndexedAccess( boolean value )
+ {
+ indexedAccess = value;
+ }
+
+ /**
+ * Returns true if this property is itself an index reference.
+ *
+ * @return Returns true if this property is itself an index reference.
+ */
+ public boolean isIndexedAccess()
+ {
+ return indexedAccess;
+ }
+
+ /**
+ * Returns true if this property is described by an IndexedPropertyDescriptor and that if followed by an index
+ * specifier it will call the index get/set methods rather than go through property accessors.
+ *
+ * @param context The context
+ * @param source The object source
+ * @return true, if this property is described by an IndexedPropertyDescriptor
+ * @throws OgnlException if an error occurs
+ */
+ public int getIndexedPropertyType( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ Class type = context.getCurrentType();
+ Class prevType = context.getPreviousType();
+ try
+ {
+ if ( !isIndexedAccess() )
+ {
+ Object property = getProperty( context, source );
+
+ if ( property instanceof String )
+ {
+ return OgnlRuntime.getIndexedPropertyType( context, ( source == null )
+ ? null
+ : OgnlRuntime.getCompiler( context ).getInterfaceClass( source.getClass() ),
+ (String) property );
+ }
+ }
+
+ return OgnlRuntime.INDEXED_PROPERTY_NONE;
+ }
+ finally
+ {
+ context.setCurrentObject( source );
+ context.setCurrentType( type );
+ context.setPreviousType( prevType );
+ }
+ }
+
+ public Object getProperty( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ return children[0].getValue( context, context.getRoot() );
+ }
+
+ protected Object getValueBody( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ Object property = getProperty( context, source );
+
+ Object result = OgnlRuntime.getProperty( context, source, property );
+
+ if ( result == null )
+ {
+ result =
+ OgnlRuntime.getNullHandler( OgnlRuntime.getTargetClass( source ) ).nullPropertyValue( context, source,
+ property );
+ }
+
+ return result;
+ }
+
+ protected void setValueBody( OgnlContext context, Object target, Object value )
+ throws OgnlException
+ {
+ OgnlRuntime.setProperty( context, target, getProperty( context, target ), value );
+ }
+
+ public boolean isNodeSimpleProperty( OgnlContext context )
+ throws OgnlException
+ {
+ return ( children != null ) && ( children.length == 1 ) && ( (SimpleNode) children[0] ).isConstant( context );
+ }
+
+ public Class getGetterClass()
+ {
+ return getterClass;
+ }
+
+ public Class getSetterClass()
+ {
+ return setterClass;
+ }
+
+ public String toGetSourceString( OgnlContext context, Object target )
+ {
+ if ( context.getCurrentObject() == null )
+ {
+ throw new UnsupportedCompilationException( "Current target is null." );
+ }
+ String result = "";
+ Method m = null;
+
+ try
+ {
+ /*
+ * System.out.println("astproperty is indexed? : " + isIndexedAccess() + " child: " +
+ * _children[0].getClass().getName() + " target: " + target.getClass().getName() + " current object: " +
+ * context.getCurrentObject().getClass().getName());
+ */
+
+ Node child = children[0];
+ if ( isIndexedAccess() )
+ {
+ Object value = child.getValue( context, context.getRoot() );
+
+ if ( value == null || DynamicSubscript.class.isAssignableFrom( value.getClass() ) )
+ {
+ throw new UnsupportedCompilationException(
+ "Value passed as indexed property was null or not supported." );
+ }
+ // Get root cast string if the child is a type that needs it (like a nested ASTProperty)
+
+ String srcString = getSourceString( context, child );
+
+ if ( context.get( "_indexedMethod" ) != null )
+ {
+ m = (Method) context.remove( "_indexedMethod" );
+ getterClass = m.getReturnType();
+
+ Object indexedValue = OgnlRuntime.callMethod( context, target, m.getName(), new Object[]{ value } );
+
+ context.setCurrentType( getterClass );
+ context.setCurrentObject( indexedValue );
+ context.setCurrentAccessor(
+ OgnlRuntime.getCompiler( context ).getSuperOrInterfaceClass( m, m.getDeclaringClass() ) );
+
+ return "." + m.getName() + "(" + srcString + ")";
+ }
+ PropertyAccessor propertyAccessor = OgnlRuntime.getPropertyAccessor( target.getClass() );
+
+ // System.out.println("child value : " + _children[0].getValue(context, context.getCurrentObject())
+ // + " using propaccessor " + p.getClass().getName()
+ // + " and srcString " + srcString + " on target: " + target);
+
+ Object currentObject = context.getCurrentObject();
+ if ( child instanceof ASTConst && currentObject instanceof Number)
+ {
+ context.setCurrentType( OgnlRuntime.getPrimitiveWrapperClass( currentObject.getClass() ) );
+ }
+ Object indexValue = propertyAccessor.getProperty( context, target, value );
+ result = propertyAccessor.getSourceAccessor( context, target, srcString );
+ getterClass = context.getCurrentType();
+ context.setCurrentObject( indexValue );
+
+ return result;
+ }
+
+ String name = ( (ASTConst) child ).getValue().toString();
+
+ target = getTarget( context, target, name );
+
+ PropertyDescriptor pd = OgnlRuntime.getPropertyDescriptor( context.getCurrentObject().getClass(), name );
+
+ if ( pd != null && pd.getReadMethod() != null && !context.getMemberAccess().isAccessible( context,
+ context.getCurrentObject(),
+ pd.getReadMethod(),
+ name ) )
+ {
+ throw new UnsupportedCompilationException( "Member access forbidden for property " + name + " on class "
+ + context.getCurrentObject().getClass() );
+ }
+
+ if ( this.getIndexedPropertyType( context, context.getCurrentObject() ) > 0 && pd != null )
+ {
+ // if an indexed method accessor need to use special property descriptors to find methods
+
+ if ( pd instanceof IndexedPropertyDescriptor )
+ {
+ m = ( (IndexedPropertyDescriptor) pd ).getIndexedReadMethod();
+ }
+ else
+ {
+ if ( !(pd instanceof ObjectIndexedPropertyDescriptor) ) {
+ throw new OgnlException( "property '" + name + "' is not an indexed property" );
+ }
+ m = ( (ObjectIndexedPropertyDescriptor) pd ).getIndexedReadMethod();
+ }
+
+ if ( parent == null )
+ {
+ // the above pd will be the wrong result sometimes, such as methods like getValue(int) vs String[]
+ // getValue()
+ m = OgnlRuntime.getReadMethod( context.getCurrentObject().getClass(), name );
+
+ result = m.getName() + "()";
+ getterClass = m.getReturnType();
+ }
+ else
+ {
+ context.put( "_indexedMethod", m );
+ }
+ }
+ else
+ {
+
+ /*
+ * System.out.println("astproperty trying to get " + name + " on object target: " +
+ * context.getCurrentObject().getClass().getName() + " current type " + context.getCurrentType() +
+ * " current accessor " + context.getCurrentAccessor() + " prev type " + context.getPreviousType() +
+ * " prev accessor " + context.getPreviousAccessor());
+ */
+
+ PropertyAccessor pa = OgnlRuntime.getPropertyAccessor( context.getCurrentObject().getClass() );
+
+ if ( context.getCurrentObject().getClass().isArray() )
+ {
+ if ( pd == null )
+ {
+ pd = OgnlRuntime.getProperty( context.getCurrentObject().getClass(), name );
+
+ if ( pd != null && pd.getReadMethod() != null )
+ {
+ m = pd.getReadMethod();
+ result = pd.getName();
+ }
+ else
+ {
+ getterClass = int.class;
+ context.setCurrentAccessor( context.getCurrentObject().getClass() );
+ context.setCurrentType( int.class );
+ result = "." + name;
+ }
+ }
+ }
+ else
+ {
+ if ( pd != null && pd.getReadMethod() != null )
+ {
+ m = pd.getReadMethod();
+ result = "." + m.getName() + "()";
+ }
+ else if ( pa != null )
+ {
+ Object currObj = context.getCurrentObject();
+ Class currType = context.getCurrentType();
+ Class prevType = context.getPreviousType();
+
+ String srcString = child.toGetSourceString( context, context.getRoot() );
+
+ if ( child instanceof ASTConst && context.getCurrentObject() instanceof String)
+ {
+ srcString = "\"" + srcString + "\"";
+ }
+ context.setCurrentObject( currObj );
+ context.setCurrentType( currType );
+ context.setPreviousType( prevType );
+
+ result = pa.getSourceAccessor( context, context.getCurrentObject(), srcString );
+
+ getterClass = context.getCurrentType();
+ }
+ }
+ }
+
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+
+ // set known property types for NodeType interface when possible
+
+ if ( m != null )
+ {
+ getterClass = m.getReturnType();
+
+ context.setCurrentType( m.getReturnType() );
+ context.setCurrentAccessor(
+ OgnlRuntime.getCompiler( context ).getSuperOrInterfaceClass( m, m.getDeclaringClass() ) );
+ }
+
+ context.setCurrentObject( target );
+
+ return result;
+ }
+
+ Object getTarget( OgnlContext context, Object target, String name )
+ throws OgnlException
+ {
+ Class<?> clazz = context.getCurrentObject().getClass();
+ if ( !Iterator.class.isAssignableFrom( clazz ) || ( Iterator.class.isAssignableFrom( clazz ) && !name.contains(
+ "next" ) ) )
+ {
+ Object currObj = target;
+
+ try
+ {
+ target = getValue( context, context.getCurrentObject() );
+ }
+ catch ( NoSuchPropertyException e )
+ {
+ try
+ {
+ target = getValue( context, context.getRoot() );
+ }
+ catch ( NoSuchPropertyException ex )
+ {
+ // ignore
+ }
+ }
+ finally
+ {
+ context.setCurrentObject( currObj );
+ }
+ }
+ return target;
+ }
+
+ Method getIndexedWriteMethod( PropertyDescriptor pd )
+ {
+ if (pd instanceof IndexedPropertyDescriptor)
+ {
+ return ( (IndexedPropertyDescriptor) pd ).getIndexedWriteMethod();
+ }
+ if (pd instanceof ObjectIndexedPropertyDescriptor)
+ {
+ return ( (ObjectIndexedPropertyDescriptor) pd ).getIndexedWriteMethod();
+ }
+
+ return null;
+ }
+
+ public String toSetSourceString( OgnlContext context, Object target )
+ {
+ String result = "";
+ Method m = null;
+
+ if ( context.getCurrentObject() == null )
+ {
+ throw new UnsupportedCompilationException( "Current target is null." );
+ }
+ /*
+ * System.out.println("astproperty(setter) is indexed? : " + isIndexedAccess() + " child: " +
+ * _children[0].getClass().getName() + " target: " + target.getClass().getName() + " children length: " +
+ * _children.length);
+ */
+
+ try
+ {
+
+ Node child = children[0];
+ if ( isIndexedAccess() )
+ {
+ Object value = child.getValue( context, context.getRoot() );
+
+ if ( value == null )
+ {
+ throw new UnsupportedCompilationException(
+ "Value passed as indexed property is null, can't enhance statement to bytecode." );
+ }
+
+ String srcString = getSourceString( context, child );
+
+ // System.out.println("astproperty setter using indexed value " + value + " and srcString: " +
+ // srcString);
+
+ if ( context.get( "_indexedMethod" ) == null ) {
+ PropertyAccessor propertyAccessor = OgnlRuntime.getPropertyAccessor( target.getClass() );
+
+ Object currentObject = context.getCurrentObject();
+ if ( child instanceof ASTConst && currentObject instanceof Number)
+ {
+ context.setCurrentType( OgnlRuntime.getPrimitiveWrapperClass( currentObject.getClass() ) );
+ }
+ Object indexValue = propertyAccessor.getProperty( context, target, value );
+ result = lastChild( context )
+ ? propertyAccessor.getSourceSetter( context, target, srcString )
+ : propertyAccessor.getSourceAccessor( context, target, srcString );
+
+ /*
+ * System.out.println("ASTProperty using propertyaccessor and isLastChild? " + lastChild(context) +
+ * " generated source of: " + result + " using accessor class: " + p.getClass().getName());
+ */
+
+ // result = p.getSourceAccessor(context, target, srcString);
+ getterClass = context.getCurrentType();
+ context.setCurrentObject( indexValue );
+
+ /*
+ * PropertyAccessor p = OgnlRuntime.getPropertyAccessor(target.getClass()); if
+ * (ASTConst.class.isInstance(_children[0]) && Number.class.isInstance(context.getCurrentObject()))
+ * {
+ * context.setCurrentType(OgnlRuntime.getPrimitiveWrapperClass(context.getCurrentObject().getClass(
+ * ))); } result = p.getSourceSetter(context, target, srcString); context.setCurrentObject(value);
+ * context.setCurrentType(getterClass);
+ */
+ return result;
+ }
+ m = (Method) context.remove( "_indexedMethod" );
+ PropertyDescriptor pd = (PropertyDescriptor) context.remove( "_indexedDescriptor" );
+
+ boolean lastChild = lastChild( context );
+ if ( lastChild )
+ {
+ m = getIndexedWriteMethod( pd );
+
+ if ( m == null )
+ {
+ throw new UnsupportedCompilationException(
+ "Indexed property has no corresponding write method." );
+ }
+ }
+
+ setterClass = m.getParameterTypes()[0];
+
+ Object indexedValue = null;
+ if ( !lastChild )
+ {
+ indexedValue = OgnlRuntime.callMethod( context, target, m.getName(), new Object[]{ value } );
+ }
+ context.setCurrentType( setterClass );
+ context.setCurrentAccessor(
+ OgnlRuntime.getCompiler( context ).getSuperOrInterfaceClass( m, m.getDeclaringClass() ) );
+
+ if ( !lastChild )
+ {
+ context.setCurrentObject( indexedValue );
+ return "." + m.getName() + "(" + srcString + ")";
+ }
+ return "." + m.getName() + "(" + srcString + ", $3)";
+ }
+
+ String name = ( (ASTConst) child ).getValue().toString();
+
+ // System.out.println(" astprop(setter) : trying to set " + name + " on object target " +
+ // context.getCurrentObject().getClass().getName());
+
+ target = getTarget( context, target, name );
+
+ PropertyDescriptor pd = OgnlRuntime.getPropertyDescriptor(
+ OgnlRuntime.getCompiler( context ).getInterfaceClass( context.getCurrentObject().getClass() ), name );
+
+ if ( pd != null )
+ {
+ Method pdMethod = lastChild( context ) ? pd.getWriteMethod() : pd.getReadMethod();
+
+ if ( pdMethod != null && !context.getMemberAccess().isAccessible( context, context.getCurrentObject(),
+ pdMethod, name ) )
+ {
+ throw new UnsupportedCompilationException(
+ "Member access forbidden for property " + name + " on class "
+ + context.getCurrentObject().getClass() );
+ }
+ }
+
+ if ( pd != null && this.getIndexedPropertyType( context, context.getCurrentObject() ) > 0 )
+ {
+ // if an indexed method accessor need to use special property descriptors to find methods
+
+ if ( pd instanceof IndexedPropertyDescriptor )
+ {
+ IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
+ m = lastChild( context ) ? ipd.getIndexedWriteMethod() : ipd.getIndexedReadMethod();
+ }
+ else
+ {
+ if ( !(pd instanceof ObjectIndexedPropertyDescriptor) ) {
+ throw new OgnlException( "property '" + name + "' is not an indexed property" );
+ }
+ ObjectIndexedPropertyDescriptor opd = (ObjectIndexedPropertyDescriptor) pd;
+
+ m = lastChild( context ) ? opd.getIndexedWriteMethod() : opd.getIndexedReadMethod();
+ }
+
+ if ( parent == null )
+ {
+ // the above pd will be the wrong result sometimes, such as methods like getValue(int) vs String[]
+ // getValue()
+
+ m = OgnlRuntime.getWriteMethod( context.getCurrentObject().getClass(), name );
+ Class parm = m.getParameterTypes()[0];
+ String cast = parm.isArray() ? ExpressionCompiler.getCastString( parm ) : parm.getName();
+
+ result = m.getName() + "((" + cast + ")$3)";
+ setterClass = parm;
+ }
+ else
+ {
+ context.put( "_indexedMethod", m );
+ context.put( "_indexedDescriptor", pd );
+ }
+
+ }
+ else
+ {
+ PropertyAccessor pa = OgnlRuntime.getPropertyAccessor( context.getCurrentObject().getClass() );
+
+ /*
+ * System.out.println("astproperty trying to set " + name + " on object target: " +
+ * context.getCurrentObject().getClass().getName() + " using propertyaccessor type: " + pa);
+ */
+
+ if ( target != null )
+ {
+ setterClass = target.getClass();
+ }
+ if ( parent != null && pd != null && pa == null )
+ {
+ m = pd.getReadMethod();
+ result = m.getName() + "()";
+ }
+ else
+ {
+ if ( context.getCurrentObject().getClass().isArray() )
+ {
+ result = "";
+ }
+ else if ( pa != null )
+ {
+ Object currObj = context.getCurrentObject();
+ // Class currType = context.getCurrentType();
+ // Class prevType = context.getPreviousType();
+
+ String srcString = child.toGetSourceString( context, context.getRoot() );
+
+ if ( child instanceof ASTConst && context.getCurrentObject() instanceof String)
+ {
+ srcString = "\"" + srcString + "\"";
+ }
+
+ context.setCurrentObject( currObj );
+ // context.setCurrentType(currType);
+ // context.setPreviousType(prevType);
+
+ if ( !lastChild( context ) )
+ {
+ result = pa.getSourceAccessor( context, context.getCurrentObject(), srcString );
+ }
+ else
+ {
+ result = pa.getSourceSetter( context, context.getCurrentObject(), srcString );
+ }
+
+ getterClass = context.getCurrentType();
+ }
+ }
+ }
+
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+
+ context.setCurrentObject( target );
+
+ if ( m != null )
+ {
+ context.setCurrentType( m.getReturnType() );
+ context.setCurrentAccessor(
+ OgnlRuntime.getCompiler( context ).getSuperOrInterfaceClass( m, m.getDeclaringClass() ) );
+ }
+
+ return result;
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+
+ private static String getSourceString( OgnlContext context, Node child )
+ {
+ String srcString = child.toGetSourceString( context, context.getRoot() );
+ srcString = ExpressionCompiler.getRootExpression( child, context.getRoot(), context ) + srcString;
+
+ if (child instanceof ASTChain)
+ {
+ String cast = (String) context.remove( ExpressionCompiler.PRE_CAST );
+ if ( cast != null )
+ {
+ srcString = cast + srcString;
+ }
+ }
+
+ if ( child instanceof ASTConst && context.getCurrentObject() instanceof String)
+ {
+ srcString = "\"" + srcString + "\"";
+ }
+ // System.out.println("indexed getting with child srcString: " + srcString + " value class: " +
+ // value.getClass() + " and child: " + _children[0].getClass());
+ return srcString;
+ }
+
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTRemainder.java b/src/main/java/org/apache/commons/ognl/ASTRemainder.java
index b1aaea1..cb0c30d 100644
--- a/src/main/java/org/apache/commons/ognl/ASTRemainder.java
+++ b/src/main/java/org/apache/commons/ognl/ASTRemainder.java
@@ -1,56 +1,55 @@
-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 ASTRemainder
- extends NumericExpression
-{
- public ASTRemainder( int id )
- {
- super( id );
- }
-
- public ASTRemainder( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- protected Object getValueBody( OgnlContext context, Object source )
- throws OgnlException
- {
- Object v1 = children[0].getValue( context, source );
- Object v2 = children[1].getValue( context, source );
- return OgnlOps.remainder( v1, v2 );
- }
-
- 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 ASTRemainder
+ extends NumericExpression
+{
+ public ASTRemainder( int id )
+ {
+ super( id );
+ }
+
+ public ASTRemainder( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ protected Object getValueBody( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ Object v1 = children[0].getValue( context, source );
+ Object v2 = children[1].getValue( context, source );
+ return OgnlOps.remainder( v1, v2 );
+ }
+
+ 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/ASTRootVarRef.java b/src/main/java/org/apache/commons/ognl/ASTRootVarRef.java
index c747749..d554c38 100644
--- a/src/main/java/org/apache/commons/ognl/ASTRootVarRef.java
+++ b/src/main/java/org/apache/commons/ognl/ASTRootVarRef.java
@@ -1,86 +1,85 @@
-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;
-
-/**
- * $Id$
- */
-public class ASTRootVarRef
- extends ASTVarRef
-{
- public ASTRootVarRef( int id )
- {
- super( id );
- }
-
- public ASTRootVarRef( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- protected Object getValueBody( OgnlContext context, Object source )
- throws OgnlException
- {
- return context.getRoot();
- }
-
- protected void setValueBody( OgnlContext context, Object target, Object value )
- throws OgnlException
- {
- context.setRoot( value );
- }
-
- public String toGetSourceString( OgnlContext context, Object target )
- {
- if ( target != null )
- {
- getterClass = target.getClass();
- }
-
- if ( getterClass != null )
- {
-
- context.setCurrentType( getterClass );
- }
-
- if ( parent == null || ( getterClass != null && getterClass.isArray() ) )
- {
- return "";
- }
- return ExpressionCompiler.getRootExpression( this, target, context );
- }
-
- public String toSetSourceString( OgnlContext context, Object target )
- {
- if ( parent == null || ( getterClass != null && getterClass.isArray() ) )
- {
- return "";
- }
- return "$3";
- }
-
- 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;
+
+/**
+ */
+public class ASTRootVarRef
+ extends ASTVarRef
+{
+ public ASTRootVarRef( int id )
+ {
+ super( id );
+ }
+
+ public ASTRootVarRef( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ protected Object getValueBody( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ return context.getRoot();
+ }
+
+ protected void setValueBody( OgnlContext context, Object target, Object value )
+ throws OgnlException
+ {
+ context.setRoot( value );
+ }
+
+ public String toGetSourceString( OgnlContext context, Object target )
+ {
+ if ( target != null )
+ {
+ getterClass = target.getClass();
+ }
+
+ if ( getterClass != null )
+ {
+
+ context.setCurrentType( getterClass );
+ }
+
+ if ( parent == null || ( getterClass != null && getterClass.isArray() ) )
+ {
+ return "";
+ }
+ return ExpressionCompiler.getRootExpression( this, target, context );
+ }
+
+ public String toSetSourceString( OgnlContext context, Object target )
+ {
+ if ( parent == null || ( getterClass != null && getterClass.isArray() ) )
+ {
+ return "";
+ }
+ return "$3";
+ }
+
+ 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/ASTSelect.java b/src/main/java/org/apache/commons/ognl/ASTSelect.java
index f2c5515..927ea5c 100644
--- a/src/main/java/org/apache/commons/ognl/ASTSelect.java
+++ b/src/main/java/org/apache/commons/ognl/ASTSelect.java
@@ -1,81 +1,80 @@
-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.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-
-/**
- * $Id$
- */
-class ASTSelect
- extends SimpleNode
-{
-
- public ASTSelect( int id )
- {
- super( id );
- }
-
- public ASTSelect( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- protected Object getValueBody( OgnlContext context, Object source )
- throws OgnlException
- {
- Node expr = children[0];
- List answer = new ArrayList();
-
- ElementsAccessor elementsAccessor = OgnlRuntime.getElementsAccessor( OgnlRuntime.getTargetClass( source ) );
-
- for ( Enumeration e = elementsAccessor.getElements( source ); e.hasMoreElements(); )
- {
- Object next = e.nextElement();
-
- if ( OgnlOps.booleanValue( expr.getValue( context, next ) ) )
- {
- answer.add( next );
- }
- }
-
- return answer;
- }
-
- 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( "Eval 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;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+
+/**
+ */
+class ASTSelect
+ extends SimpleNode
+{
+
+ public ASTSelect( int id )
+ {
+ super( id );
+ }
+
+ public ASTSelect( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ protected Object getValueBody( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ Node expr = children[0];
+ List answer = new ArrayList();
+
+ ElementsAccessor elementsAccessor = OgnlRuntime.getElementsAccessor( OgnlRuntime.getTargetClass( source ) );
+
+ for ( Enumeration e = elementsAccessor.getElements( source ); e.hasMoreElements(); )
+ {
+ Object next = e.nextElement();
+
+ if ( OgnlOps.booleanValue( expr.getValue( context, next ) ) )
+ {
+ answer.add( next );
+ }
+ }
+
+ return answer;
+ }
+
+ 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( "Eval 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/ASTSelectFirst.java b/src/main/java/org/apache/commons/ognl/ASTSelectFirst.java
index 948e2d0..ebd70fe 100644
--- a/src/main/java/org/apache/commons/ognl/ASTSelectFirst.java
+++ b/src/main/java/org/apache/commons/ognl/ASTSelectFirst.java
@@ -1,79 +1,78 @@
-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.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-
-/**
- * $Id$
- */
-class ASTSelectFirst
- extends SimpleNode
-{
- public ASTSelectFirst( int id )
- {
- super( id );
- }
-
- public ASTSelectFirst( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- protected Object getValueBody( OgnlContext context, Object source )
- throws OgnlException
- {
- Node expr = children[0];
- List answer = new ArrayList();
- ElementsAccessor elementsAccessor = OgnlRuntime.getElementsAccessor( OgnlRuntime.getTargetClass( source ) );
-
- for ( Enumeration e = elementsAccessor.getElements( source ); e.hasMoreElements(); )
- {
- Object next = e.nextElement();
-
- if ( OgnlOps.booleanValue( expr.getValue( context, next ) ) )
- {
- answer.add( next );
- break;
- }
- }
- return answer;
- }
-
- public 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( "Eval 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;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+
+/**
+ */
+class ASTSelectFirst
+ extends SimpleNode
+{
+ public ASTSelectFirst( int id )
+ {
+ super( id );
+ }
+
+ public ASTSelectFirst( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ protected Object getValueBody( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ Node expr = children[0];
+ List answer = new ArrayList();
+ ElementsAccessor elementsAccessor = OgnlRuntime.getElementsAccessor( OgnlRuntime.getTargetClass( source ) );
+
+ for ( Enumeration e = elementsAccessor.getElements( source ); e.hasMoreElements(); )
+ {
+ Object next = e.nextElement();
+
+ if ( OgnlOps.booleanValue( expr.getValue( context, next ) ) )
+ {
+ answer.add( next );
+ break;
+ }
+ }
+ return answer;
+ }
+
+ public 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( "Eval 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/ASTSelectLast.java b/src/main/java/org/apache/commons/ognl/ASTSelectLast.java
index 33297f2..2a4db18 100644
--- a/src/main/java/org/apache/commons/ognl/ASTSelectLast.java
+++ b/src/main/java/org/apache/commons/ognl/ASTSelectLast.java
@@ -1,79 +1,78 @@
-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.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-
-/**
- * $Id$
- */
-class ASTSelectLast
- extends SimpleNode
-{
- public ASTSelectLast( int id )
- {
- super( id );
- }
-
- public ASTSelectLast( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- protected Object getValueBody( OgnlContext context, Object source )
- throws OgnlException
- {
- Node expr = children[0];
- List answer = new ArrayList();
- ElementsAccessor elementsAccessor = OgnlRuntime.getElementsAccessor( OgnlRuntime.getTargetClass( source ) );
-
- for ( Enumeration e = elementsAccessor.getElements( source ); e.hasMoreElements(); )
- {
- Object next = e.nextElement();
-
- if ( OgnlOps.booleanValue( expr.getValue( context, next ) ) )
- {
- answer.clear();
- answer.add( next );
- }
- }
- return answer;
- }
-
- public 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( "Eval 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;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+
+/**
+ */
+class ASTSelectLast
+ extends SimpleNode
+{
+ public ASTSelectLast( int id )
+ {
+ super( id );
+ }
+
+ public ASTSelectLast( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ protected Object getValueBody( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ Node expr = children[0];
+ List answer = new ArrayList();
+ ElementsAccessor elementsAccessor = OgnlRuntime.getElementsAccessor( OgnlRuntime.getTargetClass( source ) );
+
+ for ( Enumeration e = elementsAccessor.getElements( source ); e.hasMoreElements(); )
+ {
+ Object next = e.nextElement();
+
+ if ( OgnlOps.booleanValue( expr.getValue( context, next ) ) )
+ {
+ answer.clear();
+ answer.add( next );
+ }
+ }
+ return answer;
+ }
+
+ public 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( "Eval 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/ASTSequence.java b/src/main/java/org/apache/commons/ognl/ASTSequence.java
index 0142420..aeb765d 100644
--- a/src/main/java/org/apache/commons/ognl/ASTSequence.java
+++ b/src/main/java/org/apache/commons/ognl/ASTSequence.java
@@ -1,166 +1,165 @@
-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;
-
-/**
- * $Id$
- */
-public class ASTSequence
- extends SimpleNode
- implements NodeType, OrderedReturn
-{
- private Class getterClass;
-
- private String lastExpression;
-
- private String coreExpression;
-
- public ASTSequence( int id )
- {
- super( id );
- }
-
- public ASTSequence( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- public void jjtClose()
- {
- flattenTree();
- }
-
- protected Object getValueBody( OgnlContext context, Object source )
- throws OgnlException
- {
- Object result = null;
- for ( int i = 0; i < children.length; ++i )
- {
- result = children[i].getValue( context, source );
- }
-
- return result; // The result is just the last one we saw.
- }
-
- protected void setValueBody( OgnlContext context, Object target, Object value )
- throws OgnlException
- {
- int last = children.length - 1;
- for ( int i = 0; i < last; ++i )
- {
- children[i].getValue( context, target );
- }
- children[last].setValue( context, target, value );
- }
-
- public Class getGetterClass()
- {
- return getterClass;
- }
-
- public Class getSetterClass()
- {
- return null;
- }
-
- public String getLastExpression()
- {
- return lastExpression;
- }
-
- public String getCoreExpression()
- {
- return coreExpression;
- }
-
- public String toSetSourceString( OgnlContext context, Object target )
- {
- return "";
- }
-
- public String toGetSourceString( OgnlContext context, Object target )
- {
- String result = "";
-
- NodeType lastType = null;
-
- for ( int i = 0; i < children.length; ++i )
- {
- // System.out.println("astsequence child : " + _children[i].getClass().getName());
- String seqValue = children[i].toGetSourceString( context, target );
-
- if ( ( i + 1 ) < children.length && children[i] instanceof ASTOr)
- {
- seqValue = "(" + seqValue + ")";
- }
-
- if ( i > 0 && children[i] instanceof ASTProperty && seqValue != null
- && !seqValue.trim().isEmpty() )
- {
- String pre = (String) context.get( "_currentChain" );
- if ( pre == null )
- {
- pre = "";
- }
-
- seqValue =
- ExpressionCompiler.getRootExpression( children[i], context.getRoot(), context ) + pre + seqValue;
- context.setCurrentAccessor( context.getRoot().getClass() );
- }
-
- if ( ( i + 1 ) >= children.length )
- {
- coreExpression = result;
- lastExpression = seqValue;
- }
-
- if ( seqValue != null && !seqValue.trim().isEmpty() && ( i + 1 ) < children.length )
- {
- result += seqValue + ";";
- }
- else if ( seqValue != null && !seqValue.trim().isEmpty() )
- {
- result += seqValue;
- }
- // set last known type from last child with a type
-
- if ( children[i] instanceof NodeType && ( (NodeType) children[i] ).getGetterClass() != null )
- {
- lastType = (NodeType) children[i];
- }
- }
-
- if ( lastType != null )
- {
- getterClass = lastType.getGetterClass();
- }
-
- 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;
+
+/**
+ */
+public class ASTSequence
+ extends SimpleNode
+ implements NodeType, OrderedReturn
+{
+ private Class getterClass;
+
+ private String lastExpression;
+
+ private String coreExpression;
+
+ public ASTSequence( int id )
+ {
+ super( id );
+ }
+
+ public ASTSequence( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ public void jjtClose()
+ {
+ flattenTree();
+ }
+
+ protected Object getValueBody( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ Object result = null;
+ for ( int i = 0; i < children.length; ++i )
+ {
+ result = children[i].getValue( context, source );
+ }
+
+ return result; // The result is just the last one we saw.
+ }
+
+ protected void setValueBody( OgnlContext context, Object target, Object value )
+ throws OgnlException
+ {
+ int last = children.length - 1;
+ for ( int i = 0; i < last; ++i )
+ {
+ children[i].getValue( context, target );
+ }
+ children[last].setValue( context, target, value );
+ }
+
+ public Class getGetterClass()
+ {
+ return getterClass;
+ }
+
+ public Class getSetterClass()
+ {
+ return null;
+ }
+
+ public String getLastExpression()
+ {
+ return lastExpression;
+ }
+
+ public String getCoreExpression()
+ {
+ return coreExpression;
+ }
+
+ public String toSetSourceString( OgnlContext context, Object target )
+ {
+ return "";
+ }
+
+ public String toGetSourceString( OgnlContext context, Object target )
+ {
+ String result = "";
+
+ NodeType lastType = null;
+
+ for ( int i = 0; i < children.length; ++i )
+ {
+ // System.out.println("astsequence child : " + _children[i].getClass().getName());
+ String seqValue = children[i].toGetSourceString( context, target );
+
+ if ( ( i + 1 ) < children.length && children[i] instanceof ASTOr)
+ {
+ seqValue = "(" + seqValue + ")";
+ }
+
+ if ( i > 0 && children[i] instanceof ASTProperty && seqValue != null
+ && !seqValue.trim().isEmpty() )
+ {
+ String pre = (String) context.get( "_currentChain" );
+ if ( pre == null )
+ {
+ pre = "";
+ }
+
+ seqValue =
+ ExpressionCompiler.getRootExpression( children[i], context.getRoot(), context ) + pre + seqValue;
+ context.setCurrentAccessor( context.getRoot().getClass() );
+ }
+
+ if ( ( i + 1 ) >= children.length )
+ {
+ coreExpression = result;
+ lastExpression = seqValue;
+ }
+
+ if ( seqValue != null && !seqValue.trim().isEmpty() && ( i + 1 ) < children.length )
+ {
+ result += seqValue + ";";
+ }
+ else if ( seqValue != null && !seqValue.trim().isEmpty() )
+ {
+ result += seqValue;
+ }
+ // set last known type from last child with a type
+
+ if ( children[i] instanceof NodeType && ( (NodeType) children[i] ).getGetterClass() != null )
+ {
+ lastType = (NodeType) children[i];
+ }
+ }
+
+ if ( lastType != null )
+ {
+ getterClass = lastType.getGetterClass();
+ }
+
+ 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/ASTShiftLeft.java b/src/main/java/org/apache/commons/ognl/ASTShiftLeft.java
index 113d61b..ed0c725 100644
--- a/src/main/java/org/apache/commons/ognl/ASTShiftLeft.java
+++ b/src/main/java/org/apache/commons/ognl/ASTShiftLeft.java
@@ -1,56 +1,55 @@
-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 ASTShiftLeft
- extends NumericExpression
-{
- public ASTShiftLeft( int id )
- {
- super( id );
- }
-
- public ASTShiftLeft( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- protected Object getValueBody( OgnlContext context, Object source )
- throws OgnlException
- {
- Object v1 = children[0].getValue( context, source );
- Object v2 = children[1].getValue( context, source );
- return OgnlOps.shiftLeft( v1, v2 );
- }
-
- 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 ASTShiftLeft
+ extends NumericExpression
+{
+ public ASTShiftLeft( int id )
+ {
+ super( id );
+ }
+
+ public ASTShiftLeft( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ protected Object getValueBody( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ Object v1 = children[0].getValue( context, source );
+ Object v2 = children[1].getValue( context, source );
+ return OgnlOps.shiftLeft( v1, v2 );
+ }
+
+ 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/ASTShiftRight.java b/src/main/java/org/apache/commons/ognl/ASTShiftRight.java
index f5de697..2169900 100644
--- a/src/main/java/org/apache/commons/ognl/ASTShiftRight.java
+++ b/src/main/java/org/apache/commons/ognl/ASTShiftRight.java
@@ -1,56 +1,55 @@
-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 ASTShiftRight
- extends NumericExpression
-{
- public ASTShiftRight( int id )
- {
- super( id );
- }
-
- public ASTShiftRight( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- protected Object getValueBody( OgnlContext context, Object source )
- throws OgnlException
- {
- Object v1 = children[0].getValue( context, source );
- Object v2 = children[1].getValue( context, source );
- return OgnlOps.shiftRight( v1, v2 );
- }
-
- 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 ASTShiftRight
+ extends NumericExpression
+{
+ public ASTShiftRight( int id )
+ {
+ super( id );
+ }
+
+ public ASTShiftRight( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ protected Object getValueBody( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ Object v1 = children[0].getValue( context, source );
+ Object v2 = children[1].getValue( context, source );
+ return OgnlOps.shiftRight( v1, v2 );
+ }
+
+ 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/ASTStaticField.java b/src/main/java/org/apache/commons/ognl/ASTStaticField.java
index f6f4ad8..5bdec11 100644
--- a/src/main/java/org/apache/commons/ognl/ASTStaticField.java
+++ b/src/main/java/org/apache/commons/ognl/ASTStaticField.java
@@ -1,221 +1,220 @@
-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 java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-
-/**
- * $Id$
- */
-public class ASTStaticField
- extends SimpleNode
- implements NodeType
-{
-
- private String className;
-
- private String fieldName;
-
- private Class getterClass;
-
- public ASTStaticField( int id )
- {
- super( id );
- }
-
- public ASTStaticField( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- /** Called from parser action. */
- void init( String className, String fieldName )
- {
- this.className = className;
- this.fieldName = fieldName;
- }
-
- protected Object getValueBody( OgnlContext context, Object source )
- throws OgnlException
- {
- return OgnlRuntime.getStaticField( context, className, fieldName );
- }
-
- public boolean isNodeConstant( OgnlContext context )
- throws OgnlException
- {
- boolean result = false;
- Exception cause = null;
-
- try
- {
- Class clazz = OgnlRuntime.classForName( context, className );
-
- /*
- * Check for virtual static field "class"; this cannot interfere with normal static fields because it is a
- * reserved word. It is considered constant.
- */
- if ( "class".equals( fieldName ) )
- {
- result = true;
- }
- else if ( clazz.isEnum() )
- {
- result = true;
- }
- else
- {
- Field field = clazz.getField( fieldName );
-
- if ( !Modifier.isStatic( field.getModifiers() ) )
- {
- throw new OgnlException( "Field " + fieldName + " of class " + className + " is not static" );
- }
- result = Modifier.isFinal( field.getModifiers() );
- }
- }
- catch ( ClassNotFoundException | SecurityException | NoSuchFieldException e )
- {
- cause = e;
- }
-
- if ( cause != null )
- {
- throw new OgnlException( "Could not get static field " + fieldName + " from class " + className, cause );
- }
-
- return result;
- }
-
- Class getFieldClass( OgnlContext context )
- throws OgnlException
- {
- Exception cause;
-
- try
- {
- Class clazz = OgnlRuntime.classForName( context, className );
-
- /*
- * Check for virtual static field "class"; this cannot interfere with normal static fields because it is a
- * reserved word. It is considered constant.
- */
- if ( "class".equals( fieldName ) )
- {
- return clazz;
- }
- if ( clazz.isEnum() )
- {
- return clazz;
- }
- Field field = clazz.getField( fieldName );
-
- return field.getType();
- }
- catch ( ClassNotFoundException | SecurityException | NoSuchFieldException e )
- {
- cause = e;
- }
- throw new OgnlException( "Could not get static field " + fieldName + " from class " + className, cause );
- }
-
- public Class getGetterClass()
- {
- return getterClass;
- }
-
- public Class getSetterClass()
- {
- return getterClass;
- }
-
- public String toGetSourceString( OgnlContext context, Object target )
- {
- try
- {
-
- Object obj = OgnlRuntime.getStaticField( context, className, fieldName );
-
- context.setCurrentObject( obj );
-
- getterClass = getFieldClass( context );
-
- context.setCurrentType( getterClass );
-
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
-
- return className + "." + fieldName;
- }
-
- public String toSetSourceString( OgnlContext context, Object target )
- {
- try
- {
-
- Object obj = OgnlRuntime.getStaticField( context, className, fieldName );
-
- context.setCurrentObject( obj );
-
- getterClass = getFieldClass( context );
-
- context.setCurrentType( getterClass );
-
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
-
- return className + "." + fieldName;
- }
-
- public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
- throws OgnlException
- {
- return visitor.visit( this, data );
- }
-
- /**
- * Get the field name for this field.
- *
- * @return the field name.
- * @since 4.0
- */
- String getFieldName()
- {
- return fieldName;
- }
-
- /**
- * Get the class name for this field.
- *
- * @return the class name.
- * @since 4.0
- */
- String getClassName()
- {
- return className;
- }
-}
+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 java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+
+/**
+ */
+public class ASTStaticField
+ extends SimpleNode
+ implements NodeType
+{
+
+ private String className;
+
+ private String fieldName;
+
+ private Class getterClass;
+
+ public ASTStaticField( int id )
+ {
+ super( id );
+ }
+
+ public ASTStaticField( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ /** Called from parser action. */
+ void init( String className, String fieldName )
+ {
+ this.className = className;
+ this.fieldName = fieldName;
+ }
+
+ protected Object getValueBody( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ return OgnlRuntime.getStaticField( context, className, fieldName );
+ }
+
+ public boolean isNodeConstant( OgnlContext context )
+ throws OgnlException
+ {
+ boolean result = false;
+ Exception cause = null;
+
+ try
+ {
+ Class clazz = OgnlRuntime.classForName( context, className );
+
+ /*
+ * Check for virtual static field "class"; this cannot interfere with normal static fields because it is a
+ * reserved word. It is considered constant.
+ */
+ if ( "class".equals( fieldName ) )
+ {
+ result = true;
+ }
+ else if ( clazz.isEnum() )
+ {
+ result = true;
+ }
+ else
+ {
+ Field field = clazz.getField( fieldName );
+
+ if ( !Modifier.isStatic( field.getModifiers() ) )
+ {
+ throw new OgnlException( "Field " + fieldName + " of class " + className + " is not static" );
+ }
+ result = Modifier.isFinal( field.getModifiers() );
+ }
+ }
+ catch ( ClassNotFoundException | SecurityException | NoSuchFieldException e )
+ {
+ cause = e;
+ }
+
+ if ( cause != null )
+ {
+ throw new OgnlException( "Could not get static field " + fieldName + " from class " + className, cause );
+ }
+
+ return result;
+ }
+
+ Class getFieldClass( OgnlContext context )
+ throws OgnlException
+ {
+ Exception cause;
+
+ try
+ {
+ Class clazz = OgnlRuntime.classForName( context, className );
+
+ /*
+ * Check for virtual static field "class"; this cannot interfere with normal static fields because it is a
+ * reserved word. It is considered constant.
+ */
+ if ( "class".equals( fieldName ) )
+ {
+ return clazz;
+ }
+ if ( clazz.isEnum() )
+ {
+ return clazz;
+ }
+ Field field = clazz.getField( fieldName );
+
+ return field.getType();
+ }
+ catch ( ClassNotFoundException | SecurityException | NoSuchFieldException e )
+ {
+ cause = e;
+ }
+ throw new OgnlException( "Could not get static field " + fieldName + " from class " + className, cause );
+ }
+
+ public Class getGetterClass()
+ {
+ return getterClass;
+ }
+
+ public Class getSetterClass()
+ {
+ return getterClass;
+ }
+
+ public String toGetSourceString( OgnlContext context, Object target )
+ {
+ try
+ {
+
+ Object obj = OgnlRuntime.getStaticField( context, className, fieldName );
+
+ context.setCurrentObject( obj );
+
+ getterClass = getFieldClass( context );
+
+ context.setCurrentType( getterClass );
+
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+
+ return className + "." + fieldName;
+ }
+
+ public String toSetSourceString( OgnlContext context, Object target )
+ {
+ try
+ {
+
+ Object obj = OgnlRuntime.getStaticField( context, className, fieldName );
+
+ context.setCurrentObject( obj );
+
+ getterClass = getFieldClass( context );
+
+ context.setCurrentType( getterClass );
+
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+
+ return className + "." + fieldName;
+ }
+
+ public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
+ throws OgnlException
+ {
+ return visitor.visit( this, data );
+ }
+
+ /**
+ * Get the field name for this field.
+ *
+ * @return the field name.
+ * @since 4.0
+ */
+ String getFieldName()
+ {
+ return fieldName;
+ }
+
+ /**
+ * Get the class name for this field.
+ *
+ * @return the class name.
+ * @since 4.0
+ */
+ String getClassName()
+ {
+ return className;
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTStaticMethod.java b/src/main/java/org/apache/commons/ognl/ASTStaticMethod.java
index 7134dfc..1ae7b29 100644
--- a/src/main/java/org/apache/commons/ognl/ASTStaticMethod.java
+++ b/src/main/java/org/apache/commons/ognl/ASTStaticMethod.java
@@ -1,230 +1,229 @@
-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.lang.reflect.Method;
-
-/**
- * $Id$
- */
-public class ASTStaticMethod
- extends SimpleNode
- implements NodeType
-{
-
- private String className;
-
- private String methodName;
-
- private Class getterClass;
-
- public ASTStaticMethod( int id )
- {
- super( id );
- }
-
- public ASTStaticMethod( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- /**
- * Called from parser action.
- */
- void init( String className, String methodName )
- {
- this.className = className;
- this.methodName = methodName;
- }
-
- protected Object getValueBody( OgnlContext context, Object source )
- throws OgnlException
- {
- Object[] args = new Object[jjtGetNumChildren()];
- Object root = context.getRoot();
-
- for ( int i = 0, icount = args.length; i < icount; ++i )
- {
- args[i] = children[i].getValue( context, root );
- }
-
- return OgnlRuntime.callStaticMethod( context, className, methodName, args );
- }
-
- public Class getGetterClass()
- {
- return getterClass;
- }
-
- public Class getSetterClass()
- {
- return getterClass;
- }
-
- public String toGetSourceString( OgnlContext context, Object target )
- {
- StringBuilder result = new StringBuilder(className + "#" + methodName + "(");
-
- try
- {
- Class clazz = OgnlRuntime.classForName( context, className );
- Method m = OgnlRuntime.getMethod( context, clazz, methodName, children, true );
-
- if ( m == null )
- {
- throw new UnsupportedCompilationException(
- "Unable to find class/method combo " + className + " / " + methodName );
- }
-
- if ( !context.getMemberAccess().isAccessible( context, clazz, m, methodName ) )
- {
- throw new UnsupportedCompilationException(
- "Method is not accessible, check your jvm runtime security settings. " + "For static class method "
- + className + " / " + methodName );
- }
-
- OgnlExpressionCompiler compiler = OgnlRuntime.getCompiler( context );
- if ( ( children != null ) && ( children.length > 0 ) )
- {
- Class[] parms = m.getParameterTypes();
-
- for ( int i = 0; i < children.length; i++ )
- {
- if ( i > 0 )
- {
- result.append(", ");
- }
-
- Class prevType = context.getCurrentType();
-
- Node child = children[i];
- Object root = context.getRoot();
-
- String parmString = ASTMethodUtil.getParmString( context, root, child, prevType );
-
- Class valueClass = ASTMethodUtil.getValueClass( context, root, child );
-
- if ( valueClass != parms[i] )
- {
- if ( parms[i].isArray() )
- {
- parmString = compiler.createLocalReference( context, "(" + ExpressionCompiler.getCastString(
- parms[i] ) + ")org.apache.commons.ognl.OgnlOps.toArray(" + parmString + ", "
- + parms[i].getComponentType().getName() + ".class, true)", parms[i] );
-
- }
- else if ( parms[i].isPrimitive() )
- {
- Class wrapClass = OgnlRuntime.getPrimitiveWrapperClass( parms[i] );
-
- parmString = compiler.createLocalReference( context, "((" + wrapClass.getName()
- + ")org.apache.commons.ognl.OgnlOps.convertValue(" + parmString + ","
- + wrapClass.getName() + ".class, true))." + OgnlRuntime.getNumericValueGetter(
- wrapClass ), parms[i] );
-
- }
- else if ( parms[i] != Object.class )
- {
- parmString = compiler.createLocalReference( context, "(" + parms[i].getName()
- + ")org.apache.commons.ognl.OgnlOps.convertValue(" + parmString + ","
- + parms[i].getName() + ".class)", parms[i] );
- }
- else if ( ( child instanceof NodeType && ( (NodeType) child ).getGetterClass() != null
- && Number.class.isAssignableFrom( ( (NodeType) child ).getGetterClass() ) )
- || valueClass.isPrimitive() )
- {
- parmString = " ($w) " + parmString;
- }
- else if ( valueClass.isPrimitive() )
- {
- parmString = "($w) " + parmString;
- }
- }
-
- result.append(parmString);
- }
- }
-
- result.append(")");
-
- try
- {
- Object contextObj = getValueBody( context, target );
- context.setCurrentObject( contextObj );
- }
- catch ( Throwable t )
- {
- // ignore
- }
-
- if ( m != null )
- {
- getterClass = m.getReturnType();
-
- context.setCurrentType( m.getReturnType() );
- context.setCurrentAccessor( compiler.getSuperOrInterfaceClass( m, m.getDeclaringClass() ) );
- }
-
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
-
- return result.toString();
- }
-
- 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 );
- }
-
- /**
- * Get the class name for this method.
- *
- * @return the class name.
- * @since 4.0
- */
- public String getClassName()
- {
- return className;
- }
-
- /**
- * Get the method name for this method.
- *
- * @return the method name.
- * @since 4.0
- */
- public String getMethodName()
- {
- return methodName;
- }
-}
+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.lang.reflect.Method;
+
+/**
+ */
+public class ASTStaticMethod
+ extends SimpleNode
+ implements NodeType
+{
+
+ private String className;
+
+ private String methodName;
+
+ private Class getterClass;
+
+ public ASTStaticMethod( int id )
+ {
+ super( id );
+ }
+
+ public ASTStaticMethod( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ /**
+ * Called from parser action.
+ */
+ void init( String className, String methodName )
+ {
+ this.className = className;
+ this.methodName = methodName;
+ }
+
+ protected Object getValueBody( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ Object[] args = new Object[jjtGetNumChildren()];
+ Object root = context.getRoot();
+
+ for ( int i = 0, icount = args.length; i < icount; ++i )
+ {
+ args[i] = children[i].getValue( context, root );
+ }
+
+ return OgnlRuntime.callStaticMethod( context, className, methodName, args );
+ }
+
+ public Class getGetterClass()
+ {
+ return getterClass;
+ }
+
+ public Class getSetterClass()
+ {
+ return getterClass;
+ }
+
+ public String toGetSourceString( OgnlContext context, Object target )
+ {
+ StringBuilder result = new StringBuilder(className + "#" + methodName + "(");
+
+ try
+ {
+ Class clazz = OgnlRuntime.classForName( context, className );
+ Method m = OgnlRuntime.getMethod( context, clazz, methodName, children, true );
+
+ if ( m == null )
+ {
+ throw new UnsupportedCompilationException(
+ "Unable to find class/method combo " + className + " / " + methodName );
+ }
+
+ if ( !context.getMemberAccess().isAccessible( context, clazz, m, methodName ) )
+ {
+ throw new UnsupportedCompilationException(
+ "Method is not accessible, check your jvm runtime security settings. " + "For static class method "
+ + className + " / " + methodName );
+ }
+
+ OgnlExpressionCompiler compiler = OgnlRuntime.getCompiler( context );
+ if ( ( children != null ) && ( children.length > 0 ) )
+ {
+ Class[] parms = m.getParameterTypes();
+
+ for ( int i = 0; i < children.length; i++ )
+ {
+ if ( i > 0 )
+ {
+ result.append(", ");
+ }
+
+ Class prevType = context.getCurrentType();
+
+ Node child = children[i];
+ Object root = context.getRoot();
+
+ String parmString = ASTMethodUtil.getParmString( context, root, child, prevType );
+
+ Class valueClass = ASTMethodUtil.getValueClass( context, root, child );
+
+ if ( valueClass != parms[i] )
+ {
+ if ( parms[i].isArray() )
+ {
+ parmString = compiler.createLocalReference( context, "(" + ExpressionCompiler.getCastString(
+ parms[i] ) + ")org.apache.commons.ognl.OgnlOps.toArray(" + parmString + ", "
+ + parms[i].getComponentType().getName() + ".class, true)", parms[i] );
+
+ }
+ else if ( parms[i].isPrimitive() )
+ {
+ Class wrapClass = OgnlRuntime.getPrimitiveWrapperClass( parms[i] );
+
+ parmString = compiler.createLocalReference( context, "((" + wrapClass.getName()
+ + ")org.apache.commons.ognl.OgnlOps.convertValue(" + parmString + ","
+ + wrapClass.getName() + ".class, true))." + OgnlRuntime.getNumericValueGetter(
+ wrapClass ), parms[i] );
+
+ }
+ else if ( parms[i] != Object.class )
+ {
+ parmString = compiler.createLocalReference( context, "(" + parms[i].getName()
+ + ")org.apache.commons.ognl.OgnlOps.convertValue(" + parmString + ","
+ + parms[i].getName() + ".class)", parms[i] );
+ }
+ else if ( ( child instanceof NodeType && ( (NodeType) child ).getGetterClass() != null
+ && Number.class.isAssignableFrom( ( (NodeType) child ).getGetterClass() ) )
+ || valueClass.isPrimitive() )
+ {
+ parmString = " ($w) " + parmString;
+ }
+ else if ( valueClass.isPrimitive() )
+ {
+ parmString = "($w) " + parmString;
+ }
+ }
+
+ result.append(parmString);
+ }
+ }
+
+ result.append(")");
+
+ try
+ {
+ Object contextObj = getValueBody( context, target );
+ context.setCurrentObject( contextObj );
+ }
+ catch ( Throwable t )
+ {
+ // ignore
+ }
+
+ if ( m != null )
+ {
+ getterClass = m.getReturnType();
+
+ context.setCurrentType( m.getReturnType() );
+ context.setCurrentAccessor( compiler.getSuperOrInterfaceClass( m, m.getDeclaringClass() ) );
+ }
+
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+
+ return result.toString();
+ }
+
+ 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 );
+ }
+
+ /**
+ * Get the class name for this method.
+ *
+ * @return the class name.
+ * @since 4.0
+ */
+ public String getClassName()
+ {
+ return className;
+ }
+
+ /**
+ * Get the method name for this method.
+ *
+ * @return the method name.
+ * @since 4.0
+ */
+ public String getMethodName()
+ {
+ return methodName;
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTSubtract.java b/src/main/java/org/apache/commons/ognl/ASTSubtract.java
index da84eef..4281746 100644
--- a/src/main/java/org/apache/commons/ognl/ASTSubtract.java
+++ b/src/main/java/org/apache/commons/ognl/ASTSubtract.java
@@ -1,56 +1,55 @@
-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 ASTSubtract
- extends NumericExpression
-{
- public ASTSubtract( int id )
- {
- super( id );
- }
-
- public ASTSubtract( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- protected Object getValueBody( OgnlContext context, Object source )
- throws OgnlException
- {
- Object v1 = children[0].getValue( context, source );
- Object v2 = children[1].getValue( context, source );
- return OgnlOps.subtract( v1, v2 );
- }
-
- 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 ASTSubtract
+ extends NumericExpression
+{
+ public ASTSubtract( int id )
+ {
+ super( id );
+ }
+
+ public ASTSubtract( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ protected Object getValueBody( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ Object v1 = children[0].getValue( context, source );
+ Object v2 = children[1].getValue( context, source );
+ return OgnlOps.subtract( v1, v2 );
+ }
+
+ 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/ASTTest.java b/src/main/java/org/apache/commons/ognl/ASTTest.java
index 62bb200..25d73a7 100644
--- a/src/main/java/org/apache/commons/ognl/ASTTest.java
+++ b/src/main/java/org/apache/commons/ognl/ASTTest.java
@@ -1,153 +1,152 @@
-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 ASTTest
- extends ExpressionNode
-{
- public ASTTest( int id )
- {
- super( id );
- }
-
- public ASTTest( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- protected Object getValueBody( OgnlContext context, Object source )
- throws OgnlException
- {
- Object test = children[0].getValue( context, source );
- int branch = OgnlOps.booleanValue( test ) ? 1 : 2;
- return children[branch].getValue( context, source );
- }
-
- protected void setValueBody( OgnlContext context, Object target, Object value )
- throws OgnlException
- {
- Object test = children[0].getValue( context, target );
- int branch = OgnlOps.booleanValue( test ) ? 1 : 2;
- children[branch].setValue( context, target, value );
- }
-
- public String getExpressionOperator( int index )
- {
- return ( index == 1 ) ? "?" : ":";
- }
-
- public String toGetSourceString( OgnlContext context, Object target )
- {
- if ( target == null )
- {
- throw new UnsupportedCompilationException( "evaluation resulted in null expression." );
- }
-
- if ( children.length != 3 )
- {
- throw new UnsupportedCompilationException( "Can only compile test expressions with two children."
- + children.length );
- }
-
- String result = "";
-
- try
- {
-
- String first = OgnlRuntime.getChildSource( context, target, children[0] );
- if ( !OgnlRuntime.isBoolean( first ) && !context.getCurrentType().isPrimitive() )
- {
- first = OgnlRuntime.getCompiler( context ).createLocalReference( context, first, context.getCurrentType() );
- }
-
- if (children[0] instanceof ExpressionNode)
- {
- first = "(" + first + ")";
- }
-
- String second = OgnlRuntime.getChildSource( context, target, children[1] );
- Class secondType = context.getCurrentType();
-
- if ( !OgnlRuntime.isBoolean( second ) && !context.getCurrentType().isPrimitive() )
- {
- second = OgnlRuntime.getCompiler( context ).createLocalReference( context, second, context.getCurrentType() );
- }
-
- if (children[1] instanceof ExpressionNode)
- {
- second = "(" + second + ")";
- }
-
- String third = OgnlRuntime.getChildSource( context, target, children[2] );
- Class thirdType = context.getCurrentType();
-
- if ( !OgnlRuntime.isBoolean( third ) && !context.getCurrentType().isPrimitive() )
- {
- third = OgnlRuntime.getCompiler( context ).createLocalReference( context, third, context.getCurrentType() );
-
- }
-
- if (children[2] instanceof ExpressionNode)
- {
- third = "(" + third + ")";
- }
-
- boolean mismatched =
- ( secondType.isPrimitive( ) && !thirdType.isPrimitive( ) ) || ( !secondType.isPrimitive( )
- && thirdType.isPrimitive( ) );
-
- result += "org.apache.commons.ognl.OgnlOps.booleanValue(" + first + ")";
-
- result += " ? ";
-
- result += ( mismatched ? " ($w) " : "" ) + second;
- result += " : ";
-
- result += ( mismatched ? " ($w) " : "" ) + third;
-
- context.setCurrentObject( target );
- context.setCurrentType( mismatched ? Object.class : secondType );
-
- return result;
-
- }
- catch ( NullPointerException e )
- {
-
- // expected to happen in some instances
- 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 ASTTest
+ extends ExpressionNode
+{
+ public ASTTest( int id )
+ {
+ super( id );
+ }
+
+ public ASTTest( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ protected Object getValueBody( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ Object test = children[0].getValue( context, source );
+ int branch = OgnlOps.booleanValue( test ) ? 1 : 2;
+ return children[branch].getValue( context, source );
+ }
+
+ protected void setValueBody( OgnlContext context, Object target, Object value )
+ throws OgnlException
+ {
+ Object test = children[0].getValue( context, target );
+ int branch = OgnlOps.booleanValue( test ) ? 1 : 2;
+ children[branch].setValue( context, target, value );
+ }
+
+ public String getExpressionOperator( int index )
+ {
+ return ( index == 1 ) ? "?" : ":";
+ }
+
+ public String toGetSourceString( OgnlContext context, Object target )
+ {
+ if ( target == null )
+ {
+ throw new UnsupportedCompilationException( "evaluation resulted in null expression." );
+ }
+
+ if ( children.length != 3 )
+ {
+ throw new UnsupportedCompilationException( "Can only compile test expressions with two children."
+ + children.length );
+ }
+
+ String result = "";
+
+ try
+ {
+
+ String first = OgnlRuntime.getChildSource( context, target, children[0] );
+ if ( !OgnlRuntime.isBoolean( first ) && !context.getCurrentType().isPrimitive() )
+ {
+ first = OgnlRuntime.getCompiler( context ).createLocalReference( context, first, context.getCurrentType() );
+ }
+
+ if (children[0] instanceof ExpressionNode)
+ {
+ first = "(" + first + ")";
+ }
+
+ String second = OgnlRuntime.getChildSource( context, target, children[1] );
+ Class secondType = context.getCurrentType();
+
+ if ( !OgnlRuntime.isBoolean( second ) && !context.getCurrentType().isPrimitive() )
+ {
+ second = OgnlRuntime.getCompiler( context ).createLocalReference( context, second, context.getCurrentType() );
+ }
+
+ if (children[1] instanceof ExpressionNode)
+ {
+ second = "(" + second + ")";
+ }
+
+ String third = OgnlRuntime.getChildSource( context, target, children[2] );
+ Class thirdType = context.getCurrentType();
+
+ if ( !OgnlRuntime.isBoolean( third ) && !context.getCurrentType().isPrimitive() )
+ {
+ third = OgnlRuntime.getCompiler( context ).createLocalReference( context, third, context.getCurrentType() );
+
+ }
+
+ if (children[2] instanceof ExpressionNode)
+ {
+ third = "(" + third + ")";
+ }
+
+ boolean mismatched =
+ ( secondType.isPrimitive( ) && !thirdType.isPrimitive( ) ) || ( !secondType.isPrimitive( )
+ && thirdType.isPrimitive( ) );
+
+ result += "org.apache.commons.ognl.OgnlOps.booleanValue(" + first + ")";
+
+ result += " ? ";
+
+ result += ( mismatched ? " ($w) " : "" ) + second;
+ result += " : ";
+
+ result += ( mismatched ? " ($w) " : "" ) + third;
+
+ context.setCurrentObject( target );
+ context.setCurrentType( mismatched ? Object.class : secondType );
+
+ return result;
+
+ }
+ catch ( NullPointerException e )
+ {
+
+ // expected to happen in some instances
+ 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 );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/ASTThisVarRef.java b/src/main/java/org/apache/commons/ognl/ASTThisVarRef.java
index dd9b13a..87a511a 100644
--- a/src/main/java/org/apache/commons/ognl/ASTThisVarRef.java
+++ b/src/main/java/org/apache/commons/ognl/ASTThisVarRef.java
@@ -1,68 +1,67 @@
-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 ASTThisVarRef
- extends ASTVarRef
-{
-
- public ASTThisVarRef( int id )
- {
- super( id );
- }
-
- public ASTThisVarRef( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- protected Object getValueBody( OgnlContext context, Object source )
- throws OgnlException
- {
- return context.getCurrentObject();
- }
-
- protected void setValueBody( OgnlContext context, Object target, Object value )
- throws OgnlException
- {
- context.setCurrentObject( value );
- }
-
- public String toGetSourceString( OgnlContext context, Object target )
- {
- throw new UnsupportedCompilationException( "Unable to compile this references." );
- }
-
- public String toSetSourceString( OgnlContext context, Object target )
- {
- throw new UnsupportedCompilationException( "Unable to compile this references." );
- }
-
- 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 ASTThisVarRef
+ extends ASTVarRef
+{
+
+ public ASTThisVarRef( int id )
+ {
+ super( id );
+ }
+
+ public ASTThisVarRef( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ protected Object getValueBody( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ return context.getCurrentObject();
+ }
+
+ protected void setValueBody( OgnlContext context, Object target, Object value )
+ throws OgnlException
+ {
+ context.setCurrentObject( value );
+ }
+
+ public String toGetSourceString( OgnlContext context, Object target )
+ {
+ throw new UnsupportedCompilationException( "Unable to compile this references." );
+ }
+
+ public String toSetSourceString( OgnlContext context, Object target )
+ {
+ throw new UnsupportedCompilationException( "Unable to compile this references." );
+ }
+
+ 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/ASTUnsignedShiftRight.java b/src/main/java/org/apache/commons/ognl/ASTUnsignedShiftRight.java
index 037d29b..facb259 100644
--- a/src/main/java/org/apache/commons/ognl/ASTUnsignedShiftRight.java
+++ b/src/main/java/org/apache/commons/ognl/ASTUnsignedShiftRight.java
@@ -1,92 +1,91 @@
-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 ASTUnsignedShiftRight
- extends NumericExpression
-{
- public ASTUnsignedShiftRight( int id )
- {
- super( id );
- }
-
- public ASTUnsignedShiftRight( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- protected Object getValueBody( OgnlContext context, Object source )
- throws OgnlException
- {
- Object v1 = children[0].getValue( context, source );
- Object v2 = children[1].getValue( context, source );
- return OgnlOps.unsignedShiftRight( v1, v2 );
- }
-
- public String getExpressionOperator( int index )
- {
- return ">>>";
- }
-
- public String toGetSourceString( OgnlContext context, Object target )
- {
- String result = "";
-
- try
- {
-
- String child1 = OgnlRuntime.getChildSource( context, target, children[0] );
- child1 = coerceToNumeric( child1, context, children[0] );
-
- String child2 = OgnlRuntime.getChildSource( context, target, children[1] );
- child2 = coerceToNumeric( child2, context, children[1] );
-
- Object v1 = children[0].getValue( context, target );
- int type = OgnlOps.getNumericType( v1 );
-
- if ( type <= OgnlOps.INT )
- {
- child1 = "(int)" + child1;
- child2 = "(int)" + child2;
- }
-
- result = child1 + " >>> " + child2;
-
- context.setCurrentType( Integer.TYPE );
- context.setCurrentObject( getValueBody( context, target ) );
-
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
-
- 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.
+ */
+
+/**
+ */
+class ASTUnsignedShiftRight
+ extends NumericExpression
+{
+ public ASTUnsignedShiftRight( int id )
+ {
+ super( id );
+ }
+
+ public ASTUnsignedShiftRight( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ protected Object getValueBody( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ Object v1 = children[0].getValue( context, source );
+ Object v2 = children[1].getValue( context, source );
+ return OgnlOps.unsignedShiftRight( v1, v2 );
+ }
+
+ public String getExpressionOperator( int index )
+ {
+ return ">>>";
+ }
+
+ public String toGetSourceString( OgnlContext context, Object target )
+ {
+ String result = "";
+
+ try
+ {
+
+ String child1 = OgnlRuntime.getChildSource( context, target, children[0] );
+ child1 = coerceToNumeric( child1, context, children[0] );
+
+ String child2 = OgnlRuntime.getChildSource( context, target, children[1] );
+ child2 = coerceToNumeric( child2, context, children[1] );
+
+ Object v1 = children[0].getValue( context, target );
+ int type = OgnlOps.getNumericType( v1 );
+
+ if ( type <= OgnlOps.INT )
+ {
+ child1 = "(int)" + child1;
+ child2 = "(int)" + child2;
+ }
+
+ result = child1 + " >>> " + child2;
+
+ context.setCurrentType( Integer.TYPE );
+ context.setCurrentObject( getValueBody( context, target ) );
+
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+
+ 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/ASTVarRef.java b/src/main/java/org/apache/commons/ognl/ASTVarRef.java
index 53d5fef..465d665 100644
--- a/src/main/java/org/apache/commons/ognl/ASTVarRef.java
+++ b/src/main/java/org/apache/commons/ognl/ASTVarRef.java
@@ -1,148 +1,147 @@
-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$
- */
-public class ASTVarRef
- extends SimpleNode
- implements NodeType, OrderedReturn
-{
-
- private String name;
-
- protected Class getterClass;
-
- protected String core;
-
- protected String last;
-
- public ASTVarRef( int id )
- {
- super( id );
- }
-
- public ASTVarRef( OgnlParser p, int id )
- {
- super( p, id );
- }
-
- void setName( String name )
- {
- this.name = name;
- }
- /**
- * Get the variable name.
- *
- * @return the variable name.
- * @since 4.0
- */
- String getName()
- {
- return name;
- }
-
- protected Object getValueBody( OgnlContext context, Object source )
- throws OgnlException
- {
- return context.get( name );
- }
-
- protected void setValueBody( OgnlContext context, Object target, Object value )
- throws OgnlException
- {
- context.put( name, value );
- }
-
- public Class getGetterClass()
- {
- return getterClass;
- }
-
- public Class getSetterClass()
- {
- return null;
- }
-
- public String getCoreExpression()
- {
- return core;
- }
-
- public String getLastExpression()
- {
- return last;
- }
-
- public String toGetSourceString( OgnlContext context, Object target )
- {
- Object value = context.get( name );
-
- if ( value != null )
- {
-
- getterClass = value.getClass();
- }
-
- context.setCurrentType( getterClass );
- context.setCurrentAccessor( context.getClass() );
-
- context.setCurrentObject( value );
- // context.setRoot(context.get(name));
-
- if ( context.getCurrentObject() == null )
- {
- throw new UnsupportedCompilationException( "Current context object is null, can't compile var reference." );
- }
-
- String pre = "";
- String post = "";
- if ( context.getCurrentType() != null )
- {
- pre = "((" + OgnlRuntime.getCompiler( context ).getInterfaceClass( context.getCurrentType() ).getName() + ")";
- post = ")";
- }
-
- if ( parent != null && parent instanceof ASTAssign)
- {
- core = "$1.put(\"" + name + "\",";
- last = pre + "$1.get(\"" + name + "\")" + post;
-
- return core;
- }
-
- return pre + "$1.get(\"" + name + "\")" + post;
- }
-
- 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.
+ */
+
+import org.apache.commons.ognl.enhance.OrderedReturn;
+import org.apache.commons.ognl.enhance.UnsupportedCompilationException;
+
+/**
+ */
+public class ASTVarRef
+ extends SimpleNode
+ implements NodeType, OrderedReturn
+{
+
+ private String name;
+
+ protected Class getterClass;
+
+ protected String core;
+
+ protected String last;
+
+ public ASTVarRef( int id )
+ {
+ super( id );
+ }
+
+ public ASTVarRef( OgnlParser p, int id )
+ {
+ super( p, id );
+ }
+
+ void setName( String name )
+ {
+ this.name = name;
+ }
+ /**
+ * Get the variable name.
+ *
+ * @return the variable name.
+ * @since 4.0
+ */
+ String getName()
+ {
+ return name;
+ }
+
+ protected Object getValueBody( OgnlContext context, Object source )
+ throws OgnlException
+ {
+ return context.get( name );
+ }
+
+ protected void setValueBody( OgnlContext context, Object target, Object value )
+ throws OgnlException
+ {
+ context.put( name, value );
+ }
+
+ public Class getGetterClass()
+ {
+ return getterClass;
+ }
+
+ public Class getSetterClass()
+ {
+ return null;
+ }
+
+ public String getCoreExpression()
+ {
+ return core;
+ }
+
+ public String getLastExpression()
+ {
+ return last;
+ }
+
+ public String toGetSourceString( OgnlContext context, Object target )
+ {
+ Object value = context.get( name );
+
+ if ( value != null )
+ {
+
+ getterClass = value.getClass();
+ }
+
+ context.setCurrentType( getterClass );
+ context.setCurrentAccessor( context.getClass() );
+
+ context.setCurrentObject( value );
+ // context.setRoot(context.get(name));
+
+ if ( context.getCurrentObject() == null )
+ {
+ throw new UnsupportedCompilationException( "Current context object is null, can't compile var reference." );
+ }
+
+ String pre = "";
+ String post = "";
+ if ( context.getCurrentType() != null )
+ {
+ pre = "((" + OgnlRuntime.getCompiler( context ).getInterfaceClass( context.getCurrentType() ).getName() + ")";
+ post = ")";
+ }
+
+ if ( parent != null && parent instanceof ASTAssign)
+ {
+ core = "$1.put(\"" + name + "\",";
+ last = pre + "$1.get(\"" + name + "\")" + post;
+
+ return core;
+ }
+
+ return pre + "$1.get(\"" + name + "\")" + post;
+ }
+
+ 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/ASTXor.java b/src/main/java/org/apache/commons/ognl/ASTXor.java
index 7c9ed1e..04e8e5d 100644
--- a/src/main/java/org/apache/commons/ognl/ASTXor.java
+++ b/src/main/java/org/apache/commons/ognl/ASTXor.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 ASTXor
- extends NumericExpression
-{
- public ASTXor( int id )
- {
- super( id );
- }
-
- public ASTXor( 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.binaryXor( 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 ASTXor
+ extends NumericExpression
+{
+ public ASTXor( int id )
+ {
+ super( id );
+ }
+
+ public ASTXor( 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.binaryXor( 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/JJTOgnlParserState.java b/src/main/java/org/apache/commons/ognl/JJTOgnlParserState.java
index 489310a..9d59216 100644
--- a/src/main/java/org/apache/commons/ognl/JJTOgnlParserState.java
+++ b/src/main/java/org/apache/commons/ognl/JJTOgnlParserState.java
@@ -1,173 +1,172 @@
-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.
- */
-
-/* Generated By:JavaCC: Do not edit this line. JJTOgnlParserState.java Version 4.1d1 */
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * $Id$
- */
-public class JJTOgnlParserState
-{
- private final List<Node> nodes;
-
- private final List<Integer> marks;
-
- private int numNodesOnStack;
-
- private int currentMark;
-
- private boolean nodeCreated;
-
- public JJTOgnlParserState()
- {
- nodes = new ArrayList<Node>();
- marks = new ArrayList<Integer>();
- numNodesOnStack = 0;
- currentMark = 0;
- }
-
- /*
- * Determines whether the current node was actually closed and pushed. This should only be called in the final user
- * action of a node scope.
- */
- public boolean nodeCreated()
- {
- return nodeCreated;
- }
-
- /*
- * Call this to reinitialize the node stack. It is called automatically by the parser's ReInit() method.
- */
- public void reset()
- {
- nodes.clear();
- marks.clear();
- numNodesOnStack = 0;
- currentMark = 0;
- }
-
- /*
- * Returns the root node of the AST. It only makes sense to call this after a successful parse.
- */
- public Node rootNode()
- {
- return nodes.get( 0 );
- }
-
- /* Pushes a node on to the stack. */
- public void pushNode( Node node )
- {
- nodes.add( node );
- ++numNodesOnStack;
- }
-
- /*
- * Returns the node on the top of the stack, and remove it from the stack.
- */
- public Node popNode()
- {
- if ( --numNodesOnStack < currentMark )
- {
- currentMark = marks.remove( marks.size() - 1 );
- }
- return nodes.remove( nodes.size() - 1 );
- }
-
- /* Returns the node currently on the top of the stack. */
- public Node peekNode()
- {
- return nodes.get( nodes.size() - 1 );
- }
-
- /*
- * Returns the number of children on the stack in the current node scope.
- */
- public int nodeArity()
- {
- return numNodesOnStack - currentMark;
- }
-
- public void clearNodeScope( Node unused )
- {
- while ( numNodesOnStack > currentMark )
- {
- popNode();
- }
- currentMark = marks.remove( marks.size() - 1 );
- }
-
- public void openNodeScope( Node node )
- {
- marks.add( currentMark );
- currentMark = numNodesOnStack;
- node.jjtOpen();
- }
-
- /*
- * A definite node is constructed from a specified number of children. That number of nodes are popped from the
- * stack and made the children of the definite node. Then the definite node is pushed on to the stack.
- */
- public void closeNodeScope( Node node, int num )
- {
- currentMark = marks.remove( marks.size() - 1 );
- while ( num-- > 0 )
- {
- Node poppedNode = popNode();
- poppedNode.jjtSetParent( node );
- node.jjtAddChild( poppedNode, num );
- }
- node.jjtClose();
- pushNode( node );
- nodeCreated = true;
- }
-
- /*
- * A conditional node is constructed if its condition is true. All the nodes that have been pushed since the node
- * was opened are made children of the conditional node, which is then pushed on to the stack. If the condition is
- * false the node is not constructed and they are left on the stack.
- */
- public void closeNodeScope( Node node, boolean condition )
- {
- if ( condition )
- {
- int arity = nodeArity();
- currentMark = marks.remove( marks.size() - 1 );
- while ( arity-- > 0 )
- {
- Node poppedNode = popNode();
- poppedNode.jjtSetParent( node );
- node.jjtAddChild( poppedNode, arity );
- }
- node.jjtClose();
- pushNode( node );
- nodeCreated = true;
- }
- else
- {
- currentMark = marks.remove( marks.size() - 1 );
- nodeCreated = false;
- }
- }
-}
-/* JavaCC - OriginalChecksum=61071c68a05e7c9104307c34a2e37165 (do not edit this line) */
+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.
+ */
+
+/* Generated By:JavaCC: Do not edit this line. JJTOgnlParserState.java Version 4.1d1 */
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ */
+public class JJTOgnlParserState
+{
+ private final List<Node> nodes;
+
+ private final List<Integer> marks;
+
+ private int numNodesOnStack;
+
+ private int currentMark;
+
+ private boolean nodeCreated;
+
+ public JJTOgnlParserState()
+ {
+ nodes = new ArrayList<Node>();
+ marks = new ArrayList<Integer>();
+ numNodesOnStack = 0;
+ currentMark = 0;
+ }
+
+ /*
+ * Determines whether the current node was actually closed and pushed. This should only be called in the final user
+ * action of a node scope.
+ */
+ public boolean nodeCreated()
+ {
+ return nodeCreated;
+ }
+
+ /*
+ * Call this to reinitialize the node stack. It is called automatically by the parser's ReInit() method.
+ */
+ public void reset()
+ {
+ nodes.clear();
+ marks.clear();
+ numNodesOnStack = 0;
+ currentMark = 0;
+ }
+
+ /*
+ * Returns the root node of the AST. It only makes sense to call this after a successful parse.
+ */
+ public Node rootNode()
+ {
+ return nodes.get( 0 );
+ }
+
+ /* Pushes a node on to the stack. */
+ public void pushNode( Node node )
+ {
+ nodes.add( node );
+ ++numNodesOnStack;
+ }
+
+ /*
+ * Returns the node on the top of the stack, and remove it from the stack.
+ */
+ public Node popNode()
+ {
+ if ( --numNodesOnStack < currentMark )
+ {
+ currentMark = marks.remove( marks.size() - 1 );
+ }
+ return nodes.remove( nodes.size() - 1 );
+ }
+
+ /* Returns the node currently on the top of the stack. */
+ public Node peekNode()
+ {
+ return nodes.get( nodes.size() - 1 );
+ }
+
+ /*
+ * Returns the number of children on the stack in the current node scope.
+ */
+ public int nodeArity()
+ {
+ return numNodesOnStack - currentMark;
+ }
+
+ public void clearNodeScope( Node unused )
+ {
+ while ( numNodesOnStack > currentMark )
+ {
+ popNode();
+ }
+ currentMark = marks.remove( marks.size() - 1 );
+ }
+
+ public void openNodeScope( Node node )
+ {
+ marks.add( currentMark );
+ currentMark = numNodesOnStack;
+ node.jjtOpen();
+ }
+
+ /*
+ * A definite node is constructed from a specified number of children. That number of nodes are popped from the
+ * stack and made the children of the definite node. Then the definite node is pushed on to the stack.
+ */
+ public void closeNodeScope( Node node, int num )
+ {
+ currentMark = marks.remove( marks.size() - 1 );
+ while ( num-- > 0 )
+ {
+ Node poppedNode = popNode();
+ poppedNode.jjtSetParent( node );
+ node.jjtAddChild( poppedNode, num );
+ }
+ node.jjtClose();
+ pushNode( node );
+ nodeCreated = true;
+ }
+
+ /*
+ * A conditional node is constructed if its condition is true. All the nodes that have been pushed since the node
+ * was opened are made children of the conditional node, which is then pushed on to the stack. If the condition is
+ * false the node is not constructed and they are left on the stack.
+ */
+ public void closeNodeScope( Node node, boolean condition )
+ {
+ if ( condition )
+ {
+ int arity = nodeArity();
+ currentMark = marks.remove( marks.size() - 1 );
+ while ( arity-- > 0 )
+ {
+ Node poppedNode = popNode();
+ poppedNode.jjtSetParent( node );
+ node.jjtAddChild( poppedNode, arity );
+ }
+ node.jjtClose();
+ pushNode( node );
+ nodeCreated = true;
+ }
+ else
+ {
+ currentMark = marks.remove( marks.size() - 1 );
+ nodeCreated = false;
+ }
+ }
+}
+/* JavaCC - OriginalChecksum=61071c68a05e7c9104307c34a2e37165 (do not edit this line) */
diff --git a/src/main/java/org/apache/commons/ognl/MapPropertyAccessor.java b/src/main/java/org/apache/commons/ognl/MapPropertyAccessor.java
index df526d4..2cc3834 100644
--- a/src/main/java/org/apache/commons/ognl/MapPropertyAccessor.java
+++ b/src/main/java/org/apache/commons/ognl/MapPropertyAccessor.java
@@ -1,170 +1,169 @@
-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 java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Implementation of PropertyAccessor that sets and gets properties by storing and looking up values in Maps.
- *
- * $Id$
- */
-public class MapPropertyAccessor
- implements PropertyAccessor
-{
-
- public Object getProperty( Map<String, Object> context, Object target, Object name )
- throws OgnlException
- {
- Object result;
- @SuppressWarnings( "unchecked" ) // checked by the invoker
- Map<Object, Object> map = (Map<Object, Object>) target;
- Node currentNode = ( (OgnlContext) context ).getCurrentNode().jjtGetParent();
- boolean indexedAccess = false;
-
- if ( currentNode == null )
- {
- throw new OgnlException( "node is null for '" + name + "'" );
- }
- if ( !( currentNode instanceof ASTProperty ) )
- {
- currentNode = currentNode.jjtGetParent();
- }
- if ( currentNode instanceof ASTProperty )
- {
- indexedAccess = ( (ASTProperty) currentNode ).isIndexedAccess();
- }
-
- if ( ( name instanceof String ) && !indexedAccess )
- {
- if ( "size".equals( name ) )
- {
- result = map.size();
- }
- else if ( "keys".equals( name ) || "keySet".equals( name ) )
- {
- result = map.keySet();
- }
- else if ( "values".equals( name ) )
- {
- result = map.values();
- }
- else if ( "isEmpty".equals( name ) )
- {
- result = map.isEmpty() ? Boolean.TRUE : Boolean.FALSE;
- }
- else
- {
- result = map.get( name );
- }
- }
- else
- {
- result = map.get( name );
- }
-
- return result;
- }
-
- public void setProperty( Map<String, Object> context, Object target, Object name, Object value )
- throws OgnlException
- {
- @SuppressWarnings( "unchecked" ) // checked by the invoker
- Map<Object, Object> map = (Map<Object, Object>) target;
- map.put( name, value );
- }
-
- public String getSourceAccessor( OgnlContext context, Object target, Object index )
- {
- Node currentNode = context.getCurrentNode().jjtGetParent();
- boolean indexedAccess = false;
-
- if ( currentNode == null )
- {
- throw new RuntimeException( "node is null for '" + index + "'" );
- }
-
- if ( !( currentNode instanceof ASTProperty ) )
- {
- currentNode = currentNode.jjtGetParent();
- }
-
- if ( currentNode instanceof ASTProperty )
- {
- indexedAccess = ( (ASTProperty) currentNode ).isIndexedAccess();
- }
-
- String indexStr = index.toString();
-
- context.setCurrentAccessor( Map.class );
- context.setCurrentType( Object.class );
-
- if ( index instanceof String && !indexedAccess )
- {
- String key = indexStr.replace( "\"", "" );
-
- if ( "size".equals( key ) )
- {
- context.setCurrentType( int.class );
- return ".size()";
- }
- if ( "keys".equals( key ) || "keySet".equals( key ) )
- {
- context.setCurrentType( Set.class );
- return ".keySet()";
- }
- if ( "values".equals( key ) )
- {
- context.setCurrentType( Collection.class );
- return ".values()";
- }
- if ( "isEmpty".equals( key ) )
- {
- context.setCurrentType( boolean.class );
- return ".isEmpty()";
- }
- }
-
- return ".get(" + indexStr + ")";
- }
-
- public String getSourceSetter( OgnlContext context, Object target, Object index )
- {
- context.setCurrentAccessor( Map.class );
- context.setCurrentType( Object.class );
-
- String indexStr = index.toString();
-
- if (index instanceof String)
- {
- String key = indexStr.replace( "\"", "" );
-
- if ( "size".equals( key ) || "keys".equals( key ) || "keySet".equals( key ) || "values".equals( key )
- || "isEmpty".equals( key ) )
- {
- return "";
- }
- }
-
- return ".put(" + indexStr + ", $3)";
- }
-}
+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 java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Implementation of PropertyAccessor that sets and gets properties by storing and looking up values in Maps.
+ *
+ */
+public class MapPropertyAccessor
+ implements PropertyAccessor
+{
+
+ public Object getProperty( Map<String, Object> context, Object target, Object name )
+ throws OgnlException
+ {
+ Object result;
+ @SuppressWarnings( "unchecked" ) // checked by the invoker
+ Map<Object, Object> map = (Map<Object, Object>) target;
+ Node currentNode = ( (OgnlContext) context ).getCurrentNode().jjtGetParent();
+ boolean indexedAccess = false;
+
+ if ( currentNode == null )
+ {
+ throw new OgnlException( "node is null for '" + name + "'" );
+ }
+ if ( !( currentNode instanceof ASTProperty ) )
+ {
+ currentNode = currentNode.jjtGetParent();
+ }
+ if ( currentNode instanceof ASTProperty )
+ {
+ indexedAccess = ( (ASTProperty) currentNode ).isIndexedAccess();
+ }
+
+ if ( ( name instanceof String ) && !indexedAccess )
+ {
+ if ( "size".equals( name ) )
+ {
+ result = map.size();
+ }
+ else if ( "keys".equals( name ) || "keySet".equals( name ) )
+ {
+ result = map.keySet();
+ }
+ else if ( "values".equals( name ) )
+ {
+ result = map.values();
+ }
+ else if ( "isEmpty".equals( name ) )
+ {
+ result = map.isEmpty() ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else
+ {
+ result = map.get( name );
+ }
+ }
+ else
+ {
+ result = map.get( name );
+ }
+
+ return result;
+ }
+
+ public void setProperty( Map<String, Object> context, Object target, Object name, Object value )
+ throws OgnlException
+ {
+ @SuppressWarnings( "unchecked" ) // checked by the invoker
+ Map<Object, Object> map = (Map<Object, Object>) target;
+ map.put( name, value );
+ }
+
+ public String getSourceAccessor( OgnlContext context, Object target, Object index )
+ {
+ Node currentNode = context.getCurrentNode().jjtGetParent();
+ boolean indexedAccess = false;
+
+ if ( currentNode == null )
+ {
+ throw new RuntimeException( "node is null for '" + index + "'" );
+ }
+
+ if ( !( currentNode instanceof ASTProperty ) )
+ {
+ currentNode = currentNode.jjtGetParent();
+ }
+
+ if ( currentNode instanceof ASTProperty )
+ {
+ indexedAccess = ( (ASTProperty) currentNode ).isIndexedAccess();
+ }
+
+ String indexStr = index.toString();
+
+ context.setCurrentAccessor( Map.class );
+ context.setCurrentType( Object.class );
+
+ if ( index instanceof String && !indexedAccess )
+ {
+ String key = indexStr.replace( "\"", "" );
+
+ if ( "size".equals( key ) )
+ {
+ context.setCurrentType( int.class );
+ return ".size()";
+ }
+ if ( "keys".equals( key ) || "keySet".equals( key ) )
+ {
+ context.setCurrentType( Set.class );
+ return ".keySet()";
+ }
+ if ( "values".equals( key ) )
+ {
+ context.setCurrentType( Collection.class );
+ return ".values()";
+ }
+ if ( "isEmpty".equals( key ) )
+ {
+ context.setCurrentType( boolean.class );
+ return ".isEmpty()";
+ }
+ }
+
+ return ".get(" + indexStr + ")";
+ }
+
+ public String getSourceSetter( OgnlContext context, Object target, Object index )
+ {
+ context.setCurrentAccessor( Map.class );
+ context.setCurrentType( Object.class );
+
+ String indexStr = index.toString();
+
+ if (index instanceof String)
+ {
+ String key = indexStr.replace( "\"", "" );
+
+ if ( "size".equals( key ) || "keys".equals( key ) || "keySet".equals( key ) || "values".equals( key )
+ || "isEmpty".equals( key ) )
+ {
+ return "";
+ }
+ }
+
+ return ".put(" + indexStr + ", $3)";
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/OgnlParserTreeConstants.java b/src/main/java/org/apache/commons/ognl/OgnlParserTreeConstants.java
index 734379d..31a4a6c 100644
--- a/src/main/java/org/apache/commons/ognl/OgnlParserTreeConstants.java
+++ b/src/main/java/org/apache/commons/ognl/OgnlParserTreeConstants.java
@@ -1,130 +1,129 @@
-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$
- * Generated By:JavaCC: Do not edit this line. OgnlParserTreeConstants.java Version 4.1d1
- */
-
-public interface OgnlParserTreeConstants
-{
- int JJTVOID = 0;
-
- int JJTSEQUENCE = 1;
-
- int JJTASSIGN = 2;
-
- int JJTTEST = 3;
-
- int JJTOR = 4;
-
- int JJTAND = 5;
-
- int JJTBITOR = 6;
-
- int JJTXOR = 7;
-
- int JJTBITAND = 8;
-
- int JJTEQ = 9;
-
- int JJTNOTEQ = 10;
-
- int JJTLESS = 11;
-
- int JJTGREATER = 12;
-
- int JJTLESSEQ = 13;
-
- int JJTGREATEREQ = 14;
-
- int JJTIN = 15;
-
- int JJTNOTIN = 16;
-
- int JJTSHIFTLEFT = 17;
-
- int JJTSHIFTRIGHT = 18;
-
- int JJTUNSIGNEDSHIFTRIGHT = 19;
-
- int JJTADD = 20;
-
- int JJTSUBTRACT = 21;
-
- int JJTMULTIPLY = 22;
-
- int JJTDIVIDE = 23;
-
- int JJTREMAINDER = 24;
-
- int JJTNEGATE = 25;
-
- int JJTBITNEGATE = 26;
-
- int JJTNOT = 27;
-
- int JJTINSTANCEOF = 28;
-
- int JJTCHAIN = 29;
-
- int JJTEVAL = 30;
-
- int JJTCONST = 31;
-
- int JJTTHISVARREF = 32;
-
- int JJTROOTVARREF = 33;
-
- int JJTVARREF = 34;
-
- int JJTLIST = 35;
-
- int JJTMAP = 36;
-
- int JJTKEYVALUE = 37;
-
- int JJTSTATICFIELD = 38;
-
- int JJTCTOR = 39;
-
- int JJTPROPERTY = 40;
-
- int JJTSTATICMETHOD = 41;
-
- int JJTMETHOD = 42;
-
- int JJTPROJECT = 43;
-
- int JJTSELECT = 44;
-
- int JJTSELECTFIRST = 45;
-
- int JJTSELECTLAST = 46;
-
- String[] jjtNodeName =
- { "void", "Sequence", "Assign", "Test", "Or", "And", "BitOr", "Xor", "BitAnd", "Eq", "NotEq", "Less", "Greater",
- "LessEq", "GreaterEq", "In", "NotIn", "ShiftLeft", "ShiftRight", "UnsignedShiftRight", "Add", "Subtract",
- "Multiply", "Divide", "Remainder", "Negate", "BitNegate", "Not", "Instanceof", "Chain", "Eval", "Const",
- "ThisVarRef", "RootVarRef", "VarRef", "List", "Map", "KeyValue", "StaticField", "Ctor", "Property",
- "StaticMethod", "Method", "Project", "Select", "SelectFirst", "SelectLast", };
-}
-/* JavaCC - OriginalChecksum=effe3edc2df093c4b217c61a43612af5 (do not edit this line) */
+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.
+ */
+
+/**
+ * Generated By:JavaCC: Do not edit this line. OgnlParserTreeConstants.java Version 4.1d1
+ */
+
+public interface OgnlParserTreeConstants
+{
+ int JJTVOID = 0;
+
+ int JJTSEQUENCE = 1;
+
+ int JJTASSIGN = 2;
+
+ int JJTTEST = 3;
+
+ int JJTOR = 4;
+
+ int JJTAND = 5;
+
+ int JJTBITOR = 6;
+
+ int JJTXOR = 7;
+
+ int JJTBITAND = 8;
+
+ int JJTEQ = 9;
+
+ int JJTNOTEQ = 10;
+
+ int JJTLESS = 11;
+
+ int JJTGREATER = 12;
+
+ int JJTLESSEQ = 13;
+
+ int JJTGREATEREQ = 14;
+
+ int JJTIN = 15;
+
+ int JJTNOTIN = 16;
+
+ int JJTSHIFTLEFT = 17;
+
+ int JJTSHIFTRIGHT = 18;
+
+ int JJTUNSIGNEDSHIFTRIGHT = 19;
+
+ int JJTADD = 20;
+
+ int JJTSUBTRACT = 21;
+
+ int JJTMULTIPLY = 22;
+
+ int JJTDIVIDE = 23;
+
+ int JJTREMAINDER = 24;
+
+ int JJTNEGATE = 25;
+
+ int JJTBITNEGATE = 26;
+
+ int JJTNOT = 27;
+
+ int JJTINSTANCEOF = 28;
+
+ int JJTCHAIN = 29;
+
+ int JJTEVAL = 30;
+
+ int JJTCONST = 31;
+
+ int JJTTHISVARREF = 32;
+
+ int JJTROOTVARREF = 33;
+
+ int JJTVARREF = 34;
+
+ int JJTLIST = 35;
+
+ int JJTMAP = 36;
+
+ int JJTKEYVALUE = 37;
+
+ int JJTSTATICFIELD = 38;
+
+ int JJTCTOR = 39;
+
+ int JJTPROPERTY = 40;
+
+ int JJTSTATICMETHOD = 41;
+
+ int JJTMETHOD = 42;
+
+ int JJTPROJECT = 43;
+
+ int JJTSELECT = 44;
+
+ int JJTSELECTFIRST = 45;
+
+ int JJTSELECTLAST = 46;
+
+ String[] jjtNodeName =
+ { "void", "Sequence", "Assign", "Test", "Or", "And", "BitOr", "Xor", "BitAnd", "Eq", "NotEq", "Less", "Greater",
+ "LessEq", "GreaterEq", "In", "NotIn", "ShiftLeft", "ShiftRight", "UnsignedShiftRight", "Add", "Subtract",
+ "Multiply", "Divide", "Remainder", "Negate", "BitNegate", "Not", "Instanceof", "Chain", "Eval", "Const",
+ "ThisVarRef", "RootVarRef", "VarRef", "List", "Map", "KeyValue", "StaticField", "Ctor", "Property",
+ "StaticMethod", "Method", "Project", "Select", "SelectFirst", "SelectLast", };
+}
+/* JavaCC - OriginalChecksum=effe3edc2df093c4b217c61a43612af5 (do not edit this line) */
diff --git a/src/main/java/org/apache/commons/ognl/OgnlRuntime.java b/src/main/java/org/apache/commons/ognl/OgnlRuntime.java
index 338fed3..0e234d4 100644
--- a/src/main/java/org/apache/commons/ognl/OgnlRuntime.java
+++ b/src/main/java/org/apache/commons/ognl/OgnlRuntime.java
@@ -1,2117 +1,2116 @@
-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.internal.CacheException;
-import org.apache.commons.ognl.internal.entry.DeclaredMethodCacheEntry;
-import org.apache.commons.ognl.internal.entry.GenericMethodParameterTypeCacheEntry;
-import org.apache.commons.ognl.internal.entry.MethodAccessEntryValue;
-import org.apache.commons.ognl.internal.entry.PermissionCacheEntry;
-
-import java.beans.BeanInfo;
-import java.beans.IndexedPropertyDescriptor;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.MethodDescriptor;
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Proxy;
-import java.security.Permission;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Utility class used by internal OGNL API to do various things like:
- * <ul>
- * <li>Handles majority of reflection logic / caching.</li>
- * <li>Utility methods for casting strings / various numeric types used by {@link OgnlExpressionCompiler}.</li.
- * <li>Core runtime configuration point for setting/using global {@link TypeConverter} / {@link OgnlExpressionCompiler}
- * / {@link NullHandler} instances / etc..</li>
- * </ul>
- *
- * $Id$
- */
-public class OgnlRuntime
-{
- /**
- * Constant expression used to indicate that a given method / property couldn't be found during reflection
- * operations.
- */
- public static final Object NotFound = new Object();
-
- public static final Object[] NoArguments = new Object[]{ };
-
- /**
- * Token returned by TypeConverter for no conversion possible
- */
- public static final Object NoConversionPossible = "ognl.NoConversionPossible";
-
- /**
- * Not an indexed property
- */
- public static final int INDEXED_PROPERTY_NONE = 0;
-
- /**
- * JavaBeans IndexedProperty
- */
- public static final int INDEXED_PROPERTY_INT = 1;
-
- /**
- * OGNL ObjectIndexedProperty
- */
- public static final int INDEXED_PROPERTY_OBJECT = 2;
-
- /**
- * Constant string representation of null string.
- */
- public static final String NULL_STRING = "" + null;
-
- /**
- * Java beans standard set method prefix.
- */
- public static final String SET_PREFIX = "set";
-
- /**
- * Java beans standard get method prefix.
- */
- public static final String GET_PREFIX = "get";
-
- /**
- * Java beans standard is<Foo> boolean getter prefix.
- */
- public static final String IS_PREFIX = "is";
-
- /**
- * Prefix padding for hexadecimal numbers to HEX_LENGTH.
- */
- private static final Map<Integer, String> HEX_PADDING = new HashMap<Integer, String>();
-
- private static final int HEX_LENGTH = 8;
-
- /**
- * Returned by <CODE>getUniqueDescriptor()</CODE> when the object is <CODE>null</CODE>.
- */
- private static final String NULL_OBJECT_STRING = "<null>";
-
- static final OgnlCache cache = new OgnlCache();
-
- private static final PrimitiveTypes primitiveTypes = new PrimitiveTypes();
-
- private static final PrimitiveDefaults primitiveDefaults = new PrimitiveDefaults();
-
- private static SecurityManager securityManager = System.getSecurityManager();
-
- /**
- * Expression compiler used by {@link Ognl#compileExpression(OgnlContext, Object, String)} calls.
- */
- private static OgnlExpressionCompiler compiler;
-
- /**
- * Used to provide primitive type equivalent conversions into and out of native / object types.
- */
- private static final PrimitiveWrapperClasses primitiveWrapperClasses = new PrimitiveWrapperClasses();
-
- /**
- * Constant strings for casting different primitive types.
- */
- private static final NumericCasts numericCasts = new NumericCasts();
-
- /**
- * Constant strings for getting the primitive value of different native types on the generic {@link Number} object
- * interface. (or the less generic BigDecimal/BigInteger types)
- */
- private static final NumericValues numericValues = new NumericValues();
-
- /**
- * Numeric primitive literal string expressions.
- */
- private static final NumericLiterals numericLiterals = new NumericLiterals();
-
- private static final NumericDefaults numericDefaults = new NumericDefaults();
-
- /**
- * Clears all of the cached reflection information normally used to improve the speed of expressions that operate on
- * the same classes or are executed multiple times.
- * <p>
- * <strong>Warning:</strong> Calling this too often can be a huge performance drain on your expressions - use with
- * care.
- * </p>
- */
- public static void clearCache()
- {
- cache.clear();
- }
-
- public static String getNumericValueGetter( Class<?> type )
- {
- return numericValues.get( type );
- }
-
- public static Class<?> getPrimitiveWrapperClass( Class<?> primitiveClass )
- {
- return primitiveWrapperClasses.get( primitiveClass );
- }
-
- public static String getNumericCast( Class<? extends Number> type )
- {
- return numericCasts.get( type );
- }
-
- public static String getNumericLiteral( Class<? extends Number> type )
- {
- return numericLiterals.get( type );
- }
-
- public static void setCompiler( OgnlExpressionCompiler compiler )
- {
- OgnlRuntime.compiler = compiler;
- }
-
- public static OgnlExpressionCompiler getCompiler( OgnlContext ognlContext )
- {
- if ( compiler == null )
- {
- try
- {
- OgnlRuntime.classForName( ognlContext, "javassist.ClassPool" );
- compiler = new ExpressionCompiler();
- }
- catch ( ClassNotFoundException e )
- {
- throw new IllegalArgumentException(
- "Javassist library is missing in classpath! Please add missed dependency!", e );
- }
- }
- return compiler;
- }
-
- public static void compileExpression( OgnlContext context, Node expression, Object root )
- throws Exception
- {
- getCompiler( context ).compileExpression( context, expression, root );
- }
-
- /**
- * Gets the "target" class of an object for looking up accessors that are registered on the target. If the object is
- * a Class object this will return the Class itself, else it will return object's getClass() result.
- */
- public static Class<?> getTargetClass( Object o )
- {
- return ( o == null ) ? null : ( ( o instanceof Class ) ? (Class<?>) o : o.getClass() );
- }
-
- /**
- * Returns the base name (the class name without the package name prepended) of the object given.
- */
- public static String getBaseName( Object o )
- {
- return ( o == null ) ? null : getClassBaseName( o.getClass() );
- }
-
- /**
- * Returns the base name (the class name without the package name prepended) of the class given.
- */
- public static String getClassBaseName( Class<?> clazz )
- {
- String className = clazz.getName();
- return className.substring( className.lastIndexOf( '.' ) + 1 );
- }
-
- public static String getClassName( Object object, boolean fullyQualified )
- {
- if ( !( object instanceof Class ) )
- {
- object = object.getClass();
- }
-
- return getClassName( (Class<?>) object, fullyQualified );
- }
-
- public static String getClassName( Class<?> clazz, boolean fullyQualified )
- {
- return fullyQualified ? clazz.getName() : getClassBaseName( clazz );
- }
-
- /**
- * Returns the package name of the object's class.
- */
- public static String getPackageName( Object object )
- {
- return ( object == null ) ? null : getClassPackageName( object.getClass() );
- }
-
- /**
- * Returns the package name of the class given.
- */
- public static String getClassPackageName( Class<?> clazz )
- {
- String className = clazz.getName();
- int index = className.lastIndexOf( '.' );
-
- return ( index < 0 ) ? null : className.substring( 0, index );
- }
-
- /**
- * Returns a "pointer" string in the usual format for these things - 0x<hex digits>.
- */
- public static String getPointerString( int num )
- {
- String hex = Integer.toHexString( num ), pad;
- Integer l = hex.length();
-
- // stringBuilder.append(HEX_PREFIX);
- if ( ( pad = HEX_PADDING.get( l ) ) == null )
- {
- StringBuilder paddingStringBuilder = new StringBuilder();
-
- for ( int i = hex.length(); i < HEX_LENGTH; i++ )
- {
- paddingStringBuilder.append( '0' );
- }
- pad = paddingStringBuilder.toString();
- HEX_PADDING.put( l, pad );
- }
- return new StringBuilder().append( pad ).append( hex ).toString();
- }
-
- /**
- * Returns a "pointer" string in the usual format for these things - 0x<hex digits> for the object given. This will
- * always return a unique value for each object.
- */
- public static String getPointerString( Object object )
- {
- return getPointerString( ( object == null ) ? 0 : System.identityHashCode( object ) );
- }
-
- /**
- * Returns a unique descriptor string that includes the object's class and a unique integer identifier. If
- * fullyQualified is true then the class name will be fully qualified to include the package name, else it will be
- * just the class' base name.
- */
- public static String getUniqueDescriptor( Object object, boolean fullyQualified )
- {
- StringBuilder stringBuilder = new StringBuilder();
-
- if ( object != null )
- {
- if ( object instanceof Proxy )
- {
- Class<?> interfaceClass = object.getClass().getInterfaces()[0];
-
- String className = getClassName( interfaceClass, fullyQualified );
- stringBuilder.append( className ).append( '^' );
- object = Proxy.getInvocationHandler( object );
- }
- String className = getClassName( object, fullyQualified );
- String pointerString = getPointerString( object );
- stringBuilder.append( className ).append( '@' ).append( pointerString );
- }
- else
- {
- stringBuilder.append( NULL_OBJECT_STRING );
- }
- return stringBuilder.toString();
- }
-
- /**
- * Returns a unique descriptor string that includes the object's class' base name and a unique integer identifier.
- */
- public static String getUniqueDescriptor( Object object )
- {
- return getUniqueDescriptor( object, false );
- }
-
- /**
- * Utility to convert a List into an Object[] array. If the list is zero elements this will return a constant array;
- * toArray() on List always returns a new object and this is wasteful for our purposes.
- */
- public static <T> Object[] toArray( List<T> list )
- {
- Object[] array;
- int size = list.size();
-
- if ( size == 0 )
- {
- array = NoArguments;
- }
- else
- {
- array = new Object[size];
- for ( int i = 0; i < size; i++ )
- {
- array[i] = list.get( i );
- }
- }
- return array;
- }
-
- /**
- * Returns the parameter types of the given method.
- */
- public static Class<?>[] getParameterTypes( Method method )
- throws CacheException
- {
- return cache.getMethodParameterTypes( method );
- }
-
- /**
- * Finds the appropriate parameter types for the given {@link Method} and {@link Class} instance of the type the
- * method is associated with. Correctly finds generic types if running in >= 1.5 jre as well.
- *
- * @param type The class type the method is being executed against.
- * @param method The method to find types for.
- * @return Array of parameter types for the given method.
- * @throws org.apache.commons.ognl.internal.CacheException
- */
- public static Class<?>[] findParameterTypes( Class<?> type, Method method )
- throws CacheException
- {
- if ( type == null || type.getGenericSuperclass() == null || !(type.getGenericSuperclass() instanceof ParameterizedType) || method.getDeclaringClass().getTypeParameters() == null )
- {
- return getParameterTypes( method );
- }
-
- GenericMethodParameterTypeCacheEntry key = new GenericMethodParameterTypeCacheEntry( method, type );
- return cache.getGenericMethodParameterTypes( key );
- }
-
- /**
- * Returns the parameter types of the given method.
- * @param constructor
- * @return
- * @throws org.apache.commons.ognl.internal.CacheException
- */
- public static Class<?>[] getParameterTypes( Constructor<?> constructor )
- throws CacheException
- {
- return cache.getParameterTypes( constructor );
- }
-
- /**
- * Gets the SecurityManager that OGNL uses to determine permissions for invoking methods.
- *
- * @return SecurityManager for OGNL
- */
- public static SecurityManager getSecurityManager()
- {
- return securityManager;
- }
-
- /**
- * Sets the SecurityManager that OGNL uses to determine permissions for invoking methods.
- *
- * @param securityManager SecurityManager to set
- */
- public static void setSecurityManager( SecurityManager securityManager )
- {
- OgnlRuntime.securityManager = securityManager;
- cache.setSecurityManager(securityManager);
- }
-
- /**
- * Permission will be named "invoke.<declaring-class>.<method-name>".
- * @param method
- * @return
- * @throws org.apache.commons.ognl.internal.CacheException
- */
- public static Permission getPermission( Method method )
- throws CacheException
- {
- PermissionCacheEntry key = new PermissionCacheEntry( method );
- return cache.getInvokePermission( key );
- }
-
- public static Object invokeMethod( Object target, Method method, Object[] argsArray )
- throws InvocationTargetException, IllegalAccessException, CacheException
- {
- Object result;
-
- if ( securityManager != null && !cache.getMethodPerm( method ) )
- {
- throw new IllegalAccessException( "Method [" + method + "] cannot be accessed." );
- }
-
- MethodAccessEntryValue entry = cache.getMethodAccess( method );
- if ( !entry.isAccessible() )
- {
- // only synchronize method invocation if it actually requires it
- synchronized ( method )
- {
-
- if ( entry.isNotPublic() && !entry.isAccessible() )
- {
- method.setAccessible( true );
- }
-
- result = method.invoke( target, argsArray );
-
- if ( !entry.isAccessible() )
- {
- method.setAccessible( false );
- }
- }
- }
- else
- {
- result = method.invoke( target, argsArray );
- }
-
- return result;
- }
-
- /**
- * Gets the class for a method argument that is appropriate for looking up methods by reflection, by looking for the
- * standard primitive wrapper classes and exchanging for them their underlying primitive class objects. Other
- * classes are passed through unchanged.
- *
- * @param arg an object that is being passed to a method
- * @return the class to use to look up the method
- */
- public static Class<?> getArgClass( Object arg )
- {
- if ( arg == null )
- {
- return null;
- }
- Class<?> clazz = arg.getClass();
- if ( clazz == Boolean.class )
- {
- return Boolean.TYPE;
- }
- if ( clazz.getSuperclass() == Number.class )
- {
- if ( clazz == Integer.class )
- {
- return Integer.TYPE;
- }
- if ( clazz == Double.class )
- {
- return Double.TYPE;
- }
- if ( clazz == Byte.class )
- {
- return Byte.TYPE;
- }
- if ( clazz == Long.class )
- {
- return Long.TYPE;
- }
- if ( clazz == Float.class )
- {
- return Float.TYPE;
- }
- if ( clazz == Short.class )
- {
- return Short.TYPE;
- }
- }
- else if ( clazz == Character.class )
- {
- return Character.TYPE;
- }
- return clazz;
- }
-
- /**
- * Tells whether the given object is compatible with the given class ---that is, whether the given object can be
- * passed as an argument to a method or constructor whose parameter type is the given class. If object is null this
- * will return true because null is compatible with any type.
- */
- public static boolean isTypeCompatible( Object object, Class<?> clazz )
- {
- boolean result = true;
-
- if ( object != null )
- {
- if ( clazz.isPrimitive() )
- {
- if ( getArgClass( object ) != clazz )
- {
- result = false;
- }
- }
- else if ( !clazz.isInstance( object ) )
- {
- result = false;
- }
- }
- return result;
- }
-
- /**
- * Tells whether the given array of objects is compatible with the given array of classes---that is, whether the
- * given array of objects can be passed as arguments to a method or constructor whose parameter types are the given
- * array of classes.
- */
- public static boolean areArgsCompatible( Object[] args, Class<?>[] classes )
- {
- return areArgsCompatible( args, classes, null );
- }
-
- public static boolean areArgsCompatible( Object[] args, Class<?>[] classes, Method method )
- {
- boolean result = true;
- boolean varArgs = method != null && method.isVarArgs();
-
- if ( args.length != classes.length && !varArgs )
- {
- result = false;
- }
- else if ( varArgs )
- {
- for ( int index = 0; result && ( index < args.length ); ++index )
- {
- if ( index >= classes.length )
- {
- break;
- }
-
- result = isTypeCompatible( args[index], classes[index] );
-
- if ( !result && classes[index].isArray() )
- {
- result = isTypeCompatible( args[index], classes[index].getComponentType() );
- }
- }
- }
- else
- {
- for ( int index = 0; result && ( index < args.length ); ++index )
- {
- result = isTypeCompatible( args[index], classes[index] );
- }
- }
- return result;
- }
-
- /**
- * Tells whether the first array of classes is more specific than the second. Assumes that the two arrays are of the
- * same length.
- */
- public static boolean isMoreSpecific( Class<?>[] classes1, Class<?>[] classes2 )
- {
- for ( int index = 0; index < classes1.length; ++index )
- {
- Class<?> class1 = classes1[index], class2 = classes2[index];
- if ( class1 != class2 )
- {
- if ( class1.isPrimitive() )
- {
- return true;
- }
- if ( class1.isAssignableFrom( class2 ) )
- {
- return false;
- }
- if ( class2.isAssignableFrom( class1 ) )
- {
- return true;
- }
- }
- }
-
- // They are the same! So the first is not more specific than the second.
- return false;
- }
-
- public static Class<?> classForName( OgnlContext context, String className )
- throws ClassNotFoundException
- {
- Class<?> result = primitiveTypes.get( className );
-
- if ( result == null )
- {
- ClassResolver resolver;
-
- if ( ( context == null ) || ( ( resolver = context.getClassResolver() ) == null ) )
- {
- resolver = OgnlContext.DEFAULT_CLASS_RESOLVER;
- }
- result = resolver.classForName( className, context );
- }
-
- if ( result == null )
- {
- throw new ClassNotFoundException( "Unable to resolve class: " + className );
- }
-
- return result;
- }
-
- public static boolean isInstance( OgnlContext context, Object value, String className )
- throws OgnlException
- {
- try
- {
- Class<?> clazz = classForName( context, className );
- return clazz.isInstance( value );
- }
- catch ( ClassNotFoundException e )
- {
- throw new OgnlException( "No such class: " + className, e );
- }
- }
-
- public static Object getPrimitiveDefaultValue( Class<?> forClass )
- {
- return primitiveDefaults.get( forClass );
- }
-
- public static Object getNumericDefaultValue( Class<?> forClass )
- {
- return numericDefaults.get( forClass );
- }
-
- public static Object getConvertedType( OgnlContext context, Object target, Member member, String propertyName,
- Object value, Class<?> type )
- {
- return context.getTypeConverter().convertValue( context, target, member, propertyName, value, type );
- }
-
- public static boolean getConvertedTypes( OgnlContext context, Object target, Member member, String propertyName,
- Class<?>[] parameterTypes, Object[] args, Object[] newArgs )
-
- {
- boolean result = false;
-
- if ( parameterTypes.length == args.length )
- {
- result = true;
- for ( int i = 0; result && ( i <= parameterTypes.length - 1 ); i++ )
- {
- Object arg = args[i];
- Class<?> type = parameterTypes[i];
-
- if ( isTypeCompatible( arg, type ) )
- {
- newArgs[i] = arg;
- }
- else
- {
- Object convertedType = getConvertedType( context, target, member, propertyName, arg, type );
-
- if ( convertedType == OgnlRuntime.NoConversionPossible )
- {
- result = false;
- }
- else
- {
- newArgs[i] = convertedType;
- }
- }
- }
- }
- return result;
- }
-
- public static Method getConvertedMethodAndArgs( OgnlContext context, Object target, String propertyName,
- List<Method> methods, Object[] args, Object[] newArgs )
-
- {
- Method convertedMethod = null;
- TypeConverter typeConverter = context.getTypeConverter();
-
- if ( ( typeConverter != null ) && ( methods != null ) )
- {
- int methodsSize = methods.size();
- for ( int i = 0; ( convertedMethod == null ) && ( i < methodsSize ); i++ )
- {
- Method method = methods.get( i );
- Class<?>[] parameterTypes =
- findParameterTypes( target != null ? target.getClass() : null, method );// getParameterTypes(method);
-
- if ( getConvertedTypes( context, target, method, propertyName, parameterTypes, args, newArgs ) )
- {
- convertedMethod = method;
- }
- }
- }
- return convertedMethod;
- }
-
- public static Constructor<?> getConvertedConstructorAndArgs( OgnlContext context, Object target,
- List<Constructor<?>> constructors, Object[] args,
- Object[] newArgs )
-
- {
- Constructor<?> constructor = null;
- TypeConverter typeConverter = context.getTypeConverter();
-
- if ( ( typeConverter != null ) && ( constructors != null ) )
- {
- for ( int i = 0; ( constructor == null ) && ( i < constructors.size() ); i++ )
- {
- Constructor<?> ctor = constructors.get( i );
- Class<?>[] parameterTypes = getParameterTypes( ctor );
-
- if ( getConvertedTypes( context, target, ctor, null, parameterTypes, args, newArgs ) )
- {
- constructor = ctor;
- }
- }
- }
- return constructor;
- }
-
- /**
- * Gets the appropriate method to be called for the given target, method name and arguments. If successful this
- * method will return the Method within the target that can be called and the converted arguments in actualArgs. If
- * unsuccessful this method will return null and the actualArgs will be empty.
- *
- * @param context The current execution context.
- * @param source Target object to run against or method name.
- * @param target Instance of object to be run against.
- * @param propertyName Name of property to get method of.
- * @param methods List of current known methods.
- * @param args Arguments originally passed in.
- * @param actualArgs Converted arguments.
- * @return Best method match or null if none could be found.
- */
- public static Method getAppropriateMethod( OgnlContext context, Object source, Object target, String propertyName,
- List<Method> methods, Object[] args, Object[] actualArgs )
-
- {
- Method appropriateMethod = null;
- Class<?>[] resultParameterTypes = null;
-
- if ( methods != null )
- {
- for ( Method method : methods )
- {
- Class<?> typeClass = target != null ? target.getClass() : null;
- if ( typeClass == null && source != null && source instanceof Class)
- {
- typeClass = (Class<?>) source;
- }
-
- Class<?>[] mParameterTypes = findParameterTypes( typeClass, method );
-
- if ( areArgsCompatible( args, mParameterTypes, method ) &&
- ( ( appropriateMethod == null ) || isMoreSpecific( mParameterTypes, resultParameterTypes ) ) )
- {
- appropriateMethod = method;
- resultParameterTypes = mParameterTypes;
- System.arraycopy( args, 0, actualArgs, 0, args.length );
-
- for ( int i = 0; i < mParameterTypes.length; i++ )
- {
- Class<?> type = mParameterTypes[i];
-
- if ( type.isPrimitive() && ( actualArgs[i] == null ) )
- {
- actualArgs[i] = getConvertedType( context, source, appropriateMethod, propertyName, null, type );
- }
- }
- }
- }
- }
-
- if ( appropriateMethod == null )
- {
- appropriateMethod = getConvertedMethodAndArgs( context, target, propertyName, methods, args, actualArgs );
- }
-
- return appropriateMethod;
- }
-
- public static Object callAppropriateMethod( OgnlContext context, Object source, Object target, String methodName,
- String propertyName, List<Method> methods, Object[] args )
- throws MethodFailedException
- {
- Throwable cause = null;
- Object[] actualArgs = new Object[args.length];
-
- try
- {
- Method method = getAppropriateMethod( context, source, target, propertyName, methods, args, actualArgs );
-
- if ( ( method == null ) || !isMethodAccessible( context, source, method, propertyName ) )
- {
- StringBuilder buffer = new StringBuilder();
- String className = "";
-
- if ( target != null )
- {
- className = target.getClass().getName() + ".";
- }
-
- for ( int i = 0, ilast = args.length - 1; i <= ilast; i++ )
- {
- Object arg = args[i];
-
- buffer.append( ( arg == null ) ? NULL_STRING : arg.getClass().getName() );
- if ( i < ilast )
- {
- buffer.append( ", " );
- }
- }
-
- throw new NoSuchMethodException( className + methodName + "(" + buffer + ")" );
- }
-
- Object[] convertedArgs = actualArgs;
-
- if ( method.isVarArgs() )
- {
- Class<?>[] parmTypes = method.getParameterTypes();
-
- // split arguments in to two dimensional array for varargs reflection invocation
- // where it is expected that the parameter passed in to invoke the method
- // will look like "new Object[] { arrayOfNonVarArgsArguments, arrayOfVarArgsArguments }"
-
- for ( int i = 0; i < parmTypes.length; i++ )
- {
- if ( parmTypes[i].isArray() )
- {
- convertedArgs = new Object[i + 1];
- System.arraycopy( actualArgs, 0, convertedArgs, 0, convertedArgs.length );
-
- Object[] varArgs;
-
- // if they passed in varargs arguments grab them and dump in to new varargs array
-
- if ( actualArgs.length > i )
- {
- List<Object> varArgsList = new ArrayList<Object>();
- for ( int j = i; j < actualArgs.length; j++ )
- {
- if ( actualArgs[j] != null )
- {
- varArgsList.add( actualArgs[j] );
- }
- }
-
- varArgs = varArgsList.toArray();
- }
- else
- {
- varArgs = new Object[0];
- }
-
- convertedArgs[i] = varArgs;
- break;
- }
- }
- }
-
- return invokeMethod( target, method, convertedArgs );
-
- }
- catch ( NoSuchMethodException | IllegalAccessException e )
- {
- cause = e;
- } catch ( InvocationTargetException e )
- {
- cause = e.getTargetException();
- }
-
- throw new MethodFailedException( source, methodName, cause );
- }
-
- public static Object callStaticMethod( OgnlContext context, String className, String methodName, Object[] args )
- throws OgnlException
- {
- try
- {
- Class<?> targetClass = classForName( context, className );
-
- MethodAccessor methodAccessor = getMethodAccessor( targetClass );
-
- return methodAccessor.callStaticMethod( context, targetClass, methodName, args );
- }
- catch ( ClassNotFoundException ex )
- {
- throw new MethodFailedException( className, methodName, ex );
- }
- }
-
- /**
- * Invokes the specified method against the target object.
- *
- * @param context The current execution context.
- * @param target The object to invoke the method on.
- * @param methodName Name of the method - as in "getValue" or "add", etc..
- * @param args Optional arguments needed for method.
- * @return Result of invoking method.
- * @throws OgnlException For lots of different reasons.
- */
- public static Object callMethod( OgnlContext context, Object target, String methodName, Object[] args )
- throws OgnlException
- {
- if ( target == null )
- {
- throw new NullPointerException( "target is null for method " + methodName );
- }
-
- return getMethodAccessor( target.getClass() ).callMethod( context, target, methodName, args );
- }
-
- public static Object callConstructor( OgnlContext context, String className, Object[] args )
- throws OgnlException
- {
- Throwable cause = null;
- Object[] actualArgs = args;
-
- try
- {
- Constructor<?> ctor = null;
- Class<?>[] ctorParameterTypes = null;
- Class<?> target = classForName( context, className );
- List<Constructor<?>> constructors = getConstructors( target );
-
- for ( Constructor<?> constructor : constructors )
- {
- Class<?>[] cParameterTypes = getParameterTypes( constructor );
-
- if ( areArgsCompatible( args, cParameterTypes ) && ( ctor == null || isMoreSpecific( cParameterTypes,
- ctorParameterTypes ) ) )
- {
- ctor = constructor;
- ctorParameterTypes = cParameterTypes;
- }
- }
- if ( ctor == null )
- {
- actualArgs = new Object[args.length];
- if ( ( ctor = getConvertedConstructorAndArgs( context, target, constructors, args, actualArgs ) ) == null )
- {
- throw new NoSuchMethodException();
- }
- }
- if ( !context.getMemberAccess().isAccessible( context, target, ctor, null ) )
- {
- throw new IllegalAccessException( "access denied to " + target.getName() + "()" );
- }
- return ctor.newInstance( actualArgs );
- }
- catch ( ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException e )
- {
- cause = e;
- } catch ( InvocationTargetException e )
- {
- cause = e.getTargetException();
- }
-
- throw new MethodFailedException( className, "new", cause );
- }
-
- public static Object getMethodValue( OgnlContext context, Object target, String propertyName )
- throws OgnlException, IllegalAccessException, NoSuchMethodException, IntrospectionException
- {
- return getMethodValue( context, target, propertyName, false );
- }
-
- /**
- * If the checkAccessAndExistence flag is true this method will check to see if the method exists and if it is
- * accessible according to the context's MemberAccess. If neither test passes this will return NotFound.
- */
- public static Object getMethodValue( OgnlContext context, Object target, String propertyName,
- boolean checkAccessAndExistence )
- throws OgnlException, IllegalAccessException, NoSuchMethodException, IntrospectionException
- {
- Object methodValue = null;
- Class<?> targetClass = target == null ? null : target.getClass();
- Method method = getGetMethod( context, targetClass, propertyName );
- if ( method == null )
- {
- method = getReadMethod( targetClass, propertyName, 0 );
- }
-
- if ( checkAccessAndExistence && (( method == null ) || !context.getMemberAccess().isAccessible( context, target, method, propertyName )) )
- {
- methodValue = NotFound;
- }
- if ( methodValue == null )
- {
- if ( method == null ) {
- throw new NoSuchMethodException( propertyName );
- }
- try
- {
- methodValue = invokeMethod( target, method, NoArguments );
- }
- catch ( InvocationTargetException ex )
- {
- throw new OgnlException( propertyName, ex.getTargetException() );
- }
- }
- return methodValue;
- }
-
- public static boolean setMethodValue( OgnlContext context, Object target, String propertyName, Object value )
- throws OgnlException, IllegalAccessException, NoSuchMethodException, IntrospectionException
- {
- return setMethodValue( context, target, propertyName, value, false );
- }
-
- public static boolean setMethodValue( OgnlContext context, Object target, String propertyName, Object value,
- boolean checkAccessAndExistence )
- throws OgnlException, IllegalAccessException, NoSuchMethodException, IntrospectionException
- {
- boolean result = true;
- Method method = getSetMethod( context, ( target == null ) ? null : target.getClass(), propertyName );
-
- if ( checkAccessAndExistence && (( method == null ) || !context.getMemberAccess().isAccessible( context, target, method, propertyName )) )
- {
- result = false;
- }
-
- if ( result )
- {
- if ( method != null )
- {
- Object[] args = new Object[]{ value };
- callAppropriateMethod( context, target, target, method.getName(), propertyName,
- Collections.nCopies( 1, method ), args );
- }
- else
- {
- result = false;
- }
- }
-
- return result;
- }
-
- public static List<Constructor<?>> getConstructors( Class<?> targetClass )
- {
- return cache.getConstructor( targetClass );
- }
-
- /**
- * @param targetClass
- * @param staticMethods if true (false) returns only the (non-)static methods
- * @return Returns the map of methods for a given class
- */
- public static Map<String, List<Method>> getMethods( Class<?> targetClass, boolean staticMethods )
- {
- DeclaredMethodCacheEntry.MethodType type = staticMethods ?
- DeclaredMethodCacheEntry.MethodType.STATIC :
- DeclaredMethodCacheEntry.MethodType.NON_STATIC;
- DeclaredMethodCacheEntry key = new DeclaredMethodCacheEntry( targetClass, type );
- return cache.getMethod( key );
- }
-
- public static List<Method> getMethods( Class<?> targetClass, String name, boolean staticMethods )
- {
- return getMethods( targetClass, staticMethods ).get( name );
- }
-
- public static Map<String, Field> getFields( Class<?> targetClass )
- {
- return cache.getField( targetClass );
- }
-
- public static Field getField( Class<?> inClass, String name )
- {
- Field field = getFields( inClass ).get( name );
-
- if ( field == null )
- {
- // if field is null, it should search along the superclasses
- Class<?> superClass = inClass.getSuperclass();
- while ( superClass != null )
- {
- field = getFields( superClass ).get( name );
- if ( field != null )
- {
- return field;
- }
- superClass = superClass.getSuperclass();
- }
- }
- return field;
- }
-
- public static Object getFieldValue( OgnlContext context, Object target, String propertyName )
- throws NoSuchFieldException
- {
- return getFieldValue( context, target, propertyName, false );
- }
-
- public static Object getFieldValue( OgnlContext context, Object target, String propertyName,
- boolean checkAccessAndExistence )
- throws NoSuchFieldException
- {
- Object result = null;
- Class<?> targetClass = target == null ? null : target.getClass();
- Field field = getField( targetClass, propertyName );
-
- if ( checkAccessAndExistence && (( field == null ) || !context.getMemberAccess().isAccessible( context, target, field, propertyName )) )
- {
- result = NotFound;
- }
- if ( result == null )
- {
- if ( field == null )
- {
- throw new NoSuchFieldException( propertyName );
- }
- try
- {
- Object state;
-
- if ( Modifier.isStatic( field.getModifiers() ) ) {
- throw new NoSuchFieldException( propertyName );
- }
- state = context.getMemberAccess().setup( context, target, field, propertyName );
- result = field.get( target );
- context.getMemberAccess().restore( context, target, field, propertyName, state );
-
- }
- catch ( IllegalAccessException ex )
- {
- throw new NoSuchFieldException( propertyName );
- }
- }
- return result;
- }
-
- public static boolean setFieldValue( OgnlContext context, Object target, String propertyName, Object value )
- throws OgnlException
- {
- boolean result = false;
-
- try
- {
- Class<?> targetClass = target == null ? null : target.getClass();
- Field field = getField( targetClass, propertyName );
- Object state;
-
- if ( ( field != null ) && !Modifier.isStatic( field.getModifiers() ) )
- {
- state = context.getMemberAccess().setup( context, target, field, propertyName );
- try
- {
- if ( isTypeCompatible( value, field.getType() ) || (
- ( value = getConvertedType( context, target, field, propertyName, value, field.getType() ) ) != null ) )
- {
- field.set( target, value );
- result = true;
- }
- }
- finally
- {
- context.getMemberAccess().restore( context, target, field, propertyName, state );
- }
- }
- }
- catch ( IllegalAccessException ex )
- {
- throw new NoSuchPropertyException( target, propertyName, ex );
- }
- return result;
- }
-
- public static boolean isFieldAccessible( OgnlContext context, Object target, Class<?> inClass, String propertyName )
- {
- return isFieldAccessible( context, target, getField( inClass, propertyName ), propertyName );
- }
-
- public static boolean isFieldAccessible( OgnlContext context, Object target, Field field, String propertyName )
- {
- return context.getMemberAccess().isAccessible( context, target, field, propertyName );
- }
-
- public static boolean hasField( OgnlContext context, Object target, Class<?> inClass, String propertyName )
- {
- Field field = getField( inClass, propertyName );
-
- return ( field != null ) && isFieldAccessible( context, target, field, propertyName );
- }
-
- public static Object getStaticField( OgnlContext context, String className, String fieldName )
- throws OgnlException
- {
- Exception cause;
- try
- {
- Class<?> clazz = classForName( context, className );
-
- /*
- * Check for virtual static field "class"; this cannot interfere with normal static fields because it is a
- * reserved word.
- */
- if ( "class".equals( fieldName ) )
- {
- return clazz;
- }
- if ( clazz.isEnum() )
- {
- return Enum.valueOf( (Class<? extends Enum>) clazz, fieldName );
- }
- Field field = clazz.getField( fieldName );
- if ( !Modifier.isStatic(field.getModifiers()) )
- {
- throw new OgnlException( "Field " + fieldName + " of class " + className + " is not static" );
- }
-
- return field.get( null );
- }
- catch ( ClassNotFoundException | IllegalAccessException | SecurityException | NoSuchFieldException e )
- {
- cause = e;
- }
-
- throw new OgnlException( "Could not get static field " + fieldName + " from class " + className, cause );
- }
-
- /**
- * @param targetClass
- * @param propertyName
- * @param findSets
- * @return Returns the list of (g)setter of a class for a given property name
- * @
- */
- public static List<Method> getDeclaredMethods( Class<?> targetClass, String propertyName, boolean findSets )
- {
- String baseName = Character.toUpperCase( propertyName.charAt( 0 ) ) + propertyName.substring( 1 );
- List<Method> methods = new ArrayList<Method>();
- List<String> methodNames = new ArrayList<String>( 2 );
- if ( findSets )
- {
- methodNames.add( SET_PREFIX + baseName );
- }
- else
- {
- methodNames.add( IS_PREFIX + baseName );
- methodNames.add( GET_PREFIX + baseName );
- }
- for ( String methodName : methodNames )
- {
- DeclaredMethodCacheEntry key = new DeclaredMethodCacheEntry( targetClass );
- List<Method> methodList = cache.getMethod( key ).get( methodName );
- if ( methodList != null )
- {
- methods.addAll( methodList );
- }
- }
-
- return methods;
- }
-
- /**
- * Convenience used to check if a method is volatile or synthetic so as to avoid calling un-callable methods.
- *
- * @param method The method to check.
- * @return True if the method should be callable, false otherwise.
- */
- //TODO: the method was intended as private, so it'd need to move in a util class
- public static boolean isMethodCallable( Method method )
- {
- return !( method.isSynthetic() || Modifier.isVolatile( method.getModifiers() ) );
-
- }
-
- public static Method getGetMethod( OgnlContext unused, Class<?> targetClass, String propertyName )
- throws IntrospectionException, OgnlException
- {
- Method result = null;
-
- List<Method> methods = getDeclaredMethods( targetClass, propertyName, false /* find 'get' methods */ );
-
- if ( methods != null )
- {
- for ( Method method : methods )
- {
- Class<?>[] mParameterTypes = findParameterTypes( targetClass, method ); // getParameterTypes(method);
-
- if ( mParameterTypes.length == 0 )
- {
- result = method;
- break;
- }
- }
- }
-
- return result;
- }
-
- public static boolean isMethodAccessible( OgnlContext context, Object target, Method method, String propertyName )
- {
- return ( method != null ) && context.getMemberAccess().isAccessible( context, target, method, propertyName );
- }
-
- public static boolean hasGetMethod( OgnlContext context, Object target, Class<?> targetClass, String propertyName )
- throws IntrospectionException, OgnlException
- {
- return isMethodAccessible( context, target, getGetMethod( context, targetClass, propertyName ), propertyName );
- }
-
- public static Method getSetMethod( OgnlContext context, Class<?> targetClass, String propertyName )
- throws IntrospectionException, OgnlException
- {
- Method setMethod = null;
-
- List<Method> methods = getDeclaredMethods( targetClass, propertyName, true /* find 'set' methods */ );
-
- if ( methods != null )
- {
- for ( Method method : methods )
- {
- Class<?>[] mParameterTypes = findParameterTypes( targetClass, method ); // getParameterTypes(method);
-
- if ( mParameterTypes.length == 1 )
- {
- setMethod = method;
- break;
- }
- }
- }
-
- return setMethod;
- }
-
- public static boolean hasSetMethod( OgnlContext context, Object target, Class<?> targetClass, String propertyName )
- throws IntrospectionException, OgnlException
- {
- return isMethodAccessible( context, target, getSetMethod( context, targetClass, propertyName ), propertyName );
- }
-
- public static boolean hasGetProperty( OgnlContext context, Object target, Object oname )
- throws IntrospectionException, OgnlException
- {
- Class<?> targetClass = ( target == null ) ? null : target.getClass();
- String name = oname.toString();
-
- return hasGetMethod( context, target, targetClass, name ) || hasField( context, target, targetClass, name );
- }
-
- public static boolean hasSetProperty( OgnlContext context, Object target, Object oname )
- throws IntrospectionException, OgnlException
- {
- Class<?> targetClass = ( target == null ) ? null : target.getClass();
- String name = oname.toString();
-
- return hasSetMethod( context, target, targetClass, name ) || hasField( context, target, targetClass, name );
- }
-
- /**
- * This method returns the property descriptors for the given class as a Map.
- *
- * @param targetClass The class to get the descriptors for.
- * @return Map map of property descriptors for class.
- * @throws IntrospectionException on errors using {@link Introspector}.
- * @throws OgnlException On general errors.
- */
- public static Map<String, PropertyDescriptor> getPropertyDescriptors( Class<?> targetClass )
- throws IntrospectionException, OgnlException
- {
- return cache.getPropertyDescriptor( targetClass );
- }
-
- /**
- * This method returns a PropertyDescriptor for the given class and property name using a Map lookup (using
- * getPropertyDescriptorsMap()).
- * @param targetClass a target class.
- * @param propertyName a property name.
- * @return the PropertyDescriptor for the given targetClass and propertyName.
- * @throws java.beans.IntrospectionException
- * @throws OgnlException
- */
- public static PropertyDescriptor getPropertyDescriptor( Class<?> targetClass, String propertyName )
- throws IntrospectionException, OgnlException
- {
- if ( targetClass == null )
- {
- return null;
- }
-
- return getPropertyDescriptors( targetClass ).get( propertyName );
- }
-
- public static PropertyDescriptor[] getPropertyDescriptorsArray( Class<?> targetClass )
- throws IntrospectionException, OgnlException
- {
- Collection<PropertyDescriptor> propertyDescriptors = getPropertyDescriptors( targetClass ).values();
- return propertyDescriptors.toArray( new PropertyDescriptor[propertyDescriptors.size()] );
- }
-
- /**
- * Gets the property descriptor with the given name for the target class given.
- *
- * @param targetClass Class for which property descriptor is desired
- * @param name Name of property
- * @return PropertyDescriptor of the named property or null if the class has no property with the given name
- * @throws java.beans.IntrospectionException
- * @throws OgnlException
- */
- public static PropertyDescriptor getPropertyDescriptorFromArray( Class<?> targetClass, String name )
- throws IntrospectionException, OgnlException
- {
- PropertyDescriptor result = null;
- PropertyDescriptor[] propertyDescriptors = getPropertyDescriptorsArray( targetClass );
-
- for ( PropertyDescriptor propertyDescriptor : propertyDescriptors )
- {
- if ( result != null )
- {
- break;
- }
- if ( propertyDescriptor.getName().compareTo( name ) == 0 )
- {
- result = propertyDescriptor;
- }
- }
- return result;
- }
-
- public static void setMethodAccessor( Class<?> clazz, MethodAccessor accessor )
- {
- cache.setMethodAccessor( clazz, accessor );
- }
-
- public static MethodAccessor getMethodAccessor( Class<?> clazz )
- throws OgnlException
- {
- return cache.getMethodAccessor( clazz );
- }
-
- public static void setPropertyAccessor( Class<?> clazz, PropertyAccessor accessor )
- {
- cache.setPropertyAccessor( clazz, accessor );
- }
-
- public static PropertyAccessor getPropertyAccessor( Class<?> clazz )
- throws OgnlException
- {
- return cache.getPropertyAccessor( clazz );
- }
-
- public static ElementsAccessor getElementsAccessor( Class<?> clazz )
- throws OgnlException
- {
- return cache.getElementsAccessor( clazz );
- }
-
- public static void setElementsAccessor( Class<?> clazz, ElementsAccessor accessor )
- {
- cache.setElementsAccessor( clazz, accessor );
- }
-
- public static NullHandler getNullHandler( Class<?> clazz )
- throws OgnlException
- {
- return cache.getNullHandler( clazz );
- }
-
- public static void setNullHandler( Class<?> clazz, NullHandler handler )
- {
- cache.setNullHandler( clazz, handler );
- }
-
- public static Object getProperty( OgnlContext context, Object source, Object name )
- throws OgnlException
- {
- PropertyAccessor accessor;
-
- if ( source == null )
- {
- throw new OgnlException( "source is null for getProperty(null, \"" + name + "\")" );
- }
- if ( ( accessor = getPropertyAccessor( getTargetClass( source ) ) ) == null )
- {
- throw new OgnlException( "No property accessor for " + getTargetClass( source ).getName() );
- }
-
- return accessor.getProperty( context, source, name );
- }
-
- public static void setProperty( OgnlContext context, Object target, Object name, Object value )
- throws OgnlException
- {
- PropertyAccessor accessor;
-
- if ( target == null )
- {
- throw new OgnlException( "target is null for setProperty(null, \"" + name + "\", " + value + ")" );
- }
- if ( ( accessor = getPropertyAccessor( getTargetClass( target ) ) ) == null )
- {
- throw new OgnlException( "No property accessor for " + getTargetClass( target ).getName() );
- }
-
- accessor.setProperty( context, target, name, value );
- }
-
- /**
- * Determines the index property type, if any. Returns <code>INDEXED_PROPERTY_NONE</code> if the property is not
- * index-accessible as determined by OGNL or JavaBeans. If it is indexable then this will return whether it is a
- * JavaBeans indexed property, conforming to the indexed property patterns (returns
- * <code>INDEXED_PROPERTY_INT</code>) or if it conforms to the OGNL arbitrary object indexable (returns
- * <code>INDEXED_PROPERTY_OBJECT</code>).
- */
- public static int getIndexedPropertyType( OgnlContext context, Class<?> sourceClass, String name )
- throws OgnlException
- {
- int result = INDEXED_PROPERTY_NONE;
-
- try
- {
- PropertyDescriptor propertyDescriptor = getPropertyDescriptor( sourceClass, name );
- if ( propertyDescriptor != null )
- {
- if ( propertyDescriptor instanceof IndexedPropertyDescriptor )
- {
- result = INDEXED_PROPERTY_INT;
- }
- else
- {
- if ( propertyDescriptor instanceof ObjectIndexedPropertyDescriptor )
- {
- result = INDEXED_PROPERTY_OBJECT;
- }
- }
- }
- }
- catch ( Exception ex )
- {
- throw new OgnlException( "problem determining if '" + name + "' is an indexed property", ex );
- }
- return result;
- }
-
- public static Object getIndexedProperty( OgnlContext context, Object source, String name, Object index )
- throws OgnlException
- {
- Object[] args = new Object[] { index };
-
- try
- {
- PropertyDescriptor propertyDescriptor = getPropertyDescriptor( ( source == null ) ? null : source.getClass(), name );
- Method method;
-
- if ( propertyDescriptor instanceof IndexedPropertyDescriptor )
- {
- method = ( (IndexedPropertyDescriptor) propertyDescriptor ).getIndexedReadMethod();
- }
- else
- {
- if ( !(propertyDescriptor instanceof ObjectIndexedPropertyDescriptor) ) {
- throw new OgnlException( "property '" + name + "' is not an indexed property" );
- }
- method = ( (ObjectIndexedPropertyDescriptor) propertyDescriptor ).getIndexedReadMethod();
- }
-
- return callMethod( context, source, method.getName(), args );
-
- }
- catch ( OgnlException ex )
- {
- throw ex;
- }
- catch ( Exception ex )
- {
- throw new OgnlException( "getting indexed property descriptor for '" + name + "'", ex );
- }
- }
-
- public static void setIndexedProperty( OgnlContext context, Object source, String name, Object index, Object value )
- throws OgnlException
- {
- Object[] args = new Object[] { index, value };
-
- try
- {
- PropertyDescriptor propertyDescriptor = getPropertyDescriptor( ( source == null ) ? null : source.getClass(), name );
- Method method;
-
- if ( propertyDescriptor instanceof IndexedPropertyDescriptor )
- {
- method = ( (IndexedPropertyDescriptor) propertyDescriptor ).getIndexedWriteMethod();
- }
- else
- {
- if ( !(propertyDescriptor instanceof ObjectIndexedPropertyDescriptor) ) {
- throw new OgnlException( "property '" + name + "' is not an indexed property" );
- }
- method = ( (ObjectIndexedPropertyDescriptor) propertyDescriptor ).getIndexedWriteMethod();
- }
-
- callMethod( context, source, method.getName(), args );
-
- }
- catch ( OgnlException ex )
- {
- throw ex;
- }
- catch ( Exception ex )
- {
- throw new OgnlException( "getting indexed property descriptor for '" + name + "'", ex );
- }
- }
-
- /**
- * Registers the specified {@link ClassCacheInspector} with all class reflection based internal caches. This may
- * have a significant performance impact so be careful using this in production scenarios.
- *
- * @param inspector The inspector instance that will be registered with all internal cache instances.
- */
- public static void setClassCacheInspector( ClassCacheInspector inspector )
- {
- cache.setClassCacheInspector( inspector );
- }
-
- public static Method getMethod( OgnlContext context, Class<?> target, String name, Node[] children,
- boolean includeStatic )
- throws Exception
- {
- Class<?>[] parms;
- if ( children != null && children.length > 0 )
- {
- parms = new Class[children.length];
-
- // used to reset context after loop
- Class<?> currType = context.getCurrentType();
- Class<?> currAccessor = context.getCurrentAccessor();
- Object cast = context.get( ExpressionCompiler.PRE_CAST );
-
- context.setCurrentObject( context.getRoot() );
- context.setCurrentType( context.getRoot() != null ? context.getRoot().getClass() : null );
- context.setCurrentAccessor( null );
- context.setPreviousType( null );
-
- for ( int i = 0; i < children.length; i++ )
- {
- children[i].toGetSourceString( context, context.getRoot() );
- parms[i] = context.getCurrentType();
- }
-
- context.put( ExpressionCompiler.PRE_CAST, cast );
-
- context.setCurrentType( currType );
- context.setCurrentAccessor( currAccessor );
- context.setCurrentObject( target );
- }
- else
- {
- parms = new Class[0];
- }
-
- List<Method> methods = OgnlRuntime.getMethods( target, name, includeStatic );
- if ( methods == null )
- {
- return null;
- }
-
- for ( Method method : methods )
- {
- boolean varArgs = method.isVarArgs();
-
- if ( parms.length != method.getParameterTypes().length && !varArgs )
- {
- continue;
- }
-
- Class<?>[] methodParameterTypes = method.getParameterTypes();
- boolean matched = true;
- for ( int i = 0; i < methodParameterTypes.length; i++ )
- {
- Class<?> methodParameterType = methodParameterTypes[i];
- if ( varArgs && methodParameterType.isArray() )
- {
- continue;
- }
-
- Class<?> parm = parms[i];
- if ( parm == null )
- {
- matched = false;
- break;
- }
-
- if ( parm == methodParameterType || methodParameterType.isPrimitive() && Character.TYPE != methodParameterType && Byte.TYPE != methodParameterType
- && Number.class.isAssignableFrom(parm)
- && OgnlRuntime.getPrimitiveWrapperClass(parm) == methodParameterType)
- {
- continue;
- }
-
- matched = false;
- break;
- }
-
- if ( matched )
- {
- return method;
- }
- }
-
- return null;
- }
-
- /**
- * Finds the best possible match for a method on the specified target class with a matching name.
- * <p>
- * The name matched will also try different combinations like <code>is + name, has + name, get + name, etc..</code>
- * </p>
- *
- * @param target The class to find a matching method against.
- * @param name The name of the method.
- * @return The most likely matching {@link Method}, or null if none could be found.
- */
- public static Method getReadMethod( Class<?> target, String name )
- {
- return getReadMethod( target, name, -1 );
- }
-
- public static Method getReadMethod( Class<?> target, String name, int numParms )
- {
- try
- {
- name = name.replace( "\"", "" ).toLowerCase();
-
- BeanInfo info = Introspector.getBeanInfo( target );
- MethodDescriptor[] methodDescriptors = info.getMethodDescriptors();
-
- // exact matches first
-
- Method method = null;
-
- for ( MethodDescriptor methodDescriptor : methodDescriptors )
- {
- if ( !isMethodCallable( methodDescriptor.getMethod() ) )
- {
- continue;
- }
-
- String methodName = methodDescriptor.getName();
- String lowerMethodName = methodName.toLowerCase();
- int methodParamLen = methodDescriptor.getMethod().getParameterTypes().length;
-
- if ( ( methodName.equalsIgnoreCase( name ) || lowerMethodName.equals( "get" + name )
- || lowerMethodName.equals( "has" + name ) || lowerMethodName.equals( "is" + name ) )
- && !methodName.startsWith( "set" ) )
- {
- if ( numParms > 0 && methodParamLen == numParms )
- {
- return methodDescriptor.getMethod();
- }
- if ( numParms < 0 )
- {
- if ( methodName.equals( name ) )
- {
- return methodDescriptor.getMethod();
- }
- if ( method == null || ( method.getParameterTypes().length > methodParamLen ) )
- {
- method = methodDescriptor.getMethod();
- }
- }
- }
- }
-
- if ( method != null )
- {
- return method;
- }
-
- for ( MethodDescriptor methodDescriptor : methodDescriptors )
- {
- if ( !isMethodCallable( methodDescriptor.getMethod() ) )
- {
- continue;
- }
-
- if ( methodDescriptor.getName().toLowerCase().endsWith( name ) && !methodDescriptor.getName().startsWith( "set" )
- && methodDescriptor.getMethod().getReturnType() != Void.TYPE )
- {
-
- if ( numParms > 0 && methodDescriptor.getMethod().getParameterTypes().length == numParms )
- {
- return methodDescriptor.getMethod();
- }
- if ( (numParms < 0) && (method == null || ( method.getParameterTypes().length
- > methodDescriptor.getMethod().getParameterTypes().length )) )
- {
- method = methodDescriptor.getMethod();
- }
- }
- }
-
- if ( method != null )
- {
- return method;
- }
-
- // try one last time adding a get to beginning
-
- if ( !name.startsWith( "get" ) )
- {
- return OgnlRuntime.getReadMethod( target, "get" + name, numParms );
- }
-
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
-
- return null;
- }
-
- public static Method getWriteMethod( Class<?> target, String name )
- {
- return getWriteMethod( target, name, -1 );
- }
-
- public static Method getWriteMethod( Class<?> target, String name, int numParms )
- {
- try
- {
- name = name.replace( "\"", "" );
-
- BeanInfo info = Introspector.getBeanInfo( target );
- MethodDescriptor[] methods = info.getMethodDescriptors();
-
- for ( MethodDescriptor method : methods )
- {
- if ( !isMethodCallable( method.getMethod() ) )
- {
- continue;
- }
-
- if ( ( method.getName().equalsIgnoreCase( name ) || method.getName().toLowerCase().equals(
- name.toLowerCase() ) || method.getName().toLowerCase().equals( "set" + name.toLowerCase() ) )
- && !method.getName().startsWith( "get" ) )
- {
-
- if ( numParms > 0 && method.getMethod().getParameterTypes().length == numParms )
- {
- return method.getMethod();
- }
- if ( numParms < 0 )
- {
- return method.getMethod();
- }
- }
- }
-
- // try again on pure class
-
- Method[] cmethods = target.getClass().getMethods();
- for ( Method cmethod : cmethods )
- {
- if ( !isMethodCallable( cmethod ) )
- {
- continue;
- }
-
- if ( ( cmethod.getName().equalsIgnoreCase( name ) || cmethod.getName().toLowerCase().equals(
- name.toLowerCase() ) || cmethod.getName().toLowerCase().equals( "set" + name.toLowerCase() ) )
- && !cmethod.getName().startsWith( "get" ) )
- {
-
- if ( numParms > 0 && cmethod.getParameterTypes().length == numParms )
- {
- return cmethod;
- }
- if ( numParms < 0 )
- {
- return cmethod;
- }
- }
- }
-
- // try one last time adding a set to beginning
-
- if ( !name.startsWith( "set" ) )
- {
- return OgnlRuntime.getReadMethod( target, "set" + name, numParms );
- }
-
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
-
- return null;
- }
-
- public static PropertyDescriptor getProperty( Class<?> target, String name )
- {
- try
- {
- BeanInfo info = Introspector.getBeanInfo( target );
-
- PropertyDescriptor[] propertyDescriptors = info.getPropertyDescriptors();
-
- for ( PropertyDescriptor propertyDescriptor : propertyDescriptors )
- {
-
- String propertyDescriptorName = propertyDescriptor.getName();
- if ( propertyDescriptorName.equalsIgnoreCase( name ) || propertyDescriptorName.toLowerCase().equals( name.toLowerCase() )
- || propertyDescriptorName.toLowerCase().endsWith( name.toLowerCase() ) )
- {
- return propertyDescriptor;
- }
- }
-
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
-
- return null;
- }
-
- public static boolean isBoolean( String expression )
- {
- return expression != null && ( "true".equals( expression ) || "false".equals( expression )
- || "!true".equals( expression ) || "!false".equals( expression ) || "(true)".equals( expression )
- || "!(true)".equals( expression ) || "(false)".equals( expression ) || "!(false)".equals( expression )
- || expression.startsWith( "org.apache.commons.ognl.OgnlOps" ) );
- }
-
- /**
- * Compares the {@link OgnlContext#getCurrentType()} and {@link OgnlContext#getPreviousType()} class types on the
- * stack to determine if a numeric expression should force object conversion.
- * <p/>
- * <p/>
- * Normally used in conjunction with the <code>forceConversion</code> parameter of
- * {@link OgnlRuntime#getChildSource(OgnlContext, Object, Node, boolean)}.
- * </p>
- *
- * @param context The current context.
- * @return True, if the class types on the stack wouldn't be comparable in a pure numeric expression such as
- * <code>o1 >= o2</code>.
- */
- public static boolean shouldConvertNumericTypes( OgnlContext context )
- {
- Class<?> currentType = context.getCurrentType();
- Class<?> previousType = context.getPreviousType();
- return currentType == null || previousType == null
- || !( currentType == previousType && currentType.isPrimitive() && previousType.isPrimitive() )
- && !currentType.isArray() && !previousType.isArray();
- }
-
- /**
- * Attempts to get the java source string represented by the specific child expression via the
- * {@link JavaSource#toGetSourceString(OgnlContext, Object)} interface method.
- *
- * @param context The ognl context to pass to the child.
- * @param target The current object target to use.
- * @param child The child expression.
- * @return The result of calling {@link JavaSource#toGetSourceString(OgnlContext, Object)} plus additional enclosures
- * of {@link OgnlOps#convertValue(Object, Class, boolean)} for conversions.
- * @throws OgnlException Mandatory exception throwing catching.. (blehh)
- */
- public static String getChildSource( OgnlContext context, Object target, Node child )
- throws OgnlException
- {
- return getChildSource( context, target, child, false );
- }
-
- /**
- * Attempts to get the java source string represented by the specific child expression via the
- * {@link JavaSource#toGetSourceString(OgnlContext, Object)} interface method.
- *
- * @param context The ognl context to pass to the child.
- * @param target The current object target to use.
- * @param child The child expression.
- * @param forceConversion If true, forces {@link OgnlOps#convertValue(Object, Class)} conversions on the objects.
- * @return The result of calling {@link JavaSource#toGetSourceString(OgnlContext, Object)} plus additional enclosures
- * of {@link OgnlOps#convertValue(Object, Class, boolean)} for conversions.
- * @throws OgnlException Mandatory exception throwing catching.. (blehh)
- */
- public static String getChildSource( OgnlContext context, Object target, Node child, boolean forceConversion )
- throws OgnlException
- {
- String pre = (String) context.get( "_currentChain" );
- if ( pre == null )
- {
- pre = "";
- }
-
- try
- {
- child.getValue( context, target );
- }
- catch ( NullPointerException e )
- {
- // ignore
- }
- catch ( ArithmeticException e )
- {
- context.setCurrentType( int.class );
- return "0";
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
-
- String source;
-
- try
- {
- source = child.toGetSourceString( context, target );
- }
- catch ( Throwable t )
- {
- throw OgnlOps.castToRuntime( t );
- }
-
- // handle root / method expressions that may not have proper root java source access
-
- if ( !(child instanceof ASTConst) && ( target == null || context.getRoot() != target ) )
- {
- source = pre + source;
- }
-
- if ( context.getRoot() != null )
- {
- source = ExpressionCompiler.getRootExpression( child, context.getRoot(), context ) + source;
- context.setCurrentAccessor( context.getRoot().getClass() );
- }
-
- if (child instanceof ASTChain)
- {
- String cast = (String) context.remove( ExpressionCompiler.PRE_CAST );
- if ( cast == null )
- {
- cast = "";
- }
-
- source = cast + source;
- }
-
- if ( source == null || source.trim().length() < 1 )
- {
- source = "null";
- }
-
- return source;
- }
-}
+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.internal.CacheException;
+import org.apache.commons.ognl.internal.entry.DeclaredMethodCacheEntry;
+import org.apache.commons.ognl.internal.entry.GenericMethodParameterTypeCacheEntry;
+import org.apache.commons.ognl.internal.entry.MethodAccessEntryValue;
+import org.apache.commons.ognl.internal.entry.PermissionCacheEntry;
+
+import java.beans.BeanInfo;
+import java.beans.IndexedPropertyDescriptor;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.MethodDescriptor;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Proxy;
+import java.security.Permission;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Utility class used by internal OGNL API to do various things like:
+ * <ul>
+ * <li>Handles majority of reflection logic / caching.</li>
+ * <li>Utility methods for casting strings / various numeric types used by {@link OgnlExpressionCompiler}.</li.
+ * <li>Core runtime configuration point for setting/using global {@link TypeConverter} / {@link OgnlExpressionCompiler}
+ * / {@link NullHandler} instances / etc..</li>
+ * </ul>
+ *
+ */
+public class OgnlRuntime
+{
+ /**
+ * Constant expression used to indicate that a given method / property couldn't be found during reflection
+ * operations.
+ */
+ public static final Object NotFound = new Object();
+
+ public static final Object[] NoArguments = new Object[]{ };
+
+ /**
+ * Token returned by TypeConverter for no conversion possible
+ */
+ public static final Object NoConversionPossible = "ognl.NoConversionPossible";
+
+ /**
+ * Not an indexed property
+ */
+ public static final int INDEXED_PROPERTY_NONE = 0;
+
+ /**
+ * JavaBeans IndexedProperty
+ */
+ public static final int INDEXED_PROPERTY_INT = 1;
+
+ /**
+ * OGNL ObjectIndexedProperty
+ */
+ public static final int INDEXED_PROPERTY_OBJECT = 2;
+
+ /**
+ * Constant string representation of null string.
+ */
+ public static final String NULL_STRING = "" + null;
+
+ /**
+ * Java beans standard set method prefix.
+ */
+ public static final String SET_PREFIX = "set";
+
+ /**
+ * Java beans standard get method prefix.
+ */
+ public static final String GET_PREFIX = "get";
+
+ /**
+ * Java beans standard is<Foo> boolean getter prefix.
+ */
+ public static final String IS_PREFIX = "is";
+
+ /**
+ * Prefix padding for hexadecimal numbers to HEX_LENGTH.
+ */
+ private static final Map<Integer, String> HEX_PADDING = new HashMap<Integer, String>();
+
+ private static final int HEX_LENGTH = 8;
+
+ /**
+ * Returned by <CODE>getUniqueDescriptor()</CODE> when the object is <CODE>null</CODE>.
+ */
+ private static final String NULL_OBJECT_STRING = "<null>";
+
+ static final OgnlCache cache = new OgnlCache();
+
+ private static final PrimitiveTypes primitiveTypes = new PrimitiveTypes();
+
+ private static final PrimitiveDefaults primitiveDefaults = new PrimitiveDefaults();
+
+ private static SecurityManager securityManager = System.getSecurityManager();
+
+ /**
+ * Expression compiler used by {@link Ognl#compileExpression(OgnlContext, Object, String)} calls.
+ */
+ private static OgnlExpressionCompiler compiler;
+
+ /**
+ * Used to provide primitive type equivalent conversions into and out of native / object types.
+ */
+ private static final PrimitiveWrapperClasses primitiveWrapperClasses = new PrimitiveWrapperClasses();
+
+ /**
+ * Constant strings for casting different primitive types.
+ */
+ private static final NumericCasts numericCasts = new NumericCasts();
+
+ /**
+ * Constant strings for getting the primitive value of different native types on the generic {@link Number} object
+ * interface. (or the less generic BigDecimal/BigInteger types)
+ */
+ private static final NumericValues numericValues = new NumericValues();
+
+ /**
+ * Numeric primitive literal string expressions.
+ */
+ private static final NumericLiterals numericLiterals = new NumericLiterals();
+
+ private static final NumericDefaults numericDefaults = new NumericDefaults();
+
+ /**
+ * Clears all of the cached reflection information normally used to improve the speed of expressions that operate on
+ * the same classes or are executed multiple times.
+ * <p>
+ * <strong>Warning:</strong> Calling this too often can be a huge performance drain on your expressions - use with
+ * care.
+ * </p>
+ */
+ public static void clearCache()
+ {
+ cache.clear();
+ }
+
+ public static String getNumericValueGetter( Class<?> type )
+ {
+ return numericValues.get( type );
+ }
+
+ public static Class<?> getPrimitiveWrapperClass( Class<?> primitiveClass )
+ {
+ return primitiveWrapperClasses.get( primitiveClass );
+ }
+
+ public static String getNumericCast( Class<? extends Number> type )
+ {
+ return numericCasts.get( type );
+ }
+
+ public static String getNumericLiteral( Class<? extends Number> type )
+ {
+ return numericLiterals.get( type );
+ }
+
+ public static void setCompiler( OgnlExpressionCompiler compiler )
+ {
+ OgnlRuntime.compiler = compiler;
+ }
+
+ public static OgnlExpressionCompiler getCompiler( OgnlContext ognlContext )
+ {
+ if ( compiler == null )
+ {
+ try
+ {
+ OgnlRuntime.classForName( ognlContext, "javassist.ClassPool" );
+ compiler = new ExpressionCompiler();
+ }
+ catch ( ClassNotFoundException e )
+ {
+ throw new IllegalArgumentException(
+ "Javassist library is missing in classpath! Please add missed dependency!", e );
+ }
+ }
+ return compiler;
+ }
+
+ public static void compileExpression( OgnlContext context, Node expression, Object root )
+ throws Exception
+ {
+ getCompiler( context ).compileExpression( context, expression, root );
+ }
+
+ /**
+ * Gets the "target" class of an object for looking up accessors that are registered on the target. If the object is
+ * a Class object this will return the Class itself, else it will return object's getClass() result.
+ */
+ public static Class<?> getTargetClass( Object o )
+ {
+ return ( o == null ) ? null : ( ( o instanceof Class ) ? (Class<?>) o : o.getClass() );
+ }
+
+ /**
+ * Returns the base name (the class name without the package name prepended) of the object given.
+ */
+ public static String getBaseName( Object o )
+ {
+ return ( o == null ) ? null : getClassBaseName( o.getClass() );
+ }
+
+ /**
+ * Returns the base name (the class name without the package name prepended) of the class given.
+ */
+ public static String getClassBaseName( Class<?> clazz )
+ {
+ String className = clazz.getName();
+ return className.substring( className.lastIndexOf( '.' ) + 1 );
+ }
+
+ public static String getClassName( Object object, boolean fullyQualified )
+ {
+ if ( !( object instanceof Class ) )
+ {
+ object = object.getClass();
+ }
+
+ return getClassName( (Class<?>) object, fullyQualified );
+ }
+
+ public static String getClassName( Class<?> clazz, boolean fullyQualified )
+ {
+ return fullyQualified ? clazz.getName() : getClassBaseName( clazz );
+ }
+
+ /**
+ * Returns the package name of the object's class.
+ */
+ public static String getPackageName( Object object )
+ {
+ return ( object == null ) ? null : getClassPackageName( object.getClass() );
+ }
+
+ /**
+ * Returns the package name of the class given.
+ */
+ public static String getClassPackageName( Class<?> clazz )
+ {
+ String className = clazz.getName();
+ int index = className.lastIndexOf( '.' );
+
+ return ( index < 0 ) ? null : className.substring( 0, index );
+ }
+
+ /**
+ * Returns a "pointer" string in the usual format for these things - 0x<hex digits>.
+ */
+ public static String getPointerString( int num )
+ {
+ String hex = Integer.toHexString( num ), pad;
+ Integer l = hex.length();
+
+ // stringBuilder.append(HEX_PREFIX);
+ if ( ( pad = HEX_PADDING.get( l ) ) == null )
+ {
+ StringBuilder paddingStringBuilder = new StringBuilder();
+
+ for ( int i = hex.length(); i < HEX_LENGTH; i++ )
+ {
+ paddingStringBuilder.append( '0' );
+ }
+ pad = paddingStringBuilder.toString();
+ HEX_PADDING.put( l, pad );
+ }
+ return new StringBuilder().append( pad ).append( hex ).toString();
+ }
+
+ /**
+ * Returns a "pointer" string in the usual format for these things - 0x<hex digits> for the object given. This will
+ * always return a unique value for each object.
+ */
+ public static String getPointerString( Object object )
+ {
+ return getPointerString( ( object == null ) ? 0 : System.identityHashCode( object ) );
+ }
+
+ /**
+ * Returns a unique descriptor string that includes the object's class and a unique integer identifier. If
+ * fullyQualified is true then the class name will be fully qualified to include the package name, else it will be
+ * just the class' base name.
+ */
+ public static String getUniqueDescriptor( Object object, boolean fullyQualified )
+ {
+ StringBuilder stringBuilder = new StringBuilder();
+
+ if ( object != null )
+ {
+ if ( object instanceof Proxy )
+ {
+ Class<?> interfaceClass = object.getClass().getInterfaces()[0];
+
+ String className = getClassName( interfaceClass, fullyQualified );
+ stringBuilder.append( className ).append( '^' );
+ object = Proxy.getInvocationHandler( object );
+ }
+ String className = getClassName( object, fullyQualified );
+ String pointerString = getPointerString( object );
+ stringBuilder.append( className ).append( '@' ).append( pointerString );
+ }
+ else
+ {
+ stringBuilder.append( NULL_OBJECT_STRING );
+ }
+ return stringBuilder.toString();
+ }
+
+ /**
+ * Returns a unique descriptor string that includes the object's class' base name and a unique integer identifier.
+ */
+ public static String getUniqueDescriptor( Object object )
+ {
+ return getUniqueDescriptor( object, false );
+ }
+
+ /**
+ * Utility to convert a List into an Object[] array. If the list is zero elements this will return a constant array;
+ * toArray() on List always returns a new object and this is wasteful for our purposes.
+ */
+ public static <T> Object[] toArray( List<T> list )
+ {
+ Object[] array;
+ int size = list.size();
+
+ if ( size == 0 )
+ {
+ array = NoArguments;
+ }
+ else
+ {
+ array = new Object[size];
+ for ( int i = 0; i < size; i++ )
+ {
+ array[i] = list.get( i );
+ }
+ }
+ return array;
+ }
+
+ /**
+ * Returns the parameter types of the given method.
+ */
+ public static Class<?>[] getParameterTypes( Method method )
+ throws CacheException
+ {
+ return cache.getMethodParameterTypes( method );
+ }
+
+ /**
+ * Finds the appropriate parameter types for the given {@link Method} and {@link Class} instance of the type the
+ * method is associated with. Correctly finds generic types if running in >= 1.5 jre as well.
+ *
+ * @param type The class type the method is being executed against.
+ * @param method The method to find types for.
+ * @return Array of parameter types for the given method.
+ * @throws org.apache.commons.ognl.internal.CacheException
+ */
+ public static Class<?>[] findParameterTypes( Class<?> type, Method method )
+ throws CacheException
+ {
+ if ( type == null || type.getGenericSuperclass() == null || !(type.getGenericSuperclass() instanceof ParameterizedType) || method.getDeclaringClass().getTypeParameters() == null )
+ {
+ return getParameterTypes( method );
+ }
+
+ GenericMethodParameterTypeCacheEntry key = new GenericMethodParameterTypeCacheEntry( method, type );
+ return cache.getGenericMethodParameterTypes( key );
+ }
+
+ /**
+ * Returns the parameter types of the given method.
+ * @param constructor
+ * @return
+ * @throws org.apache.commons.ognl.internal.CacheException
+ */
+ public static Class<?>[] getParameterTypes( Constructor<?> constructor )
+ throws CacheException
+ {
+ return cache.getParameterTypes( constructor );
+ }
+
+ /**
+ * Gets the SecurityManager that OGNL uses to determine permissions for invoking methods.
+ *
+ * @return SecurityManager for OGNL
+ */
+ public static SecurityManager getSecurityManager()
+ {
+ return securityManager;
+ }
+
+ /**
+ * Sets the SecurityManager that OGNL uses to determine permissions for invoking methods.
+ *
+ * @param securityManager SecurityManager to set
+ */
+ public static void setSecurityManager( SecurityManager securityManager )
+ {
+ OgnlRuntime.securityManager = securityManager;
+ cache.setSecurityManager(securityManager);
+ }
+
+ /**
+ * Permission will be named "invoke.<declaring-class>.<method-name>".
+ * @param method
+ * @return
+ * @throws org.apache.commons.ognl.internal.CacheException
+ */
+ public static Permission getPermission( Method method )
+ throws CacheException
+ {
+ PermissionCacheEntry key = new PermissionCacheEntry( method );
+ return cache.getInvokePermission( key );
+ }
+
+ public static Object invokeMethod( Object target, Method method, Object[] argsArray )
+ throws InvocationTargetException, IllegalAccessException, CacheException
+ {
+ Object result;
+
+ if ( securityManager != null && !cache.getMethodPerm( method ) )
+ {
+ throw new IllegalAccessException( "Method [" + method + "] cannot be accessed." );
+ }
+
+ MethodAccessEntryValue entry = cache.getMethodAccess( method );
+ if ( !entry.isAccessible() )
+ {
+ // only synchronize method invocation if it actually requires it
+ synchronized ( method )
+ {
+
+ if ( entry.isNotPublic() && !entry.isAccessible() )
+ {
+ method.setAccessible( true );
+ }
+
+ result = method.invoke( target, argsArray );
+
+ if ( !entry.isAccessible() )
+ {
+ method.setAccessible( false );
+ }
+ }
+ }
+ else
+ {
+ result = method.invoke( target, argsArray );
+ }
+
+ return result;
+ }
+
+ /**
+ * Gets the class for a method argument that is appropriate for looking up methods by reflection, by looking for the
+ * standard primitive wrapper classes and exchanging for them their underlying primitive class objects. Other
+ * classes are passed through unchanged.
+ *
+ * @param arg an object that is being passed to a method
+ * @return the class to use to look up the method
+ */
+ public static Class<?> getArgClass( Object arg )
+ {
+ if ( arg == null )
+ {
+ return null;
+ }
+ Class<?> clazz = arg.getClass();
+ if ( clazz == Boolean.class )
+ {
+ return Boolean.TYPE;
+ }
+ if ( clazz.getSuperclass() == Number.class )
+ {
+ if ( clazz == Integer.class )
+ {
+ return Integer.TYPE;
+ }
+ if ( clazz == Double.class )
+ {
+ return Double.TYPE;
+ }
+ if ( clazz == Byte.class )
+ {
+ return Byte.TYPE;
+ }
+ if ( clazz == Long.class )
+ {
+ return Long.TYPE;
+ }
+ if ( clazz == Float.class )
+ {
+ return Float.TYPE;
+ }
+ if ( clazz == Short.class )
+ {
+ return Short.TYPE;
+ }
+ }
+ else if ( clazz == Character.class )
+ {
+ return Character.TYPE;
+ }
+ return clazz;
+ }
+
+ /**
+ * Tells whether the given object is compatible with the given class ---that is, whether the given object can be
+ * passed as an argument to a method or constructor whose parameter type is the given class. If object is null this
+ * will return true because null is compatible with any type.
+ */
+ public static boolean isTypeCompatible( Object object, Class<?> clazz )
+ {
+ boolean result = true;
+
+ if ( object != null )
+ {
+ if ( clazz.isPrimitive() )
+ {
+ if ( getArgClass( object ) != clazz )
+ {
+ result = false;
+ }
+ }
+ else if ( !clazz.isInstance( object ) )
+ {
+ result = false;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Tells whether the given array of objects is compatible with the given array of classes---that is, whether the
+ * given array of objects can be passed as arguments to a method or constructor whose parameter types are the given
+ * array of classes.
+ */
+ public static boolean areArgsCompatible( Object[] args, Class<?>[] classes )
+ {
+ return areArgsCompatible( args, classes, null );
+ }
+
+ public static boolean areArgsCompatible( Object[] args, Class<?>[] classes, Method method )
+ {
+ boolean result = true;
+ boolean varArgs = method != null && method.isVarArgs();
+
+ if ( args.length != classes.length && !varArgs )
+ {
+ result = false;
+ }
+ else if ( varArgs )
+ {
+ for ( int index = 0; result && ( index < args.length ); ++index )
+ {
+ if ( index >= classes.length )
+ {
+ break;
+ }
+
+ result = isTypeCompatible( args[index], classes[index] );
+
+ if ( !result && classes[index].isArray() )
+ {
+ result = isTypeCompatible( args[index], classes[index].getComponentType() );
+ }
+ }
+ }
+ else
+ {
+ for ( int index = 0; result && ( index < args.length ); ++index )
+ {
+ result = isTypeCompatible( args[index], classes[index] );
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Tells whether the first array of classes is more specific than the second. Assumes that the two arrays are of the
+ * same length.
+ */
+ public static boolean isMoreSpecific( Class<?>[] classes1, Class<?>[] classes2 )
+ {
+ for ( int index = 0; index < classes1.length; ++index )
+ {
+ Class<?> class1 = classes1[index], class2 = classes2[index];
+ if ( class1 != class2 )
+ {
+ if ( class1.isPrimitive() )
+ {
+ return true;
+ }
+ if ( class1.isAssignableFrom( class2 ) )
+ {
+ return false;
+ }
+ if ( class2.isAssignableFrom( class1 ) )
+ {
+ return true;
+ }
+ }
+ }
+
+ // They are the same! So the first is not more specific than the second.
+ return false;
+ }
+
+ public static Class<?> classForName( OgnlContext context, String className )
+ throws ClassNotFoundException
+ {
+ Class<?> result = primitiveTypes.get( className );
+
+ if ( result == null )
+ {
+ ClassResolver resolver;
+
+ if ( ( context == null ) || ( ( resolver = context.getClassResolver() ) == null ) )
+ {
+ resolver = OgnlContext.DEFAULT_CLASS_RESOLVER;
+ }
+ result = resolver.classForName( className, context );
+ }
+
+ if ( result == null )
+ {
+ throw new ClassNotFoundException( "Unable to resolve class: " + className );
+ }
+
+ return result;
+ }
+
+ public static boolean isInstance( OgnlContext context, Object value, String className )
+ throws OgnlException
+ {
+ try
+ {
+ Class<?> clazz = classForName( context, className );
+ return clazz.isInstance( value );
+ }
+ catch ( ClassNotFoundException e )
+ {
+ throw new OgnlException( "No such class: " + className, e );
+ }
+ }
+
+ public static Object getPrimitiveDefaultValue( Class<?> forClass )
+ {
+ return primitiveDefaults.get( forClass );
+ }
+
+ public static Object getNumericDefaultValue( Class<?> forClass )
+ {
+ return numericDefaults.get( forClass );
+ }
+
+ public static Object getConvertedType( OgnlContext context, Object target, Member member, String propertyName,
+ Object value, Class<?> type )
+ {
+ return context.getTypeConverter().convertValue( context, target, member, propertyName, value, type );
+ }
+
+ public static boolean getConvertedTypes( OgnlContext context, Object target, Member member, String propertyName,
+ Class<?>[] parameterTypes, Object[] args, Object[] newArgs )
+
+ {
+ boolean result = false;
+
+ if ( parameterTypes.length == args.length )
+ {
+ result = true;
+ for ( int i = 0; result && ( i <= parameterTypes.length - 1 ); i++ )
+ {
+ Object arg = args[i];
+ Class<?> type = parameterTypes[i];
+
+ if ( isTypeCompatible( arg, type ) )
+ {
+ newArgs[i] = arg;
+ }
+ else
+ {
+ Object convertedType = getConvertedType( context, target, member, propertyName, arg, type );
+
+ if ( convertedType == OgnlRuntime.NoConversionPossible )
+ {
+ result = false;
+ }
+ else
+ {
+ newArgs[i] = convertedType;
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ public static Method getConvertedMethodAndArgs( OgnlContext context, Object target, String propertyName,
+ List<Method> methods, Object[] args, Object[] newArgs )
+
+ {
+ Method convertedMethod = null;
+ TypeConverter typeConverter = context.getTypeConverter();
+
+ if ( ( typeConverter != null ) && ( methods != null ) )
+ {
+ int methodsSize = methods.size();
+ for ( int i = 0; ( convertedMethod == null ) && ( i < methodsSize ); i++ )
+ {
+ Method method = methods.get( i );
+ Class<?>[] parameterTypes =
+ findParameterTypes( target != null ? target.getClass() : null, method );// getParameterTypes(method);
+
+ if ( getConvertedTypes( context, target, method, propertyName, parameterTypes, args, newArgs ) )
+ {
+ convertedMethod = method;
+ }
+ }
+ }
+ return convertedMethod;
+ }
+
+ public static Constructor<?> getConvertedConstructorAndArgs( OgnlContext context, Object target,
+ List<Constructor<?>> constructors, Object[] args,
+ Object[] newArgs )
+
+ {
+ Constructor<?> constructor = null;
+ TypeConverter typeConverter = context.getTypeConverter();
+
+ if ( ( typeConverter != null ) && ( constructors != null ) )
+ {
+ for ( int i = 0; ( constructor == null ) && ( i < constructors.size() ); i++ )
+ {
+ Constructor<?> ctor = constructors.get( i );
+ Class<?>[] parameterTypes = getParameterTypes( ctor );
+
+ if ( getConvertedTypes( context, target, ctor, null, parameterTypes, args, newArgs ) )
+ {
+ constructor = ctor;
+ }
+ }
+ }
+ return constructor;
+ }
+
+ /**
+ * Gets the appropriate method to be called for the given target, method name and arguments. If successful this
+ * method will return the Method within the target that can be called and the converted arguments in actualArgs. If
+ * unsuccessful this method will return null and the actualArgs will be empty.
+ *
+ * @param context The current execution context.
+ * @param source Target object to run against or method name.
+ * @param target Instance of object to be run against.
+ * @param propertyName Name of property to get method of.
+ * @param methods List of current known methods.
+ * @param args Arguments originally passed in.
+ * @param actualArgs Converted arguments.
+ * @return Best method match or null if none could be found.
+ */
+ public static Method getAppropriateMethod( OgnlContext context, Object source, Object target, String propertyName,
+ List<Method> methods, Object[] args, Object[] actualArgs )
+
+ {
+ Method appropriateMethod = null;
+ Class<?>[] resultParameterTypes = null;
+
+ if ( methods != null )
+ {
+ for ( Method method : methods )
+ {
+ Class<?> typeClass = target != null ? target.getClass() : null;
+ if ( typeClass == null && source != null && source instanceof Class)
+ {
+ typeClass = (Class<?>) source;
+ }
+
+ Class<?>[] mParameterTypes = findParameterTypes( typeClass, method );
+
+ if ( areArgsCompatible( args, mParameterTypes, method ) &&
+ ( ( appropriateMethod == null ) || isMoreSpecific( mParameterTypes, resultParameterTypes ) ) )
+ {
+ appropriateMethod = method;
+ resultParameterTypes = mParameterTypes;
+ System.arraycopy( args, 0, actualArgs, 0, args.length );
+
+ for ( int i = 0; i < mParameterTypes.length; i++ )
+ {
+ Class<?> type = mParameterTypes[i];
+
+ if ( type.isPrimitive() && ( actualArgs[i] == null ) )
+ {
+ actualArgs[i] = getConvertedType( context, source, appropriateMethod, propertyName, null, type );
+ }
+ }
+ }
+ }
+ }
+
+ if ( appropriateMethod == null )
+ {
+ appropriateMethod = getConvertedMethodAndArgs( context, target, propertyName, methods, args, actualArgs );
+ }
+
+ return appropriateMethod;
+ }
+
+ public static Object callAppropriateMethod( OgnlContext context, Object source, Object target, String methodName,
+ String propertyName, List<Method> methods, Object[] args )
+ throws MethodFailedException
+ {
+ Throwable cause = null;
+ Object[] actualArgs = new Object[args.length];
+
+ try
+ {
+ Method method = getAppropriateMethod( context, source, target, propertyName, methods, args, actualArgs );
+
+ if ( ( method == null ) || !isMethodAccessible( context, source, method, propertyName ) )
+ {
+ StringBuilder buffer = new StringBuilder();
+ String className = "";
+
+ if ( target != null )
+ {
+ className = target.getClass().getName() + ".";
+ }
+
+ for ( int i = 0, ilast = args.length - 1; i <= ilast; i++ )
+ {
+ Object arg = args[i];
+
+ buffer.append( ( arg == null ) ? NULL_STRING : arg.getClass().getName() );
+ if ( i < ilast )
+ {
+ buffer.append( ", " );
+ }
+ }
+
+ throw new NoSuchMethodException( className + methodName + "(" + buffer + ")" );
+ }
+
+ Object[] convertedArgs = actualArgs;
+
+ if ( method.isVarArgs() )
+ {
+ Class<?>[] parmTypes = method.getParameterTypes();
+
+ // split arguments in to two dimensional array for varargs reflection invocation
+ // where it is expected that the parameter passed in to invoke the method
+ // will look like "new Object[] { arrayOfNonVarArgsArguments, arrayOfVarArgsArguments }"
+
+ for ( int i = 0; i < parmTypes.length; i++ )
+ {
+ if ( parmTypes[i].isArray() )
+ {
+ convertedArgs = new Object[i + 1];
+ System.arraycopy( actualArgs, 0, convertedArgs, 0, convertedArgs.length );
+
+ Object[] varArgs;
+
+ // if they passed in varargs arguments grab them and dump in to new varargs array
+
+ if ( actualArgs.length > i )
+ {
+ List<Object> varArgsList = new ArrayList<Object>();
+ for ( int j = i; j < actualArgs.length; j++ )
+ {
+ if ( actualArgs[j] != null )
+ {
+ varArgsList.add( actualArgs[j] );
+ }
+ }
+
+ varArgs = varArgsList.toArray();
+ }
+ else
+ {
+ varArgs = new Object[0];
+ }
+
+ convertedArgs[i] = varArgs;
+ break;
+ }
+ }
+ }
+
+ return invokeMethod( target, method, convertedArgs );
+
+ }
+ catch ( NoSuchMethodException | IllegalAccessException e )
+ {
+ cause = e;
+ } catch ( InvocationTargetException e )
+ {
+ cause = e.getTargetException();
+ }
+
+ throw new MethodFailedException( source, methodName, cause );
+ }
+
+ public static Object callStaticMethod( OgnlContext context, String className, String methodName, Object[] args )
+ throws OgnlException
+ {
+ try
+ {
+ Class<?> targetClass = classForName( context, className );
+
+ MethodAccessor methodAccessor = getMethodAccessor( targetClass );
+
+ return methodAccessor.callStaticMethod( context, targetClass, methodName, args );
+ }
+ catch ( ClassNotFoundException ex )
+ {
+ throw new MethodFailedException( className, methodName, ex );
+ }
+ }
+
+ /**
+ * Invokes the specified method against the target object.
+ *
+ * @param context The current execution context.
+ * @param target The object to invoke the method on.
+ * @param methodName Name of the method - as in "getValue" or "add", etc..
+ * @param args Optional arguments needed for method.
+ * @return Result of invoking method.
+ * @throws OgnlException For lots of different reasons.
+ */
+ public static Object callMethod( OgnlContext context, Object target, String methodName, Object[] args )
+ throws OgnlException
+ {
+ if ( target == null )
+ {
+ throw new NullPointerException( "target is null for method " + methodName );
+ }
+
+ return getMethodAccessor( target.getClass() ).callMethod( context, target, methodName, args );
+ }
+
+ public static Object callConstructor( OgnlContext context, String className, Object[] args )
+ throws OgnlException
+ {
+ Throwable cause = null;
+ Object[] actualArgs = args;
+
+ try
+ {
+ Constructor<?> ctor = null;
+ Class<?>[] ctorParameterTypes = null;
+ Class<?> target = classForName( context, className );
+ List<Constructor<?>> constructors = getConstructors( target );
+
+ for ( Constructor<?> constructor : constructors )
+ {
+ Class<?>[] cParameterTypes = getParameterTypes( constructor );
+
+ if ( areArgsCompatible( args, cParameterTypes ) && ( ctor == null || isMoreSpecific( cParameterTypes,
+ ctorParameterTypes ) ) )
+ {
+ ctor = constructor;
+ ctorParameterTypes = cParameterTypes;
+ }
+ }
+ if ( ctor == null )
+ {
+ actualArgs = new Object[args.length];
+ if ( ( ctor = getConvertedConstructorAndArgs( context, target, constructors, args, actualArgs ) ) == null )
+ {
+ throw new NoSuchMethodException();
+ }
+ }
+ if ( !context.getMemberAccess().isAccessible( context, target, ctor, null ) )
+ {
+ throw new IllegalAccessException( "access denied to " + target.getName() + "()" );
+ }
+ return ctor.newInstance( actualArgs );
+ }
+ catch ( ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException e )
+ {
+ cause = e;
+ } catch ( InvocationTargetException e )
+ {
+ cause = e.getTargetException();
+ }
+
+ throw new MethodFailedException( className, "new", cause );
+ }
+
+ public static Object getMethodValue( OgnlContext context, Object target, String propertyName )
+ throws OgnlException, IllegalAccessException, NoSuchMethodException, IntrospectionException
+ {
+ return getMethodValue( context, target, propertyName, false );
+ }
+
+ /**
+ * If the checkAccessAndExistence flag is true this method will check to see if the method exists and if it is
+ * accessible according to the context's MemberAccess. If neither test passes this will return NotFound.
+ */
+ public static Object getMethodValue( OgnlContext context, Object target, String propertyName,
+ boolean checkAccessAndExistence )
+ throws OgnlException, IllegalAccessException, NoSuchMethodException, IntrospectionException
+ {
+ Object methodValue = null;
+ Class<?> targetClass = target == null ? null : target.getClass();
+ Method method = getGetMethod( context, targetClass, propertyName );
+ if ( method == null )
+ {
+ method = getReadMethod( targetClass, propertyName, 0 );
+ }
+
+ if ( checkAccessAndExistence && (( method == null ) || !context.getMemberAccess().isAccessible( context, target, method, propertyName )) )
+ {
+ methodValue = NotFound;
+ }
+ if ( methodValue == null )
+ {
+ if ( method == null ) {
+ throw new NoSuchMethodException( propertyName );
+ }
+ try
+ {
+ methodValue = invokeMethod( target, method, NoArguments );
+ }
+ catch ( InvocationTargetException ex )
+ {
+ throw new OgnlException( propertyName, ex.getTargetException() );
+ }
+ }
+ return methodValue;
+ }
+
+ public static boolean setMethodValue( OgnlContext context, Object target, String propertyName, Object value )
+ throws OgnlException, IllegalAccessException, NoSuchMethodException, IntrospectionException
+ {
+ return setMethodValue( context, target, propertyName, value, false );
+ }
+
+ public static boolean setMethodValue( OgnlContext context, Object target, String propertyName, Object value,
+ boolean checkAccessAndExistence )
+ throws OgnlException, IllegalAccessException, NoSuchMethodException, IntrospectionException
+ {
+ boolean result = true;
+ Method method = getSetMethod( context, ( target == null ) ? null : target.getClass(), propertyName );
+
+ if ( checkAccessAndExistence && (( method == null ) || !context.getMemberAccess().isAccessible( context, target, method, propertyName )) )
+ {
+ result = false;
+ }
+
+ if ( result )
+ {
+ if ( method != null )
+ {
+ Object[] args = new Object[]{ value };
+ callAppropriateMethod( context, target, target, method.getName(), propertyName,
+ Collections.nCopies( 1, method ), args );
+ }
+ else
+ {
+ result = false;
+ }
+ }
+
+ return result;
+ }
+
+ public static List<Constructor<?>> getConstructors( Class<?> targetClass )
+ {
+ return cache.getConstructor( targetClass );
+ }
+
+ /**
+ * @param targetClass
+ * @param staticMethods if true (false) returns only the (non-)static methods
+ * @return Returns the map of methods for a given class
+ */
+ public static Map<String, List<Method>> getMethods( Class<?> targetClass, boolean staticMethods )
+ {
+ DeclaredMethodCacheEntry.MethodType type = staticMethods ?
+ DeclaredMethodCacheEntry.MethodType.STATIC :
+ DeclaredMethodCacheEntry.MethodType.NON_STATIC;
+ DeclaredMethodCacheEntry key = new DeclaredMethodCacheEntry( targetClass, type );
+ return cache.getMethod( key );
+ }
+
+ public static List<Method> getMethods( Class<?> targetClass, String name, boolean staticMethods )
+ {
+ return getMethods( targetClass, staticMethods ).get( name );
+ }
+
+ public static Map<String, Field> getFields( Class<?> targetClass )
+ {
+ return cache.getField( targetClass );
+ }
+
+ public static Field getField( Class<?> inClass, String name )
+ {
+ Field field = getFields( inClass ).get( name );
+
+ if ( field == null )
+ {
+ // if field is null, it should search along the superclasses
+ Class<?> superClass = inClass.getSuperclass();
+ while ( superClass != null )
+ {
+ field = getFields( superClass ).get( name );
+ if ( field != null )
+ {
+ return field;
+ }
+ superClass = superClass.getSuperclass();
+ }
+ }
+ return field;
+ }
+
+ public static Object getFieldValue( OgnlContext context, Object target, String propertyName )
+ throws NoSuchFieldException
+ {
+ return getFieldValue( context, target, propertyName, false );
+ }
+
+ public static Object getFieldValue( OgnlContext context, Object target, String propertyName,
+ boolean checkAccessAndExistence )
+ throws NoSuchFieldException
+ {
+ Object result = null;
+ Class<?> targetClass = target == null ? null : target.getClass();
+ Field field = getField( targetClass, propertyName );
+
+ if ( checkAccessAndExistence && (( field == null ) || !context.getMemberAccess().isAccessible( context, target, field, propertyName )) )
+ {
+ result = NotFound;
+ }
+ if ( result == null )
+ {
+ if ( field == null )
+ {
+ throw new NoSuchFieldException( propertyName );
+ }
+ try
+ {
+ Object state;
+
+ if ( Modifier.isStatic( field.getModifiers() ) ) {
+ throw new NoSuchFieldException( propertyName );
+ }
+ state = context.getMemberAccess().setup( context, target, field, propertyName );
+ result = field.get( target );
+ context.getMemberAccess().restore( context, target, field, propertyName, state );
+
+ }
+ catch ( IllegalAccessException ex )
+ {
+ throw new NoSuchFieldException( propertyName );
+ }
+ }
+ return result;
+ }
+
+ public static boolean setFieldValue( OgnlContext context, Object target, String propertyName, Object value )
+ throws OgnlException
+ {
+ boolean result = false;
+
+ try
+ {
+ Class<?> targetClass = target == null ? null : target.getClass();
+ Field field = getField( targetClass, propertyName );
+ Object state;
+
+ if ( ( field != null ) && !Modifier.isStatic( field.getModifiers() ) )
+ {
+ state = context.getMemberAccess().setup( context, target, field, propertyName );
+ try
+ {
+ if ( isTypeCompatible( value, field.getType() ) || (
+ ( value = getConvertedType( context, target, field, propertyName, value, field.getType() ) ) != null ) )
+ {
+ field.set( target, value );
+ result = true;
+ }
+ }
+ finally
+ {
+ context.getMemberAccess().restore( context, target, field, propertyName, state );
+ }
+ }
+ }
+ catch ( IllegalAccessException ex )
+ {
+ throw new NoSuchPropertyException( target, propertyName, ex );
+ }
+ return result;
+ }
+
+ public static boolean isFieldAccessible( OgnlContext context, Object target, Class<?> inClass, String propertyName )
+ {
+ return isFieldAccessible( context, target, getField( inClass, propertyName ), propertyName );
+ }
+
+ public static boolean isFieldAccessible( OgnlContext context, Object target, Field field, String propertyName )
+ {
+ return context.getMemberAccess().isAccessible( context, target, field, propertyName );
+ }
+
+ public static boolean hasField( OgnlContext context, Object target, Class<?> inClass, String propertyName )
+ {
+ Field field = getField( inClass, propertyName );
+
+ return ( field != null ) && isFieldAccessible( context, target, field, propertyName );
+ }
+
+ public static Object getStaticField( OgnlContext context, String className, String fieldName )
+ throws OgnlException
+ {
+ Exception cause;
+ try
+ {
+ Class<?> clazz = classForName( context, className );
+
+ /*
+ * Check for virtual static field "class"; this cannot interfere with normal static fields because it is a
+ * reserved word.
+ */
+ if ( "class".equals( fieldName ) )
+ {
+ return clazz;
+ }
+ if ( clazz.isEnum() )
+ {
+ return Enum.valueOf( (Class<? extends Enum>) clazz, fieldName );
+ }
+ Field field = clazz.getField( fieldName );
+ if ( !Modifier.isStatic(field.getModifiers()) )
+ {
+ throw new OgnlException( "Field " + fieldName + " of class " + className + " is not static" );
+ }
+
+ return field.get( null );
+ }
+ catch ( ClassNotFoundException | IllegalAccessException | SecurityException | NoSuchFieldException e )
+ {
+ cause = e;
+ }
+
+ throw new OgnlException( "Could not get static field " + fieldName + " from class " + className, cause );
+ }
+
+ /**
+ * @param targetClass
+ * @param propertyName
+ * @param findSets
+ * @return Returns the list of (g)setter of a class for a given property name
+ * @
+ */
+ public static List<Method> getDeclaredMethods( Class<?> targetClass, String propertyName, boolean findSets )
+ {
+ String baseName = Character.toUpperCase( propertyName.charAt( 0 ) ) + propertyName.substring( 1 );
+ List<Method> methods = new ArrayList<Method>();
+ List<String> methodNames = new ArrayList<String>( 2 );
+ if ( findSets )
+ {
+ methodNames.add( SET_PREFIX + baseName );
+ }
+ else
+ {
+ methodNames.add( IS_PREFIX + baseName );
+ methodNames.add( GET_PREFIX + baseName );
+ }
+ for ( String methodName : methodNames )
+ {
+ DeclaredMethodCacheEntry key = new DeclaredMethodCacheEntry( targetClass );
+ List<Method> methodList = cache.getMethod( key ).get( methodName );
+ if ( methodList != null )
+ {
+ methods.addAll( methodList );
+ }
+ }
+
+ return methods;
+ }
+
+ /**
+ * Convenience used to check if a method is volatile or synthetic so as to avoid calling un-callable methods.
+ *
+ * @param method The method to check.
+ * @return True if the method should be callable, false otherwise.
+ */
+ //TODO: the method was intended as private, so it'd need to move in a util class
+ public static boolean isMethodCallable( Method method )
+ {
+ return !( method.isSynthetic() || Modifier.isVolatile( method.getModifiers() ) );
+
+ }
+
+ public static Method getGetMethod( OgnlContext unused, Class<?> targetClass, String propertyName )
+ throws IntrospectionException, OgnlException
+ {
+ Method result = null;
+
+ List<Method> methods = getDeclaredMethods( targetClass, propertyName, false /* find 'get' methods */ );
+
+ if ( methods != null )
+ {
+ for ( Method method : methods )
+ {
+ Class<?>[] mParameterTypes = findParameterTypes( targetClass, method ); // getParameterTypes(method);
+
+ if ( mParameterTypes.length == 0 )
+ {
+ result = method;
+ break;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public static boolean isMethodAccessible( OgnlContext context, Object target, Method method, String propertyName )
+ {
+ return ( method != null ) && context.getMemberAccess().isAccessible( context, target, method, propertyName );
+ }
+
+ public static boolean hasGetMethod( OgnlContext context, Object target, Class<?> targetClass, String propertyName )
+ throws IntrospectionException, OgnlException
+ {
+ return isMethodAccessible( context, target, getGetMethod( context, targetClass, propertyName ), propertyName );
+ }
+
+ public static Method getSetMethod( OgnlContext context, Class<?> targetClass, String propertyName )
+ throws IntrospectionException, OgnlException
+ {
+ Method setMethod = null;
+
+ List<Method> methods = getDeclaredMethods( targetClass, propertyName, true /* find 'set' methods */ );
+
+ if ( methods != null )
+ {
+ for ( Method method : methods )
+ {
+ Class<?>[] mParameterTypes = findParameterTypes( targetClass, method ); // getParameterTypes(method);
+
+ if ( mParameterTypes.length == 1 )
+ {
+ setMethod = method;
+ break;
+ }
+ }
+ }
+
+ return setMethod;
+ }
+
+ public static boolean hasSetMethod( OgnlContext context, Object target, Class<?> targetClass, String propertyName )
+ throws IntrospectionException, OgnlException
+ {
+ return isMethodAccessible( context, target, getSetMethod( context, targetClass, propertyName ), propertyName );
+ }
+
+ public static boolean hasGetProperty( OgnlContext context, Object target, Object oname )
+ throws IntrospectionException, OgnlException
+ {
+ Class<?> targetClass = ( target == null ) ? null : target.getClass();
+ String name = oname.toString();
+
+ return hasGetMethod( context, target, targetClass, name ) || hasField( context, target, targetClass, name );
+ }
+
+ public static boolean hasSetProperty( OgnlContext context, Object target, Object oname )
+ throws IntrospectionException, OgnlException
+ {
+ Class<?> targetClass = ( target == null ) ? null : target.getClass();
+ String name = oname.toString();
+
+ return hasSetMethod( context, target, targetClass, name ) || hasField( context, target, targetClass, name );
+ }
+
+ /**
+ * This method returns the property descriptors for the given class as a Map.
+ *
+ * @param targetClass The class to get the descriptors for.
+ * @return Map map of property descriptors for class.
+ * @throws IntrospectionException on errors using {@link Introspector}.
+ * @throws OgnlException On general errors.
+ */
+ public static Map<String, PropertyDescriptor> getPropertyDescriptors( Class<?> targetClass )
+ throws IntrospectionException, OgnlException
+ {
+ return cache.getPropertyDescriptor( targetClass );
+ }
+
+ /**
+ * This method returns a PropertyDescriptor for the given class and property name using a Map lookup (using
+ * getPropertyDescriptorsMap()).
+ * @param targetClass a target class.
+ * @param propertyName a property name.
+ * @return the PropertyDescriptor for the given targetClass and propertyName.
+ * @throws java.beans.IntrospectionException
+ * @throws OgnlException
+ */
+ public static PropertyDescriptor getPropertyDescriptor( Class<?> targetClass, String propertyName )
+ throws IntrospectionException, OgnlException
+ {
+ if ( targetClass == null )
+ {
+ return null;
+ }
+
+ return getPropertyDescriptors( targetClass ).get( propertyName );
+ }
+
+ public static PropertyDescriptor[] getPropertyDescriptorsArray( Class<?> targetClass )
+ throws IntrospectionException, OgnlException
+ {
+ Collection<PropertyDescriptor> propertyDescriptors = getPropertyDescriptors( targetClass ).values();
+ return propertyDescriptors.toArray( new PropertyDescriptor[propertyDescriptors.size()] );
+ }
+
+ /**
+ * Gets the property descriptor with the given name for the target class given.
+ *
+ * @param targetClass Class for which property descriptor is desired
+ * @param name Name of property
+ * @return PropertyDescriptor of the named property or null if the class has no property with the given name
+ * @throws java.beans.IntrospectionException
+ * @throws OgnlException
+ */
+ public static PropertyDescriptor getPropertyDescriptorFromArray( Class<?> targetClass, String name )
+ throws IntrospectionException, OgnlException
+ {
+ PropertyDescriptor result = null;
+ PropertyDescriptor[] propertyDescriptors = getPropertyDescriptorsArray( targetClass );
+
+ for ( PropertyDescriptor propertyDescriptor : propertyDescriptors )
+ {
+ if ( result != null )
+ {
+ break;
+ }
+ if ( propertyDescriptor.getName().compareTo( name ) == 0 )
+ {
+ result = propertyDescriptor;
+ }
+ }
+ return result;
+ }
+
+ public static void setMethodAccessor( Class<?> clazz, MethodAccessor accessor )
+ {
+ cache.setMethodAccessor( clazz, accessor );
+ }
+
+ public static MethodAccessor getMethodAccessor( Class<?> clazz )
+ throws OgnlException
+ {
+ return cache.getMethodAccessor( clazz );
+ }
+
+ public static void setPropertyAccessor( Class<?> clazz, PropertyAccessor accessor )
+ {
+ cache.setPropertyAccessor( clazz, accessor );
+ }
+
+ public static PropertyAccessor getPropertyAccessor( Class<?> clazz )
+ throws OgnlException
+ {
+ return cache.getPropertyAccessor( clazz );
+ }
+
+ public static ElementsAccessor getElementsAccessor( Class<?> clazz )
+ throws OgnlException
+ {
+ return cache.getElementsAccessor( clazz );
+ }
+
+ public static void setElementsAccessor( Class<?> clazz, ElementsAccessor accessor )
+ {
+ cache.setElementsAccessor( clazz, accessor );
+ }
+
+ public static NullHandler getNullHandler( Class<?> clazz )
+ throws OgnlException
+ {
+ return cache.getNullHandler( clazz );
+ }
+
+ public static void setNullHandler( Class<?> clazz, NullHandler handler )
+ {
+ cache.setNullHandler( clazz, handler );
+ }
+
+ public static Object getProperty( OgnlContext context, Object source, Object name )
+ throws OgnlException
+ {
+ PropertyAccessor accessor;
+
+ if ( source == null )
+ {
+ throw new OgnlException( "source is null for getProperty(null, \"" + name + "\")" );
+ }
+ if ( ( accessor = getPropertyAccessor( getTargetClass( source ) ) ) == null )
+ {
+ throw new OgnlException( "No property accessor for " + getTargetClass( source ).getName() );
+ }
+
+ return accessor.getProperty( context, source, name );
+ }
+
+ public static void setProperty( OgnlContext context, Object target, Object name, Object value )
+ throws OgnlException
+ {
+ PropertyAccessor accessor;
+
+ if ( target == null )
+ {
+ throw new OgnlException( "target is null for setProperty(null, \"" + name + "\", " + value + ")" );
+ }
+ if ( ( accessor = getPropertyAccessor( getTargetClass( target ) ) ) == null )
+ {
+ throw new OgnlException( "No property accessor for " + getTargetClass( target ).getName() );
+ }
+
+ accessor.setProperty( context, target, name, value );
+ }
+
+ /**
+ * Determines the index property type, if any. Returns <code>INDEXED_PROPERTY_NONE</code> if the property is not
+ * index-accessible as determined by OGNL or JavaBeans. If it is indexable then this will return whether it is a
+ * JavaBeans indexed property, conforming to the indexed property patterns (returns
+ * <code>INDEXED_PROPERTY_INT</code>) or if it conforms to the OGNL arbitrary object indexable (returns
+ * <code>INDEXED_PROPERTY_OBJECT</code>).
+ */
+ public static int getIndexedPropertyType( OgnlContext context, Class<?> sourceClass, String name )
+ throws OgnlException
+ {
+ int result = INDEXED_PROPERTY_NONE;
+
+ try
+ {
+ PropertyDescriptor propertyDescriptor = getPropertyDescriptor( sourceClass, name );
+ if ( propertyDescriptor != null )
+ {
+ if ( propertyDescriptor instanceof IndexedPropertyDescriptor )
+ {
+ result = INDEXED_PROPERTY_INT;
+ }
+ else
+ {
+ if ( propertyDescriptor instanceof ObjectIndexedPropertyDescriptor )
+ {
+ result = INDEXED_PROPERTY_OBJECT;
+ }
+ }
+ }
+ }
+ catch ( Exception ex )
+ {
+ throw new OgnlException( "problem determining if '" + name + "' is an indexed property", ex );
+ }
+ return result;
+ }
+
+ public static Object getIndexedProperty( OgnlContext context, Object source, String name, Object index )
+ throws OgnlException
+ {
+ Object[] args = new Object[] { index };
+
+ try
+ {
+ PropertyDescriptor propertyDescriptor = getPropertyDescriptor( ( source == null ) ? null : source.getClass(), name );
+ Method method;
+
+ if ( propertyDescriptor instanceof IndexedPropertyDescriptor )
+ {
+ method = ( (IndexedPropertyDescriptor) propertyDescriptor ).getIndexedReadMethod();
+ }
+ else
+ {
+ if ( !(propertyDescriptor instanceof ObjectIndexedPropertyDescriptor) ) {
+ throw new OgnlException( "property '" + name + "' is not an indexed property" );
+ }
+ method = ( (ObjectIndexedPropertyDescriptor) propertyDescriptor ).getIndexedReadMethod();
+ }
+
+ return callMethod( context, source, method.getName(), args );
+
+ }
+ catch ( OgnlException ex )
+ {
+ throw ex;
+ }
+ catch ( Exception ex )
+ {
+ throw new OgnlException( "getting indexed property descriptor for '" + name + "'", ex );
+ }
+ }
+
+ public static void setIndexedProperty( OgnlContext context, Object source, String name, Object index, Object value )
+ throws OgnlException
+ {
+ Object[] args = new Object[] { index, value };
+
+ try
+ {
+ PropertyDescriptor propertyDescriptor = getPropertyDescriptor( ( source == null ) ? null : source.getClass(), name );
+ Method method;
+
+ if ( propertyDescriptor instanceof IndexedPropertyDescriptor )
+ {
+ method = ( (IndexedPropertyDescriptor) propertyDescriptor ).getIndexedWriteMethod();
+ }
+ else
+ {
+ if ( !(propertyDescriptor instanceof ObjectIndexedPropertyDescriptor) ) {
+ throw new OgnlException( "property '" + name + "' is not an indexed property" );
+ }
+ method = ( (ObjectIndexedPropertyDescriptor) propertyDescriptor ).getIndexedWriteMethod();
+ }
+
+ callMethod( context, source, method.getName(), args );
+
+ }
+ catch ( OgnlException ex )
+ {
+ throw ex;
+ }
+ catch ( Exception ex )
+ {
+ throw new OgnlException( "getting indexed property descriptor for '" + name + "'", ex );
+ }
+ }
+
+ /**
+ * Registers the specified {@link ClassCacheInspector} with all class reflection based internal caches. This may
+ * have a significant performance impact so be careful using this in production scenarios.
+ *
+ * @param inspector The inspector instance that will be registered with all internal cache instances.
+ */
+ public static void setClassCacheInspector( ClassCacheInspector inspector )
+ {
+ cache.setClassCacheInspector( inspector );
+ }
+
+ public static Method getMethod( OgnlContext context, Class<?> target, String name, Node[] children,
+ boolean includeStatic )
+ throws Exception
+ {
+ Class<?>[] parms;
+ if ( children != null && children.length > 0 )
+ {
+ parms = new Class[children.length];
+
+ // used to reset context after loop
+ Class<?> currType = context.getCurrentType();
+ Class<?> currAccessor = context.getCurrentAccessor();
+ Object cast = context.get( ExpressionCompiler.PRE_CAST );
+
+ context.setCurrentObject( context.getRoot() );
+ context.setCurrentType( context.getRoot() != null ? context.getRoot().getClass() : null );
+ context.setCurrentAccessor( null );
+ context.setPreviousType( null );
+
+ for ( int i = 0; i < children.length; i++ )
+ {
+ children[i].toGetSourceString( context, context.getRoot() );
+ parms[i] = context.getCurrentType();
+ }
+
+ context.put( ExpressionCompiler.PRE_CAST, cast );
+
+ context.setCurrentType( currType );
+ context.setCurrentAccessor( currAccessor );
+ context.setCurrentObject( target );
+ }
+ else
+ {
+ parms = new Class[0];
+ }
+
+ List<Method> methods = OgnlRuntime.getMethods( target, name, includeStatic );
+ if ( methods == null )
+ {
+ return null;
+ }
+
+ for ( Method method : methods )
+ {
+ boolean varArgs = method.isVarArgs();
+
+ if ( parms.length != method.getParameterTypes().length && !varArgs )
+ {
+ continue;
+ }
+
+ Class<?>[] methodParameterTypes = method.getParameterTypes();
+ boolean matched = true;
+ for ( int i = 0; i < methodParameterTypes.length; i++ )
+ {
+ Class<?> methodParameterType = methodParameterTypes[i];
+ if ( varArgs && methodParameterType.isArray() )
+ {
+ continue;
+ }
+
+ Class<?> parm = parms[i];
+ if ( parm == null )
+ {
+ matched = false;
+ break;
+ }
+
+ if ( parm == methodParameterType || methodParameterType.isPrimitive() && Character.TYPE != methodParameterType && Byte.TYPE != methodParameterType
+ && Number.class.isAssignableFrom(parm)
+ && OgnlRuntime.getPrimitiveWrapperClass(parm) == methodParameterType)
+ {
+ continue;
+ }
+
+ matched = false;
+ break;
+ }
+
+ if ( matched )
+ {
+ return method;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Finds the best possible match for a method on the specified target class with a matching name.
+ * <p>
+ * The name matched will also try different combinations like <code>is + name, has + name, get + name, etc..</code>
+ * </p>
+ *
+ * @param target The class to find a matching method against.
+ * @param name The name of the method.
+ * @return The most likely matching {@link Method}, or null if none could be found.
+ */
+ public static Method getReadMethod( Class<?> target, String name )
+ {
+ return getReadMethod( target, name, -1 );
+ }
+
+ public static Method getReadMethod( Class<?> target, String name, int numParms )
+ {
+ try
+ {
+ name = name.replace( "\"", "" ).toLowerCase();
+
+ BeanInfo info = Introspector.getBeanInfo( target );
+ MethodDescriptor[] methodDescriptors = info.getMethodDescriptors();
+
+ // exact matches first
+
+ Method method = null;
+
+ for ( MethodDescriptor methodDescriptor : methodDescriptors )
+ {
+ if ( !isMethodCallable( methodDescriptor.getMethod() ) )
+ {
+ continue;
+ }
+
+ String methodName = methodDescriptor.getName();
+ String lowerMethodName = methodName.toLowerCase();
+ int methodParamLen = methodDescriptor.getMethod().getParameterTypes().length;
+
+ if ( ( methodName.equalsIgnoreCase( name ) || lowerMethodName.equals( "get" + name )
+ || lowerMethodName.equals( "has" + name ) || lowerMethodName.equals( "is" + name ) )
+ && !methodName.startsWith( "set" ) )
+ {
+ if ( numParms > 0 && methodParamLen == numParms )
+ {
+ return methodDescriptor.getMethod();
+ }
+ if ( numParms < 0 )
+ {
+ if ( methodName.equals( name ) )
+ {
+ return methodDescriptor.getMethod();
+ }
+ if ( method == null || ( method.getParameterTypes().length > methodParamLen ) )
+ {
+ method = methodDescriptor.getMethod();
+ }
+ }
+ }
+ }
+
+ if ( method != null )
+ {
+ return method;
+ }
+
+ for ( MethodDescriptor methodDescriptor : methodDescriptors )
+ {
+ if ( !isMethodCallable( methodDescriptor.getMethod() ) )
+ {
+ continue;
+ }
+
+ if ( methodDescriptor.getName().toLowerCase().endsWith( name ) && !methodDescriptor.getName().startsWith( "set" )
+ && methodDescriptor.getMethod().getReturnType() != Void.TYPE )
+ {
+
+ if ( numParms > 0 && methodDescriptor.getMethod().getParameterTypes().length == numParms )
+ {
+ return methodDescriptor.getMethod();
+ }
+ if ( (numParms < 0) && (method == null || ( method.getParameterTypes().length
+ > methodDescriptor.getMethod().getParameterTypes().length )) )
+ {
+ method = methodDescriptor.getMethod();
+ }
+ }
+ }
+
+ if ( method != null )
+ {
+ return method;
+ }
+
+ // try one last time adding a get to beginning
+
+ if ( !name.startsWith( "get" ) )
+ {
+ return OgnlRuntime.getReadMethod( target, "get" + name, numParms );
+ }
+
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+
+ return null;
+ }
+
+ public static Method getWriteMethod( Class<?> target, String name )
+ {
+ return getWriteMethod( target, name, -1 );
+ }
+
+ public static Method getWriteMethod( Class<?> target, String name, int numParms )
+ {
+ try
+ {
+ name = name.replace( "\"", "" );
+
+ BeanInfo info = Introspector.getBeanInfo( target );
+ MethodDescriptor[] methods = info.getMethodDescriptors();
+
+ for ( MethodDescriptor method : methods )
+ {
+ if ( !isMethodCallable( method.getMethod() ) )
+ {
+ continue;
+ }
+
+ if ( ( method.getName().equalsIgnoreCase( name ) || method.getName().toLowerCase().equals(
+ name.toLowerCase() ) || method.getName().toLowerCase().equals( "set" + name.toLowerCase() ) )
+ && !method.getName().startsWith( "get" ) )
+ {
+
+ if ( numParms > 0 && method.getMethod().getParameterTypes().length == numParms )
+ {
+ return method.getMethod();
+ }
+ if ( numParms < 0 )
+ {
+ return method.getMethod();
+ }
+ }
+ }
+
+ // try again on pure class
+
+ Method[] cmethods = target.getClass().getMethods();
+ for ( Method cmethod : cmethods )
+ {
+ if ( !isMethodCallable( cmethod ) )
+ {
+ continue;
+ }
+
+ if ( ( cmethod.getName().equalsIgnoreCase( name ) || cmethod.getName().toLowerCase().equals(
+ name.toLowerCase() ) || cmethod.getName().toLowerCase().equals( "set" + name.toLowerCase() ) )
+ && !cmethod.getName().startsWith( "get" ) )
+ {
+
+ if ( numParms > 0 && cmethod.getParameterTypes().length == numParms )
+ {
+ return cmethod;
+ }
+ if ( numParms < 0 )
+ {
+ return cmethod;
+ }
+ }
+ }
+
+ // try one last time adding a set to beginning
+
+ if ( !name.startsWith( "set" ) )
+ {
+ return OgnlRuntime.getReadMethod( target, "set" + name, numParms );
+ }
+
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+
+ return null;
+ }
+
+ public static PropertyDescriptor getProperty( Class<?> target, String name )
+ {
+ try
+ {
+ BeanInfo info = Introspector.getBeanInfo( target );
+
+ PropertyDescriptor[] propertyDescriptors = info.getPropertyDescriptors();
+
+ for ( PropertyDescriptor propertyDescriptor : propertyDescriptors )
+ {
+
+ String propertyDescriptorName = propertyDescriptor.getName();
+ if ( propertyDescriptorName.equalsIgnoreCase( name ) || propertyDescriptorName.toLowerCase().equals( name.toLowerCase() )
+ || propertyDescriptorName.toLowerCase().endsWith( name.toLowerCase() ) )
+ {
+ return propertyDescriptor;
+ }
+ }
+
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+
+ return null;
+ }
+
+ public static boolean isBoolean( String expression )
+ {
+ return expression != null && ( "true".equals( expression ) || "false".equals( expression )
+ || "!true".equals( expression ) || "!false".equals( expression ) || "(true)".equals( expression )
+ || "!(true)".equals( expression ) || "(false)".equals( expression ) || "!(false)".equals( expression )
+ || expression.startsWith( "org.apache.commons.ognl.OgnlOps" ) );
+ }
+
+ /**
+ * Compares the {@link OgnlContext#getCurrentType()} and {@link OgnlContext#getPreviousType()} class types on the
+ * stack to determine if a numeric expression should force object conversion.
+ * <p/>
+ * <p/>
+ * Normally used in conjunction with the <code>forceConversion</code> parameter of
+ * {@link OgnlRuntime#getChildSource(OgnlContext, Object, Node, boolean)}.
+ * </p>
+ *
+ * @param context The current context.
+ * @return True, if the class types on the stack wouldn't be comparable in a pure numeric expression such as
+ * <code>o1 >= o2</code>.
+ */
+ public static boolean shouldConvertNumericTypes( OgnlContext context )
+ {
+ Class<?> currentType = context.getCurrentType();
+ Class<?> previousType = context.getPreviousType();
+ return currentType == null || previousType == null
+ || !( currentType == previousType && currentType.isPrimitive() && previousType.isPrimitive() )
+ && !currentType.isArray() && !previousType.isArray();
+ }
+
+ /**
+ * Attempts to get the java source string represented by the specific child expression via the
+ * {@link JavaSource#toGetSourceString(OgnlContext, Object)} interface method.
+ *
+ * @param context The ognl context to pass to the child.
+ * @param target The current object target to use.
+ * @param child The child expression.
+ * @return The result of calling {@link JavaSource#toGetSourceString(OgnlContext, Object)} plus additional enclosures
+ * of {@link OgnlOps#convertValue(Object, Class, boolean)} for conversions.
+ * @throws OgnlException Mandatory exception throwing catching.. (blehh)
+ */
+ public static String getChildSource( OgnlContext context, Object target, Node child )
+ throws OgnlException
+ {
+ return getChildSource( context, target, child, false );
+ }
+
+ /**
+ * Attempts to get the java source string represented by the specific child expression via the
+ * {@link JavaSource#toGetSourceString(OgnlContext, Object)} interface method.
+ *
+ * @param context The ognl context to pass to the child.
+ * @param target The current object target to use.
+ * @param child The child expression.
+ * @param forceConversion If true, forces {@link OgnlOps#convertValue(Object, Class)} conversions on the objects.
+ * @return The result of calling {@link JavaSource#toGetSourceString(OgnlContext, Object)} plus additional enclosures
+ * of {@link OgnlOps#convertValue(Object, Class, boolean)} for conversions.
+ * @throws OgnlException Mandatory exception throwing catching.. (blehh)
+ */
+ public static String getChildSource( OgnlContext context, Object target, Node child, boolean forceConversion )
+ throws OgnlException
+ {
+ String pre = (String) context.get( "_currentChain" );
+ if ( pre == null )
+ {
+ pre = "";
+ }
+
+ try
+ {
+ child.getValue( context, target );
+ }
+ catch ( NullPointerException e )
+ {
+ // ignore
+ }
+ catch ( ArithmeticException e )
+ {
+ context.setCurrentType( int.class );
+ return "0";
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+
+ String source;
+
+ try
+ {
+ source = child.toGetSourceString( context, target );
+ }
+ catch ( Throwable t )
+ {
+ throw OgnlOps.castToRuntime( t );
+ }
+
+ // handle root / method expressions that may not have proper root java source access
+
+ if ( !(child instanceof ASTConst) && ( target == null || context.getRoot() != target ) )
+ {
+ source = pre + source;
+ }
+
+ if ( context.getRoot() != null )
+ {
+ source = ExpressionCompiler.getRootExpression( child, context.getRoot(), context ) + source;
+ context.setCurrentAccessor( context.getRoot().getClass() );
+ }
+
+ if (child instanceof ASTChain)
+ {
+ String cast = (String) context.remove( ExpressionCompiler.PRE_CAST );
+ if ( cast == null )
+ {
+ cast = "";
+ }
+
+ source = cast + source;
+ }
+
+ if ( source == null || source.trim().length() < 1 )
+ {
+ source = "null";
+ }
+
+ return source;
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/Cache.java b/src/main/java/org/apache/commons/ognl/internal/Cache.java
index 8f7e6e3..feb72fe 100644
--- a/src/main/java/org/apache/commons/ognl/internal/Cache.java
+++ b/src/main/java/org/apache/commons/ognl/internal/Cache.java
@@ -1,36 +1,35 @@
-package org.apache.commons.ognl.internal;
-
-/*
- * 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 interface Cache<K, V>
-{
- void clear();
-
- int getSize();
-
- V get( K key )
- throws CacheException;
-
- V put( K key, V value );
-
-}
+package org.apache.commons.ognl.internal;
+
+/*
+ * 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 interface Cache<K, V>
+{
+ void clear();
+
+ int getSize();
+
+ V get( K key )
+ throws CacheException;
+
+ V put( K key, V value );
+
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/CacheException.java b/src/main/java/org/apache/commons/ognl/internal/CacheException.java
index d324660..3ea20e4 100644
--- a/src/main/java/org/apache/commons/ognl/internal/CacheException.java
+++ b/src/main/java/org/apache/commons/ognl/internal/CacheException.java
@@ -1,32 +1,31 @@
-package org.apache.commons.ognl.internal;
-
-/*
- * 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 CacheException
- extends RuntimeException
-{
- public CacheException( Throwable e )
- {
- super( e.getMessage(), e );
- }
-}
+package org.apache.commons.ognl.internal;
+
+/*
+ * 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 CacheException
+ extends RuntimeException
+{
+ public CacheException( Throwable e )
+ {
+ super( e.getMessage(), e );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/ClassCache.java b/src/main/java/org/apache/commons/ognl/internal/ClassCache.java
index 266ada5..bca2b25 100644
--- a/src/main/java/org/apache/commons/ognl/internal/ClassCache.java
+++ b/src/main/java/org/apache/commons/ognl/internal/ClassCache.java
@@ -1,34 +1,33 @@
-package org.apache.commons.ognl.internal;
-
-/*
- * 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$
- */
-import org.apache.commons.ognl.ClassCacheInspector;
-
-/**
- * This is a highly specialized map for storing values keyed by Class objects.
- */
-public interface ClassCache<V>
- extends Cache<Class<?>, V>
-{
- void setClassInspector( ClassCacheInspector inspector );
-}
+package org.apache.commons.ognl.internal;
+
+/*
+ * 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.ClassCacheInspector;
+
+/**
+ * This is a highly specialized map for storing values keyed by Class objects.
+ */
+public interface ClassCache<V>
+ extends Cache<Class<?>, V>
+{
+ void setClassInspector( ClassCacheInspector inspector );
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/ClassCacheHandler.java b/src/main/java/org/apache/commons/ognl/internal/ClassCacheHandler.java
index bde12ce..216a9e8 100644
--- a/src/main/java/org/apache/commons/ognl/internal/ClassCacheHandler.java
+++ b/src/main/java/org/apache/commons/ognl/internal/ClassCacheHandler.java
@@ -1,86 +1,85 @@
-package org.apache.commons.ognl.internal;
-
-/*
- * 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 ClassCacheHandler
-{
-
- private ClassCacheHandler()
- {
- }
-
- public static <T> T getHandler( Class<?> forClass, ClassCache<T> handlers )
- throws CacheException
- {
- T answer;
-
- synchronized ( handlers )
- {
- answer = handlers.get( forClass );
- if ( answer == null )
- {
- Class<?> keyFound;
-
- if ( forClass.isArray() )
- {
- answer = handlers.get( Object[].class );
- keyFound = null;
- }
- else
- {
- keyFound = forClass;
- outer:
- for ( Class<?> clazz = forClass; clazz != null; clazz = clazz.getSuperclass() )
- {
- answer = handlers.get( clazz );
- if ( answer != null ) {
- keyFound = clazz;
- break;
- }
- Class<?>[] interfaces = clazz.getInterfaces();
- for ( Class<?> iface : interfaces )
- {
- answer = handlers.get( iface );
- if ( answer == null )
- {
- /* Try super-interfaces */
- answer = getHandler( iface, handlers );
- }
- if ( answer != null )
- {
- keyFound = iface;
- break outer;
- }
- }
- }
- }
- if ( answer != null && keyFound != forClass )
- {
- handlers.put( forClass, answer );
- }
- }
- }
- return answer;
-
- }
-}
+package org.apache.commons.ognl.internal;
+
+/*
+ * 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 ClassCacheHandler
+{
+
+ private ClassCacheHandler()
+ {
+ }
+
+ public static <T> T getHandler( Class<?> forClass, ClassCache<T> handlers )
+ throws CacheException
+ {
+ T answer;
+
+ synchronized ( handlers )
+ {
+ answer = handlers.get( forClass );
+ if ( answer == null )
+ {
+ Class<?> keyFound;
+
+ if ( forClass.isArray() )
+ {
+ answer = handlers.get( Object[].class );
+ keyFound = null;
+ }
+ else
+ {
+ keyFound = forClass;
+ outer:
+ for ( Class<?> clazz = forClass; clazz != null; clazz = clazz.getSuperclass() )
+ {
+ answer = handlers.get( clazz );
+ if ( answer != null ) {
+ keyFound = clazz;
+ break;
+ }
+ Class<?>[] interfaces = clazz.getInterfaces();
+ for ( Class<?> iface : interfaces )
+ {
+ answer = handlers.get( iface );
+ if ( answer == null )
+ {
+ /* Try super-interfaces */
+ answer = getHandler( iface, handlers );
+ }
+ if ( answer != null )
+ {
+ keyFound = iface;
+ break outer;
+ }
+ }
+ }
+ }
+ if ( answer != null && keyFound != forClass )
+ {
+ handlers.put( forClass, answer );
+ }
+ }
+ }
+ return answer;
+
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/ClassCacheImpl.java b/src/main/java/org/apache/commons/ognl/internal/ClassCacheImpl.java
index dfff584..a9f756c 100644
--- a/src/main/java/org/apache/commons/ognl/internal/ClassCacheImpl.java
+++ b/src/main/java/org/apache/commons/ognl/internal/ClassCacheImpl.java
@@ -1,161 +1,160 @@
-package org.apache.commons.ognl.internal;
-
-/*
- * 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$
- */
-
-import org.apache.commons.ognl.ClassCacheInspector;
-
-import java.util.Arrays;
-
-/**
- * Implementation of {@link ClassCache}.
- */
-public class ClassCacheImpl<V>
- implements ClassCache<V>
-{
-
- /* this MUST be a power of 2 */
- private static final int TABLE_SIZE = 512;
-
- /* ...and now you see why. The table size is used as a mask for generating hashes */
- private static final int TABLE_SIZE_MASK = TABLE_SIZE - 1;
-
- private final Entry<Class<?>, V>[] table = new Entry[TABLE_SIZE];
-
- private ClassCacheInspector classInspector;
-
- private int size = 0;
-
- /**
- * {@inheritDoc}
- */
- public void setClassInspector( ClassCacheInspector inspector )
- {
- classInspector = inspector;
- }
-
- /**
- * {@inheritDoc}
- */
- public void clear()
- {
- Arrays.fill(table, null);
-
- size = 0;
- }
-
- /**
- * {@inheritDoc}
- */
- public int getSize()
- {
- return size;
- }
-
- /**
- * {@inheritDoc}
- */
- public final V get( Class<?> key )
- throws CacheException
- {
- int i = key.hashCode() & TABLE_SIZE_MASK;
-
- Entry<Class<?>, V> entry = table[i];
-
- while ( entry != null )
- {
- if ( key == entry.getKey() )
- {
- return entry.getValue();
- }
-
- entry = entry.getNext();
- }
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public final V put( Class<?> key, V value )
- {
- if ( classInspector != null && !classInspector.shouldCache( key ) )
- {
- return value;
- }
-
- V result = null;
- int i = key.hashCode() & TABLE_SIZE_MASK;
-
- Entry<Class<?>, V> entry = table[i];
-
- if ( entry == null )
- {
- table[i] = new Entry<Class<?>, V>( key, value );
- size++;
- }
- else
- {
- if ( key == entry.getKey() )
- {
- result = entry.getValue();
- entry.setValue( value );
- }
- else
- {
- while ( true )
- {
- if ( key == entry.getKey() )
- {
- /* replace value */
- result = entry.getValue();
- entry.setValue( value );
- break;
- }
-
- if ( entry.getNext() == null )
- {
- /* add value */
- entry.setNext( new Entry<Class<?>, V>( key, value ) );
- break;
- }
-
- entry = entry.getNext();
- }
- }
- }
-
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString()
- {
- return "ClassCacheImpl[" + "_table=" + ( table == null ? null : Arrays.asList( table ) ) + '\n'
- + ", _classInspector=" + classInspector + '\n' + ", _size=" + size + '\n' + ']';
- }
-
-}
+package org.apache.commons.ognl.internal;
+
+/*
+ * 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.ClassCacheInspector;
+
+import java.util.Arrays;
+
+/**
+ * Implementation of {@link ClassCache}.
+ */
+public class ClassCacheImpl<V>
+ implements ClassCache<V>
+{
+
+ /* this MUST be a power of 2 */
+ private static final int TABLE_SIZE = 512;
+
+ /* ...and now you see why. The table size is used as a mask for generating hashes */
+ private static final int TABLE_SIZE_MASK = TABLE_SIZE - 1;
+
+ private final Entry<Class<?>, V>[] table = new Entry[TABLE_SIZE];
+
+ private ClassCacheInspector classInspector;
+
+ private int size = 0;
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setClassInspector( ClassCacheInspector inspector )
+ {
+ classInspector = inspector;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void clear()
+ {
+ Arrays.fill(table, null);
+
+ size = 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getSize()
+ {
+ return size;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public final V get( Class<?> key )
+ throws CacheException
+ {
+ int i = key.hashCode() & TABLE_SIZE_MASK;
+
+ Entry<Class<?>, V> entry = table[i];
+
+ while ( entry != null )
+ {
+ if ( key == entry.getKey() )
+ {
+ return entry.getValue();
+ }
+
+ entry = entry.getNext();
+ }
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public final V put( Class<?> key, V value )
+ {
+ if ( classInspector != null && !classInspector.shouldCache( key ) )
+ {
+ return value;
+ }
+
+ V result = null;
+ int i = key.hashCode() & TABLE_SIZE_MASK;
+
+ Entry<Class<?>, V> entry = table[i];
+
+ if ( entry == null )
+ {
+ table[i] = new Entry<Class<?>, V>( key, value );
+ size++;
+ }
+ else
+ {
+ if ( key == entry.getKey() )
+ {
+ result = entry.getValue();
+ entry.setValue( value );
+ }
+ else
+ {
+ while ( true )
+ {
+ if ( key == entry.getKey() )
+ {
+ /* replace value */
+ result = entry.getValue();
+ entry.setValue( value );
+ break;
+ }
+
+ if ( entry.getNext() == null )
+ {
+ /* add value */
+ entry.setNext( new Entry<Class<?>, V>( key, value ) );
+ break;
+ }
+
+ entry = entry.getNext();
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return "ClassCacheImpl[" + "_table=" + ( table == null ? null : Arrays.asList( table ) ) + '\n'
+ + ", _classInspector=" + classInspector + '\n' + ", _size=" + size + '\n' + ']';
+ }
+
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/ConcurrentHashMapCache.java b/src/main/java/org/apache/commons/ognl/internal/ConcurrentHashMapCache.java
index 84a98a6..2d10913 100644
--- a/src/main/java/org/apache/commons/ognl/internal/ConcurrentHashMapCache.java
+++ b/src/main/java/org/apache/commons/ognl/internal/ConcurrentHashMapCache.java
@@ -1,86 +1,85 @@
-package org.apache.commons.ognl.internal;
-
-/*
- * 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$
- */
-import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
-
-import java.util.concurrent.ConcurrentHashMap;
-
-public class ConcurrentHashMapCache<K, V>
- implements Cache<K, V>
-{
- private final ConcurrentHashMap<K, V> cache = new ConcurrentHashMap<K, V>();
-
- private CacheEntryFactory<K, V> cacheEntryFactory;
-
- public ConcurrentHashMapCache()
- {
- }
-
- public ConcurrentHashMapCache( CacheEntryFactory<K, V> cacheEntryFactory )
- {
- this.cacheEntryFactory = cacheEntryFactory;
- }
-
- public void clear()
- {
- cache.clear();
- }
-
- public int getSize()
- {
- return cache.size();
- }
-
- public V get( K key )
- throws CacheException
- {
- V v = cache.get( key );
- if ( shouldCreate( cacheEntryFactory, v ) )
- {
- return put( key, cacheEntryFactory.create( key ) );
- }
- return v;
- }
-
- protected boolean shouldCreate( CacheEntryFactory<K, V> cacheEntryFactory, V v )
- throws CacheException
- {
- return cacheEntryFactory != null && v == null;
- }
-
- public V put( K key, V value )
- {
- V collision = cache.putIfAbsent( key, value );
- if ( collision != null )
- {
- return collision;
- }
- return value;
- }
-
- public boolean contains( K key )
- {
- return this.cache.contains( key );
- }
-}
+package org.apache.commons.ognl.internal;
+
+/*
+ * 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.internal.entry.CacheEntryFactory;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+public class ConcurrentHashMapCache<K, V>
+ implements Cache<K, V>
+{
+ private final ConcurrentHashMap<K, V> cache = new ConcurrentHashMap<K, V>();
+
+ private CacheEntryFactory<K, V> cacheEntryFactory;
+
+ public ConcurrentHashMapCache()
+ {
+ }
+
+ public ConcurrentHashMapCache( CacheEntryFactory<K, V> cacheEntryFactory )
+ {
+ this.cacheEntryFactory = cacheEntryFactory;
+ }
+
+ public void clear()
+ {
+ cache.clear();
+ }
+
+ public int getSize()
+ {
+ return cache.size();
+ }
+
+ public V get( K key )
+ throws CacheException
+ {
+ V v = cache.get( key );
+ if ( shouldCreate( cacheEntryFactory, v ) )
+ {
+ return put( key, cacheEntryFactory.create( key ) );
+ }
+ return v;
+ }
+
+ protected boolean shouldCreate( CacheEntryFactory<K, V> cacheEntryFactory, V v )
+ throws CacheException
+ {
+ return cacheEntryFactory != null && v == null;
+ }
+
+ public V put( K key, V value )
+ {
+ V collision = cache.putIfAbsent( key, value );
+ if ( collision != null )
+ {
+ return collision;
+ }
+ return value;
+ }
+
+ public boolean contains( K key )
+ {
+ return this.cache.contains( key );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/ConcurrentHashMapCacheFactory.java b/src/main/java/org/apache/commons/ognl/internal/ConcurrentHashMapCacheFactory.java
index a9d26ee..dd889ae 100644
--- a/src/main/java/org/apache/commons/ognl/internal/ConcurrentHashMapCacheFactory.java
+++ b/src/main/java/org/apache/commons/ognl/internal/ConcurrentHashMapCacheFactory.java
@@ -1,47 +1,46 @@
-package org.apache.commons.ognl.internal;
-
-/*
- * 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$
- */
-
-import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
-import org.apache.commons.ognl.internal.entry.ClassCacheEntryFactory;
-
-public class ConcurrentHashMapCacheFactory
- implements CacheFactory
-{
-
- public <K, V> Cache<K, V> createCache( CacheEntryFactory<K, V> entryFactory )
- {
- return new ConcurrentHashMapCache<K, V>( entryFactory );
- }
-
- public <V> ClassCache<V> createClassCache()
- {
- return createClassCache( null );
- }
-
- public <V> ClassCache<V> createClassCache( ClassCacheEntryFactory<V> entryFactory )
- {
- return new ConcurrentHashMapClassCache<V>( entryFactory );
- }
-}
+package org.apache.commons.ognl.internal;
+
+/*
+ * 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.internal.entry.CacheEntryFactory;
+import org.apache.commons.ognl.internal.entry.ClassCacheEntryFactory;
+
+public class ConcurrentHashMapCacheFactory
+ implements CacheFactory
+{
+
+ public <K, V> Cache<K, V> createCache( CacheEntryFactory<K, V> entryFactory )
+ {
+ return new ConcurrentHashMapCache<K, V>( entryFactory );
+ }
+
+ public <V> ClassCache<V> createClassCache()
+ {
+ return createClassCache( null );
+ }
+
+ public <V> ClassCache<V> createClassCache( ClassCacheEntryFactory<V> entryFactory )
+ {
+ return new ConcurrentHashMapClassCache<V>( entryFactory );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/ConcurrentHashMapClassCache.java b/src/main/java/org/apache/commons/ognl/internal/ConcurrentHashMapClassCache.java
index 30d28ec..c80eff6 100644
--- a/src/main/java/org/apache/commons/ognl/internal/ConcurrentHashMapClassCache.java
+++ b/src/main/java/org/apache/commons/ognl/internal/ConcurrentHashMapClassCache.java
@@ -1,54 +1,53 @@
-package org.apache.commons.ognl.internal;
-
-/*
- * 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.ClassCacheInspector;
-import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
-
-/*
- * $Id$
- */
-
-public class ConcurrentHashMapClassCache<T>
- extends ConcurrentHashMapCache<Class<?>, T>
- implements ClassCache<T>
-{
- private ClassCacheInspector inspector;
-
- public ConcurrentHashMapClassCache( CacheEntryFactory<Class<?>, T> entryFactory )
- {
- super( entryFactory );
- }
-
- public void setClassInspector( ClassCacheInspector inspector )
- {
- this.inspector = inspector;
- }
-
- @Override
- public T put( Class<?> key, T value )
- {
- if ( inspector != null && !inspector.shouldCache( key ) )
- {
- return value;
- }
- return super.put( key, value );
- }
-}
+package org.apache.commons.ognl.internal;
+
+/*
+ * 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.ClassCacheInspector;
+import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
+
+/*
+ */
+
+public class ConcurrentHashMapClassCache<T>
+ extends ConcurrentHashMapCache<Class<?>, T>
+ implements ClassCache<T>
+{
+ private ClassCacheInspector inspector;
+
+ public ConcurrentHashMapClassCache( CacheEntryFactory<Class<?>, T> entryFactory )
+ {
+ super( entryFactory );
+ }
+
+ public void setClassInspector( ClassCacheInspector inspector )
+ {
+ this.inspector = inspector;
+ }
+
+ @Override
+ public T put( Class<?> key, T value )
+ {
+ if ( inspector != null && !inspector.shouldCache( key ) )
+ {
+ return value;
+ }
+ return super.put( key, value );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/Entry.java b/src/main/java/org/apache/commons/ognl/internal/Entry.java
index d182a81..2cfefeb 100644
--- a/src/main/java/org/apache/commons/ognl/internal/Entry.java
+++ b/src/main/java/org/apache/commons/ognl/internal/Entry.java
@@ -1,74 +1,73 @@
-package org.apache.commons.ognl.internal;
-
-/*
- * 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.
- */
-
-
-/**
- * Used by {@link ClassCacheImpl} to store entries in the cache.
- * <p/>
- * $Id$
- */
-class Entry<K, V>
-{
-
- private Entry<K, V> next;
-
- private final K key;
-
- private V value;
-
- public Entry( K key, V value )
- {
- this.key = key;
- this.value = value;
- }
-
- public K getKey()
- {
- return key;
- }
-
- public V getValue()
- {
- return value;
- }
-
- public void setValue( V value )
- {
- this.value = value;
- }
-
- public Entry<K, V> getNext()
- {
- return next;
- }
-
- public void setNext( Entry<K, V> next )
- {
- this.next = next;
- }
-
- @Override
- public String toString()
- {
- return "Entry[" + "next=" + next + '\n' + ", key=" + key + '\n' + ", value=" + value + '\n' + ']';
- }
-
-}
+package org.apache.commons.ognl.internal;
+
+/*
+ * 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.
+ */
+
+
+/**
+ * Used by {@link ClassCacheImpl} to store entries in the cache.
+ * <p/>
+ */
+class Entry<K, V>
+{
+
+ private Entry<K, V> next;
+
+ private final K key;
+
+ private V value;
+
+ public Entry( K key, V value )
+ {
+ this.key = key;
+ this.value = value;
+ }
+
+ public K getKey()
+ {
+ return key;
+ }
+
+ public V getValue()
+ {
+ return value;
+ }
+
+ public void setValue( V value )
+ {
+ this.value = value;
+ }
+
+ public Entry<K, V> getNext()
+ {
+ return next;
+ }
+
+ public void setNext( Entry<K, V> next )
+ {
+ this.next = next;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Entry[" + "next=" + next + '\n' + ", key=" + key + '\n' + ", value=" + value + '\n' + ']';
+ }
+
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/HashMapCache.java b/src/main/java/org/apache/commons/ognl/internal/HashMapCache.java
index d69c7ab..efa330f 100644
--- a/src/main/java/org/apache/commons/ognl/internal/HashMapCache.java
+++ b/src/main/java/org/apache/commons/ognl/internal/HashMapCache.java
@@ -1,98 +1,97 @@
-package org.apache.commons.ognl.internal;
-
-/*
- * 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$
- */
-
-import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class HashMapCache<K, V>
- implements Cache<K, V>
-{
- private final Map<K, V> cache = new HashMap<K, V>( 512 );
-
- private final CacheEntryFactory<K, V> cacheEntryFactory;
-
- public HashMapCache( CacheEntryFactory<K, V> cacheEntryFactory )
- {
- this.cacheEntryFactory = cacheEntryFactory;
- }
-
- public void clear()
- {
- synchronized ( cache )
- {
- cache.clear();
- }
- }
-
- public int getSize()
- {
- synchronized ( cache )
- {
- return cache.size();
- }
- }
-
- public V get( K key )
- throws CacheException
- {
- V v = cache.get( key );
- if ( shouldCreate( cacheEntryFactory, v ) )
- {
- synchronized ( cache )
- {
- v = cache.get( key );
- if ( v != null )
- {
- return v;
- }
- return put( key, cacheEntryFactory.create( key ) );
- }
- }
- return v;
- }
-
- protected boolean shouldCreate( CacheEntryFactory<K, V> cacheEntryFactory, V v )
- throws CacheException
- {
- return cacheEntryFactory != null && v == null;
- }
-
- public V put( K key, V value )
- {
- synchronized ( cache )
- {
- cache.put( key, value );
- return value;
- }
- }
-
-
- public boolean contains( K key )
- {
- return this.cache.containsKey( key );
- }
-}
+package org.apache.commons.ognl.internal;
+
+/*
+ * 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.internal.entry.CacheEntryFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class HashMapCache<K, V>
+ implements Cache<K, V>
+{
+ private final Map<K, V> cache = new HashMap<K, V>( 512 );
+
+ private final CacheEntryFactory<K, V> cacheEntryFactory;
+
+ public HashMapCache( CacheEntryFactory<K, V> cacheEntryFactory )
+ {
+ this.cacheEntryFactory = cacheEntryFactory;
+ }
+
+ public void clear()
+ {
+ synchronized ( cache )
+ {
+ cache.clear();
+ }
+ }
+
+ public int getSize()
+ {
+ synchronized ( cache )
+ {
+ return cache.size();
+ }
+ }
+
+ public V get( K key )
+ throws CacheException
+ {
+ V v = cache.get( key );
+ if ( shouldCreate( cacheEntryFactory, v ) )
+ {
+ synchronized ( cache )
+ {
+ v = cache.get( key );
+ if ( v != null )
+ {
+ return v;
+ }
+ return put( key, cacheEntryFactory.create( key ) );
+ }
+ }
+ return v;
+ }
+
+ protected boolean shouldCreate( CacheEntryFactory<K, V> cacheEntryFactory, V v )
+ throws CacheException
+ {
+ return cacheEntryFactory != null && v == null;
+ }
+
+ public V put( K key, V value )
+ {
+ synchronized ( cache )
+ {
+ cache.put( key, value );
+ return value;
+ }
+ }
+
+
+ public boolean contains( K key )
+ {
+ return this.cache.containsKey( key );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/HashMapCacheFactory.java b/src/main/java/org/apache/commons/ognl/internal/HashMapCacheFactory.java
index d5122b2..c0b5843 100644
--- a/src/main/java/org/apache/commons/ognl/internal/HashMapCacheFactory.java
+++ b/src/main/java/org/apache/commons/ognl/internal/HashMapCacheFactory.java
@@ -1,46 +1,45 @@
-package org.apache.commons.ognl.internal;
-
-/*
- * 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$
- */
-
-import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
-import org.apache.commons.ognl.internal.entry.ClassCacheEntryFactory;
-
-public class HashMapCacheFactory
- implements CacheFactory
-{
- public <K, V> Cache<K, V> createCache( CacheEntryFactory<K, V> entryFactory )
- {
- return new HashMapCache<K, V>( entryFactory );
- }
-
- public <V> ClassCache<V> createClassCache()
- {
- return createClassCache( null );
- }
-
- public <V> ClassCache<V> createClassCache( ClassCacheEntryFactory<V> entryFactory )
- {
- return new HashMapClassCache<V>( entryFactory );
- }
-}
+package org.apache.commons.ognl.internal;
+
+/*
+ * 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.internal.entry.CacheEntryFactory;
+import org.apache.commons.ognl.internal.entry.ClassCacheEntryFactory;
+
+public class HashMapCacheFactory
+ implements CacheFactory
+{
+ public <K, V> Cache<K, V> createCache( CacheEntryFactory<K, V> entryFactory )
+ {
+ return new HashMapCache<K, V>( entryFactory );
+ }
+
+ public <V> ClassCache<V> createClassCache()
+ {
+ return createClassCache( null );
+ }
+
+ public <V> ClassCache<V> createClassCache( ClassCacheEntryFactory<V> entryFactory )
+ {
+ return new HashMapClassCache<V>( entryFactory );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/HashMapClassCache.java b/src/main/java/org/apache/commons/ognl/internal/HashMapClassCache.java
index fe28b26..6422f9a 100644
--- a/src/main/java/org/apache/commons/ognl/internal/HashMapClassCache.java
+++ b/src/main/java/org/apache/commons/ognl/internal/HashMapClassCache.java
@@ -1,54 +1,53 @@
-package org.apache.commons.ognl.internal;
-
-/*
- * 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$
- *
- */
-
-import org.apache.commons.ognl.ClassCacheInspector;
-import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
-
-public class HashMapClassCache<T>
- extends HashMapCache<Class<?>,T>
- implements ClassCache<T>
-{
- private ClassCacheInspector inspector;
-
- public HashMapClassCache( CacheEntryFactory<Class<?>, T> entryFactory )
- {
- super( entryFactory );
- }
-
- public void setClassInspector( ClassCacheInspector inspector )
- {
- this.inspector = inspector;
- }
-
- public T put( Class<?> key, T value )
- {
- if ( inspector != null && !inspector.shouldCache( key ) )
- {
- return value;
- }
- return super.put( key, value );
- }
-}
+package org.apache.commons.ognl.internal;
+
+/*
+ * 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.ClassCacheInspector;
+import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
+
+public class HashMapClassCache<T>
+ extends HashMapCache<Class<?>,T>
+ implements ClassCache<T>
+{
+ private ClassCacheInspector inspector;
+
+ public HashMapClassCache( CacheEntryFactory<Class<?>, T> entryFactory )
+ {
+ super( entryFactory );
+ }
+
+ public void setClassInspector( ClassCacheInspector inspector )
+ {
+ this.inspector = inspector;
+ }
+
+ public T put( Class<?> key, T value )
+ {
+ if ( inspector != null && !inspector.shouldCache( key ) )
+ {
+ return value;
+ }
+ return super.put( key, value );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/ReentrantReadWriteLockCache.java b/src/main/java/org/apache/commons/ognl/internal/ReentrantReadWriteLockCache.java
index 3520d75..8db237c 100644
--- a/src/main/java/org/apache/commons/ognl/internal/ReentrantReadWriteLockCache.java
+++ b/src/main/java/org/apache/commons/ognl/internal/ReentrantReadWriteLockCache.java
@@ -1,131 +1,130 @@
-package org.apache.commons.ognl.internal;
-
-/*
- * 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$
- */
-
-import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-public class ReentrantReadWriteLockCache<K, V>
- implements Cache<K, V>
-{
- private final ReadWriteLock lock = new ReentrantReadWriteLock();
-
- private final Lock readLock = lock.readLock();
-
- private final Lock writeLock = lock.writeLock();
-
- final Map<K, V> cache = new HashMap<K, V>();
-
- private CacheEntryFactory<K, V> cacheEntryFactory;
-
- public ReentrantReadWriteLockCache()
- {
- }
-
- public ReentrantReadWriteLockCache( CacheEntryFactory<K, V> cacheEntryFactory )
- {
- this.cacheEntryFactory = cacheEntryFactory;
- }
-
- public void clear()
- {
- synchronized ( cache )
- {
- cache.clear();
- }
- }
-
- public int getSize()
- {
- synchronized ( cache )
- {
- return cache.size();
- }
- }
-
-
- public V get( K key )
- throws CacheException
- {
- V v;
- boolean shouldCreate;
- readLock.lock();
- try
- {
- v = cache.get( key );
- shouldCreate = shouldCreate( cacheEntryFactory, v );
- }
- finally
- {
- readLock.unlock();
- }
- if ( shouldCreate )
- {
- try
- {
- writeLock.lock();
- v = cache.get( key );
- if ( !shouldCreate( cacheEntryFactory, v ) )
- {
- return v;
- }
- v = cacheEntryFactory.create( key );
- cache.put( key, v );
- return v;
- }
- finally
- {
- writeLock.unlock();
- }
-
- }
-
- return v;
- }
-
- protected boolean shouldCreate( CacheEntryFactory<K, V> cacheEntryFactory, V v )
- throws CacheException
- {
- return cacheEntryFactory != null && v == null;
- }
-
- public V put( K key, V value )
- {
- writeLock.lock();
- try
- {
- cache.put( key, value );
- return value;
- }
- finally
- {
- writeLock.unlock();
- }
- }
+package org.apache.commons.ognl.internal;
+
+/*
+ * 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.internal.entry.CacheEntryFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+public class ReentrantReadWriteLockCache<K, V>
+ implements Cache<K, V>
+{
+ private final ReadWriteLock lock = new ReentrantReadWriteLock();
+
+ private final Lock readLock = lock.readLock();
+
+ private final Lock writeLock = lock.writeLock();
+
+ final Map<K, V> cache = new HashMap<K, V>();
+
+ private CacheEntryFactory<K, V> cacheEntryFactory;
+
+ public ReentrantReadWriteLockCache()
+ {
+ }
+
+ public ReentrantReadWriteLockCache( CacheEntryFactory<K, V> cacheEntryFactory )
+ {
+ this.cacheEntryFactory = cacheEntryFactory;
+ }
+
+ public void clear()
+ {
+ synchronized ( cache )
+ {
+ cache.clear();
+ }
+ }
+
+ public int getSize()
+ {
+ synchronized ( cache )
+ {
+ return cache.size();
+ }
+ }
+
+
+ public V get( K key )
+ throws CacheException
+ {
+ V v;
+ boolean shouldCreate;
+ readLock.lock();
+ try
+ {
+ v = cache.get( key );
+ shouldCreate = shouldCreate( cacheEntryFactory, v );
+ }
+ finally
+ {
+ readLock.unlock();
+ }
+ if ( shouldCreate )
+ {
+ try
+ {
+ writeLock.lock();
+ v = cache.get( key );
+ if ( !shouldCreate( cacheEntryFactory, v ) )
+ {
+ return v;
+ }
+ v = cacheEntryFactory.create( key );
+ cache.put( key, v );
+ return v;
+ }
+ finally
+ {
+ writeLock.unlock();
+ }
+
+ }
+
+ return v;
+ }
+
+ protected boolean shouldCreate( CacheEntryFactory<K, V> cacheEntryFactory, V v )
+ throws CacheException
+ {
+ return cacheEntryFactory != null && v == null;
+ }
+
+ public V put( K key, V value )
+ {
+ writeLock.lock();
+ try
+ {
+ cache.put( key, value );
+ return value;
+ }
+ finally
+ {
+ writeLock.unlock();
+ }
+ }
}
\ No newline at end of file
diff --git a/src/main/java/org/apache/commons/ognl/internal/ReentrantReadWriteLockCacheFactory.java b/src/main/java/org/apache/commons/ognl/internal/ReentrantReadWriteLockCacheFactory.java
index 9a355c0..8cadf35 100644
--- a/src/main/java/org/apache/commons/ognl/internal/ReentrantReadWriteLockCacheFactory.java
+++ b/src/main/java/org/apache/commons/ognl/internal/ReentrantReadWriteLockCacheFactory.java
@@ -1,46 +1,45 @@
-package org.apache.commons.ognl.internal;
-
-/*
- * 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$
- */
-
-import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
-import org.apache.commons.ognl.internal.entry.ClassCacheEntryFactory;
-
-public class ReentrantReadWriteLockCacheFactory
- implements CacheFactory
-{
- public <K, V> Cache<K, V> createCache( CacheEntryFactory<K, V> entryFactory )
- {
- return new ReentrantReadWriteLockCache<K, V>( entryFactory );
- }
-
- public <V> ClassCache<V> createClassCache()
- {
- return createClassCache( null );
- }
-
- public <V> ClassCache<V> createClassCache( ClassCacheEntryFactory<V> entryFactory )
- {
- return new ReentrantReadWriteLockClassCache<V>( entryFactory );
- }
-}
+package org.apache.commons.ognl.internal;
+
+/*
+ * 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.internal.entry.CacheEntryFactory;
+import org.apache.commons.ognl.internal.entry.ClassCacheEntryFactory;
+
+public class ReentrantReadWriteLockCacheFactory
+ implements CacheFactory
+{
+ public <K, V> Cache<K, V> createCache( CacheEntryFactory<K, V> entryFactory )
+ {
+ return new ReentrantReadWriteLockCache<K, V>( entryFactory );
+ }
+
+ public <V> ClassCache<V> createClassCache()
+ {
+ return createClassCache( null );
+ }
+
+ public <V> ClassCache<V> createClassCache( ClassCacheEntryFactory<V> entryFactory )
+ {
+ return new ReentrantReadWriteLockClassCache<V>( entryFactory );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/ReentrantReadWriteLockClassCache.java b/src/main/java/org/apache/commons/ognl/internal/ReentrantReadWriteLockClassCache.java
index 81209d9..40a06c0 100644
--- a/src/main/java/org/apache/commons/ognl/internal/ReentrantReadWriteLockClassCache.java
+++ b/src/main/java/org/apache/commons/ognl/internal/ReentrantReadWriteLockClassCache.java
@@ -1,54 +1,53 @@
-package org.apache.commons.ognl.internal;
-
-/*
- * 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$
- */
-
-import org.apache.commons.ognl.ClassCacheInspector;
-import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
-
-
-public class ReentrantReadWriteLockClassCache<T>
- extends HashMapCache<Class<?>, T>
- implements ClassCache<T>
-{
- private ClassCacheInspector inspector;
-
- public ReentrantReadWriteLockClassCache( CacheEntryFactory<Class<?>, T> entryFactory )
- {
- super( entryFactory );
- }
-
- public void setClassInspector( ClassCacheInspector inspector )
- {
- this.inspector = inspector;
- }
-
- public T put( Class<?> key, T value )
- {
- if ( inspector != null && !inspector.shouldCache( key ) )
- {
- return value;
- }
- return super.put( key, value );
- }
-}
+package org.apache.commons.ognl.internal;
+
+/*
+ * 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.ClassCacheInspector;
+import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
+
+
+public class ReentrantReadWriteLockClassCache<T>
+ extends HashMapCache<Class<?>, T>
+ implements ClassCache<T>
+{
+ private ClassCacheInspector inspector;
+
+ public ReentrantReadWriteLockClassCache( CacheEntryFactory<Class<?>, T> entryFactory )
+ {
+ super( entryFactory );
+ }
+
+ public void setClassInspector( ClassCacheInspector inspector )
+ {
+ this.inspector = inspector;
+ }
+
+ public T put( Class<?> key, T value )
+ {
+ if ( inspector != null && !inspector.shouldCache( key ) )
+ {
+ return value;
+ }
+ return super.put( key, value );
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/entry/CacheEntry.java b/src/main/java/org/apache/commons/ognl/internal/entry/CacheEntry.java
index c8e30fa..5617c63 100644
--- a/src/main/java/org/apache/commons/ognl/internal/entry/CacheEntry.java
+++ b/src/main/java/org/apache/commons/ognl/internal/entry/CacheEntry.java
@@ -1,28 +1,27 @@
-package org.apache.commons.ognl.internal.entry;
-
-/*
- * 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 interface CacheEntry
-{
-}
+package org.apache.commons.ognl.internal.entry;
+
+/*
+ * 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 interface CacheEntry
+{
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/entry/CacheEntryFactory.java b/src/main/java/org/apache/commons/ognl/internal/entry/CacheEntryFactory.java
index 510f927..5b9a49b 100644
--- a/src/main/java/org/apache/commons/ognl/internal/entry/CacheEntryFactory.java
+++ b/src/main/java/org/apache/commons/ognl/internal/entry/CacheEntryFactory.java
@@ -1,32 +1,31 @@
-package org.apache.commons.ognl.internal.entry;
-
-/*
- * 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$
- */
-
-import org.apache.commons.ognl.internal.CacheException;
-
-public interface CacheEntryFactory<K, V>
-{
- V create( K key )
- throws CacheException;
-}
+package org.apache.commons.ognl.internal.entry;
+
+/*
+ * 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.internal.CacheException;
+
+public interface CacheEntryFactory<K, V>
+{
+ V create( K key )
+ throws CacheException;
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/entry/ClassCacheEntryFactory.java b/src/main/java/org/apache/commons/ognl/internal/entry/ClassCacheEntryFactory.java
index fbab042..5865763 100644
--- a/src/main/java/org/apache/commons/ognl/internal/entry/ClassCacheEntryFactory.java
+++ b/src/main/java/org/apache/commons/ognl/internal/entry/ClassCacheEntryFactory.java
@@ -1,29 +1,28 @@
-package org.apache.commons.ognl.internal.entry;
-
-/*
- * 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 interface ClassCacheEntryFactory<T>
- extends CacheEntryFactory<Class<?>, T>
-{
-}
+package org.apache.commons.ognl.internal.entry;
+
+/*
+ * 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 interface ClassCacheEntryFactory<T>
+ extends CacheEntryFactory<Class<?>, T>
+{
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/entry/DeclaredMethodCacheEntry.java b/src/main/java/org/apache/commons/ognl/internal/entry/DeclaredMethodCacheEntry.java
index d88d309..b567e3c 100644
--- a/src/main/java/org/apache/commons/ognl/internal/entry/DeclaredMethodCacheEntry.java
+++ b/src/main/java/org/apache/commons/ognl/internal/entry/DeclaredMethodCacheEntry.java
@@ -1,76 +1,75 @@
-package org.apache.commons.ognl.internal.entry;
-
-/*
- * 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 DeclaredMethodCacheEntry
- extends MethodCacheEntry
-{
-
- MethodType type;
-
- public enum MethodType
- {
- STATIC, NON_STATIC
- }
-
- public DeclaredMethodCacheEntry( Class<?> targetClass )
- {
- super( targetClass );
- }
-
- public DeclaredMethodCacheEntry( Class<?> targetClass, MethodType type )
- {
- super( targetClass );
- this.type = type;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o)
- {
- return true;
- }
- if (!(o instanceof DeclaredMethodCacheEntry))
- {
- return false;
- }
- if (!super.equals(o))
- {
- return false;
- }
-
- DeclaredMethodCacheEntry that = (DeclaredMethodCacheEntry) o;
-
- return type == that.type;
-
- }
-
- @Override
- public int hashCode()
- {
- int result = super.hashCode();
- result = 31 * result + ( type != null ? type.hashCode() : 0 );
- return result;
- }
-}
+package org.apache.commons.ognl.internal.entry;
+
+/*
+ * 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 DeclaredMethodCacheEntry
+ extends MethodCacheEntry
+{
+
+ MethodType type;
+
+ public enum MethodType
+ {
+ STATIC, NON_STATIC
+ }
+
+ public DeclaredMethodCacheEntry( Class<?> targetClass )
+ {
+ super( targetClass );
+ }
+
+ public DeclaredMethodCacheEntry( Class<?> targetClass, MethodType type )
+ {
+ super( targetClass );
+ this.type = type;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ {
+ return true;
+ }
+ if (!(o instanceof DeclaredMethodCacheEntry))
+ {
+ return false;
+ }
+ if (!super.equals(o))
+ {
+ return false;
+ }
+
+ DeclaredMethodCacheEntry that = (DeclaredMethodCacheEntry) o;
+
+ return type == that.type;
+
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = super.hashCode();
+ result = 31 * result + ( type != null ? type.hashCode() : 0 );
+ return result;
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/entry/DeclaredMethodCacheEntryFactory.java b/src/main/java/org/apache/commons/ognl/internal/entry/DeclaredMethodCacheEntryFactory.java
index 989e10b..9d68eca 100644
--- a/src/main/java/org/apache/commons/ognl/internal/entry/DeclaredMethodCacheEntryFactory.java
+++ b/src/main/java/org/apache/commons/ognl/internal/entry/DeclaredMethodCacheEntryFactory.java
@@ -1,52 +1,51 @@
-package org.apache.commons.ognl.internal.entry;
-
-/*
- * 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$
- */
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-
-/**
- * User: mcucchiara
- * Date: 13/10/11
- * Time: 13.00
- */
-public class DeclaredMethodCacheEntryFactory
- extends MethodCacheEntryFactory<DeclaredMethodCacheEntry>
-{
- @Override
- protected boolean shouldCache( DeclaredMethodCacheEntry key, Method method )
- {
- if ( key.type == null )
- {
- return true;
- }
- boolean isStatic = Modifier.isStatic( method.getModifiers() );
- if ( key.type == DeclaredMethodCacheEntry.MethodType.STATIC )
- {
- return isStatic;
- }
- return !isStatic;
-
- }
-}
+package org.apache.commons.ognl.internal.entry;
+
+/*
+ * 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 java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+/**
+ * User: mcucchiara
+ * Date: 13/10/11
+ * Time: 13.00
+ */
+public class DeclaredMethodCacheEntryFactory
+ extends MethodCacheEntryFactory<DeclaredMethodCacheEntry>
+{
+ @Override
+ protected boolean shouldCache( DeclaredMethodCacheEntry key, Method method )
+ {
+ if ( key.type == null )
+ {
+ return true;
+ }
+ boolean isStatic = Modifier.isStatic( method.getModifiers() );
+ if ( key.type == DeclaredMethodCacheEntry.MethodType.STATIC )
+ {
+ return isStatic;
+ }
+ return !isStatic;
+
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/entry/GenericMethodParameterTypeCacheEntry.java b/src/main/java/org/apache/commons/ognl/internal/entry/GenericMethodParameterTypeCacheEntry.java
index 7e7d424..7834dcf 100644
--- a/src/main/java/org/apache/commons/ognl/internal/entry/GenericMethodParameterTypeCacheEntry.java
+++ b/src/main/java/org/apache/commons/ognl/internal/entry/GenericMethodParameterTypeCacheEntry.java
@@ -1,66 +1,65 @@
-package org.apache.commons.ognl.internal.entry;
-
-/*
- * 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$
- */
-
-import java.lang.reflect.Method;
-
-public class GenericMethodParameterTypeCacheEntry
- implements CacheEntry
-{
- final Method method;
-
- final Class<?> type;
-
- public GenericMethodParameterTypeCacheEntry( Method method, Class<?> type )
- {
- this.method = method;
- this.type = type;
- }
-
- @Override
- public boolean equals( Object o )
- {
- if ( this == o )
- {
- return true;
- }
- if ( !( o instanceof GenericMethodParameterTypeCacheEntry ) )
- {
- return false;
- }
-
- GenericMethodParameterTypeCacheEntry that = (GenericMethodParameterTypeCacheEntry) o;
-
- return method.equals( that.method ) && type.equals( that.type );
-
- }
-
- @Override
- public int hashCode()
- {
- int result = method.hashCode();
- result = 31 * result + type.hashCode();
- return result;
- }
-}
+package org.apache.commons.ognl.internal.entry;
+
+/*
+ * 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 java.lang.reflect.Method;
+
+public class GenericMethodParameterTypeCacheEntry
+ implements CacheEntry
+{
+ final Method method;
+
+ final Class<?> type;
+
+ public GenericMethodParameterTypeCacheEntry( Method method, Class<?> type )
+ {
+ this.method = method;
+ this.type = type;
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
+ return true;
+ }
+ if ( !( o instanceof GenericMethodParameterTypeCacheEntry ) )
+ {
+ return false;
+ }
+
+ GenericMethodParameterTypeCacheEntry that = (GenericMethodParameterTypeCacheEntry) o;
+
+ return method.equals( that.method ) && type.equals( that.type );
+
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = method.hashCode();
+ result = 31 * result + type.hashCode();
+ return result;
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/entry/GenericMethodParameterTypeFactory.java b/src/main/java/org/apache/commons/ognl/internal/entry/GenericMethodParameterTypeFactory.java
index 55af62b..3eab94d 100644
--- a/src/main/java/org/apache/commons/ognl/internal/entry/GenericMethodParameterTypeFactory.java
+++ b/src/main/java/org/apache/commons/ognl/internal/entry/GenericMethodParameterTypeFactory.java
@@ -1,107 +1,106 @@
-package org.apache.commons.ognl.internal.entry;
-
-/*
- * 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$
- */
-
-import org.apache.commons.ognl.internal.CacheException;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-
-public class GenericMethodParameterTypeFactory
- implements CacheEntryFactory<GenericMethodParameterTypeCacheEntry, Class<?>[]>
-{
- public Class<?>[] create( GenericMethodParameterTypeCacheEntry entry )
- throws CacheException
- {
- Class<?>[] types;
-
- ParameterizedType param = (ParameterizedType) entry.type.getGenericSuperclass();
- Type[] genTypes = entry.method.getGenericParameterTypes();
- TypeVariable<?>[] declaredTypes = entry.method.getDeclaringClass().getTypeParameters();
-
- types = new Class[genTypes.length];
-
- for ( int i = 0; i < genTypes.length; i++ )
- {
- TypeVariable<?> paramType = null;
-
- if (genTypes[i] instanceof TypeVariable)
- {
- paramType = (TypeVariable<?>) genTypes[i];
- }
- else if (genTypes[i] instanceof GenericArrayType)
- {
- paramType = (TypeVariable<?>) ( (GenericArrayType) genTypes[i] ).getGenericComponentType();
- }
- else if (genTypes[i] instanceof ParameterizedType)
- {
- types[i] = (Class<?>) ( (ParameterizedType) genTypes[i] ).getRawType();
- continue;
- }
- else if (genTypes[i] instanceof Class)
- {
- types[i] = (Class<?>) genTypes[i];
- continue;
- }
-
- Class<?> resolved = resolveType( param, paramType, declaredTypes );
-
- if ( resolved != null )
- {
- if (genTypes[i] instanceof GenericArrayType)
- {
- resolved = Array.newInstance( resolved, 0 ).getClass();
- }
-
- types[i] = resolved;
- continue;
- }
- types[i] = entry.method.getParameterTypes()[i];
- }
-
- return types;
- }
-
- private Class<?> resolveType( ParameterizedType param, TypeVariable<?> var, TypeVariable<?>[] declaredTypes )
- {
- if ( param.getActualTypeArguments().length < 1 )
- {
- return null;
- }
-
- for ( int i = 0; i < declaredTypes.length; i++ )
- {
- if ( !(param.getActualTypeArguments()[i] instanceof TypeVariable)
- && declaredTypes[i].getName().equals( var.getName() ) )
- {
- return (Class<?>) param.getActualTypeArguments()[i];
- }
- }
-
- return null;
- }
-}
+package org.apache.commons.ognl.internal.entry;
+
+/*
+ * 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.internal.CacheException;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+
+public class GenericMethodParameterTypeFactory
+ implements CacheEntryFactory<GenericMethodParameterTypeCacheEntry, Class<?>[]>
+{
+ public Class<?>[] create( GenericMethodParameterTypeCacheEntry entry )
+ throws CacheException
+ {
+ Class<?>[] types;
+
+ ParameterizedType param = (ParameterizedType) entry.type.getGenericSuperclass();
+ Type[] genTypes = entry.method.getGenericParameterTypes();
+ TypeVariable<?>[] declaredTypes = entry.method.getDeclaringClass().getTypeParameters();
+
+ types = new Class[genTypes.length];
+
+ for ( int i = 0; i < genTypes.length; i++ )
+ {
+ TypeVariable<?> paramType = null;
+
+ if (genTypes[i] instanceof TypeVariable)
+ {
+ paramType = (TypeVariable<?>) genTypes[i];
+ }
+ else if (genTypes[i] instanceof GenericArrayType)
+ {
+ paramType = (TypeVariable<?>) ( (GenericArrayType) genTypes[i] ).getGenericComponentType();
+ }
+ else if (genTypes[i] instanceof ParameterizedType)
+ {
+ types[i] = (Class<?>) ( (ParameterizedType) genTypes[i] ).getRawType();
+ continue;
+ }
+ else if (genTypes[i] instanceof Class)
+ {
+ types[i] = (Class<?>) genTypes[i];
+ continue;
+ }
+
+ Class<?> resolved = resolveType( param, paramType, declaredTypes );
+
+ if ( resolved != null )
+ {
+ if (genTypes[i] instanceof GenericArrayType)
+ {
+ resolved = Array.newInstance( resolved, 0 ).getClass();
+ }
+
+ types[i] = resolved;
+ continue;
+ }
+ types[i] = entry.method.getParameterTypes()[i];
+ }
+
+ return types;
+ }
+
+ private Class<?> resolveType( ParameterizedType param, TypeVariable<?> var, TypeVariable<?>[] declaredTypes )
+ {
+ if ( param.getActualTypeArguments().length < 1 )
+ {
+ return null;
+ }
+
+ for ( int i = 0; i < declaredTypes.length; i++ )
+ {
+ if ( !(param.getActualTypeArguments()[i] instanceof TypeVariable)
+ && declaredTypes[i].getName().equals( var.getName() ) )
+ {
+ return (Class<?>) param.getActualTypeArguments()[i];
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/entry/MethodAccessCacheEntryFactory.java b/src/main/java/org/apache/commons/ognl/internal/entry/MethodAccessCacheEntryFactory.java
index 181ae8b..8ec2a2d 100644
--- a/src/main/java/org/apache/commons/ognl/internal/entry/MethodAccessCacheEntryFactory.java
+++ b/src/main/java/org/apache/commons/ognl/internal/entry/MethodAccessCacheEntryFactory.java
@@ -1,56 +1,55 @@
-package org.apache.commons.ognl.internal.entry;
-
-/*
- * 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$
- */
-
-import org.apache.commons.ognl.internal.CacheException;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-
-public class MethodAccessCacheEntryFactory
- implements CacheEntryFactory<Method, MethodAccessEntryValue>
-{
-
- public static final MethodAccessEntryValue INACCESSIBLE_NON_PUBLIC_METHOD =
- new MethodAccessEntryValue( false, true );
-
- public static final MethodAccessEntryValue ACCESSIBLE_NON_PUBLIC_METHOD = new MethodAccessEntryValue( true, true );
-
- public static final MethodAccessEntryValue PUBLIC_METHOD = new MethodAccessEntryValue( true );
-
- public MethodAccessEntryValue create( Method method )
- throws CacheException
- {
- final boolean notPublic = !Modifier.isPublic( method.getModifiers() ) || !Modifier.isPublic(
- method.getDeclaringClass().getModifiers() );
- if ( !notPublic ) {
- return PUBLIC_METHOD;
- }
- if ( !method.isAccessible() )
- {
- return INACCESSIBLE_NON_PUBLIC_METHOD;
- }
- return ACCESSIBLE_NON_PUBLIC_METHOD;
- }
-}
+package org.apache.commons.ognl.internal.entry;
+
+/*
+ * 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.internal.CacheException;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+public class MethodAccessCacheEntryFactory
+ implements CacheEntryFactory<Method, MethodAccessEntryValue>
+{
+
+ public static final MethodAccessEntryValue INACCESSIBLE_NON_PUBLIC_METHOD =
+ new MethodAccessEntryValue( false, true );
+
+ public static final MethodAccessEntryValue ACCESSIBLE_NON_PUBLIC_METHOD = new MethodAccessEntryValue( true, true );
+
+ public static final MethodAccessEntryValue PUBLIC_METHOD = new MethodAccessEntryValue( true );
+
+ public MethodAccessEntryValue create( Method method )
+ throws CacheException
+ {
+ final boolean notPublic = !Modifier.isPublic( method.getModifiers() ) || !Modifier.isPublic(
+ method.getDeclaringClass().getModifiers() );
+ if ( !notPublic ) {
+ return PUBLIC_METHOD;
+ }
+ if ( !method.isAccessible() )
+ {
+ return INACCESSIBLE_NON_PUBLIC_METHOD;
+ }
+ return ACCESSIBLE_NON_PUBLIC_METHOD;
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/entry/MethodAccessEntryValue.java b/src/main/java/org/apache/commons/ognl/internal/entry/MethodAccessEntryValue.java
index c0e295b..c22de26 100644
--- a/src/main/java/org/apache/commons/ognl/internal/entry/MethodAccessEntryValue.java
+++ b/src/main/java/org/apache/commons/ognl/internal/entry/MethodAccessEntryValue.java
@@ -1,52 +1,51 @@
-package org.apache.commons.ognl.internal.entry;
-
-/*
- * 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 MethodAccessEntryValue
-{
- private final boolean isAccessible;
-
- private boolean notPublic;
-
- public MethodAccessEntryValue( boolean accessible )
- {
- this.isAccessible = accessible;
- }
-
- public MethodAccessEntryValue( boolean accessible, boolean notPublic )
- {
- isAccessible = accessible;
- this.notPublic = notPublic;
- }
-
- public boolean isAccessible()
- {
- return isAccessible;
- }
-
- public boolean isNotPublic()
- {
- return notPublic;
- }
-}
+package org.apache.commons.ognl.internal.entry;
+
+/*
+ * 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 MethodAccessEntryValue
+{
+ private final boolean isAccessible;
+
+ private boolean notPublic;
+
+ public MethodAccessEntryValue( boolean accessible )
+ {
+ this.isAccessible = accessible;
+ }
+
+ public MethodAccessEntryValue( boolean accessible, boolean notPublic )
+ {
+ isAccessible = accessible;
+ this.notPublic = notPublic;
+ }
+
+ public boolean isAccessible()
+ {
+ return isAccessible;
+ }
+
+ public boolean isNotPublic()
+ {
+ return notPublic;
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/entry/MethodCacheEntry.java b/src/main/java/org/apache/commons/ognl/internal/entry/MethodCacheEntry.java
index cccaf78..02c2250 100644
--- a/src/main/java/org/apache/commons/ognl/internal/entry/MethodCacheEntry.java
+++ b/src/main/java/org/apache/commons/ognl/internal/entry/MethodCacheEntry.java
@@ -1,59 +1,58 @@
-package org.apache.commons.ognl.internal.entry;
-
-/*
- * 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 MethodCacheEntry
- implements CacheEntry
-{
- public final Class<?> targetClass;
-
- public MethodCacheEntry( Class<?> targetClass )
- {
- this.targetClass = targetClass;
- }
-
- @Override
- public boolean equals( Object o )
- {
- if ( this == o )
- {
- return true;
- }
- if ( !( o instanceof MethodCacheEntry ) )
- {
- return false;
- }
-
- MethodCacheEntry that = (MethodCacheEntry) o;
-
- return targetClass.equals( that.targetClass );
-
- }
-
- @Override
- public int hashCode()
- {
- return targetClass.hashCode();
- }
-}
+package org.apache.commons.ognl.internal.entry;
+
+/*
+ * 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 MethodCacheEntry
+ implements CacheEntry
+{
+ public final Class<?> targetClass;
+
+ public MethodCacheEntry( Class<?> targetClass )
+ {
+ this.targetClass = targetClass;
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
+ return true;
+ }
+ if ( !( o instanceof MethodCacheEntry ) )
+ {
+ return false;
+ }
+
+ MethodCacheEntry that = (MethodCacheEntry) o;
+
+ return targetClass.equals( that.targetClass );
+
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return targetClass.hashCode();
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/entry/MethodCacheEntryFactory.java b/src/main/java/org/apache/commons/ognl/internal/entry/MethodCacheEntryFactory.java
index 95b0f72..bbb2cd5 100644
--- a/src/main/java/org/apache/commons/ognl/internal/entry/MethodCacheEntryFactory.java
+++ b/src/main/java/org/apache/commons/ognl/internal/entry/MethodCacheEntryFactory.java
@@ -1,69 +1,68 @@
-package org.apache.commons.ognl.internal.entry;
-
-/*
- * 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$
- */
-
-
-import org.apache.commons.ognl.OgnlRuntime;
-import org.apache.commons.ognl.internal.CacheException;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public abstract class MethodCacheEntryFactory<T extends MethodCacheEntry>
- implements CacheEntryFactory<T, Map<String, List<Method>>>
-{
- public Map<String, List<Method>> create( T key )
- throws CacheException
- {
- Map<String, List<Method>> result = new HashMap<String, List<Method>>( 23 );
-
- Class<?> c = key.targetClass;
- while ( c != null )
- {
- for ( Method method : c.getDeclaredMethods() )
- {
- // skip over synthetic methods
-
- if ( !OgnlRuntime.isMethodCallable( method ) )
- {
- continue;
- }
-
- if ( shouldCache( key, method ) )
- {
- List<Method> ml = result.computeIfAbsent(method.getName(), k -> new ArrayList<Method>());
-
- ml.add( method );
- }
- }
- c = c.getSuperclass();
- }
- return result;
- }
-
- protected abstract boolean shouldCache( T key, Method method );
-}
+package org.apache.commons.ognl.internal.entry;
+
+/*
+ * 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.OgnlRuntime;
+import org.apache.commons.ognl.internal.CacheException;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public abstract class MethodCacheEntryFactory<T extends MethodCacheEntry>
+ implements CacheEntryFactory<T, Map<String, List<Method>>>
+{
+ public Map<String, List<Method>> create( T key )
+ throws CacheException
+ {
+ Map<String, List<Method>> result = new HashMap<String, List<Method>>( 23 );
+
+ Class<?> c = key.targetClass;
+ while ( c != null )
+ {
+ for ( Method method : c.getDeclaredMethods() )
+ {
+ // skip over synthetic methods
+
+ if ( !OgnlRuntime.isMethodCallable( method ) )
+ {
+ continue;
+ }
+
+ if ( shouldCache( key, method ) )
+ {
+ List<Method> ml = result.computeIfAbsent(method.getName(), k -> new ArrayList<Method>());
+
+ ml.add( method );
+ }
+ }
+ c = c.getSuperclass();
+ }
+ return result;
+ }
+
+ protected abstract boolean shouldCache( T key, Method method );
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/entry/MethodPermCacheEntryFactory.java b/src/main/java/org/apache/commons/ognl/internal/entry/MethodPermCacheEntryFactory.java
index 3a09974..f9bf27a 100644
--- a/src/main/java/org/apache/commons/ognl/internal/entry/MethodPermCacheEntryFactory.java
+++ b/src/main/java/org/apache/commons/ognl/internal/entry/MethodPermCacheEntryFactory.java
@@ -1,60 +1,59 @@
-package org.apache.commons.ognl.internal.entry;
-
-/*
- * 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$
- */
-
-import org.apache.commons.ognl.OgnlRuntime;
-import org.apache.commons.ognl.internal.CacheException;
-
-import java.lang.reflect.Method;
-
-public class MethodPermCacheEntryFactory
- implements CacheEntryFactory<Method, Boolean>
-{
- private SecurityManager securityManager;
-
- public MethodPermCacheEntryFactory( SecurityManager securityManager )
- {
- this.securityManager = securityManager;
- }
-
- public Boolean create( Method key )
- throws CacheException
- {
- try
- {
- securityManager.checkPermission( OgnlRuntime.getPermission( key ) );
- return true;
- }
- catch ( SecurityException ex )
- {
- return false;
- }
-
- }
-
- public void setSecurityManager( SecurityManager securityManager )
- {
- this.securityManager = securityManager;
- }
-}
+package org.apache.commons.ognl.internal.entry;
+
+/*
+ * 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.OgnlRuntime;
+import org.apache.commons.ognl.internal.CacheException;
+
+import java.lang.reflect.Method;
+
+public class MethodPermCacheEntryFactory
+ implements CacheEntryFactory<Method, Boolean>
+{
+ private SecurityManager securityManager;
+
+ public MethodPermCacheEntryFactory( SecurityManager securityManager )
+ {
+ this.securityManager = securityManager;
+ }
+
+ public Boolean create( Method key )
+ throws CacheException
+ {
+ try
+ {
+ securityManager.checkPermission( OgnlRuntime.getPermission( key ) );
+ return true;
+ }
+ catch ( SecurityException ex )
+ {
+ return false;
+ }
+
+ }
+
+ public void setSecurityManager( SecurityManager securityManager )
+ {
+ this.securityManager = securityManager;
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/entry/ParametrizedCacheEntryFactory.java b/src/main/java/org/apache/commons/ognl/internal/entry/ParametrizedCacheEntryFactory.java
index 58803a0..cb2325b 100644
--- a/src/main/java/org/apache/commons/ognl/internal/entry/ParametrizedCacheEntryFactory.java
+++ b/src/main/java/org/apache/commons/ognl/internal/entry/ParametrizedCacheEntryFactory.java
@@ -1,29 +1,28 @@
-/*
- * $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.internal.entry;
-
-import java.util.Map;
-
-public interface ParametrizedCacheEntryFactory
-{
- void setParameterValues( Map<String, String> parameters );
-}
+/*
+ *
+ * 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.internal.entry;
+
+import java.util.Map;
+
+public interface ParametrizedCacheEntryFactory
+{
+ void setParameterValues( Map<String, String> parameters );
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/entry/PermissionCacheEntry.java b/src/main/java/org/apache/commons/ognl/internal/entry/PermissionCacheEntry.java
index 68c0890..4e78745 100644
--- a/src/main/java/org/apache/commons/ognl/internal/entry/PermissionCacheEntry.java
+++ b/src/main/java/org/apache/commons/ognl/internal/entry/PermissionCacheEntry.java
@@ -1,61 +1,60 @@
-package org.apache.commons.ognl.internal.entry;
-
-/*
- * 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$
- */
-
-import java.lang.reflect.Method;
-
-public class PermissionCacheEntry
- implements CacheEntry
-{
- public final Method method;
-
- public PermissionCacheEntry( Method method )
- {
- this.method = method;
- }
-
- @Override
- public boolean equals( Object o )
- {
- if ( this == o )
- {
- return true;
- }
- if ( !( o instanceof PermissionCacheEntry ) )
- {
- return false;
- }
-
- PermissionCacheEntry that = (PermissionCacheEntry) o;
-
- return !( method != null ? !method.equals( that.method ) : that.method != null );
-
- }
-
- @Override
- public int hashCode()
- {
- return method != null ? method.hashCode() : 0;
- }
-}
+package org.apache.commons.ognl.internal.entry;
+
+/*
+ * 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 java.lang.reflect.Method;
+
+public class PermissionCacheEntry
+ implements CacheEntry
+{
+ public final Method method;
+
+ public PermissionCacheEntry( Method method )
+ {
+ this.method = method;
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
+ return true;
+ }
+ if ( !( o instanceof PermissionCacheEntry ) )
+ {
+ return false;
+ }
+
+ PermissionCacheEntry that = (PermissionCacheEntry) o;
+
+ return !( method != null ? !method.equals( that.method ) : that.method != null );
+
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return method != null ? method.hashCode() : 0;
+ }
+}
diff --git a/src/main/java/org/apache/commons/ognl/internal/entry/PermissionCacheEntryFactory.java b/src/main/java/org/apache/commons/ognl/internal/entry/PermissionCacheEntryFactory.java
index b9c4007..44ecc4d 100644
--- a/src/main/java/org/apache/commons/ognl/internal/entry/PermissionCacheEntryFactory.java
+++ b/src/main/java/org/apache/commons/ognl/internal/entry/PermissionCacheEntryFactory.java
@@ -1,42 +1,41 @@
-package org.apache.commons.ognl.internal.entry;
-
-/*
- * 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$
- */
-
-import org.apache.commons.ognl.OgnlInvokePermission;
-import org.apache.commons.ognl.internal.CacheException;
-
-import java.security.Permission;
-
-public class PermissionCacheEntryFactory
- implements CacheEntryFactory<PermissionCacheEntry, Permission>
-{
-
- public Permission create( PermissionCacheEntry key )
- throws CacheException
- {
- return new OgnlInvokePermission(
- "invoke." + key.method.getDeclaringClass().getName() + "." + key.method.getName() );
- }
-}
-
+package org.apache.commons.ognl.internal.entry;
+
+/*
+ * 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.OgnlInvokePermission;
+import org.apache.commons.ognl.internal.CacheException;
+
+import java.security.Permission;
+
+public class PermissionCacheEntryFactory
+ implements CacheEntryFactory<PermissionCacheEntry, Permission>
+{
+
+ public Permission create( PermissionCacheEntry key )
+ throws CacheException
+ {
+ return new OgnlInvokePermission(
+ "invoke." + key.method.getDeclaringClass().getName() + "." + key.method.getName() );
+ }
+}
+
diff --git a/src/main/java/org/apache/commons/ognl/internal/entry/PropertyDescriptorCacheEntryFactory.java b/src/main/java/org/apache/commons/ognl/internal/entry/PropertyDescriptorCacheEntryFactory.java
index 67e5a03..db96f4c 100644
--- a/src/main/java/org/apache/commons/ognl/internal/entry/PropertyDescriptorCacheEntryFactory.java
+++ b/src/main/java/org/apache/commons/ognl/internal/entry/PropertyDescriptorCacheEntryFactory.java
@@ -1,218 +1,217 @@
-package org.apache.commons.ognl.internal.entry;
-
-/*
- * 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$
- */
-
-import org.apache.commons.ognl.ObjectIndexedPropertyDescriptor;
-import org.apache.commons.ognl.OgnlException;
-import org.apache.commons.ognl.OgnlRuntime;
-import org.apache.commons.ognl.internal.CacheException;
-
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class PropertyDescriptorCacheEntryFactory
- implements ClassCacheEntryFactory<Map<String, PropertyDescriptor>>
-{
- public Map<String, PropertyDescriptor> create( Class<?> targetClass )
- throws CacheException
- {
- Map<String, PropertyDescriptor> result = new HashMap<String, PropertyDescriptor>( 101 );
- PropertyDescriptor[] pda;
- try
- {
- pda = Introspector.getBeanInfo( targetClass ).getPropertyDescriptors();
-
- for (PropertyDescriptor aPda : pda) {
- // workaround for Introspector bug 6528714 (bugs.sun.com)
- if (aPda.getReadMethod() != null && !OgnlRuntime.isMethodCallable(aPda.getReadMethod())) {
- aPda.setReadMethod(
- findClosestMatchingMethod(targetClass, aPda.getReadMethod(), aPda.getName(),
- aPda.getPropertyType(), true));
- }
- if (aPda.getWriteMethod() != null && !OgnlRuntime.isMethodCallable(aPda.getWriteMethod())) {
- aPda.setWriteMethod(
- findClosestMatchingMethod(targetClass, aPda.getWriteMethod(), aPda.getName(),
- aPda.getPropertyType(), false));
- }
-
- result.put(aPda.getName(), aPda);
- }
-
- findObjectIndexedPropertyDescriptors( targetClass, result );
- }
- catch ( IntrospectionException | OgnlException e )
- {
- throw new CacheException( e );
- }
- return result;
- }
-
- static Method findClosestMatchingMethod( Class<?> targetClass, Method m, String propertyName, Class<?> propertyType,
- boolean isReadMethod )
- throws OgnlException
- {
- List<Method> methods = OgnlRuntime.getDeclaredMethods( targetClass, propertyName, !isReadMethod );
-
- for ( Method method : methods )
- {
- if ( method.getName().equals( m.getName() ) && m.getReturnType().isAssignableFrom( m.getReturnType() )
- && method.getReturnType() == propertyType
- && method.getParameterTypes().length == m.getParameterTypes().length )
- {
- return method;
- }
- }
-
- return m;
- }
-
- private static void findObjectIndexedPropertyDescriptors( Class<?> targetClass,
- Map<String, PropertyDescriptor> intoMap )
- throws OgnlException
- {
- Map<String, List<Method>> allMethods = OgnlRuntime.getMethods( targetClass, false );
- Map<String, List<Method>> pairs = new HashMap<String, List<Method>>( 101 );
-
- for ( Map.Entry<String, List<Method>> entry : allMethods.entrySet() )
- {
- String methodName = entry.getKey();
- List<Method> methods = entry.getValue();
-
- /*
- * Only process set/get where there is exactly one implementation of the method per class and those
- * implementations are all the same
- */
- if ( indexMethodCheck( methods ) )
- {
- boolean isGet = false, isSet;
- Method method = methods.get( 0 );
-
- if ( ( ( isSet = methodName.startsWith( OgnlRuntime.SET_PREFIX ) ) || ( isGet =
- methodName.startsWith( OgnlRuntime.GET_PREFIX ) ) ) && ( methodName.length() > 3 ) )
- {
- String propertyName = Introspector.decapitalize( methodName.substring( 3 ) );
- Class<?>[] parameterTypes = OgnlRuntime.getParameterTypes( method );
- int parameterCount = parameterTypes.length;
-
- if ( isGet && ( parameterCount == 1 ) && ( method.getReturnType() != Void.TYPE ) )
- {
- List<Method> pair = pairs.computeIfAbsent(propertyName, k -> new ArrayList<Method>());
-
- pair.add( method );
- }
- if ( isSet && ( parameterCount == 2 ) && ( method.getReturnType() == Void.TYPE ) )
- {
- List<Method> pair = pairs.computeIfAbsent(propertyName, k -> new ArrayList<Method>());
-
- pair.add( method );
- }
- }
- }
- }
-
- for ( Map.Entry<String, List<Method>> entry : pairs.entrySet() )
- {
- String propertyName = entry.getKey();
- List<Method> methods = entry.getValue();
-
- if ( methods.size() == 2 )
- {
- Method method1 = methods.get( 0 ), method2 = methods.get( 1 ), setMethod =
- ( method1.getParameterTypes().length == 2 ) ? method1 : method2, getMethod =
- ( setMethod == method1 ) ? method2 : method1;
- Class<?> keyType = getMethod.getParameterTypes()[0], propertyType = getMethod.getReturnType();
-
- if ( keyType == setMethod.getParameterTypes()[0] && propertyType == setMethod.getParameterTypes()[1] )
- {
- ObjectIndexedPropertyDescriptor propertyDescriptor;
-
- try
- {
- propertyDescriptor =
- new ObjectIndexedPropertyDescriptor( propertyName, propertyType, getMethod, setMethod );
- }
- catch ( Exception ex )
- {
- throw new OgnlException(
- "creating object indexed property descriptor for '" + propertyName + "' in "
- + targetClass, ex );
- }
- intoMap.put( propertyName, propertyDescriptor );
- }
- }
- }
- }
- private static boolean indexMethodCheck( List<Method> methods )
- {
- boolean result = false;
-
- if ( !methods.isEmpty() )
- {
- Method method = methods.get( 0 );
- Class<?>[] parameterTypes = OgnlRuntime.getParameterTypes( method );
- int numParameterTypes = parameterTypes.length;
- Class<?> lastMethodClass = method.getDeclaringClass();
-
- result = true;
- for ( int i = 1; result && ( i < methods.size() ); i++ )
- {
- Class<?> clazz = methods.get( i ).getDeclaringClass();
-
- // Check to see if more than one method implemented per class
- if ( lastMethodClass == clazz )
- {
- result = false;
- }
- else
- {
- Class<?>[] mpt = OgnlRuntime.getParameterTypes( method );
- int mpc = parameterTypes.length;
-
- if ( numParameterTypes != mpc )
- {
- result = false;
- }
- for ( int j = 0; j < numParameterTypes; j++ )
- {
- if ( parameterTypes[j] != mpt[j] )
- {
- result = false;
- break;
- }
- }
- }
- lastMethodClass = clazz;
- }
- }
- return result;
- }
-
-
-}
+package org.apache.commons.ognl.internal.entry;
+
+/*
+ * 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.ObjectIndexedPropertyDescriptor;
+import org.apache.commons.ognl.OgnlException;
+import org.apache.commons.ognl.OgnlRuntime;
+import org.apache.commons.ognl.internal.CacheException;
+
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class PropertyDescriptorCacheEntryFactory
+ implements ClassCacheEntryFactory<Map<String, PropertyDescriptor>>
+{
+ public Map<String, PropertyDescriptor> create( Class<?> targetClass )
+ throws CacheException
+ {
+ Map<String, PropertyDescriptor> result = new HashMap<String, PropertyDescriptor>( 101 );
+ PropertyDescriptor[] pda;
+ try
+ {
+ pda = Introspector.getBeanInfo( targetClass ).getPropertyDescriptors();
+
+ for (PropertyDescriptor aPda : pda) {
+ // workaround for Introspector bug 6528714 (bugs.sun.com)
+ if (aPda.getReadMethod() != null && !OgnlRuntime.isMethodCallable(aPda.getReadMethod())) {
+ aPda.setReadMethod(
+ findClosestMatchingMethod(targetClass, aPda.getReadMethod(), aPda.getName(),
+ aPda.getPropertyType(), true));
+ }
+ if (aPda.getWriteMethod() != null && !OgnlRuntime.isMethodCallable(aPda.getWriteMethod())) {
+ aPda.setWriteMethod(
+ findClosestMatchingMethod(targetClass, aPda.getWriteMethod(), aPda.getName(),
+ aPda.getPropertyType(), false));
+ }
+
+ result.put(aPda.getName(), aPda);
+ }
+
+ findObjectIndexedPropertyDescriptors( targetClass, result );
+ }
+ catch ( IntrospectionException | OgnlException e )
+ {
+ throw new CacheException( e );
+ }
+ return result;
+ }
+
+ static Method findClosestMatchingMethod( Class<?> targetClass, Method m, String propertyName, Class<?> propertyType,
+ boolean isReadMethod )
+ throws OgnlException
+ {
+ List<Method> methods = OgnlRuntime.getDeclaredMethods( targetClass, propertyName, !isReadMethod );
+
+ for ( Method method : methods )
+ {
+ if ( method.getName().equals( m.getName() ) && m.getReturnType().isAssignableFrom( m.getReturnType() )
+ && method.getReturnType() == propertyType
+ && method.getParameterTypes().length == m.getParameterTypes().length )
+ {
+ return method;
+ }
+ }
+
+ return m;
+ }
+
+ private static void findObjectIndexedPropertyDescriptors( Class<?> targetClass,
+ Map<String, PropertyDescriptor> intoMap )
+ throws OgnlException
+ {
+ Map<String, List<Method>> allMethods = OgnlRuntime.getMethods( targetClass, false );
+ Map<String, List<Method>> pairs = new HashMap<String, List<Method>>( 101 );
+
+ for ( Map.Entry<String, List<Method>> entry : allMethods.entrySet() )
+ {
+ String methodName = entry.getKey();
+ List<Method> methods = entry.getValue();
+
+ /*
+ * Only process set/get where there is exactly one implementation of the method per class and those
+ * implementations are all the same
+ */
+ if ( indexMethodCheck( methods ) )
+ {
+ boolean isGet = false, isSet;
+ Method method = methods.get( 0 );
+
+ if ( ( ( isSet = methodName.startsWith( OgnlRuntime.SET_PREFIX ) ) || ( isGet =
+ methodName.startsWith( OgnlRuntime.GET_PREFIX ) ) ) && ( methodName.length() > 3 ) )
+ {
+ String propertyName = Introspector.decapitalize( methodName.substring( 3 ) );
+ Class<?>[] parameterTypes = OgnlRuntime.getParameterTypes( method );
+ int parameterCount = parameterTypes.length;
+
+ if ( isGet && ( parameterCount == 1 ) && ( method.getReturnType() != Void.TYPE ) )
+ {
+ List<Method> pair = pairs.computeIfAbsent(propertyName, k -> new ArrayList<Method>());
+
+ pair.add( method );
+ }
+ if ( isSet && ( parameterCount == 2 ) && ( method.getReturnType() == Void.TYPE ) )
+ {
+ List<Method> pair = pairs.computeIfAbsent(propertyName, k -> new ArrayList<Method>());
+
+ pair.add( method );
+ }
+ }
+ }
+ }
+
+ for ( Map.Entry<String, List<Method>> entry : pairs.entrySet() )
+ {
+ String propertyName = entry.getKey();
+ List<Method> methods = entry.getValue();
+
+ if ( methods.size() == 2 )
+ {
+ Method method1 = methods.get( 0 ), method2 = methods.get( 1 ), setMethod =
+ ( method1.getParameterTypes().length == 2 ) ? method1 : method2, getMethod =
+ ( setMethod == method1 ) ? method2 : method1;
+ Class<?> keyType = getMethod.getParameterTypes()[0], propertyType = getMethod.getReturnType();
+
+ if ( keyType == setMethod.getParameterTypes()[0] && propertyType == setMethod.getParameterTypes()[1] )
+ {
+ ObjectIndexedPropertyDescriptor propertyDescriptor;
+
+ try
+ {
+ propertyDescriptor =
+ new ObjectIndexedPropertyDescriptor( propertyName, propertyType, getMethod, setMethod );
+ }
+ catch ( Exception ex )
+ {
+ throw new OgnlException(
+ "creating object indexed property descriptor for '" + propertyName + "' in "
+ + targetClass, ex );
+ }
+ intoMap.put( propertyName, propertyDescriptor );
+ }
+ }
+ }
+ }
+ private static boolean indexMethodCheck( List<Method> methods )
+ {
+ boolean result = false;
+
+ if ( !methods.isEmpty() )
+ {
+ Method method = methods.get( 0 );
+ Class<?>[] parameterTypes = OgnlRuntime.getParameterTypes( method );
+ int numParameterTypes = parameterTypes.length;
+ Class<?> lastMethodClass = method.getDeclaringClass();
+
+ result = true;
+ for ( int i = 1; result && ( i < methods.size() ); i++ )
+ {
+ Class<?> clazz = methods.get( i ).getDeclaringClass();
+
+ // Check to see if more than one method implemented per class
+ if ( lastMethodClass == clazz )
+ {
+ result = false;
+ }
+ else
+ {
+ Class<?>[] mpt = OgnlRuntime.getParameterTypes( method );
+ int mpc = parameterTypes.length;
+
+ if ( numParameterTypes != mpc )
+ {
+ result = false;
+ }
+ for ( int j = 0; j < numParameterTypes; j++ )
+ {
+ if ( parameterTypes[j] != mpt[j] )
+ {
+ result = false;
+ break;
+ }
+ }
+ }
+ lastMethodClass = clazz;
+ }
+ }
+ return result;
+ }
+
+
+}
diff --git a/src/main/java/org/apache/commons/ognl/package-info.java b/src/main/java/org/apache/commons/ognl/package-info.java
index 5d6bdf6..01a2765 100644
--- a/src/main/java/org/apache/commons/ognl/package-info.java
+++ b/src/main/java/org/apache/commons/ognl/package-info.java
@@ -1,39 +1,38 @@
-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.
- */
-
-/**
- * OGNL stands for Object-Graph Navigation Language; it is an expression language
- * for getting and setting properties of Java objects. You use the same expression
- * for both getting and setting the value of a property.
- *
- * OGNL started out as a way to set up associations between UI
- * components and controllers using property names. As the desire for
- * more complicated associations grew, Drew Davidson created what he
- * called KVCL, for Key-Value Coding Language, egged on by Luke
- * Blanshard. Luke then reimplemented the language using ANTLR, came up
- * with the new name, and, egged on by Drew, filled it out to its current
- * state.
- *
- * We pronounce OGNL as a word, like the last syllables of a drunken
- * pronunciation of "orthogonal" or like "ogg-null".
- * $Id$
- */
-
+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.
+ */
+
+/**
+ * OGNL stands for Object-Graph Navigation Language; it is an expression language
+ * for getting and setting properties of Java objects. You use the same expression
+ * for both getting and setting the value of a property.
+ *
+ * OGNL started out as a way to set up associations between UI
+ * components and controllers using property names. As the desire for
+ * more complicated associations grew, Drew Davidson created what he
+ * called KVCL, for Key-Value Coding Language, egged on by Luke
+ * Blanshard. Luke then reimplemented the language using ANTLR, came up
+ * with the new name, and, egged on by Drew, filled it out to its current
+ * state.
+ *
+ * We pronounce OGNL as a word, like the last syllables of a drunken
+ * pronunciation of "orthogonal" or like "ogg-null".
+ */
+
diff --git a/src/test/java/org/apache/commons/ognl/InExpressionTest.java b/src/test/java/org/apache/commons/ognl/InExpressionTest.java
index d293a62..9a169dc 100644
--- a/src/test/java/org/apache/commons/ognl/InExpressionTest.java
+++ b/src/test/java/org/apache/commons/ognl/InExpressionTest.java
@@ -1,43 +1,42 @@
-/*
- * $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;
-
-import static junit.framework.Assert.assertEquals;
-
-import org.junit.Test;
-
-/**
- * Test for OGNL-118.
- */
-public class InExpressionTest
-{
-
- @Test
- public void test_String_In()
- throws Exception
- {
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
- Object node = Ognl.parseExpression( "#name in {\"Greenland\", \"Austin\", \"Africa\", \"Rome\"}" );
- Object root = null;
-
- context.put( "name", "Austin" );
- assertEquals( Boolean.TRUE, Ognl.getValue( node, context, root ) );
- }
-}
+/*
+ * 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;
+
+import static junit.framework.Assert.assertEquals;
+
+import org.junit.Test;
+
+/**
+ * Test for OGNL-118.
+ */
+public class InExpressionTest
+{
+
+ @Test
+ public void test_String_In()
+ throws Exception
+ {
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+ Object node = Ognl.parseExpression( "#name in {\"Greenland\", \"Austin\", \"Africa\", \"Rome\"}" );
+ Object root = null;
+
+ context.put( "name", "Austin" );
+ assertEquals( Boolean.TRUE, Ognl.getValue( node, context, root ) );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/TestOgnlException.java b/src/test/java/org/apache/commons/ognl/TestOgnlException.java
index b1e0424..87ae7e9 100644
--- a/src/test/java/org/apache/commons/ognl/TestOgnlException.java
+++ b/src/test/java/org/apache/commons/ognl/TestOgnlException.java
@@ -1,57 +1,56 @@
-/*
- * $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;
-
-import org.junit.Test;
-
-import static junit.framework.Assert.assertTrue;
-
-/**
- * Tests {@link OgnlException}.
- */
-public class TestOgnlException
-{
-
- @Test
- public void test_Throwable_Reason()
- {
- try
- {
- throwException();
- }
- catch ( OgnlException e )
- {
- assertTrue( NumberFormatException.class.isInstance( e.getReason() ) );
- }
- }
-
- void throwException()
- throws OgnlException
- {
- try
- {
- Integer.parseInt( "45ac" );
- }
- catch ( NumberFormatException et )
- {
- throw new OgnlException( "Unable to parse input string.", et );
- }
- }
-}
+/*
+ * 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;
+
+import org.junit.Test;
+
+import static junit.framework.Assert.assertTrue;
+
+/**
+ * Tests {@link OgnlException}.
+ */
+public class TestOgnlException
+{
+
+ @Test
+ public void test_Throwable_Reason()
+ {
+ try
+ {
+ throwException();
+ }
+ catch ( OgnlException e )
+ {
+ assertTrue( NumberFormatException.class.isInstance( e.getReason() ) );
+ }
+ }
+
+ void throwException()
+ throws OgnlException
+ {
+ try
+ {
+ Integer.parseInt( "45ac" );
+ }
+ catch ( NumberFormatException et )
+ {
+ throw new OgnlException( "Unable to parse input string.", et );
+ }
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/TestOgnlRuntime.java b/src/test/java/org/apache/commons/ognl/TestOgnlRuntime.java
index 677ea2c..9a211fe 100644
--- a/src/test/java/org/apache/commons/ognl/TestOgnlRuntime.java
+++ b/src/test/java/org/apache/commons/ognl/TestOgnlRuntime.java
@@ -1,422 +1,421 @@
-/*
- * $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;
-
-import org.apache.commons.ognl.enhance.OgnlExpressionCompiler;
-import org.apache.commons.ognl.internal.CacheException;
-import org.apache.commons.ognl.test.objects.BaseGeneric;
-import org.apache.commons.ognl.test.objects.Bean1;
-import org.apache.commons.ognl.test.objects.Bean2;
-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.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.IForm;
-import org.apache.commons.ognl.test.objects.ListSource;
-import org.apache.commons.ognl.test.objects.ListSourceImpl;
-import org.apache.commons.ognl.test.objects.OtherObjectIndexed;
-import org.apache.commons.ognl.test.objects.Root;
-import org.apache.commons.ognl.test.objects.SetterReturns;
-import org.apache.commons.ognl.test.objects.SubclassSyntheticObject;
-import org.junit.Test;
-
-import java.beans.IntrospectionException;
-import java.beans.PropertyDescriptor;
-import java.io.Serializable;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.List;
-
-import static junit.framework.Assert.*;
-
-/**
- * Tests various methods / functionality of {@link org.apache.commons.ognl.OgnlRuntime}.
- */
-public class TestOgnlRuntime
-{
-
- @Test
- public void test_Get_Super_Or_Interface_Class()
- throws Exception
- {
- ListSource list = new ListSourceImpl();
-
- Method method = OgnlRuntime.getReadMethod( list.getClass(), "total" );
- assertNotNull( method );
-
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
- assertEquals( ListSource.class,
- OgnlRuntime.getCompiler( context ).getSuperOrInterfaceClass( method, list.getClass() ) );
- }
-
- @Test
- public void test_Get_Private_Class()
- throws Exception
- {
- List<String> list = Arrays.asList( "hello", "world" );
-
- Method m = OgnlRuntime.getReadMethod( list.getClass(), "iterator" );
- assertNotNull( m );
-
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
- assertEquals( Iterable.class,
- OgnlRuntime.getCompiler( context ).getSuperOrInterfaceClass( m, list.getClass() ) );
- }
-
- @Test
- public void test_Complicated_Inheritance()
- throws Exception
- {
- IForm form = new FormImpl();
-
- Method method = OgnlRuntime.getWriteMethod( form.getClass(), "clientId" );
- assertNotNull( method );
-
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
- assertEquals( IComponent.class,
- OgnlRuntime.getCompiler( context ).getSuperOrInterfaceClass( method, form.getClass() ) );
- }
-
- @Test
- public void test_Get_Read_Method()
- throws Exception
- {
- Method method = OgnlRuntime.getReadMethod( Bean2.class, "pageBreakAfter" );
- assertNotNull( method );
-
- assertEquals( "isPageBreakAfter", method.getName() );
- }
-
- class TestGetters
- {
- public boolean isEditorDisabled()
- {
- return false;
- }
-
- public boolean isDisabled()
- {
- return true;
- }
-
- public boolean isNotAvailable()
- {
- return false;
- }
-
- public boolean isAvailable()
- {
- return true;
- }
- }
-
- @Test
- public void test_Get_Read_Method_Multiple()
- throws Exception
- {
- Method method = OgnlRuntime.getReadMethod( TestGetters.class, "disabled" );
- assertNotNull( method );
-
- assertEquals( "isDisabled", method.getName() );
- }
-
- @Test
- public void test_Get_Read_Method_Multiple_Boolean_Getters()
- throws Exception
- {
- Method method = OgnlRuntime.getReadMethod( TestGetters.class, "available" );
- assertNotNull( method );
-
- assertEquals( "isAvailable", method.getName() );
-
- method = OgnlRuntime.getReadMethod( TestGetters.class, "notAvailable" );
- assertNotNull( method );
-
- assertEquals( "isNotAvailable", method.getName() );
- }
-
- @Test
- public void test_Find_Method_Mixed_Boolean_Getters()
- throws Exception
- {
- Method method = OgnlRuntime.getReadMethod( GetterMethods.class, "allowDisplay" );
- assertNotNull( method );
-
- assertEquals( "getAllowDisplay", method.getName() );
- }
-
- @Test
- public void test_Get_Appropriate_Method()
- throws Exception
- {
- ListSource list = new ListSourceImpl();
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
-
- Object ret = OgnlRuntime.callMethod( context, list, "addValue", new String[]{ null } );
-
- assert ret != null;
- }
-
- @Test
- public void test_Call_Static_Method_Invalid_Class()
- {
-
- try
- {
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
- OgnlRuntime.callStaticMethod( context, "made.up.Name", "foo", null );
-
- fail( "ClassNotFoundException should have been thrown by previous reference to <made.up.Name> class." );
- }
- catch ( Exception et )
- {
- assertTrue( MethodFailedException.class.isInstance( et ) );
- assertTrue( et.getMessage().contains( "made.up.Name" ) );
- }
- }
-
- @Test
- public void test_Setter_Returns()
- throws Exception
- {
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
- SetterReturns root = new SetterReturns();
-
- Method m = OgnlRuntime.getWriteMethod( root.getClass(), "value" );
- assertNotNull(m);
-
- Ognl.setValue( "value", context, root, "12__" );
- assertEquals( Ognl.getValue( "value", context, root ), "12__" );
- }
-
- @Test
- public void test_Call_Method_VarArgs()
- throws Exception
- {
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
- GenericService service = new GenericServiceImpl();
-
- GameGenericObject argument = new GameGenericObject();
-
- Object[] args = new Object[2];
- args[0] = argument;
-
- assertEquals( "Halo 3", OgnlRuntime.callMethod( context, service, "getFullMessageFor", args ) );
- }
-
- @Test
- public void test_Class_Cache_Inspector()
- throws Exception
- {
- OgnlRuntime.cache.clear();
-
- assertEquals( 0, OgnlRuntime.cache.propertyDescriptorCache.getSize() );
-
- Root root = new Root();
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
- Node expr = Ognl.compileExpression( context, root, "property.bean3.value != null" );
-
- assertTrue( (Boolean) expr.getAccessor().get( context, root ) );
-
- int size = OgnlRuntime.cache.propertyDescriptorCache.getSize();
- assertTrue( size > 0 );
-
- OgnlRuntime.clearCache();
- assertEquals( 0, OgnlRuntime.cache.propertyDescriptorCache.getSize() );
-
- // now register class cache prevention
-
- OgnlRuntime.setClassCacheInspector( new TestCacheInspector() );
-
- expr = Ognl.compileExpression( context, root, "property.bean3.value != null" );
- assertTrue( (Boolean) expr.getAccessor().get( context, root ) );
-
- assertEquals( ( size - 1 ), OgnlRuntime.cache.propertyDescriptorCache.getSize() );
- }
-
- class TestCacheInspector
- implements ClassCacheInspector
- {
-
- public boolean shouldCache( Class<?> type )
- {
- return !( type == null || type == Root.class );
- }
- }
-
- @Test
- public void test_Set_Generic_Parameter_Types()
- throws Exception
- {
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
-
- Method method = OgnlRuntime.getSetMethod( context, GenericCracker.class, "param" );
- assertNotNull( method );
-
- Class<?>[] types = method.getParameterTypes();
- assertEquals( 1, types.length );
- assertEquals( Integer.class, types[0] );
- }
-
- @Test
- public void test_Get_Generic_Parameter_Types()
- throws Exception
- {
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
-
- Method method = OgnlRuntime.getGetMethod( context, GenericCracker.class, "param" );
- assertNotNull( method );
-
- assertEquals( Integer.class, method.getReturnType() );
- }
-
- @Test
- public void test_Find_Parameter_Types()
- throws Exception
- {
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
-
- Method method = OgnlRuntime.getSetMethod( context, GameGeneric.class, "ids" );
- assertNotNull( method );
-
- Class<?>[] types = OgnlRuntime.findParameterTypes( GameGeneric.class, method );
- assertEquals( 1, types.length );
- assertEquals( Long[].class, types[0] );
- }
-
- @Test
- public void test_Find_Parameter_Types_Superclass()
- throws Exception
- {
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
-
- Method method = OgnlRuntime.getSetMethod( context, BaseGeneric.class, "ids" );
- assertNotNull( method );
-
- Class<?>[] types = OgnlRuntime.findParameterTypes( BaseGeneric.class, method );
- assertEquals( 1, types.length );
- assertEquals( Serializable[].class, types[0] );
- }
-
- @Test
- public void test_Get_Declared_Methods_With_Synthetic_Methods()
- throws Exception
- {
- List<Method> result = OgnlRuntime.getDeclaredMethods( SubclassSyntheticObject.class, "list", false );
-
- // synthetic method would be
- // "public volatile java.util.List org.ognl.test.objects.SubclassSyntheticObject.getList()",
- // causing method return size to be 3
-
- assertEquals( 2, result.size() );
- }
-
- @Test
- public void test_Get_Property_Descriptors_With_Synthetic_Methods()
- throws Exception
- {
- PropertyDescriptor propertyDescriptor = OgnlRuntime.getPropertyDescriptor( SubclassSyntheticObject.class, "list" );
-
- assert propertyDescriptor != null;
- assert OgnlRuntime.isMethodCallable( propertyDescriptor.getReadMethod() );
- }
-
- private static class GenericParent<T>
- {
- @SuppressWarnings( "unused" )
- public void save( T entity )
- {
-
- }
- }
-
- private static class StringChild
- extends GenericParent<String>
- {
-
- }
-
- private static class LongChild
- extends GenericParent<Long>
- {
-
- }
-
- /**
- * Tests OGNL parameter discovery.
- */
- @Test
- public void testOGNLParameterDiscovery()
- throws NoSuchMethodException, CacheException
- {
- Method saveMethod = GenericParent.class.getMethod( "save", Object.class );
- System.out.println( saveMethod );
-
- Class<?>[] longClass = OgnlRuntime.findParameterTypes( LongChild.class, saveMethod );
- assertNotSame( longClass[0], String.class );
- assertSame( longClass[0], Long.class );
-
- Class<?>[] stringClass = OgnlRuntime.findParameterTypes( StringChild.class, saveMethod );
- assertNotSame( "The cached parameter types from previous calls are used", stringClass[0], Long.class );
- assertSame( stringClass[0], String.class );
- }
-
- @Test
- public void testGetField()
- throws OgnlException
- {
- Field field = OgnlRuntime.getField( OtherObjectIndexed.class, "attributes" );
- assertNotNull( "Field is null", field );
- }
-
- @Test
- public void testGetSetMethod()
- throws IntrospectionException, OgnlException
- {
- Method setter = OgnlRuntime.getSetMethod( null, Bean1.class, "bean2" );
- Method getter = OgnlRuntime.getGetMethod( null, Bean1.class, "bean2" );
- assertNotNull( getter );
- assertNull( setter );
- }
-
- @Test
- public void testGetCompiler()
- {
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
- OgnlExpressionCompiler compiler1 = OgnlRuntime.getCompiler( context );
- context.put( "root2", new Root() );
- OgnlExpressionCompiler compiler2 = OgnlRuntime.getCompiler( context );
- assertSame( "compilers are not the same", compiler1, compiler2 );
- }
-
- @Test
- public void testGetPropertyDescriptorFromArray()
- throws Exception
- {
- PropertyDescriptor propertyDescriptor =
- OgnlRuntime.getPropertyDescriptorFromArray( Root.class, "disabled" );
- assertEquals( "disabled", propertyDescriptor.getName() );
- }
-}
+/*
+ * 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;
+
+import org.apache.commons.ognl.enhance.OgnlExpressionCompiler;
+import org.apache.commons.ognl.internal.CacheException;
+import org.apache.commons.ognl.test.objects.BaseGeneric;
+import org.apache.commons.ognl.test.objects.Bean1;
+import org.apache.commons.ognl.test.objects.Bean2;
+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.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.IForm;
+import org.apache.commons.ognl.test.objects.ListSource;
+import org.apache.commons.ognl.test.objects.ListSourceImpl;
+import org.apache.commons.ognl.test.objects.OtherObjectIndexed;
+import org.apache.commons.ognl.test.objects.Root;
+import org.apache.commons.ognl.test.objects.SetterReturns;
+import org.apache.commons.ognl.test.objects.SubclassSyntheticObject;
+import org.junit.Test;
+
+import java.beans.IntrospectionException;
+import java.beans.PropertyDescriptor;
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.List;
+
+import static junit.framework.Assert.*;
+
+/**
+ * Tests various methods / functionality of {@link org.apache.commons.ognl.OgnlRuntime}.
+ */
+public class TestOgnlRuntime
+{
+
+ @Test
+ public void test_Get_Super_Or_Interface_Class()
+ throws Exception
+ {
+ ListSource list = new ListSourceImpl();
+
+ Method method = OgnlRuntime.getReadMethod( list.getClass(), "total" );
+ assertNotNull( method );
+
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+ assertEquals( ListSource.class,
+ OgnlRuntime.getCompiler( context ).getSuperOrInterfaceClass( method, list.getClass() ) );
+ }
+
+ @Test
+ public void test_Get_Private_Class()
+ throws Exception
+ {
+ List<String> list = Arrays.asList( "hello", "world" );
+
+ Method m = OgnlRuntime.getReadMethod( list.getClass(), "iterator" );
+ assertNotNull( m );
+
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+ assertEquals( Iterable.class,
+ OgnlRuntime.getCompiler( context ).getSuperOrInterfaceClass( m, list.getClass() ) );
+ }
+
+ @Test
+ public void test_Complicated_Inheritance()
+ throws Exception
+ {
+ IForm form = new FormImpl();
+
+ Method method = OgnlRuntime.getWriteMethod( form.getClass(), "clientId" );
+ assertNotNull( method );
+
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+ assertEquals( IComponent.class,
+ OgnlRuntime.getCompiler( context ).getSuperOrInterfaceClass( method, form.getClass() ) );
+ }
+
+ @Test
+ public void test_Get_Read_Method()
+ throws Exception
+ {
+ Method method = OgnlRuntime.getReadMethod( Bean2.class, "pageBreakAfter" );
+ assertNotNull( method );
+
+ assertEquals( "isPageBreakAfter", method.getName() );
+ }
+
+ class TestGetters
+ {
+ public boolean isEditorDisabled()
+ {
+ return false;
+ }
+
+ public boolean isDisabled()
+ {
+ return true;
+ }
+
+ public boolean isNotAvailable()
+ {
+ return false;
+ }
+
+ public boolean isAvailable()
+ {
+ return true;
+ }
+ }
+
+ @Test
+ public void test_Get_Read_Method_Multiple()
+ throws Exception
+ {
+ Method method = OgnlRuntime.getReadMethod( TestGetters.class, "disabled" );
+ assertNotNull( method );
+
+ assertEquals( "isDisabled", method.getName() );
+ }
+
+ @Test
+ public void test_Get_Read_Method_Multiple_Boolean_Getters()
+ throws Exception
+ {
+ Method method = OgnlRuntime.getReadMethod( TestGetters.class, "available" );
+ assertNotNull( method );
+
+ assertEquals( "isAvailable", method.getName() );
+
+ method = OgnlRuntime.getReadMethod( TestGetters.class, "notAvailable" );
+ assertNotNull( method );
+
+ assertEquals( "isNotAvailable", method.getName() );
+ }
+
+ @Test
+ public void test_Find_Method_Mixed_Boolean_Getters()
+ throws Exception
+ {
+ Method method = OgnlRuntime.getReadMethod( GetterMethods.class, "allowDisplay" );
+ assertNotNull( method );
+
+ assertEquals( "getAllowDisplay", method.getName() );
+ }
+
+ @Test
+ public void test_Get_Appropriate_Method()
+ throws Exception
+ {
+ ListSource list = new ListSourceImpl();
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+
+ Object ret = OgnlRuntime.callMethod( context, list, "addValue", new String[]{ null } );
+
+ assert ret != null;
+ }
+
+ @Test
+ public void test_Call_Static_Method_Invalid_Class()
+ {
+
+ try
+ {
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+ OgnlRuntime.callStaticMethod( context, "made.up.Name", "foo", null );
+
+ fail( "ClassNotFoundException should have been thrown by previous reference to <made.up.Name> class." );
+ }
+ catch ( Exception et )
+ {
+ assertTrue( MethodFailedException.class.isInstance( et ) );
+ assertTrue( et.getMessage().contains( "made.up.Name" ) );
+ }
+ }
+
+ @Test
+ public void test_Setter_Returns()
+ throws Exception
+ {
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+ SetterReturns root = new SetterReturns();
+
+ Method m = OgnlRuntime.getWriteMethod( root.getClass(), "value" );
+ assertNotNull(m);
+
+ Ognl.setValue( "value", context, root, "12__" );
+ assertEquals( Ognl.getValue( "value", context, root ), "12__" );
+ }
+
+ @Test
+ public void test_Call_Method_VarArgs()
+ throws Exception
+ {
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+ GenericService service = new GenericServiceImpl();
+
+ GameGenericObject argument = new GameGenericObject();
+
+ Object[] args = new Object[2];
+ args[0] = argument;
+
+ assertEquals( "Halo 3", OgnlRuntime.callMethod( context, service, "getFullMessageFor", args ) );
+ }
+
+ @Test
+ public void test_Class_Cache_Inspector()
+ throws Exception
+ {
+ OgnlRuntime.cache.clear();
+
+ assertEquals( 0, OgnlRuntime.cache.propertyDescriptorCache.getSize() );
+
+ Root root = new Root();
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+ Node expr = Ognl.compileExpression( context, root, "property.bean3.value != null" );
+
+ assertTrue( (Boolean) expr.getAccessor().get( context, root ) );
+
+ int size = OgnlRuntime.cache.propertyDescriptorCache.getSize();
+ assertTrue( size > 0 );
+
+ OgnlRuntime.clearCache();
+ assertEquals( 0, OgnlRuntime.cache.propertyDescriptorCache.getSize() );
+
+ // now register class cache prevention
+
+ OgnlRuntime.setClassCacheInspector( new TestCacheInspector() );
+
+ expr = Ognl.compileExpression( context, root, "property.bean3.value != null" );
+ assertTrue( (Boolean) expr.getAccessor().get( context, root ) );
+
+ assertEquals( ( size - 1 ), OgnlRuntime.cache.propertyDescriptorCache.getSize() );
+ }
+
+ class TestCacheInspector
+ implements ClassCacheInspector
+ {
+
+ public boolean shouldCache( Class<?> type )
+ {
+ return !( type == null || type == Root.class );
+ }
+ }
+
+ @Test
+ public void test_Set_Generic_Parameter_Types()
+ throws Exception
+ {
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+
+ Method method = OgnlRuntime.getSetMethod( context, GenericCracker.class, "param" );
+ assertNotNull( method );
+
+ Class<?>[] types = method.getParameterTypes();
+ assertEquals( 1, types.length );
+ assertEquals( Integer.class, types[0] );
+ }
+
+ @Test
+ public void test_Get_Generic_Parameter_Types()
+ throws Exception
+ {
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+
+ Method method = OgnlRuntime.getGetMethod( context, GenericCracker.class, "param" );
+ assertNotNull( method );
+
+ assertEquals( Integer.class, method.getReturnType() );
+ }
+
+ @Test
+ public void test_Find_Parameter_Types()
+ throws Exception
+ {
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+
+ Method method = OgnlRuntime.getSetMethod( context, GameGeneric.class, "ids" );
+ assertNotNull( method );
+
+ Class<?>[] types = OgnlRuntime.findParameterTypes( GameGeneric.class, method );
+ assertEquals( 1, types.length );
+ assertEquals( Long[].class, types[0] );
+ }
+
+ @Test
+ public void test_Find_Parameter_Types_Superclass()
+ throws Exception
+ {
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+
+ Method method = OgnlRuntime.getSetMethod( context, BaseGeneric.class, "ids" );
+ assertNotNull( method );
+
+ Class<?>[] types = OgnlRuntime.findParameterTypes( BaseGeneric.class, method );
+ assertEquals( 1, types.length );
+ assertEquals( Serializable[].class, types[0] );
+ }
+
+ @Test
+ public void test_Get_Declared_Methods_With_Synthetic_Methods()
+ throws Exception
+ {
+ List<Method> result = OgnlRuntime.getDeclaredMethods( SubclassSyntheticObject.class, "list", false );
+
+ // synthetic method would be
+ // "public volatile java.util.List org.ognl.test.objects.SubclassSyntheticObject.getList()",
+ // causing method return size to be 3
+
+ assertEquals( 2, result.size() );
+ }
+
+ @Test
+ public void test_Get_Property_Descriptors_With_Synthetic_Methods()
+ throws Exception
+ {
+ PropertyDescriptor propertyDescriptor = OgnlRuntime.getPropertyDescriptor( SubclassSyntheticObject.class, "list" );
+
+ assert propertyDescriptor != null;
+ assert OgnlRuntime.isMethodCallable( propertyDescriptor.getReadMethod() );
+ }
+
+ private static class GenericParent<T>
+ {
+ @SuppressWarnings( "unused" )
+ public void save( T entity )
+ {
+
+ }
+ }
+
+ private static class StringChild
+ extends GenericParent<String>
+ {
+
+ }
+
+ private static class LongChild
+ extends GenericParent<Long>
+ {
+
+ }
+
+ /**
+ * Tests OGNL parameter discovery.
+ */
+ @Test
+ public void testOGNLParameterDiscovery()
+ throws NoSuchMethodException, CacheException
+ {
+ Method saveMethod = GenericParent.class.getMethod( "save", Object.class );
+ System.out.println( saveMethod );
+
+ Class<?>[] longClass = OgnlRuntime.findParameterTypes( LongChild.class, saveMethod );
+ assertNotSame( longClass[0], String.class );
+ assertSame( longClass[0], Long.class );
+
+ Class<?>[] stringClass = OgnlRuntime.findParameterTypes( StringChild.class, saveMethod );
+ assertNotSame( "The cached parameter types from previous calls are used", stringClass[0], Long.class );
+ assertSame( stringClass[0], String.class );
+ }
+
+ @Test
+ public void testGetField()
+ throws OgnlException
+ {
+ Field field = OgnlRuntime.getField( OtherObjectIndexed.class, "attributes" );
+ assertNotNull( "Field is null", field );
+ }
+
+ @Test
+ public void testGetSetMethod()
+ throws IntrospectionException, OgnlException
+ {
+ Method setter = OgnlRuntime.getSetMethod( null, Bean1.class, "bean2" );
+ Method getter = OgnlRuntime.getGetMethod( null, Bean1.class, "bean2" );
+ assertNotNull( getter );
+ assertNull( setter );
+ }
+
+ @Test
+ public void testGetCompiler()
+ {
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+ OgnlExpressionCompiler compiler1 = OgnlRuntime.getCompiler( context );
+ context.put( "root2", new Root() );
+ OgnlExpressionCompiler compiler2 = OgnlRuntime.getCompiler( context );
+ assertSame( "compilers are not the same", compiler1, compiler2 );
+ }
+
+ @Test
+ public void testGetPropertyDescriptorFromArray()
+ throws Exception
+ {
+ PropertyDescriptor propertyDescriptor =
+ OgnlRuntime.getPropertyDescriptorFromArray( Root.class, "disabled" );
+ assertEquals( "disabled", propertyDescriptor.getName() );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/internal/ConcurrentHashMapCacheTest.java b/src/test/java/org/apache/commons/ognl/internal/ConcurrentHashMapCacheTest.java
index a7861d1..7549068 100644
--- a/src/test/java/org/apache/commons/ognl/internal/ConcurrentHashMapCacheTest.java
+++ b/src/test/java/org/apache/commons/ognl/internal/ConcurrentHashMapCacheTest.java
@@ -1,101 +1,100 @@
-/*
- * $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.internal;
-
-import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
-import org.apache.commons.ognl.test.objects.Bean2;
-import org.junit.Test;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-import static junit.framework.Assert.assertNotNull;
-import static org.junit.Assert.assertFalse;
-
-public class ConcurrentHashMapCacheTest
-{
- private final ConcurrentHashMapCacheTest.DummyEntryFactory entryFactory=new DummyEntryFactory( );
- private final Cache<CacheEntry, List<Method>> cache = new ConcurrentHashMapCache<CacheEntry, List<Method>>( entryFactory );
-
-
- @Test
- public void testGet( )
- throws Exception
- {
-
- getMethods( new CacheEntry( Bean2.class, "bean3" ) );
- getMethods( new CacheEntry( Bean2.class, "id" ) );
- }
-
- private void getMethods( CacheEntry entry )
- throws CacheException
- {
- List<Method> methods = cache.get( entry);
- assertNotNull( methods );
- assertFalse( methods.isEmpty( ) );
- }
-
- private class CacheEntry
- {
- private final Class<?> clazz;
-
- private final String methodName;
-
- private CacheEntry( Class<?> clazz, String methodName )
- {
- this.clazz = clazz;
- this.methodName = methodName;
- }
-
- public Class<?> getClazz( )
- {
- return clazz;
- }
-
- public String getMethodName( )
- {
- return methodName;
- }
- }
-
- private class DummyEntryFactory
- implements CacheEntryFactory<CacheEntry, List<Method>>
- {
- public List<Method> create( CacheEntry key )
- throws CacheException
- {
- Method[] methods = key.getClazz( ).getMethods( );
- List<Method> list = new ArrayList<Method>( );
- for ( Method method : methods )
- {
- String name = method.getName( );
- boolean isGet = name.substring( 3 ).equalsIgnoreCase( key.getMethodName( ) );
- if ( isGet )
- {
- list.add( method );
- }
- }
- return list;
- }
- }
-}
+/*
+ *
+ * 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.internal;
+
+import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
+import org.apache.commons.ognl.test.objects.Bean2;
+import org.junit.Test;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import static junit.framework.Assert.assertNotNull;
+import static org.junit.Assert.assertFalse;
+
+public class ConcurrentHashMapCacheTest
+{
+ private final ConcurrentHashMapCacheTest.DummyEntryFactory entryFactory=new DummyEntryFactory( );
+ private final Cache<CacheEntry, List<Method>> cache = new ConcurrentHashMapCache<CacheEntry, List<Method>>( entryFactory );
+
+
+ @Test
+ public void testGet( )
+ throws Exception
+ {
+
+ getMethods( new CacheEntry( Bean2.class, "bean3" ) );
+ getMethods( new CacheEntry( Bean2.class, "id" ) );
+ }
+
+ private void getMethods( CacheEntry entry )
+ throws CacheException
+ {
+ List<Method> methods = cache.get( entry);
+ assertNotNull( methods );
+ assertFalse( methods.isEmpty( ) );
+ }
+
+ private class CacheEntry
+ {
+ private final Class<?> clazz;
+
+ private final String methodName;
+
+ private CacheEntry( Class<?> clazz, String methodName )
+ {
+ this.clazz = clazz;
+ this.methodName = methodName;
+ }
+
+ public Class<?> getClazz( )
+ {
+ return clazz;
+ }
+
+ public String getMethodName( )
+ {
+ return methodName;
+ }
+ }
+
+ private class DummyEntryFactory
+ implements CacheEntryFactory<CacheEntry, List<Method>>
+ {
+ public List<Method> create( CacheEntry key )
+ throws CacheException
+ {
+ Method[] methods = key.getClazz( ).getMethods( );
+ List<Method> list = new ArrayList<Method>( );
+ for ( Method method : methods )
+ {
+ String name = method.getName( );
+ boolean isGet = name.substring( 3 ).equalsIgnoreCase( key.getMethodName( ) );
+ if ( isGet )
+ {
+ list.add( method );
+ }
+ }
+ return list;
+ }
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/internal/ConstructorCacheTest.java b/src/test/java/org/apache/commons/ognl/internal/ConstructorCacheTest.java
index fa9c8cc..7f94d58 100644
--- a/src/test/java/org/apache/commons/ognl/internal/ConstructorCacheTest.java
+++ b/src/test/java/org/apache/commons/ognl/internal/ConstructorCacheTest.java
@@ -1,57 +1,56 @@
-/*
- * $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.internal;
-
-import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
-import org.apache.commons.ognl.test.objects.Root;
-import org.junit.Test;
-
-import java.lang.reflect.Constructor;
-import java.util.Arrays;
-import java.util.List;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
-
-public class ConstructorCacheTest
-{
- private int count;
- ClassCache<List<Constructor<?>>> cache = new ConcurrentHashMapClassCache<List<Constructor<?>>>(new CacheEntryFactory<Class<?>, List<Constructor<?>>>( )
- {
- public List<Constructor<?>> create( Class<?> key )
- throws CacheException
- {
- count++;
- return Arrays.<Constructor<?>>asList( key.getConstructors( ) );
- }
- });
-
- @Test
- public void testGet()
- throws CacheException
- {
- List<Constructor<?>> constructors = cache.get( Root.class );
- assertNotNull( constructors );
- cache.get( Root.class );
- assertEquals( 1, count);
- }
-}
+/*
+ *
+ * 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.internal;
+
+import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
+import org.apache.commons.ognl.test.objects.Root;
+import org.junit.Test;
+
+import java.lang.reflect.Constructor;
+import java.util.Arrays;
+import java.util.List;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+
+public class ConstructorCacheTest
+{
+ private int count;
+ ClassCache<List<Constructor<?>>> cache = new ConcurrentHashMapClassCache<List<Constructor<?>>>(new CacheEntryFactory<Class<?>, List<Constructor<?>>>( )
+ {
+ public List<Constructor<?>> create( Class<?> key )
+ throws CacheException
+ {
+ count++;
+ return Arrays.<Constructor<?>>asList( key.getConstructors( ) );
+ }
+ });
+
+ @Test
+ public void testGet()
+ throws CacheException
+ {
+ List<Constructor<?>> constructors = cache.get( Root.class );
+ assertNotNull( constructors );
+ cache.get( Root.class );
+ assertEquals( 1, count);
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/internal/DeclaredMethodCacheTest.java b/src/test/java/org/apache/commons/ognl/internal/DeclaredMethodCacheTest.java
index 453dc4f..87d5a19 100644
--- a/src/test/java/org/apache/commons/ognl/internal/DeclaredMethodCacheTest.java
+++ b/src/test/java/org/apache/commons/ognl/internal/DeclaredMethodCacheTest.java
@@ -1,64 +1,63 @@
-/*
- * $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.internal;
-
-import org.apache.commons.ognl.internal.entry.DeclaredMethodCacheEntry;
-import org.apache.commons.ognl.internal.entry.DeclaredMethodCacheEntryFactory;
-import org.apache.commons.ognl.test.objects.Root;
-import org.junit.Test;
-
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.Map;
-
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertTrue;
-
-/**
- * User: Maurizio Cucchiara
- * Date: 10/15/11
- * Time: 9:18 AM
- */
-public class DeclaredMethodCacheTest
-{
- Cache<DeclaredMethodCacheEntry, Map<String, List<Method>>> cache =
- new ConcurrentHashMapCache<DeclaredMethodCacheEntry, Map<String, List<Method>>>(new DeclaredMethodCacheEntryFactory( ) );
-
- @Test
- public void testStaticGet( )
- throws Exception
- {
- Map<String, List<Method>> methods = cache.get( new DeclaredMethodCacheEntry( Root.class, DeclaredMethodCacheEntry.MethodType.STATIC) );
- assertNotNull( methods );
- assertTrue( methods.containsKey( "getStaticInt" ) );
- }
-
- @Test
- public void testNonStaticGet( )
- throws Exception
- {
- Map<String, List<Method>> methods = cache.get( new DeclaredMethodCacheEntry( Root.class, DeclaredMethodCacheEntry.MethodType.NON_STATIC ) );
- assertNotNull( methods );
- assertTrue( methods.containsKey( "format" ) );
- }
-
-}
+/*
+ *
+ * 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.internal;
+
+import org.apache.commons.ognl.internal.entry.DeclaredMethodCacheEntry;
+import org.apache.commons.ognl.internal.entry.DeclaredMethodCacheEntryFactory;
+import org.apache.commons.ognl.test.objects.Root;
+import org.junit.Test;
+
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Map;
+
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+
+/**
+ * User: Maurizio Cucchiara
+ * Date: 10/15/11
+ * Time: 9:18 AM
+ */
+public class DeclaredMethodCacheTest
+{
+ Cache<DeclaredMethodCacheEntry, Map<String, List<Method>>> cache =
+ new ConcurrentHashMapCache<DeclaredMethodCacheEntry, Map<String, List<Method>>>(new DeclaredMethodCacheEntryFactory( ) );
+
+ @Test
+ public void testStaticGet( )
+ throws Exception
+ {
+ Map<String, List<Method>> methods = cache.get( new DeclaredMethodCacheEntry( Root.class, DeclaredMethodCacheEntry.MethodType.STATIC) );
+ assertNotNull( methods );
+ assertTrue( methods.containsKey( "getStaticInt" ) );
+ }
+
+ @Test
+ public void testNonStaticGet( )
+ throws Exception
+ {
+ Map<String, List<Method>> methods = cache.get( new DeclaredMethodCacheEntry( Root.class, DeclaredMethodCacheEntry.MethodType.NON_STATIC ) );
+ assertNotNull( methods );
+ assertTrue( methods.containsKey( "format" ) );
+ }
+
+}
diff --git a/src/test/java/org/apache/commons/ognl/internal/FieldCacheTest.java b/src/test/java/org/apache/commons/ognl/internal/FieldCacheTest.java
index d1e5e6a..253667a 100644
--- a/src/test/java/org/apache/commons/ognl/internal/FieldCacheTest.java
+++ b/src/test/java/org/apache/commons/ognl/internal/FieldCacheTest.java
@@ -1,60 +1,59 @@
-/*
- * $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.internal;
-
-import org.apache.commons.ognl.internal.entry.FieldCacheEntryFactory;
-import org.apache.commons.ognl.test.objects.Bean2;
-import org.junit.Test;
-
-import java.lang.reflect.Field;
-import java.util.Map;
-
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertTrue;
-
-/**
- * User: Maurizio Cucchiara
- * Date: 10/15/11
- * Time: 8:00 AM
- */
-public class FieldCacheTest
-{
- ConcurrentHashMapCache<Class<?>, Map<String,Field>> cache =
- new ConcurrentHashMapCache<Class<?>, Map<String,Field>>( new FieldCacheEntryFactory());
-
- @Test
- public void testGet( )
- throws Exception
- {
- Map<String, Field> d = getFields( Bean2.class );
- assertTrue( d.containsKey( "bean3" ) );
- assertTrue( d.containsKey( "_pageBreakAfter" ) );
- }
-
- private Map<String, Field> getFields( Class<?> entry )
- throws CacheException
- {
- Map<String, Field> descriptor = cache.get( entry );
- assertNotNull( descriptor );
- return descriptor;
- }
-}
+/*
+ *
+ * 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.internal;
+
+import org.apache.commons.ognl.internal.entry.FieldCacheEntryFactory;
+import org.apache.commons.ognl.test.objects.Bean2;
+import org.junit.Test;
+
+import java.lang.reflect.Field;
+import java.util.Map;
+
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+
+/**
+ * User: Maurizio Cucchiara
+ * Date: 10/15/11
+ * Time: 8:00 AM
+ */
+public class FieldCacheTest
+{
+ ConcurrentHashMapCache<Class<?>, Map<String,Field>> cache =
+ new ConcurrentHashMapCache<Class<?>, Map<String,Field>>( new FieldCacheEntryFactory());
+
+ @Test
+ public void testGet( )
+ throws Exception
+ {
+ Map<String, Field> d = getFields( Bean2.class );
+ assertTrue( d.containsKey( "bean3" ) );
+ assertTrue( d.containsKey( "_pageBreakAfter" ) );
+ }
+
+ private Map<String, Field> getFields( Class<?> entry )
+ throws CacheException
+ {
+ Map<String, Field> descriptor = cache.get( entry );
+ assertNotNull( descriptor );
+ return descriptor;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/internal/GenericMethodParameterTypeCacheTest.java b/src/test/java/org/apache/commons/ognl/internal/GenericMethodParameterTypeCacheTest.java
index b600b54..7dc211e 100644
--- a/src/test/java/org/apache/commons/ognl/internal/GenericMethodParameterTypeCacheTest.java
+++ b/src/test/java/org/apache/commons/ognl/internal/GenericMethodParameterTypeCacheTest.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.internal;
-
-import org.apache.commons.ognl.internal.entry.GenericMethodParameterTypeCacheEntry;
-import org.apache.commons.ognl.internal.entry.GenericMethodParameterTypeFactory;
-import org.apache.commons.ognl.test.objects.GameGeneric;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-
-/**
- * User: Maurizio Cucchiara
- * Date: 10/16/11
- * Time: 9:44 AM
- */
-public class GenericMethodParameterTypeCacheTest
-{
- private final ConcurrentHashMapCache<GenericMethodParameterTypeCacheEntry, Class<?>[]> cache =
- new ConcurrentHashMapCache<GenericMethodParameterTypeCacheEntry, Class<?>[]>( new GenericMethodParameterTypeFactory( ) );
-
- @Test
- public void testGet( )
- throws NoSuchMethodException, CacheException
- {
- Method m = GameGeneric.class.getMethod( "setIds", Serializable[].class );
- Class type = GameGeneric.class;
- Class<?>[] types = cache.get( new GenericMethodParameterTypeCacheEntry( m, type ) );
-
- Assert.assertEquals( 1, types.length );
- Assert.assertEquals( Long[].class, types[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.internal;
+
+import org.apache.commons.ognl.internal.entry.GenericMethodParameterTypeCacheEntry;
+import org.apache.commons.ognl.internal.entry.GenericMethodParameterTypeFactory;
+import org.apache.commons.ognl.test.objects.GameGeneric;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+
+/**
+ * User: Maurizio Cucchiara
+ * Date: 10/16/11
+ * Time: 9:44 AM
+ */
+public class GenericMethodParameterTypeCacheTest
+{
+ private final ConcurrentHashMapCache<GenericMethodParameterTypeCacheEntry, Class<?>[]> cache =
+ new ConcurrentHashMapCache<GenericMethodParameterTypeCacheEntry, Class<?>[]>( new GenericMethodParameterTypeFactory( ) );
+
+ @Test
+ public void testGet( )
+ throws NoSuchMethodException, CacheException
+ {
+ Method m = GameGeneric.class.getMethod( "setIds", Serializable[].class );
+ Class type = GameGeneric.class;
+ Class<?>[] types = cache.get( new GenericMethodParameterTypeCacheEntry( m, type ) );
+
+ Assert.assertEquals( 1, types.length );
+ Assert.assertEquals( Long[].class, types[0] );
+ }
+
+}
diff --git a/src/test/java/org/apache/commons/ognl/internal/MethodAccessCacheTest.java b/src/test/java/org/apache/commons/ognl/internal/MethodAccessCacheTest.java
index d0938a1..0317811 100644
--- a/src/test/java/org/apache/commons/ognl/internal/MethodAccessCacheTest.java
+++ b/src/test/java/org/apache/commons/ognl/internal/MethodAccessCacheTest.java
@@ -1,73 +1,72 @@
-/*
- * $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.internal;
-
-import org.apache.commons.ognl.internal.entry.MethodAccessCacheEntryFactory;
-import org.apache.commons.ognl.internal.entry.MethodAccessEntryValue;
-import org.apache.commons.ognl.test.objects.Root;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.lang.reflect.Method;
-
-/**
- * User: Maurizio Cucchiara
- * Date: 10/17/11
- * Time: 12:59 AM
- */
-public class MethodAccessCacheTest
-{
- private final Cache<Method, MethodAccessEntryValue> cache =
- new ConcurrentHashMapCache<Method, MethodAccessEntryValue>( new MethodAccessCacheEntryFactory( ) );
-
- @Test
- public void testGetAccessibleNonPublicMethod( )
- throws Exception
- {
- Method method = Root.class.getDeclaredMethod( "getPrivateAccessorIntValue3" );
- MethodAccessEntryValue methodAccessValue = cache.get( method );
- Assert.assertTrue( methodAccessValue.isNotPublic( ) );
- Assert.assertFalse( methodAccessValue.isAccessible());
- }
-
- @Test
- public void testGetNotAccessibleNonPublicMethod( )
- throws Exception
- {
- Method method = Root.class.getDeclaredMethod( "getPrivateAccessorIntValue3" );
- method.setAccessible( true );
- MethodAccessEntryValue methodAccessValue = cache.get( method );
- Assert.assertTrue( methodAccessValue.isNotPublic( ) );
- Assert.assertTrue( methodAccessValue.isAccessible());
- }
-
- @Test
- public void testGetPublicMethod( )
- throws NoSuchMethodException, CacheException
- {
- Method method = Root.class.getDeclaredMethod( "getArray" );
- MethodAccessEntryValue methodAccessValue = cache.get( method );
- Assert.assertFalse( methodAccessValue.isNotPublic( ) );
- Assert.assertTrue( methodAccessValue.isAccessible());
- }
-
-}
+/*
+ *
+ * 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.internal;
+
+import org.apache.commons.ognl.internal.entry.MethodAccessCacheEntryFactory;
+import org.apache.commons.ognl.internal.entry.MethodAccessEntryValue;
+import org.apache.commons.ognl.test.objects.Root;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.lang.reflect.Method;
+
+/**
+ * User: Maurizio Cucchiara
+ * Date: 10/17/11
+ * Time: 12:59 AM
+ */
+public class MethodAccessCacheTest
+{
+ private final Cache<Method, MethodAccessEntryValue> cache =
+ new ConcurrentHashMapCache<Method, MethodAccessEntryValue>( new MethodAccessCacheEntryFactory( ) );
+
+ @Test
+ public void testGetAccessibleNonPublicMethod( )
+ throws Exception
+ {
+ Method method = Root.class.getDeclaredMethod( "getPrivateAccessorIntValue3" );
+ MethodAccessEntryValue methodAccessValue = cache.get( method );
+ Assert.assertTrue( methodAccessValue.isNotPublic( ) );
+ Assert.assertFalse( methodAccessValue.isAccessible());
+ }
+
+ @Test
+ public void testGetNotAccessibleNonPublicMethod( )
+ throws Exception
+ {
+ Method method = Root.class.getDeclaredMethod( "getPrivateAccessorIntValue3" );
+ method.setAccessible( true );
+ MethodAccessEntryValue methodAccessValue = cache.get( method );
+ Assert.assertTrue( methodAccessValue.isNotPublic( ) );
+ Assert.assertTrue( methodAccessValue.isAccessible());
+ }
+
+ @Test
+ public void testGetPublicMethod( )
+ throws NoSuchMethodException, CacheException
+ {
+ Method method = Root.class.getDeclaredMethod( "getArray" );
+ MethodAccessEntryValue methodAccessValue = cache.get( method );
+ Assert.assertFalse( methodAccessValue.isNotPublic( ) );
+ Assert.assertTrue( methodAccessValue.isAccessible());
+ }
+
+}
diff --git a/src/test/java/org/apache/commons/ognl/internal/MethodPermCacheTest.java b/src/test/java/org/apache/commons/ognl/internal/MethodPermCacheTest.java
index 728c057..e8fb2b0 100644
--- a/src/test/java/org/apache/commons/ognl/internal/MethodPermCacheTest.java
+++ b/src/test/java/org/apache/commons/ognl/internal/MethodPermCacheTest.java
@@ -1,83 +1,82 @@
-/*
- * $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.internal;
-
-import org.apache.commons.ognl.internal.entry.MethodPermCacheEntryFactory;
-import org.apache.commons.ognl.test.objects.Root;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.lang.reflect.Method;
-import java.security.Permission;
-
-/**
- * User: Maurizio Cucchiara
- * Date: 10/17/11
- * Time: 12:13 AM
- */
-public class MethodPermCacheTest {
- private final SecurityManager allowAllSecurityManager = new AllowAllSecurityManager();
- private final SecurityManager denyAllSecurityManager = new DenyAllSecurityManager();
-
- private Cache<Method, Boolean> createCache(SecurityManager securityManager) {
- return new ConcurrentHashMapCache<Method, Boolean>(new MethodPermCacheEntryFactory(securityManager) );
- }
-
- @Test
- public void testGetPublicMethod_returnsTrue( )
- throws CacheException, NoSuchMethodException
- {
- Cache<Method, Boolean> cache = createCache(allowAllSecurityManager);
-
- Method method = Root.class.getMethod( "getArray");
- Assert.assertTrue( cache.get( method ) );
- }
-
- @Test
- public void testGetPublicMethod_returnsFalse( )
- throws CacheException, NoSuchMethodException
- {
- Cache<Method, Boolean> cache = createCache(denyAllSecurityManager);
- Method method = Root.class.getMethod( "getArray");
-
- Assert.assertFalse( cache.get( method ) );
- }
-
- private class AllowAllSecurityManager
- extends SecurityManager
- {
- @Override
- public void checkPermission( Permission perm )
- {
- }
- }
-
- private class DenyAllSecurityManager
- extends SecurityManager
- {
- @Override
- public void checkPermission( Permission perm )
- {
- throw new SecurityException("Denied.");
- }
- }
-}
+/*
+ *
+ * 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.internal;
+
+import org.apache.commons.ognl.internal.entry.MethodPermCacheEntryFactory;
+import org.apache.commons.ognl.test.objects.Root;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.lang.reflect.Method;
+import java.security.Permission;
+
+/**
+ * User: Maurizio Cucchiara
+ * Date: 10/17/11
+ * Time: 12:13 AM
+ */
+public class MethodPermCacheTest {
+ private final SecurityManager allowAllSecurityManager = new AllowAllSecurityManager();
+ private final SecurityManager denyAllSecurityManager = new DenyAllSecurityManager();
+
+ private Cache<Method, Boolean> createCache(SecurityManager securityManager) {
+ return new ConcurrentHashMapCache<Method, Boolean>(new MethodPermCacheEntryFactory(securityManager) );
+ }
+
+ @Test
+ public void testGetPublicMethod_returnsTrue( )
+ throws CacheException, NoSuchMethodException
+ {
+ Cache<Method, Boolean> cache = createCache(allowAllSecurityManager);
+
+ Method method = Root.class.getMethod( "getArray");
+ Assert.assertTrue( cache.get( method ) );
+ }
+
+ @Test
+ public void testGetPublicMethod_returnsFalse( )
+ throws CacheException, NoSuchMethodException
+ {
+ Cache<Method, Boolean> cache = createCache(denyAllSecurityManager);
+ Method method = Root.class.getMethod( "getArray");
+
+ Assert.assertFalse( cache.get( method ) );
+ }
+
+ private class AllowAllSecurityManager
+ extends SecurityManager
+ {
+ @Override
+ public void checkPermission( Permission perm )
+ {
+ }
+ }
+
+ private class DenyAllSecurityManager
+ extends SecurityManager
+ {
+ @Override
+ public void checkPermission( Permission perm )
+ {
+ throw new SecurityException("Denied.");
+ }
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/internal/PermissionCacheTest.java b/src/test/java/org/apache/commons/ognl/internal/PermissionCacheTest.java
index bb96284..f70650c 100644
--- a/src/test/java/org/apache/commons/ognl/internal/PermissionCacheTest.java
+++ b/src/test/java/org/apache/commons/ognl/internal/PermissionCacheTest.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.internal;
-
-import org.apache.commons.ognl.internal.entry.PermissionCacheEntry;
-import org.apache.commons.ognl.internal.entry.PermissionCacheEntryFactory;
-import org.apache.commons.ognl.test.objects.Bean2;
-import org.junit.Test;
-
-import java.security.Permission;
-
-import static junit.framework.Assert.assertNotNull;
-
-/**
- * User: Maurizio Cucchiara
- * Date: 10/15/11
- * Time: 8:00 AM
- */
-public class PermissionCacheTest
-{
- ConcurrentHashMapCache<PermissionCacheEntry, Permission> cache =
- new ConcurrentHashMapCache<PermissionCacheEntry, Permission>( new PermissionCacheEntryFactory());
-
- @Test
- public void testGet( )
- throws Exception
- {
-
- getPermission( new PermissionCacheEntry( Bean2.class.getMethod( "getBean3" ) ) );
- getPermission( new PermissionCacheEntry( Bean2.class.getMethod( "getId" ) ) );
- }
-
- private void getPermission( PermissionCacheEntry entry )
- throws CacheException
- {
- Permission permission = cache.get( entry );
- assertNotNull( permission );
- }
-}
+/*
+ *
+ * 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.internal;
+
+import org.apache.commons.ognl.internal.entry.PermissionCacheEntry;
+import org.apache.commons.ognl.internal.entry.PermissionCacheEntryFactory;
+import org.apache.commons.ognl.test.objects.Bean2;
+import org.junit.Test;
+
+import java.security.Permission;
+
+import static junit.framework.Assert.assertNotNull;
+
+/**
+ * User: Maurizio Cucchiara
+ * Date: 10/15/11
+ * Time: 8:00 AM
+ */
+public class PermissionCacheTest
+{
+ ConcurrentHashMapCache<PermissionCacheEntry, Permission> cache =
+ new ConcurrentHashMapCache<PermissionCacheEntry, Permission>( new PermissionCacheEntryFactory());
+
+ @Test
+ public void testGet( )
+ throws Exception
+ {
+
+ getPermission( new PermissionCacheEntry( Bean2.class.getMethod( "getBean3" ) ) );
+ getPermission( new PermissionCacheEntry( Bean2.class.getMethod( "getId" ) ) );
+ }
+
+ private void getPermission( PermissionCacheEntry entry )
+ throws CacheException
+ {
+ Permission permission = cache.get( entry );
+ assertNotNull( permission );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/internal/PropertyDescriptorCacheTest.java b/src/test/java/org/apache/commons/ognl/internal/PropertyDescriptorCacheTest.java
index 7728dc1..d16fbcf 100644
--- a/src/test/java/org/apache/commons/ognl/internal/PropertyDescriptorCacheTest.java
+++ b/src/test/java/org/apache/commons/ognl/internal/PropertyDescriptorCacheTest.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.internal;
-
-import org.apache.commons.ognl.internal.entry.PropertyDescriptorCacheEntryFactory;
-import org.apache.commons.ognl.test.objects.Bean2;
-import org.junit.Test;
-
-import java.beans.PropertyDescriptor;
-import java.util.Map;
-
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertTrue;
-
-/**
- * User: Maurizio Cucchiara
- * Date: 10/15/11
- * Time: 8:00 AM
- */
-public class PropertyDescriptorCacheTest
-{
- ConcurrentHashMapCache<Class<?>, Map<String,PropertyDescriptor>> cache =
- new ConcurrentHashMapCache<Class<?>, Map<String,PropertyDescriptor>>( new PropertyDescriptorCacheEntryFactory());
-
- @Test
- public void testGet( )
- throws Exception
- {
- Map<String, PropertyDescriptor> d = getPropertyDescriptor( Bean2.class );
- assertTrue( d.containsKey( "id" ) );
- assertTrue( d.containsKey( "bean3" ) );
- assertTrue( d.containsKey( "carrier" ) );
- }
-
- private Map<String, PropertyDescriptor> getPropertyDescriptor( Class<?> entry )
- throws CacheException
- {
- Map<String, PropertyDescriptor> descriptor = cache.get( entry );
- assertNotNull( descriptor );
- return descriptor;
- }
-}
+/*
+ *
+ * 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.internal;
+
+import org.apache.commons.ognl.internal.entry.PropertyDescriptorCacheEntryFactory;
+import org.apache.commons.ognl.test.objects.Bean2;
+import org.junit.Test;
+
+import java.beans.PropertyDescriptor;
+import java.util.Map;
+
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+
+/**
+ * User: Maurizio Cucchiara
+ * Date: 10/15/11
+ * Time: 8:00 AM
+ */
+public class PropertyDescriptorCacheTest
+{
+ ConcurrentHashMapCache<Class<?>, Map<String,PropertyDescriptor>> cache =
+ new ConcurrentHashMapCache<Class<?>, Map<String,PropertyDescriptor>>( new PropertyDescriptorCacheEntryFactory());
+
+ @Test
+ public void testGet( )
+ throws Exception
+ {
+ Map<String, PropertyDescriptor> d = getPropertyDescriptor( Bean2.class );
+ assertTrue( d.containsKey( "id" ) );
+ assertTrue( d.containsKey( "bean3" ) );
+ assertTrue( d.containsKey( "carrier" ) );
+ }
+
+ private Map<String, PropertyDescriptor> getPropertyDescriptor( Class<?> entry )
+ throws CacheException
+ {
+ Map<String, PropertyDescriptor> descriptor = cache.get( entry );
+ assertNotNull( descriptor );
+ return descriptor;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/ASTChainTest.java b/src/test/java/org/apache/commons/ognl/test/ASTChainTest.java
index 0bf51aa..4551b0a 100644
--- a/src/test/java/org/apache/commons/ognl/test/ASTChainTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/ASTChainTest.java
@@ -1,44 +1,43 @@
-/*
- * $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.test;
-
-import junit.framework.TestCase;
-import org.apache.commons.ognl.Ognl;
-import org.apache.commons.ognl.OgnlContext;
-import org.apache.commons.ognl.test.objects.IndexedSetObject;
-
-/**
- * Tests for {@link org.apache.commons.ognl.ASTChain}.
- */
-public class ASTChainTest extends TestCase {
-
- public void test_Get_Indexed_Value() throws Exception {
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null);
- IndexedSetObject root = new IndexedSetObject();
-
- String expr = "thing[\"x\"].val";
-
- assertEquals(1, (int) Ognl.getValue(expr, context, root));
-
- Ognl.setValue(expr, context, root, 2);
-
- assertEquals(2, (int) Ognl.getValue(expr, context, root));
- }
-}
+/*
+ * 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.test;
+
+import junit.framework.TestCase;
+import org.apache.commons.ognl.Ognl;
+import org.apache.commons.ognl.OgnlContext;
+import org.apache.commons.ognl.test.objects.IndexedSetObject;
+
+/**
+ * Tests for {@link org.apache.commons.ognl.ASTChain}.
+ */
+public class ASTChainTest extends TestCase {
+
+ public void test_Get_Indexed_Value() throws Exception {
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null);
+ IndexedSetObject root = new IndexedSetObject();
+
+ String expr = "thing[\"x\"].val";
+
+ assertEquals(1, (int) Ognl.getValue(expr, context, root));
+
+ Ognl.setValue(expr, context, root, 2);
+
+ assertEquals(2, (int) Ognl.getValue(expr, context, root));
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/ASTMethodTest.java b/src/test/java/org/apache/commons/ognl/test/ASTMethodTest.java
index 8201c12..58e2011 100644
--- a/src/test/java/org/apache/commons/ognl/test/ASTMethodTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/ASTMethodTest.java
@@ -1,85 +1,84 @@
-/*
- * $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.test;
-
-import junit.framework.TestCase;
-import org.apache.commons.ognl.*;
-import org.apache.commons.ognl.enhance.ExpressionCompiler;
-import org.apache.commons.ognl.test.objects.Bean2;
-import org.apache.commons.ognl.test.objects.Bean3;
-import org.apache.commons.ognl.test.objects.Root;
-
-import java.util.Map;
-
-/**
- * Tests {@link org.apache.commons.ognl.ASTMethod}.
- */
-public class ASTMethodTest
- extends TestCase
-{
-
- public void test_Context_Types()
- throws Throwable
- {
- ASTMethod p = new ASTMethod( 0 );
- p.setMethodName( "get" );
-
- ASTConst pRef = new ASTConst( 0 );
- pRef.setValue( "value" );
- p.jjtAddChild( pRef, 0 );
-
- Root root = new Root();
-
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
- context.setRoot( root.getMap() );
- context.setCurrentObject( root.getMap() );
- context.setCurrentType( root.getMap().getClass() );
-
- assertEquals( p.toGetSourceString( context, root.getMap() ), ".get(\"value\")" );
- assertEquals( context.getCurrentType(), Object.class );
- assertEquals( root.getMap().get( "value" ), context.getCurrentObject() );
- assert Map.class.isAssignableFrom( context.getCurrentAccessor() );
- assert Map.class.isAssignableFrom( context.getPreviousType() );
- assert context.getPreviousAccessor() == null;
-
- assertEquals( OgnlRuntime.getCompiler( context ).castExpression( context, p, ".get(\"value\")" ), ".get(\"value\")" );
- assert context.get( ExpressionCompiler.PRE_CAST ) == null;
-
- // now test one context level further to see casting work properly on base object types
-
- ASTProperty prop = new ASTProperty( 0 );
- ASTConst propRef = new ASTConst( 0 );
- propRef.setValue( "bean3" );
- prop.jjtAddChild( propRef, 0 );
-
- Bean2 val = (Bean2) root.getMap().get( "value" );
-
- assertEquals( prop.toGetSourceString( context, root.getMap().get( "value" ) ), ".getBean3()" );
-
- assertEquals( context.getCurrentObject(), val.getBean3() );
- assertEquals( context.getCurrentType(), Bean3.class );
- assertEquals( context.getCurrentAccessor(), Bean2.class );
- assertEquals( Object.class, context.getPreviousType() );
- assert Map.class.isAssignableFrom( context.getPreviousAccessor() );
-
- assertEquals( OgnlRuntime.getCompiler( context ).castExpression( context, prop, ".getBean3()" ), ").getBean3()" );
-
- }
-}
+/*
+ * 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.test;
+
+import junit.framework.TestCase;
+import org.apache.commons.ognl.*;
+import org.apache.commons.ognl.enhance.ExpressionCompiler;
+import org.apache.commons.ognl.test.objects.Bean2;
+import org.apache.commons.ognl.test.objects.Bean3;
+import org.apache.commons.ognl.test.objects.Root;
+
+import java.util.Map;
+
+/**
+ * Tests {@link org.apache.commons.ognl.ASTMethod}.
+ */
+public class ASTMethodTest
+ extends TestCase
+{
+
+ public void test_Context_Types()
+ throws Throwable
+ {
+ ASTMethod p = new ASTMethod( 0 );
+ p.setMethodName( "get" );
+
+ ASTConst pRef = new ASTConst( 0 );
+ pRef.setValue( "value" );
+ p.jjtAddChild( pRef, 0 );
+
+ Root root = new Root();
+
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+ context.setRoot( root.getMap() );
+ context.setCurrentObject( root.getMap() );
+ context.setCurrentType( root.getMap().getClass() );
+
+ assertEquals( p.toGetSourceString( context, root.getMap() ), ".get(\"value\")" );
+ assertEquals( context.getCurrentType(), Object.class );
+ assertEquals( root.getMap().get( "value" ), context.getCurrentObject() );
+ assert Map.class.isAssignableFrom( context.getCurrentAccessor() );
+ assert Map.class.isAssignableFrom( context.getPreviousType() );
+ assert context.getPreviousAccessor() == null;
+
+ assertEquals( OgnlRuntime.getCompiler( context ).castExpression( context, p, ".get(\"value\")" ), ".get(\"value\")" );
+ assert context.get( ExpressionCompiler.PRE_CAST ) == null;
+
+ // now test one context level further to see casting work properly on base object types
+
+ ASTProperty prop = new ASTProperty( 0 );
+ ASTConst propRef = new ASTConst( 0 );
+ propRef.setValue( "bean3" );
+ prop.jjtAddChild( propRef, 0 );
+
+ Bean2 val = (Bean2) root.getMap().get( "value" );
+
+ assertEquals( prop.toGetSourceString( context, root.getMap().get( "value" ) ), ".getBean3()" );
+
+ assertEquals( context.getCurrentObject(), val.getBean3() );
+ assertEquals( context.getCurrentType(), Bean3.class );
+ assertEquals( context.getCurrentAccessor(), Bean2.class );
+ assertEquals( Object.class, context.getPreviousType() );
+ assert Map.class.isAssignableFrom( context.getPreviousAccessor() );
+
+ assertEquals( OgnlRuntime.getCompiler( context ).castExpression( context, prop, ".getBean3()" ), ").getBean3()" );
+
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/ASTPropertyTest.java b/src/test/java/org/apache/commons/ognl/test/ASTPropertyTest.java
index bdc8feb..fe530a1 100644
--- a/src/test/java/org/apache/commons/ognl/test/ASTPropertyTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/ASTPropertyTest.java
@@ -1,332 +1,331 @@
-/*
- * $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.test;
-
-import junit.framework.TestCase;
-import org.apache.commons.ognl.ASTChain;
-import org.apache.commons.ognl.ASTConst;
-import org.apache.commons.ognl.ASTProperty;
-import org.apache.commons.ognl.Ognl;
-import org.apache.commons.ognl.OgnlContext;
-import org.apache.commons.ognl.OgnlRuntime;
-import org.apache.commons.ognl.SimpleNode;
-import org.apache.commons.ognl.test.objects.BaseGeneric;
-import org.apache.commons.ognl.test.objects.GameGeneric;
-import org.apache.commons.ognl.test.objects.GameGenericObject;
-import org.apache.commons.ognl.test.objects.GenericRoot;
-import org.apache.commons.ognl.test.objects.Root;
-
-import java.util.List;
-import java.util.Map;
-
-import static org.apache.commons.ognl.test.OgnlTestCase.isEqual;
-
-/**
- * Tests functionality of {@link org.apache.commons.ognl.ASTProperty}.
- */
-public class ASTPropertyTest
- extends TestCase
-{
-
- public void test_Get_Indexed_Property_Type()
- throws Exception
- {
- ASTProperty p = new ASTProperty( 0 );
- p.setIndexedAccess( false );
- ASTConst pRef = new ASTConst( 0 );
- pRef.setValue( "nested" );
- pRef.jjtSetParent( p );
- p.jjtAddChild( pRef, 0 );
-
- Map root = new Root().getMap();
-
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
- context.setRoot( root );
- context.setCurrentObject( root );
- context.setCurrentNode( pRef );
-
- assertEquals( root.getClass(), context.getCurrentType() );
- assertNull(context.getPreviousType());
- assertEquals( root, context.getCurrentObject() );
- assertNull(context.getCurrentAccessor());
- assertNull(context.getPreviousAccessor());
-
- int type = p.getIndexedPropertyType( context, root );
-
- assertEquals( OgnlRuntime.INDEXED_PROPERTY_NONE, type );
- assertEquals( root.getClass(), context.getCurrentType() );
- assertNull(context.getPreviousType());
- assertNull(context.getCurrentAccessor());
- assertNull(context.getPreviousAccessor());
- }
-
- public void test_Get_Value_Body()
- throws Exception
- {
- ASTProperty p = new ASTProperty( 0 );
- p.setIndexedAccess( false );
- ASTConst pRef = new ASTConst( 0 );
- pRef.setValue( "nested" );
- pRef.jjtSetParent( p );
- p.jjtAddChild( pRef, 0 );
-
- Map root = new Root().getMap();
-
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
- context.setRoot( root );
- context.setCurrentObject( root );
- context.setCurrentNode( pRef );
-
- assertEquals( root.getClass(), context.getCurrentType() );
- assertNull(context.getPreviousType());
- assertEquals( root, context.getCurrentObject() );
- assertNull(context.getCurrentAccessor());
- assertNull(context.getPreviousAccessor());
-
- Object value = p.getValue( context, root );
-
- assertEquals( root.get( "nested" ), value );
- assertEquals( root.getClass(), context.getCurrentType() );
- assertNull(context.getPreviousType());
- assertNull(context.getCurrentAccessor());
- assertNull(context.getPreviousAccessor());
- }
-
- public void test_Get_Source()
- throws Throwable
- {
- ASTProperty p = new ASTProperty( 0 );
- p.setIndexedAccess( false );
- ASTConst pRef = new ASTConst( 0 );
- pRef.setValue( "nested" );
- pRef.jjtSetParent( p );
- p.jjtAddChild( pRef, 0 );
-
- Map root = new Root().getMap();
-
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
- context.setRoot( root );
- context.setCurrentObject( root );
- context.setCurrentNode( pRef );
-
- assertEquals( ".get(\"nested\")", p.toGetSourceString( context, root ) );
- assertEquals( Object.class, context.getCurrentType() );
- assertEquals( Map.class, context.getCurrentAccessor() );
- assertEquals( root.getClass(), context.getPreviousType() );
- assertNull(context.getPreviousAccessor());
-
- assertEquals( root.get( "nested" ), context.getCurrentObject() );
-
- assert Map.class.isAssignableFrom( context.getCurrentAccessor() );
-
- assertEquals( root.getClass(), context.getPreviousType() );
- assertNull(context.getPreviousAccessor());
- }
-
- public void test_Set_Source()
- throws Throwable
- {
- ASTProperty p = new ASTProperty( 0 );
- p.setIndexedAccess( false );
- ASTConst pRef = new ASTConst( 0 );
- pRef.setValue( "nested" );
- pRef.jjtSetParent( p );
- p.jjtAddChild( pRef, 0 );
-
- Map root = new Root().getMap();
-
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
- context.setRoot( root );
- context.setCurrentObject( root );
- context.setCurrentNode( pRef );
-
- assertEquals( ".put(\"nested\", $3)", p.toSetSourceString( context, root ) );
- assertEquals( Object.class, context.getCurrentType() );
- assertEquals( root.get( "nested" ), context.getCurrentObject() );
-
- assert Map.class.isAssignableFrom( context.getCurrentAccessor() );
-
- assertEquals( root.getClass(), context.getPreviousType() );
- assertNull(context.getPreviousAccessor());
- }
-
- public void test_Indexed_Object_Type()
- throws Throwable
- {
- // ASTChain chain = new ASTChain(0);
-
- ASTProperty listp = new ASTProperty( 0 );
- listp.setIndexedAccess( false );
- // listp.jjtSetParent(chain);
-
- ASTConst listc = new ASTConst( 0 );
- listc.setValue( "list" );
- listc.jjtSetParent( listp );
- listp.jjtAddChild( listc, 0 );
-
- // chain.jjtAddChild(listp, 0);
-
- ASTProperty p = new ASTProperty( 0 );
- p.setIndexedAccess( true );
-
- ASTProperty pindex = new ASTProperty( 0 );
-
- ASTConst pRef = new ASTConst( 0 );
- pRef.setValue( "genericIndex" );
- pRef.jjtSetParent( pindex );
- pindex.jjtAddChild( pRef, 0 );
-
- p.jjtAddChild( pindex, 0 );
- // chain.jjtAddChild(p, 1);
-
- Root root = new Root();
-
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
- context.setRoot( root );
- context.setCurrentObject( root );
- context.setCurrentNode( listp );
-
- assertEquals( ".getList()", listp.toGetSourceString( context, root ) );
- assertEquals( List.class, context.getCurrentType() );
- assertEquals( Root.class, context.getCurrentAccessor() );
- assertNull(context.getPreviousAccessor());
- assertEquals( root.getClass(), context.getPreviousType() );
- assertEquals( root.getList(), context.getCurrentObject() );
-
- // re test with chain
-
- context = (OgnlContext) Ognl.createDefaultContext( null );
- context.setRoot( root );
- context.setCurrentObject( root );
-
- ASTChain chain = new ASTChain( 0 );
- listp.jjtSetParent( chain );
- chain.jjtAddChild( listp, 0 );
-
- context.setCurrentNode( chain );
-
- assertEquals( ".getList()", chain.toGetSourceString( context, root ) );
- assertEquals( List.class, context.getCurrentType() );
- assertEquals( Root.class, context.getCurrentAccessor() );
- assertNull(context.getPreviousAccessor());
- assertEquals( Root.class, context.getPreviousType() );
- assertEquals( root.getList(), context.getCurrentObject() );
-
- // test with only getIndex
-
- assertEquals( ".get(org.apache.commons.ognl.OgnlOps#getIntValue(((org.apache.commons.ognl.test.objects.Root)$2)..getGenericIndex().toString()))",
- p.toGetSourceString( context, root.getList() ) );
- assertEquals( root.getArray(), context.getCurrentObject() );
- assertEquals( Object.class, context.getCurrentType() );
- }
-
- public void test_Complicated_List()
- throws Exception
- {
- Root root = new Root();
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
-
- SimpleNode node =
- (SimpleNode) Ognl.compileExpression( context,
- root,
- "{ new org.apache.commons.ognl.test.objects.MenuItem('Home', 'Main', "
- + "{ new org.apache.commons.ognl.test.objects.MenuItem('Help', 'Help'), "
- + "new org.apache.commons.ognl.test.objects.MenuItem('Contact', 'Contact') }), " // end
- // first
- // item
- + "new org.apache.commons.ognl.test.objects.MenuItem('UserList', getMessages().getMessage('menu.members')), "
- + "new org.apache.commons.ognl.test.objects.MenuItem('account/BetSlipList', getMessages().getMessage('menu.account'), "
- + "{ new org.apache.commons.ognl.test.objects.MenuItem('account/BetSlipList', 'My Bets'), "
- + "new org.apache.commons.ognl.test.objects.MenuItem('account/TransactionList', 'My Transactions') }), "
- + "new org.apache.commons.ognl.test.objects.MenuItem('About', 'About'), "
- + "new org.apache.commons.ognl.test.objects.MenuItem('admin/Admin', getMessages().getMessage('menu.admin'), "
- + "{ new org.apache.commons.ognl.test.objects.MenuItem('admin/AddEvent', 'Add event'), "
- + "new org.apache.commons.ognl.test.objects.MenuItem('admin/AddResult', 'Add result') })}" );
-
- assertTrue( List.class.isAssignableFrom( node.getAccessor().get( context, root ).getClass() ) );
- }
-
- public void test_Set_Chain_Indexed_Property()
- throws Exception
- {
- Root root = new Root();
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
-
- context.setRoot( root );
- context.setCurrentObject( root );
-
- SimpleNode node = (SimpleNode) Ognl.parseExpression( "tab.searchCriteriaSelections[index1][index2]" );
- node.setValue( context, root, Boolean.FALSE );
- }
-
- public void test_Set_Generic_Property()
- throws Exception
- {
- GenericRoot root = new GenericRoot();
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
-
- context.setRoot( root );
- context.setCurrentObject( root );
-
- SimpleNode node = (SimpleNode) Ognl.parseExpression( "cracker.param" );
- node.setValue( context, root, "0" );
-
- assertEquals( new Integer( 0 ), root.getCracker().getParam() );
-
- node.setValue( context, root, "10" );
-
- assertEquals( new Integer( 10 ), root.getCracker().getParam() );
- }
-
- public void test_Get_Generic_Property()
- throws Exception
- {
- GenericRoot root = new GenericRoot();
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
-
- context.setRoot( root );
- context.setCurrentObject( root );
-
- SimpleNode node = (SimpleNode) Ognl.parseExpression( "cracker.param" );
- node.setValue( context, root, "0" );
-
- assertEquals( new Integer( 0 ), node.getValue( context, root ) );
-
- node.setValue( context, root, "10" );
-
- assertEquals( new Integer( 10 ), node.getValue( context, root ) );
- }
-
- public void test_Set_Get_Multiple_Generic_Types_Property()
- throws Exception
- {
- BaseGeneric<GameGenericObject, Long> root = new GameGeneric();
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
-
- context.setRoot( root );
- context.setCurrentObject( root );
-
- SimpleNode node = (SimpleNode) Ognl.parseExpression( "ids" );
- node.setValue( context, root, new String[] { "0", "20", "43" } );
-
- isEqual( new Long[] { new Long( 0 ), new Long( 20 ), new Long( 43 ) }, root.getIds() );
- isEqual( node.getValue( context, root ), root.getIds() );
- }
-}
+/*
+ * 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.test;
+
+import junit.framework.TestCase;
+import org.apache.commons.ognl.ASTChain;
+import org.apache.commons.ognl.ASTConst;
+import org.apache.commons.ognl.ASTProperty;
+import org.apache.commons.ognl.Ognl;
+import org.apache.commons.ognl.OgnlContext;
+import org.apache.commons.ognl.OgnlRuntime;
+import org.apache.commons.ognl.SimpleNode;
+import org.apache.commons.ognl.test.objects.BaseGeneric;
+import org.apache.commons.ognl.test.objects.GameGeneric;
+import org.apache.commons.ognl.test.objects.GameGenericObject;
+import org.apache.commons.ognl.test.objects.GenericRoot;
+import org.apache.commons.ognl.test.objects.Root;
+
+import java.util.List;
+import java.util.Map;
+
+import static org.apache.commons.ognl.test.OgnlTestCase.isEqual;
+
+/**
+ * Tests functionality of {@link org.apache.commons.ognl.ASTProperty}.
+ */
+public class ASTPropertyTest
+ extends TestCase
+{
+
+ public void test_Get_Indexed_Property_Type()
+ throws Exception
+ {
+ ASTProperty p = new ASTProperty( 0 );
+ p.setIndexedAccess( false );
+ ASTConst pRef = new ASTConst( 0 );
+ pRef.setValue( "nested" );
+ pRef.jjtSetParent( p );
+ p.jjtAddChild( pRef, 0 );
+
+ Map root = new Root().getMap();
+
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+ context.setRoot( root );
+ context.setCurrentObject( root );
+ context.setCurrentNode( pRef );
+
+ assertEquals( root.getClass(), context.getCurrentType() );
+ assertNull(context.getPreviousType());
+ assertEquals( root, context.getCurrentObject() );
+ assertNull(context.getCurrentAccessor());
+ assertNull(context.getPreviousAccessor());
+
+ int type = p.getIndexedPropertyType( context, root );
+
+ assertEquals( OgnlRuntime.INDEXED_PROPERTY_NONE, type );
+ assertEquals( root.getClass(), context.getCurrentType() );
+ assertNull(context.getPreviousType());
+ assertNull(context.getCurrentAccessor());
+ assertNull(context.getPreviousAccessor());
+ }
+
+ public void test_Get_Value_Body()
+ throws Exception
+ {
+ ASTProperty p = new ASTProperty( 0 );
+ p.setIndexedAccess( false );
+ ASTConst pRef = new ASTConst( 0 );
+ pRef.setValue( "nested" );
+ pRef.jjtSetParent( p );
+ p.jjtAddChild( pRef, 0 );
+
+ Map root = new Root().getMap();
+
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+ context.setRoot( root );
+ context.setCurrentObject( root );
+ context.setCurrentNode( pRef );
+
+ assertEquals( root.getClass(), context.getCurrentType() );
+ assertNull(context.getPreviousType());
+ assertEquals( root, context.getCurrentObject() );
+ assertNull(context.getCurrentAccessor());
+ assertNull(context.getPreviousAccessor());
+
+ Object value = p.getValue( context, root );
+
+ assertEquals( root.get( "nested" ), value );
+ assertEquals( root.getClass(), context.getCurrentType() );
+ assertNull(context.getPreviousType());
+ assertNull(context.getCurrentAccessor());
+ assertNull(context.getPreviousAccessor());
+ }
+
+ public void test_Get_Source()
+ throws Throwable
+ {
+ ASTProperty p = new ASTProperty( 0 );
+ p.setIndexedAccess( false );
+ ASTConst pRef = new ASTConst( 0 );
+ pRef.setValue( "nested" );
+ pRef.jjtSetParent( p );
+ p.jjtAddChild( pRef, 0 );
+
+ Map root = new Root().getMap();
+
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+ context.setRoot( root );
+ context.setCurrentObject( root );
+ context.setCurrentNode( pRef );
+
+ assertEquals( ".get(\"nested\")", p.toGetSourceString( context, root ) );
+ assertEquals( Object.class, context.getCurrentType() );
+ assertEquals( Map.class, context.getCurrentAccessor() );
+ assertEquals( root.getClass(), context.getPreviousType() );
+ assertNull(context.getPreviousAccessor());
+
+ assertEquals( root.get( "nested" ), context.getCurrentObject() );
+
+ assert Map.class.isAssignableFrom( context.getCurrentAccessor() );
+
+ assertEquals( root.getClass(), context.getPreviousType() );
+ assertNull(context.getPreviousAccessor());
+ }
+
+ public void test_Set_Source()
+ throws Throwable
+ {
+ ASTProperty p = new ASTProperty( 0 );
+ p.setIndexedAccess( false );
+ ASTConst pRef = new ASTConst( 0 );
+ pRef.setValue( "nested" );
+ pRef.jjtSetParent( p );
+ p.jjtAddChild( pRef, 0 );
+
+ Map root = new Root().getMap();
+
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+ context.setRoot( root );
+ context.setCurrentObject( root );
+ context.setCurrentNode( pRef );
+
+ assertEquals( ".put(\"nested\", $3)", p.toSetSourceString( context, root ) );
+ assertEquals( Object.class, context.getCurrentType() );
+ assertEquals( root.get( "nested" ), context.getCurrentObject() );
+
+ assert Map.class.isAssignableFrom( context.getCurrentAccessor() );
+
+ assertEquals( root.getClass(), context.getPreviousType() );
+ assertNull(context.getPreviousAccessor());
+ }
+
+ public void test_Indexed_Object_Type()
+ throws Throwable
+ {
+ // ASTChain chain = new ASTChain(0);
+
+ ASTProperty listp = new ASTProperty( 0 );
+ listp.setIndexedAccess( false );
+ // listp.jjtSetParent(chain);
+
+ ASTConst listc = new ASTConst( 0 );
+ listc.setValue( "list" );
+ listc.jjtSetParent( listp );
+ listp.jjtAddChild( listc, 0 );
+
+ // chain.jjtAddChild(listp, 0);
+
+ ASTProperty p = new ASTProperty( 0 );
+ p.setIndexedAccess( true );
+
+ ASTProperty pindex = new ASTProperty( 0 );
+
+ ASTConst pRef = new ASTConst( 0 );
+ pRef.setValue( "genericIndex" );
+ pRef.jjtSetParent( pindex );
+ pindex.jjtAddChild( pRef, 0 );
+
+ p.jjtAddChild( pindex, 0 );
+ // chain.jjtAddChild(p, 1);
+
+ Root root = new Root();
+
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+ context.setRoot( root );
+ context.setCurrentObject( root );
+ context.setCurrentNode( listp );
+
+ assertEquals( ".getList()", listp.toGetSourceString( context, root ) );
+ assertEquals( List.class, context.getCurrentType() );
+ assertEquals( Root.class, context.getCurrentAccessor() );
+ assertNull(context.getPreviousAccessor());
+ assertEquals( root.getClass(), context.getPreviousType() );
+ assertEquals( root.getList(), context.getCurrentObject() );
+
+ // re test with chain
+
+ context = (OgnlContext) Ognl.createDefaultContext( null );
+ context.setRoot( root );
+ context.setCurrentObject( root );
+
+ ASTChain chain = new ASTChain( 0 );
+ listp.jjtSetParent( chain );
+ chain.jjtAddChild( listp, 0 );
+
+ context.setCurrentNode( chain );
+
+ assertEquals( ".getList()", chain.toGetSourceString( context, root ) );
+ assertEquals( List.class, context.getCurrentType() );
+ assertEquals( Root.class, context.getCurrentAccessor() );
+ assertNull(context.getPreviousAccessor());
+ assertEquals( Root.class, context.getPreviousType() );
+ assertEquals( root.getList(), context.getCurrentObject() );
+
+ // test with only getIndex
+
+ assertEquals( ".get(org.apache.commons.ognl.OgnlOps#getIntValue(((org.apache.commons.ognl.test.objects.Root)$2)..getGenericIndex().toString()))",
+ p.toGetSourceString( context, root.getList() ) );
+ assertEquals( root.getArray(), context.getCurrentObject() );
+ assertEquals( Object.class, context.getCurrentType() );
+ }
+
+ public void test_Complicated_List()
+ throws Exception
+ {
+ Root root = new Root();
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+
+ SimpleNode node =
+ (SimpleNode) Ognl.compileExpression( context,
+ root,
+ "{ new org.apache.commons.ognl.test.objects.MenuItem('Home', 'Main', "
+ + "{ new org.apache.commons.ognl.test.objects.MenuItem('Help', 'Help'), "
+ + "new org.apache.commons.ognl.test.objects.MenuItem('Contact', 'Contact') }), " // end
+ // first
+ // item
+ + "new org.apache.commons.ognl.test.objects.MenuItem('UserList', getMessages().getMessage('menu.members')), "
+ + "new org.apache.commons.ognl.test.objects.MenuItem('account/BetSlipList', getMessages().getMessage('menu.account'), "
+ + "{ new org.apache.commons.ognl.test.objects.MenuItem('account/BetSlipList', 'My Bets'), "
+ + "new org.apache.commons.ognl.test.objects.MenuItem('account/TransactionList', 'My Transactions') }), "
+ + "new org.apache.commons.ognl.test.objects.MenuItem('About', 'About'), "
+ + "new org.apache.commons.ognl.test.objects.MenuItem('admin/Admin', getMessages().getMessage('menu.admin'), "
+ + "{ new org.apache.commons.ognl.test.objects.MenuItem('admin/AddEvent', 'Add event'), "
+ + "new org.apache.commons.ognl.test.objects.MenuItem('admin/AddResult', 'Add result') })}" );
+
+ assertTrue( List.class.isAssignableFrom( node.getAccessor().get( context, root ).getClass() ) );
+ }
+
+ public void test_Set_Chain_Indexed_Property()
+ throws Exception
+ {
+ Root root = new Root();
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+
+ context.setRoot( root );
+ context.setCurrentObject( root );
+
+ SimpleNode node = (SimpleNode) Ognl.parseExpression( "tab.searchCriteriaSelections[index1][index2]" );
+ node.setValue( context, root, Boolean.FALSE );
+ }
+
+ public void test_Set_Generic_Property()
+ throws Exception
+ {
+ GenericRoot root = new GenericRoot();
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+
+ context.setRoot( root );
+ context.setCurrentObject( root );
+
+ SimpleNode node = (SimpleNode) Ognl.parseExpression( "cracker.param" );
+ node.setValue( context, root, "0" );
+
+ assertEquals( new Integer( 0 ), root.getCracker().getParam() );
+
+ node.setValue( context, root, "10" );
+
+ assertEquals( new Integer( 10 ), root.getCracker().getParam() );
+ }
+
+ public void test_Get_Generic_Property()
+ throws Exception
+ {
+ GenericRoot root = new GenericRoot();
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+
+ context.setRoot( root );
+ context.setCurrentObject( root );
+
+ SimpleNode node = (SimpleNode) Ognl.parseExpression( "cracker.param" );
+ node.setValue( context, root, "0" );
+
+ assertEquals( new Integer( 0 ), node.getValue( context, root ) );
+
+ node.setValue( context, root, "10" );
+
+ assertEquals( new Integer( 10 ), node.getValue( context, root ) );
+ }
+
+ public void test_Set_Get_Multiple_Generic_Types_Property()
+ throws Exception
+ {
+ BaseGeneric<GameGenericObject, Long> root = new GameGeneric();
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+
+ context.setRoot( root );
+ context.setCurrentObject( root );
+
+ SimpleNode node = (SimpleNode) Ognl.parseExpression( "ids" );
+ node.setValue( context, root, new String[] { "0", "20", "43" } );
+
+ isEqual( new Long[] { new Long( 0 ), new Long( 20 ), new Long( 43 ) }, root.getIds() );
+ isEqual( node.getValue( context, root ), root.getIds() );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/ArithmeticAndLogicalOperatorsTest.java b/src/test/java/org/apache/commons/ognl/test/ArithmeticAndLogicalOperatorsTest.java
index 73ba053..c122a32 100644
--- a/src/test/java/org/apache/commons/ognl/test/ArithmeticAndLogicalOperatorsTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/ArithmeticAndLogicalOperatorsTest.java
@@ -1,182 +1,181 @@
-/*
- * $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.test;
-
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class ArithmeticAndLogicalOperatorsTest
- extends OgnlTestCase
-{
-
- private static final Object[][] TESTS = {
- // Double-valued arithmetic expressions
- { "-1d", new Double( -1 ) },
- { "+1d", new Double( 1 ) },
- { "--1f", new Double( 1 ) },
- { "2*2.0", new Double( 4.0 ) },
- { "5/2.", new Double( 2.5 ) },
- { "5+2D", new Double( 7 ) },
- { "5f-2F", new Double( 3.0 ) },
- { "5.+2*3", new Double( 11 ) },
- { "(5.+2)*3", new Double( 21 ) },
-
- // BigDecimal-valued arithmetic expressions
- { "-1b", new Integer( -1 ) },
- { "+1b", new Integer( 1 ) },
- { "--1b", new Integer( 1 ) },
- { "2*2.0b", new Double( 4.0 ) },
- { "5/2.B", new Integer( 2 ) },
- { "5.0B/2", new Double( 2.5 ) },
- { "5+2b", new Integer( 7 ) },
- { "5-2B", new Integer( 3 ) },
- { "5.+2b*3", new Double( 11 ) },
- { "(5.+2b)*3", new Double( 21 ) },
-
- // Integer-valued arithmetic expressions
- { "-1", new Integer( -1 ) },
- { "+1", new Integer( 1 ) },
- { "--1", new Integer( 1 ) },
- { "2*2", new Integer( 4 ) },
- { "5/2", new Integer( 2 ) },
- { "5+2", new Integer( 7 ) },
- { "5-2", new Integer( 3 ) },
- { "5+2*3", new Integer( 11 ) },
- { "(5+2)*3", new Integer( 21 ) },
- { "~1", new Integer( ~1 ) },
- { "5%2", new Integer( 1 ) },
- { "5<<2", new Integer( 20 ) },
- { "5>>2", new Integer( 1 ) },
- { "5>>1+1", new Integer( 1 ) },
- { "-5>>>2", new Integer( -5 >>> 2 ) },
- { "-5L>>>2", new Long( -5L >>> 2 ) },
- { "5. & 3", new Long( 1 ) },
- { "5 ^3", new Integer( 6 ) },
- { "5l&3|5^3", new Long( 7 ) },
- { "5&(3|5^3)", new Long( 5 ) },
- { "true ? 1 : 1/0", new Integer( 1 ) },
-
- // BigInteger-valued arithmetic expressions
- { "-1h", Integer.valueOf( -1 ) },
- { "+1H", Integer.valueOf( 1 ) },
- { "--1h", Integer.valueOf( 1 ) },
- { "2h*2", Integer.valueOf( 4 ) },
- { "5/2h", Integer.valueOf( 2 ) },
- { "5h+2", Integer.valueOf( 7 ) },
- { "5-2h", Integer.valueOf( 3 ) },
- { "5+2H*3", Integer.valueOf( 11 ) },
- { "(5+2H)*3", Integer.valueOf( 21 ) },
- { "~1h", Integer.valueOf( ~1 ) },
- { "5h%2", Integer.valueOf( 1 ) },
- { "5h<<2", Integer.valueOf( 20 ) },
- { "5h>>2", Integer.valueOf( 1 ) },
- { "5h>>1+1", Integer.valueOf( 1 ) },
- { "-5h>>>2", Integer.valueOf( -2 ) },
- { "5.b & 3", new Long( 1 ) },
- { "5h ^3", Integer.valueOf( 6 ) },
- { "5h&3|5^3", new Long( 7 ) },
- { "5H&(3|5^3)", new Long( 5 ) },
-
- // Logical expressions
- { "!1", Boolean.FALSE }, { "!null", Boolean.TRUE },
- { "5<2", Boolean.FALSE },
- { "5>2", Boolean.TRUE },
- { "5<=5", Boolean.TRUE },
- { "5>=3", Boolean.TRUE },
- { "5<-5>>>2", Boolean.TRUE },
- { "5==5.0", Boolean.TRUE },
- { "5!=5.0", Boolean.FALSE },
- { "null in {true,false,null}", Boolean.TRUE },
- { "null not in {true,false,null}", Boolean.FALSE },
- { "null in {true,false,null}.toArray()", Boolean.TRUE },
- { "5 in {true,false,null}", Boolean.FALSE },
- { "5 not in {true,false,null}", Boolean.TRUE },
- { "5 instanceof java.lang.Integer", Boolean.TRUE },
- { "5. instanceof java.lang.Integer", Boolean.FALSE },
- { "!false || true", Boolean.TRUE },
- { "!(true && true)", Boolean.FALSE },
- { "(1 > 0 && true) || 2 > 0", Boolean.TRUE },
-
- // Logical expressions (string versions)
- { "2 or 0", Integer.valueOf( 2 ) }, { "1 and 0", Integer.valueOf( 0 ) }, { "1 bor 0", new Integer( 1 ) },
- { "true && 12", Integer.valueOf( 12 ) }, { "1 xor 0", new Integer( 1 ) }, { "1 band 0", new Long( 0 ) },
- { "1 eq 1", Boolean.TRUE }, { "1 neq 1", Boolean.FALSE }, { "1 lt 5", Boolean.TRUE },
- { "1 lte 5", Boolean.TRUE }, { "1 gt 5", Boolean.FALSE }, { "1 gte 5", Boolean.FALSE },
- { "1 lt 5", Boolean.TRUE }, { "1 shl 2", new Integer( 4 ) }, { "4 shr 2", new Integer( 1 ) },
- { "4 ushr 2", new Integer( 1 ) }, { "not null", Boolean.TRUE }, { "not 1", Boolean.FALSE },
-
- { "#x > 0", Boolean.TRUE }, { "#x < 0", Boolean.FALSE }, { "#x == 0", Boolean.FALSE },
- { "#x == 1", Boolean.TRUE }, { "0 > #x", Boolean.FALSE }, { "0 < #x", Boolean.TRUE },
- { "0 == #x", Boolean.FALSE }, { "1 == #x", Boolean.TRUE }, { "\"1\" > 0", Boolean.TRUE },
- { "\"1\" < 0", Boolean.FALSE }, { "\"1\" == 0", Boolean.FALSE }, { "\"1\" == 1", Boolean.TRUE },
- { "0 > \"1\"", Boolean.FALSE }, { "0 < \"1\"", Boolean.TRUE }, { "0 == \"1\"", Boolean.FALSE },
- { "1 == \"1\"", Boolean.TRUE }, { "#x + 1", "11" }, { "1 + #x", "11" }, { "#y == 1", Boolean.TRUE },
- { "#y == \"1\"", Boolean.TRUE }, { "#y + \"1\"", "11" }, { "\"1\" + #y", "11" } };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( Object[] TEST : TESTS )
- {
- Object[] tmp = new Object[4];
- tmp[0] = TEST[0] + " (" + TEST[1] + ")";
- tmp[1] = null;
- tmp[2] = TEST[0];
- tmp[3] = TEST[1];
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
-
- public ArithmeticAndLogicalOperatorsTest( String name, Object root, String expressionString, Object expectedResult )
- {
- super( name, root, expressionString, expectedResult );
- }
- /*
- * =================================================================== Overridden methods
- * ===================================================================
- */
- @Before
- @Override
- public void setUp()
- {
- super.setUp();
- _context.put( "x", "1" );
- _context.put("y", new BigDecimal(1));
- }
-}
+/*
+ * 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.test;
+
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class ArithmeticAndLogicalOperatorsTest
+ extends OgnlTestCase
+{
+
+ private static final Object[][] TESTS = {
+ // Double-valued arithmetic expressions
+ { "-1d", new Double( -1 ) },
+ { "+1d", new Double( 1 ) },
+ { "--1f", new Double( 1 ) },
+ { "2*2.0", new Double( 4.0 ) },
+ { "5/2.", new Double( 2.5 ) },
+ { "5+2D", new Double( 7 ) },
+ { "5f-2F", new Double( 3.0 ) },
+ { "5.+2*3", new Double( 11 ) },
+ { "(5.+2)*3", new Double( 21 ) },
+
+ // BigDecimal-valued arithmetic expressions
+ { "-1b", new Integer( -1 ) },
+ { "+1b", new Integer( 1 ) },
+ { "--1b", new Integer( 1 ) },
+ { "2*2.0b", new Double( 4.0 ) },
+ { "5/2.B", new Integer( 2 ) },
+ { "5.0B/2", new Double( 2.5 ) },
+ { "5+2b", new Integer( 7 ) },
+ { "5-2B", new Integer( 3 ) },
+ { "5.+2b*3", new Double( 11 ) },
+ { "(5.+2b)*3", new Double( 21 ) },
+
+ // Integer-valued arithmetic expressions
+ { "-1", new Integer( -1 ) },
+ { "+1", new Integer( 1 ) },
+ { "--1", new Integer( 1 ) },
+ { "2*2", new Integer( 4 ) },
+ { "5/2", new Integer( 2 ) },
+ { "5+2", new Integer( 7 ) },
+ { "5-2", new Integer( 3 ) },
+ { "5+2*3", new Integer( 11 ) },
+ { "(5+2)*3", new Integer( 21 ) },
+ { "~1", new Integer( ~1 ) },
+ { "5%2", new Integer( 1 ) },
+ { "5<<2", new Integer( 20 ) },
+ { "5>>2", new Integer( 1 ) },
+ { "5>>1+1", new Integer( 1 ) },
+ { "-5>>>2", new Integer( -5 >>> 2 ) },
+ { "-5L>>>2", new Long( -5L >>> 2 ) },
+ { "5. & 3", new Long( 1 ) },
+ { "5 ^3", new Integer( 6 ) },
+ { "5l&3|5^3", new Long( 7 ) },
+ { "5&(3|5^3)", new Long( 5 ) },
+ { "true ? 1 : 1/0", new Integer( 1 ) },
+
+ // BigInteger-valued arithmetic expressions
+ { "-1h", Integer.valueOf( -1 ) },
+ { "+1H", Integer.valueOf( 1 ) },
+ { "--1h", Integer.valueOf( 1 ) },
+ { "2h*2", Integer.valueOf( 4 ) },
+ { "5/2h", Integer.valueOf( 2 ) },
+ { "5h+2", Integer.valueOf( 7 ) },
+ { "5-2h", Integer.valueOf( 3 ) },
+ { "5+2H*3", Integer.valueOf( 11 ) },
+ { "(5+2H)*3", Integer.valueOf( 21 ) },
+ { "~1h", Integer.valueOf( ~1 ) },
+ { "5h%2", Integer.valueOf( 1 ) },
+ { "5h<<2", Integer.valueOf( 20 ) },
+ { "5h>>2", Integer.valueOf( 1 ) },
+ { "5h>>1+1", Integer.valueOf( 1 ) },
+ { "-5h>>>2", Integer.valueOf( -2 ) },
+ { "5.b & 3", new Long( 1 ) },
+ { "5h ^3", Integer.valueOf( 6 ) },
+ { "5h&3|5^3", new Long( 7 ) },
+ { "5H&(3|5^3)", new Long( 5 ) },
+
+ // Logical expressions
+ { "!1", Boolean.FALSE }, { "!null", Boolean.TRUE },
+ { "5<2", Boolean.FALSE },
+ { "5>2", Boolean.TRUE },
+ { "5<=5", Boolean.TRUE },
+ { "5>=3", Boolean.TRUE },
+ { "5<-5>>>2", Boolean.TRUE },
+ { "5==5.0", Boolean.TRUE },
+ { "5!=5.0", Boolean.FALSE },
+ { "null in {true,false,null}", Boolean.TRUE },
+ { "null not in {true,false,null}", Boolean.FALSE },
+ { "null in {true,false,null}.toArray()", Boolean.TRUE },
+ { "5 in {true,false,null}", Boolean.FALSE },
+ { "5 not in {true,false,null}", Boolean.TRUE },
+ { "5 instanceof java.lang.Integer", Boolean.TRUE },
+ { "5. instanceof java.lang.Integer", Boolean.FALSE },
+ { "!false || true", Boolean.TRUE },
+ { "!(true && true)", Boolean.FALSE },
+ { "(1 > 0 && true) || 2 > 0", Boolean.TRUE },
+
+ // Logical expressions (string versions)
+ { "2 or 0", Integer.valueOf( 2 ) }, { "1 and 0", Integer.valueOf( 0 ) }, { "1 bor 0", new Integer( 1 ) },
+ { "true && 12", Integer.valueOf( 12 ) }, { "1 xor 0", new Integer( 1 ) }, { "1 band 0", new Long( 0 ) },
+ { "1 eq 1", Boolean.TRUE }, { "1 neq 1", Boolean.FALSE }, { "1 lt 5", Boolean.TRUE },
+ { "1 lte 5", Boolean.TRUE }, { "1 gt 5", Boolean.FALSE }, { "1 gte 5", Boolean.FALSE },
+ { "1 lt 5", Boolean.TRUE }, { "1 shl 2", new Integer( 4 ) }, { "4 shr 2", new Integer( 1 ) },
+ { "4 ushr 2", new Integer( 1 ) }, { "not null", Boolean.TRUE }, { "not 1", Boolean.FALSE },
+
+ { "#x > 0", Boolean.TRUE }, { "#x < 0", Boolean.FALSE }, { "#x == 0", Boolean.FALSE },
+ { "#x == 1", Boolean.TRUE }, { "0 > #x", Boolean.FALSE }, { "0 < #x", Boolean.TRUE },
+ { "0 == #x", Boolean.FALSE }, { "1 == #x", Boolean.TRUE }, { "\"1\" > 0", Boolean.TRUE },
+ { "\"1\" < 0", Boolean.FALSE }, { "\"1\" == 0", Boolean.FALSE }, { "\"1\" == 1", Boolean.TRUE },
+ { "0 > \"1\"", Boolean.FALSE }, { "0 < \"1\"", Boolean.TRUE }, { "0 == \"1\"", Boolean.FALSE },
+ { "1 == \"1\"", Boolean.TRUE }, { "#x + 1", "11" }, { "1 + #x", "11" }, { "#y == 1", Boolean.TRUE },
+ { "#y == \"1\"", Boolean.TRUE }, { "#y + \"1\"", "11" }, { "\"1\" + #y", "11" } };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( Object[] TEST : TESTS )
+ {
+ Object[] tmp = new Object[4];
+ tmp[0] = TEST[0] + " (" + TEST[1] + ")";
+ tmp[1] = null;
+ tmp[2] = TEST[0];
+ tmp[3] = TEST[1];
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+
+ public ArithmeticAndLogicalOperatorsTest( String name, Object root, String expressionString, Object expectedResult )
+ {
+ super( name, root, expressionString, expectedResult );
+ }
+ /*
+ * =================================================================== Overridden methods
+ * ===================================================================
+ */
+ @Before
+ @Override
+ public void setUp()
+ {
+ super.setUp();
+ _context.put( "x", "1" );
+ _context.put("y", new BigDecimal(1));
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/ArrayCreationTest.java b/src/test/java/org/apache/commons/ognl/test/ArrayCreationTest.java
index e448a40..c1a7024 100644
--- a/src/test/java/org/apache/commons/ognl/test/ArrayCreationTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/ArrayCreationTest.java
@@ -1,114 +1,113 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.ExpressionSyntaxException;
-import org.apache.commons.ognl.test.objects.Entry;
-import org.apache.commons.ognl.test.objects.Root;
-import org.apache.commons.ognl.test.objects.Simple;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class ArrayCreationTest
- extends OgnlTestCase
-{
-
- private static final Root ROOT = new Root();
-
- private static final Object[][] TESTS =
- {
- // Array creation
- { ROOT, "new String[] { \"one\", \"two\" }", new String[] { "one", "two" } },
- { ROOT, "new String[] { 1, 2 }", new String[] { "1", "2" } },
- { ROOT, "new Integer[] { \"1\", 2, \"3\" }",
- new Integer[] { 1, 2, 3 } },
- { ROOT, "new String[10]", new String[10] },
- { ROOT, "new Object[4] { #root, #this }", ExpressionSyntaxException.class },
- { ROOT, "new Object[4]", new Object[4] },
- { ROOT, "new Object[] { #root, #this }", new Object[] { ROOT, ROOT } },
- {
- ROOT,
- "new org.apache.commons.ognl.test.objects.Simple[] { new org.apache.commons.ognl.test.objects.Simple(), new org.apache.commons.ognl.test.objects.Simple(\"foo\", 1.0f, 2) }",
- new Simple[] { new Simple(), new Simple( "foo", 1.0f, 2 ) } },
- { ROOT, "new org.apache.commons.ognl.test.objects.Simple[5]", new Simple[5] },
- { ROOT, "new org.apache.commons.ognl.test.objects.Simple(new Object[5])", new Simple( new Object[5] ) },
- { ROOT, "new org.apache.commons.ognl.test.objects.Simple(new String[5])", new Simple( new String[5] ) },
- {
- ROOT,
- "objectIndex ? new org.apache.commons.ognl.test.objects.Entry[] { new org.apache.commons.ognl.test.objects.Entry(), new org.apache.commons.ognl.test.objects.Entry()} "
- + ": new org.apache.commons.ognl.test.objects.Entry[] { new org.apache.commons.ognl.test.objects.Entry(), new org.apache.commons.ognl.test.objects.Entry()} ",
- new Entry[] { new Entry(), new Entry() } } };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( Object[] TEST : TESTS )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TEST[1];
- tmp[1] = TEST[0];
- tmp[2] = TEST[1];
-
- switch ( TEST.length )
- {
- case 3:
- tmp[3] = TEST[2];
- break;
-
- case 4:
- tmp[3] = TEST[2];
- tmp[4] = TEST[3];
- break;
-
- case 5:
- tmp[3] = TEST[2];
- tmp[4] = TEST[3];
- tmp[5] = TEST[4];
- break;
-
- default:
- throw new RuntimeException( "don't understand TEST format with length" );
- }
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public ArrayCreationTest( String name, Object root, String expressionString, Object expectedResult,
- Object setValue, Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.ExpressionSyntaxException;
+import org.apache.commons.ognl.test.objects.Entry;
+import org.apache.commons.ognl.test.objects.Root;
+import org.apache.commons.ognl.test.objects.Simple;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class ArrayCreationTest
+ extends OgnlTestCase
+{
+
+ private static final Root ROOT = new Root();
+
+ private static final Object[][] TESTS =
+ {
+ // Array creation
+ { ROOT, "new String[] { \"one\", \"two\" }", new String[] { "one", "two" } },
+ { ROOT, "new String[] { 1, 2 }", new String[] { "1", "2" } },
+ { ROOT, "new Integer[] { \"1\", 2, \"3\" }",
+ new Integer[] { 1, 2, 3 } },
+ { ROOT, "new String[10]", new String[10] },
+ { ROOT, "new Object[4] { #root, #this }", ExpressionSyntaxException.class },
+ { ROOT, "new Object[4]", new Object[4] },
+ { ROOT, "new Object[] { #root, #this }", new Object[] { ROOT, ROOT } },
+ {
+ ROOT,
+ "new org.apache.commons.ognl.test.objects.Simple[] { new org.apache.commons.ognl.test.objects.Simple(), new org.apache.commons.ognl.test.objects.Simple(\"foo\", 1.0f, 2) }",
+ new Simple[] { new Simple(), new Simple( "foo", 1.0f, 2 ) } },
+ { ROOT, "new org.apache.commons.ognl.test.objects.Simple[5]", new Simple[5] },
+ { ROOT, "new org.apache.commons.ognl.test.objects.Simple(new Object[5])", new Simple( new Object[5] ) },
+ { ROOT, "new org.apache.commons.ognl.test.objects.Simple(new String[5])", new Simple( new String[5] ) },
+ {
+ ROOT,
+ "objectIndex ? new org.apache.commons.ognl.test.objects.Entry[] { new org.apache.commons.ognl.test.objects.Entry(), new org.apache.commons.ognl.test.objects.Entry()} "
+ + ": new org.apache.commons.ognl.test.objects.Entry[] { new org.apache.commons.ognl.test.objects.Entry(), new org.apache.commons.ognl.test.objects.Entry()} ",
+ new Entry[] { new Entry(), new Entry() } } };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( Object[] TEST : TESTS )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TEST[1];
+ tmp[1] = TEST[0];
+ tmp[2] = TEST[1];
+
+ switch ( TEST.length )
+ {
+ case 3:
+ tmp[3] = TEST[2];
+ break;
+
+ case 4:
+ tmp[3] = TEST[2];
+ tmp[4] = TEST[3];
+ break;
+
+ case 5:
+ tmp[3] = TEST[2];
+ tmp[4] = TEST[3];
+ tmp[5] = TEST[4];
+ break;
+
+ default:
+ throw new RuntimeException( "don't understand TEST format with length" );
+ }
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public ArrayCreationTest( String name, Object root, String expressionString, Object expectedResult,
+ Object setValue, Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/ArrayElementsTest.java b/src/test/java/org/apache/commons/ognl/test/ArrayElementsTest.java
index 8656de4..ae6b19f 100644
--- a/src/test/java/org/apache/commons/ognl/test/ArrayElementsTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/ArrayElementsTest.java
@@ -1,130 +1,129 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.test.objects.Root;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class ArrayElementsTest
- extends OgnlTestCase
-{
-
- private static final String[] STRING_ARRAY = new String[] { "hello", "world" };
-
- private static final int[] INT_ARRAY = new int[] { 10, 20 };
-
- private static final Root ROOT = new Root();
-
- private static final Object[][] TESTS = {
- // Array elements test
- { STRING_ARRAY, "length", 2 },
- { STRING_ARRAY, "#root[1]", "world" },
- { INT_ARRAY, "#root[1]", 20 },
- { INT_ARRAY, "#root[1]", 20, "50", 50 },
- { INT_ARRAY, "#root[1]", 50, new String[] { "50", "100" }, 50 },
- { ROOT, "intValue", 0, new String[] { "50", "100" }, 50 },
- { ROOT, "array", ROOT.getArray(), new String[] { "50", "100" }, new int[] { 50, 100 } },
- { null, "\"{Hello}\".toCharArray()[6]", '}' },
- { null, "\"Tapestry\".toCharArray()[2]", 'p' },
- { null, "{'1','2','3'}",
- Arrays.asList( '1', '2', '3' ) },
- { null, "{ true, !false }", Arrays.asList( Boolean.TRUE, Boolean.TRUE ) } };
-
- /*
- * =================================================================== Private static methods
- * ===================================================================
- */
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( Object[] TEST : TESTS )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TEST[1];
- tmp[1] = TEST[0];
- tmp[2] = TEST[1];
-
- switch ( TEST.length )
- {
- case 3:
- tmp[3] = TEST[2];
- break;
-
- case 4:
- tmp[3] = TEST[2];
- tmp[4] = TEST[3];
- break;
-
- case 5:
- tmp[3] = TEST[2];
- tmp[4] = TEST[3];
- tmp[5] = TEST[4];
- break;
-
- default:
- throw new RuntimeException( "don't understand TEST format with length" );
- }
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public ArrayElementsTest( String name, Object root, String expressionString, Object expectedResult,
- Object setValue, Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-
- /*
- * =================================================================== Overridden methods
- * ===================================================================
- */
- @Override
- @Before
- public void setUp()
- {
- super.setUp();
- /**
- * TypeConverter arrayConverter;
- * arrayConverter = new DefaultTypeConverter() { public Object convertValue(Map context, Object target, Member
- * member, String propertyName, Object value, Class toType) { if (value.getClass().isArray()) { if
- * (!toType.isArray()) { value = Array.get(value, 0); } } return super.convertValue(context, target, member,
- * propertyName, value, toType); } }; _context.setTypeConverter(arrayConverter);
- */
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.test.objects.Root;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class ArrayElementsTest
+ extends OgnlTestCase
+{
+
+ private static final String[] STRING_ARRAY = new String[] { "hello", "world" };
+
+ private static final int[] INT_ARRAY = new int[] { 10, 20 };
+
+ private static final Root ROOT = new Root();
+
+ private static final Object[][] TESTS = {
+ // Array elements test
+ { STRING_ARRAY, "length", 2 },
+ { STRING_ARRAY, "#root[1]", "world" },
+ { INT_ARRAY, "#root[1]", 20 },
+ { INT_ARRAY, "#root[1]", 20, "50", 50 },
+ { INT_ARRAY, "#root[1]", 50, new String[] { "50", "100" }, 50 },
+ { ROOT, "intValue", 0, new String[] { "50", "100" }, 50 },
+ { ROOT, "array", ROOT.getArray(), new String[] { "50", "100" }, new int[] { 50, 100 } },
+ { null, "\"{Hello}\".toCharArray()[6]", '}' },
+ { null, "\"Tapestry\".toCharArray()[2]", 'p' },
+ { null, "{'1','2','3'}",
+ Arrays.asList( '1', '2', '3' ) },
+ { null, "{ true, !false }", Arrays.asList( Boolean.TRUE, Boolean.TRUE ) } };
+
+ /*
+ * =================================================================== Private static methods
+ * ===================================================================
+ */
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( Object[] TEST : TESTS )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TEST[1];
+ tmp[1] = TEST[0];
+ tmp[2] = TEST[1];
+
+ switch ( TEST.length )
+ {
+ case 3:
+ tmp[3] = TEST[2];
+ break;
+
+ case 4:
+ tmp[3] = TEST[2];
+ tmp[4] = TEST[3];
+ break;
+
+ case 5:
+ tmp[3] = TEST[2];
+ tmp[4] = TEST[3];
+ tmp[5] = TEST[4];
+ break;
+
+ default:
+ throw new RuntimeException( "don't understand TEST format with length" );
+ }
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public ArrayElementsTest( String name, Object root, String expressionString, Object expectedResult,
+ Object setValue, Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+
+ /*
+ * =================================================================== Overridden methods
+ * ===================================================================
+ */
+ @Override
+ @Before
+ public void setUp()
+ {
+ super.setUp();
+ /**
+ * TypeConverter arrayConverter;
+ * arrayConverter = new DefaultTypeConverter() { public Object convertValue(Map context, Object target, Member
+ * member, String propertyName, Object value, Class toType) { if (value.getClass().isArray()) { if
+ * (!toType.isArray()) { value = Array.get(value, 0); } } return super.convertValue(context, target, member,
+ * propertyName, value, toType); } }; _context.setTypeConverter(arrayConverter);
+ */
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/ClassMethodTest.java b/src/test/java/org/apache/commons/ognl/test/ClassMethodTest.java
index 943a361..0de3ba6 100644
--- a/src/test/java/org/apache/commons/ognl/test/ClassMethodTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/ClassMethodTest.java
@@ -1,89 +1,88 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.test.objects.CorrectedObject;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class ClassMethodTest
- extends OgnlTestCase
-{
-
- private static final CorrectedObject CORRECTED = new CorrectedObject();
-
- private static final Object[][] TESTS = {
- // Methods on Class
- { CORRECTED, "getClass().getName()", CORRECTED.getClass().getName() },
- { CORRECTED, "getClass().getInterfaces()", CORRECTED.getClass().getInterfaces() },
- { CORRECTED, "getClass().getInterfaces().length", new Integer( CORRECTED.getClass().getInterfaces().length ) },
- { null, "@System@class.getInterfaces()", System.class.getInterfaces() },
- { null, "@Class@class.getName()", Class.class.getName() },
- { null, "@java.awt.image.ImageObserver@class.getName()", java.awt.image.ImageObserver.class.getName() }, };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][1];
- tmp[1] = TESTS[i][0];
- tmp[2] = TESTS[i][1];
- tmp[3] = TESTS[i][2];
- tmp[4] = null;
- tmp[5] = null;
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public ClassMethodTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
- Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-
- @Before
- @Override
- public void setUp()
- {
- super.setUp();
- _context.put( "x", "1" );
- _context.put( "y", new BigDecimal( 1 ) );
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.test.objects.CorrectedObject;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class ClassMethodTest
+ extends OgnlTestCase
+{
+
+ private static final CorrectedObject CORRECTED = new CorrectedObject();
+
+ private static final Object[][] TESTS = {
+ // Methods on Class
+ { CORRECTED, "getClass().getName()", CORRECTED.getClass().getName() },
+ { CORRECTED, "getClass().getInterfaces()", CORRECTED.getClass().getInterfaces() },
+ { CORRECTED, "getClass().getInterfaces().length", new Integer( CORRECTED.getClass().getInterfaces().length ) },
+ { null, "@System@class.getInterfaces()", System.class.getInterfaces() },
+ { null, "@Class@class.getName()", Class.class.getName() },
+ { null, "@java.awt.image.ImageObserver@class.getName()", java.awt.image.ImageObserver.class.getName() }, };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][1];
+ tmp[1] = TESTS[i][0];
+ tmp[2] = TESTS[i][1];
+ tmp[3] = TESTS[i][2];
+ tmp[4] = null;
+ tmp[5] = null;
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public ClassMethodTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
+ Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+
+ @Before
+ @Override
+ public void setUp()
+ {
+ super.setUp();
+ _context.put( "x", "1" );
+ _context.put( "y", new BigDecimal( 1 ) );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/CollectionDirectPropertyTest.java b/src/test/java/org/apache/commons/ognl/test/CollectionDirectPropertyTest.java
index 290ad97..e9fd304 100644
--- a/src/test/java/org/apache/commons/ognl/test/CollectionDirectPropertyTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/CollectionDirectPropertyTest.java
@@ -1,105 +1,104 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.test.objects.Root;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class CollectionDirectPropertyTest
- extends OgnlTestCase
-{
-
- private static final Root ROOT = new Root();
-
- private static final Object[][] TESTS = {
- // Collection direct properties
- { Arrays.asList( "hello", "world" ), "size", 2 },
- { Arrays.asList( "hello", "world" ), "isEmpty", Boolean.FALSE },
- { Arrays.asList(), "isEmpty", Boolean.TRUE },
- { Arrays.asList( "hello", "world" ), "iterator.next", "hello" },
- { Arrays.asList( "hello", "world" ), "iterator.hasNext", Boolean.TRUE },
- { Arrays.asList( "hello", "world" ), "#it = iterator, #it.next, #it.next, #it.hasNext", Boolean.FALSE },
- { Arrays.asList( "hello", "world" ), "#it = iterator, #it.next, #it.next", "world" },
- { Arrays.asList( "hello", "world" ), "size", 2 },
- { ROOT, "map[\"test\"]", ROOT }, { ROOT, "map.size", ROOT.getMap().size() },
- { ROOT, "map.keySet", ROOT.getMap().keySet() }, { ROOT, "map.values", ROOT.getMap().values() },
- { ROOT, "map.keys.size", ROOT.getMap().size() },
- { ROOT, "map[\"size\"]", ROOT.getMap().get( "size" ) },
- { ROOT, "map.isEmpty", ROOT.getMap().isEmpty() ? Boolean.TRUE : Boolean.FALSE },
- { ROOT, "map[\"isEmpty\"]", null }, };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( Object[] TEST : TESTS )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TEST[1];
- tmp[1] = TEST[0];
- tmp[2] = TEST[1];
-
- switch ( TEST.length )
- {
- case 3:
- tmp[3] = TEST[2];
- break;
-
- case 4:
- tmp[3] = TEST[2];
- tmp[4] = TEST[3];
- break;
-
- case 5:
- tmp[3] = TEST[2];
- tmp[4] = TEST[3];
- tmp[5] = TEST[4];
- break;
-
- default:
- throw new RuntimeException( "don't understand TEST format with length" );
- }
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public CollectionDirectPropertyTest( String name, Object root, String expressionString, Object expectedResult,
- Object setValue, Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.test.objects.Root;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class CollectionDirectPropertyTest
+ extends OgnlTestCase
+{
+
+ private static final Root ROOT = new Root();
+
+ private static final Object[][] TESTS = {
+ // Collection direct properties
+ { Arrays.asList( "hello", "world" ), "size", 2 },
+ { Arrays.asList( "hello", "world" ), "isEmpty", Boolean.FALSE },
+ { Arrays.asList(), "isEmpty", Boolean.TRUE },
+ { Arrays.asList( "hello", "world" ), "iterator.next", "hello" },
+ { Arrays.asList( "hello", "world" ), "iterator.hasNext", Boolean.TRUE },
+ { Arrays.asList( "hello", "world" ), "#it = iterator, #it.next, #it.next, #it.hasNext", Boolean.FALSE },
+ { Arrays.asList( "hello", "world" ), "#it = iterator, #it.next, #it.next", "world" },
+ { Arrays.asList( "hello", "world" ), "size", 2 },
+ { ROOT, "map[\"test\"]", ROOT }, { ROOT, "map.size", ROOT.getMap().size() },
+ { ROOT, "map.keySet", ROOT.getMap().keySet() }, { ROOT, "map.values", ROOT.getMap().values() },
+ { ROOT, "map.keys.size", ROOT.getMap().size() },
+ { ROOT, "map[\"size\"]", ROOT.getMap().get( "size" ) },
+ { ROOT, "map.isEmpty", ROOT.getMap().isEmpty() ? Boolean.TRUE : Boolean.FALSE },
+ { ROOT, "map[\"isEmpty\"]", null }, };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( Object[] TEST : TESTS )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TEST[1];
+ tmp[1] = TEST[0];
+ tmp[2] = TEST[1];
+
+ switch ( TEST.length )
+ {
+ case 3:
+ tmp[3] = TEST[2];
+ break;
+
+ case 4:
+ tmp[3] = TEST[2];
+ tmp[4] = TEST[3];
+ break;
+
+ case 5:
+ tmp[3] = TEST[2];
+ tmp[4] = TEST[3];
+ tmp[5] = TEST[4];
+ break;
+
+ default:
+ throw new RuntimeException( "don't understand TEST format with length" );
+ }
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public CollectionDirectPropertyTest( String name, Object root, String expressionString, Object expectedResult,
+ Object setValue, Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/CompilingPropertyAccessor.java b/src/test/java/org/apache/commons/ognl/test/CompilingPropertyAccessor.java
index 2b78a60..46a481b 100644
--- a/src/test/java/org/apache/commons/ognl/test/CompilingPropertyAccessor.java
+++ b/src/test/java/org/apache/commons/ognl/test/CompilingPropertyAccessor.java
@@ -1,269 +1,268 @@
-/*
- * $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.test;
-
-import javassist.ClassPool;
-import javassist.CtClass;
-import javassist.CtMethod;
-import javassist.LoaderClassPath;
-import org.apache.commons.ognl.ObjectPropertyAccessor;
-import org.apache.commons.ognl.OgnlContext;
-import org.apache.commons.ognl.OgnlException;
-import org.apache.commons.ognl.OgnlRuntime;
-import org.apache.commons.ognl.enhance.ContextClassLoader;
-import org.apache.commons.ognl.enhance.EnhancedClassLoader;
-import org.apache.commons.ognl.test.util.NameFactory;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.HashMap;
-import java.util.IdentityHashMap;
-import java.util.Map;
-
-/**
- * Implementation of PropertyAccessor that uses Javassist to compile a property accessor specifically tailored to the
- * property.
- */
-public class CompilingPropertyAccessor
- extends ObjectPropertyAccessor
-{
-
- private static final NameFactory NAME_FACTORY = new NameFactory( "ognl.PropertyAccessor", "v" );
-
- private static final Getter NOT_FOUND_GETTER = (context, target, propertyName) -> null;
-
- private static final Getter DEFAULT_GETTER = (context, target, propertyName) -> {
- try
- {
- return OgnlRuntime.getMethodValue( context, target, propertyName, true );
- }
- catch ( Exception ex )
- {
- throw new RuntimeException( ex );
- }
- };
-
- private static final Map POOLS = new HashMap();
-
- private static final Map LOADERS = new HashMap();
-
- private static final java.util.IdentityHashMap PRIMITIVE_WRAPPER_CLASSES = new IdentityHashMap();
-
- private final java.util.IdentityHashMap seenGetMethods = new java.util.IdentityHashMap();
-
- static
- {
- PRIMITIVE_WRAPPER_CLASSES.put( Boolean.TYPE, Boolean.class );
- PRIMITIVE_WRAPPER_CLASSES.put( Boolean.class, Boolean.TYPE );
- PRIMITIVE_WRAPPER_CLASSES.put( Byte.TYPE, Byte.class );
- PRIMITIVE_WRAPPER_CLASSES.put( Byte.class, Byte.TYPE );
- PRIMITIVE_WRAPPER_CLASSES.put( Character.TYPE, Character.class );
- PRIMITIVE_WRAPPER_CLASSES.put( Character.class, Character.TYPE );
- PRIMITIVE_WRAPPER_CLASSES.put( Short.TYPE, Short.class );
- PRIMITIVE_WRAPPER_CLASSES.put( Short.class, Short.TYPE );
- PRIMITIVE_WRAPPER_CLASSES.put( Integer.TYPE, Integer.class );
- PRIMITIVE_WRAPPER_CLASSES.put( Integer.class, Integer.TYPE );
- PRIMITIVE_WRAPPER_CLASSES.put( Long.TYPE, Long.class );
- PRIMITIVE_WRAPPER_CLASSES.put( Long.class, Long.TYPE );
- PRIMITIVE_WRAPPER_CLASSES.put( Float.TYPE, Float.class );
- PRIMITIVE_WRAPPER_CLASSES.put( Float.class, Float.TYPE );
- PRIMITIVE_WRAPPER_CLASSES.put( Double.TYPE, Double.class );
- PRIMITIVE_WRAPPER_CLASSES.put( Double.class, Double.TYPE );
- }
-
- public static Class getPrimitiveWrapperClass( Class primitiveClass )
- {
- return (Class) PRIMITIVE_WRAPPER_CLASSES.get( primitiveClass );
- }
-
- public interface Getter
- {
- Object get( OgnlContext context, Object target, String propertyName );
- }
-
- public static Getter generateGetter( OgnlContext context, String code )
- throws OgnlException
- {
- String className = NAME_FACTORY.getNewClassName();
-
- try
- {
- ClassPool pool = (ClassPool) POOLS.get( context.getClassResolver() );
- EnhancedClassLoader loader = (EnhancedClassLoader) LOADERS.get( context.getClassResolver() );
- CtClass newClass;
- CtClass ognlContextClass;
- CtClass objectClass;
- CtClass stringClass;
- CtMethod method;
- byte[] byteCode;
- Class compiledClass;
-
- if ( ( pool == null ) || ( loader == null ) )
- {
- ClassLoader classLoader = new ContextClassLoader( OgnlContext.class.getClassLoader(), context );
-
- pool = ClassPool.getDefault();
- pool.insertClassPath( new LoaderClassPath( classLoader ) );
- POOLS.put( context.getClassResolver(), pool );
-
- loader = new EnhancedClassLoader( classLoader );
- LOADERS.put( context.getClassResolver(), loader );
- }
-
- newClass = pool.makeClass( className );
- ognlContextClass = pool.get( OgnlContext.class.getName() );
- objectClass = pool.get( Object.class.getName() );
- stringClass = pool.get( String.class.getName() );
-
- newClass.addInterface( pool.get( Getter.class.getName() ) );
- method =
- new CtMethod( objectClass, "get", new CtClass[] { ognlContextClass, objectClass, stringClass },
- newClass );
- method.setBody( "{" + code + "}" );
- newClass.addMethod( method );
- byteCode = newClass.toBytecode();
- compiledClass = loader.defineClass( className, byteCode );
- return (Getter) compiledClass.newInstance();
- }
- catch ( Throwable ex )
- {
- throw new OgnlException( "Cannot create class", ex );
- }
- }
-
- private Getter getGetter( OgnlContext context, Object target, String propertyName )
- throws OgnlException
- {
- Getter result;
- Class targetClass = target.getClass();
- Map propertyMap;
-
- if ( ( propertyMap = (Map) seenGetMethods.get( targetClass ) ) == null )
- {
- propertyMap = new HashMap( 101 );
- seenGetMethods.put( targetClass, propertyMap );
- }
- if ( ( result = (Getter) propertyMap.get( propertyName ) ) == null )
- {
- try
- {
- Method method = OgnlRuntime.getGetMethod( context, targetClass, propertyName );
-
- if ( method != null )
- {
- if ( Modifier.isPublic( method.getModifiers() ) )
- {
- if ( method.getReturnType().isPrimitive() )
- {
- propertyMap.put( propertyName,
- result =
- generateGetter( context,
- "java.lang.Object\t\tresult;\n"
- + targetClass.getName()
- + "\t"
- + "t0 = ("
- + targetClass.getName()
- + ")$2;\n"
- + "\n"
- + "try {\n"
- + " result = new "
- + getPrimitiveWrapperClass( method.getReturnType() ).getName()
- + "(t0."
- + method.getName()
- + "());\n"
- + "} catch (java.lang.Exception ex) {\n"
- + " throw new java.lang.RuntimeException(ex);\n"
- + "}\n" + "return result;" ) );
- }
- else
- {
- propertyMap.put( propertyName,
- result =
- generateGetter( context,
- "java.lang.Object\t\tresult;\n"
- + targetClass.getName()
- + "\t"
- + "t0 = ("
- + targetClass.getName()
- + ")$2;\n"
- + "\n"
- + "try {\n"
- + " result = t0."
- + method.getName()
- + "();\n"
- + "} catch (java.lang.Exception ex) {\n"
- + " throw new java.lang.RuntimeException(ex);\n"
- + "}\n" + "return result;" ) );
- }
- }
- else
- {
- propertyMap.put( propertyName, result = DEFAULT_GETTER );
- }
- }
- else
- {
- propertyMap.put( propertyName, result = NOT_FOUND_GETTER );
- }
- }
- catch ( Exception ex )
- {
- throw new OgnlException( "getting getter", ex );
- }
- }
- return result;
- }
-
- /**
- * Returns OgnlRuntime.NotFound if the property does not exist.
- */
- public Object getPossibleProperty( Map context, Object target, String name )
- throws OgnlException
- {
- Object result;
- OgnlContext ognlContext = (OgnlContext) context;
-
- if ( context.get( "_compile" ) != null )
- {
- Getter getter = getGetter( ognlContext, target, name );
-
- if ( getter != NOT_FOUND_GETTER )
- {
- result = getter.get( ognlContext, target, name );
- }
- else
- {
- try
- {
- result = OgnlRuntime.getFieldValue( ognlContext, target, name, true );
- }
- catch ( Exception ex )
- {
- throw new OgnlException( name, ex );
- }
- }
- }
- else
- {
- result = super.getPossibleProperty( context, target, name );
- }
- return result;
- }
-}
+/*
+ * 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.test;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.CtMethod;
+import javassist.LoaderClassPath;
+import org.apache.commons.ognl.ObjectPropertyAccessor;
+import org.apache.commons.ognl.OgnlContext;
+import org.apache.commons.ognl.OgnlException;
+import org.apache.commons.ognl.OgnlRuntime;
+import org.apache.commons.ognl.enhance.ContextClassLoader;
+import org.apache.commons.ognl.enhance.EnhancedClassLoader;
+import org.apache.commons.ognl.test.util.NameFactory;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.IdentityHashMap;
+import java.util.Map;
+
+/**
+ * Implementation of PropertyAccessor that uses Javassist to compile a property accessor specifically tailored to the
+ * property.
+ */
+public class CompilingPropertyAccessor
+ extends ObjectPropertyAccessor
+{
+
+ private static final NameFactory NAME_FACTORY = new NameFactory( "ognl.PropertyAccessor", "v" );
+
+ private static final Getter NOT_FOUND_GETTER = (context, target, propertyName) -> null;
+
+ private static final Getter DEFAULT_GETTER = (context, target, propertyName) -> {
+ try
+ {
+ return OgnlRuntime.getMethodValue( context, target, propertyName, true );
+ }
+ catch ( Exception ex )
+ {
+ throw new RuntimeException( ex );
+ }
+ };
+
+ private static final Map POOLS = new HashMap();
+
+ private static final Map LOADERS = new HashMap();
+
+ private static final java.util.IdentityHashMap PRIMITIVE_WRAPPER_CLASSES = new IdentityHashMap();
+
+ private final java.util.IdentityHashMap seenGetMethods = new java.util.IdentityHashMap();
+
+ static
+ {
+ PRIMITIVE_WRAPPER_CLASSES.put( Boolean.TYPE, Boolean.class );
+ PRIMITIVE_WRAPPER_CLASSES.put( Boolean.class, Boolean.TYPE );
+ PRIMITIVE_WRAPPER_CLASSES.put( Byte.TYPE, Byte.class );
+ PRIMITIVE_WRAPPER_CLASSES.put( Byte.class, Byte.TYPE );
+ PRIMITIVE_WRAPPER_CLASSES.put( Character.TYPE, Character.class );
+ PRIMITIVE_WRAPPER_CLASSES.put( Character.class, Character.TYPE );
+ PRIMITIVE_WRAPPER_CLASSES.put( Short.TYPE, Short.class );
+ PRIMITIVE_WRAPPER_CLASSES.put( Short.class, Short.TYPE );
+ PRIMITIVE_WRAPPER_CLASSES.put( Integer.TYPE, Integer.class );
+ PRIMITIVE_WRAPPER_CLASSES.put( Integer.class, Integer.TYPE );
+ PRIMITIVE_WRAPPER_CLASSES.put( Long.TYPE, Long.class );
+ PRIMITIVE_WRAPPER_CLASSES.put( Long.class, Long.TYPE );
+ PRIMITIVE_WRAPPER_CLASSES.put( Float.TYPE, Float.class );
+ PRIMITIVE_WRAPPER_CLASSES.put( Float.class, Float.TYPE );
+ PRIMITIVE_WRAPPER_CLASSES.put( Double.TYPE, Double.class );
+ PRIMITIVE_WRAPPER_CLASSES.put( Double.class, Double.TYPE );
+ }
+
+ public static Class getPrimitiveWrapperClass( Class primitiveClass )
+ {
+ return (Class) PRIMITIVE_WRAPPER_CLASSES.get( primitiveClass );
+ }
+
+ public interface Getter
+ {
+ Object get( OgnlContext context, Object target, String propertyName );
+ }
+
+ public static Getter generateGetter( OgnlContext context, String code )
+ throws OgnlException
+ {
+ String className = NAME_FACTORY.getNewClassName();
+
+ try
+ {
+ ClassPool pool = (ClassPool) POOLS.get( context.getClassResolver() );
+ EnhancedClassLoader loader = (EnhancedClassLoader) LOADERS.get( context.getClassResolver() );
+ CtClass newClass;
+ CtClass ognlContextClass;
+ CtClass objectClass;
+ CtClass stringClass;
+ CtMethod method;
+ byte[] byteCode;
+ Class compiledClass;
+
+ if ( ( pool == null ) || ( loader == null ) )
+ {
+ ClassLoader classLoader = new ContextClassLoader( OgnlContext.class.getClassLoader(), context );
+
+ pool = ClassPool.getDefault();
+ pool.insertClassPath( new LoaderClassPath( classLoader ) );
+ POOLS.put( context.getClassResolver(), pool );
+
+ loader = new EnhancedClassLoader( classLoader );
+ LOADERS.put( context.getClassResolver(), loader );
+ }
+
+ newClass = pool.makeClass( className );
+ ognlContextClass = pool.get( OgnlContext.class.getName() );
+ objectClass = pool.get( Object.class.getName() );
+ stringClass = pool.get( String.class.getName() );
+
+ newClass.addInterface( pool.get( Getter.class.getName() ) );
+ method =
+ new CtMethod( objectClass, "get", new CtClass[] { ognlContextClass, objectClass, stringClass },
+ newClass );
+ method.setBody( "{" + code + "}" );
+ newClass.addMethod( method );
+ byteCode = newClass.toBytecode();
+ compiledClass = loader.defineClass( className, byteCode );
+ return (Getter) compiledClass.newInstance();
+ }
+ catch ( Throwable ex )
+ {
+ throw new OgnlException( "Cannot create class", ex );
+ }
+ }
+
+ private Getter getGetter( OgnlContext context, Object target, String propertyName )
+ throws OgnlException
+ {
+ Getter result;
+ Class targetClass = target.getClass();
+ Map propertyMap;
+
+ if ( ( propertyMap = (Map) seenGetMethods.get( targetClass ) ) == null )
+ {
+ propertyMap = new HashMap( 101 );
+ seenGetMethods.put( targetClass, propertyMap );
+ }
+ if ( ( result = (Getter) propertyMap.get( propertyName ) ) == null )
+ {
+ try
+ {
+ Method method = OgnlRuntime.getGetMethod( context, targetClass, propertyName );
+
+ if ( method != null )
+ {
+ if ( Modifier.isPublic( method.getModifiers() ) )
+ {
+ if ( method.getReturnType().isPrimitive() )
+ {
+ propertyMap.put( propertyName,
+ result =
+ generateGetter( context,
+ "java.lang.Object\t\tresult;\n"
+ + targetClass.getName()
+ + "\t"
+ + "t0 = ("
+ + targetClass.getName()
+ + ")$2;\n"
+ + "\n"
+ + "try {\n"
+ + " result = new "
+ + getPrimitiveWrapperClass( method.getReturnType() ).getName()
+ + "(t0."
+ + method.getName()
+ + "());\n"
+ + "} catch (java.lang.Exception ex) {\n"
+ + " throw new java.lang.RuntimeException(ex);\n"
+ + "}\n" + "return result;" ) );
+ }
+ else
+ {
+ propertyMap.put( propertyName,
+ result =
+ generateGetter( context,
+ "java.lang.Object\t\tresult;\n"
+ + targetClass.getName()
+ + "\t"
+ + "t0 = ("
+ + targetClass.getName()
+ + ")$2;\n"
+ + "\n"
+ + "try {\n"
+ + " result = t0."
+ + method.getName()
+ + "();\n"
+ + "} catch (java.lang.Exception ex) {\n"
+ + " throw new java.lang.RuntimeException(ex);\n"
+ + "}\n" + "return result;" ) );
+ }
+ }
+ else
+ {
+ propertyMap.put( propertyName, result = DEFAULT_GETTER );
+ }
+ }
+ else
+ {
+ propertyMap.put( propertyName, result = NOT_FOUND_GETTER );
+ }
+ }
+ catch ( Exception ex )
+ {
+ throw new OgnlException( "getting getter", ex );
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Returns OgnlRuntime.NotFound if the property does not exist.
+ */
+ public Object getPossibleProperty( Map context, Object target, String name )
+ throws OgnlException
+ {
+ Object result;
+ OgnlContext ognlContext = (OgnlContext) context;
+
+ if ( context.get( "_compile" ) != null )
+ {
+ Getter getter = getGetter( ognlContext, target, name );
+
+ if ( getter != NOT_FOUND_GETTER )
+ {
+ result = getter.get( ognlContext, target, name );
+ }
+ else
+ {
+ try
+ {
+ result = OgnlRuntime.getFieldValue( ognlContext, target, name, true );
+ }
+ catch ( Exception ex )
+ {
+ throw new OgnlException( name, ex );
+ }
+ }
+ }
+ else
+ {
+ result = super.getPossibleProperty( context, target, name );
+ }
+ return result;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/ConstantTest.java b/src/test/java/org/apache/commons/ognl/test/ConstantTest.java
index 51ac9cc..4a4eea6 100644
--- a/src/test/java/org/apache/commons/ognl/test/ConstantTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/ConstantTest.java
@@ -1,109 +1,108 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.ExpressionSyntaxException;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class ConstantTest
- extends OgnlTestCase
-{
-
- private static final Object[][] TESTS = {
- { "12345", new Integer( 12345 ) },
- { "0x100", new Integer( 256 ) },
- { "0xfE", new Integer( 254 ) },
- { "01000", new Integer( 512 ) },
- { "1234L", new Integer( 1234 ) },
- { "12.34", new Double( 12.34 ) },
- { ".1234", new Double( .12340000000000 ) },
- { "12.34f", Double.valueOf( 12.34 ) },
- { "12.", new Double( 12 ) },
- { "12e+1d", new Double( 120 ) },
- { "'x'", new Character( 'x' ) },
- { "'\\n'", new Character( '\n' ) },
- { "'\\u048c'", new Character( '\u048c' ) },
- { "'\\47'", new Character( '\47' ) },
- { "'\\367'", new Character( '\367' ) },
- { "'\\367", ExpressionSyntaxException.class },
- { "'\\x'", ExpressionSyntaxException.class },
- { "\"hello world\"", "hello world" },
- { "\"\\u00a0\\u0068ell\\'o\\\\\\n\\r\\f\\t\\b\\\"\\167orld\\\"\"", "\u00a0hell'o\\\n\r\f\t\b\"world\"" },
- { "\"hello world", ExpressionSyntaxException.class },
- { "\"hello\\x world\"", ExpressionSyntaxException.class },
- { "null", null },
- { "true", Boolean.TRUE },
- { "false", Boolean.FALSE },
- { "{ false, true, null, 0, 1. }",
- Arrays.asList( Boolean.FALSE, Boolean.TRUE, null, new Integer( 0 ), new Double( 1 ) ) },
- { "'HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"'",
- "HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"" }, };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][0] + " (" + TESTS[i][1] + ")";
- tmp[1] = null;
- tmp[2] = TESTS[i][0];
- tmp[3] = TESTS[i][1];
- tmp[4] = null;
- tmp[5] = null;
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public ConstantTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
- Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-
- @Before
- @Override
- public void setUp()
- {
- super.setUp();
- _context.put( "x", "1" );
- _context.put( "y", new BigDecimal( 1 ) );
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.ExpressionSyntaxException;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class ConstantTest
+ extends OgnlTestCase
+{
+
+ private static final Object[][] TESTS = {
+ { "12345", new Integer( 12345 ) },
+ { "0x100", new Integer( 256 ) },
+ { "0xfE", new Integer( 254 ) },
+ { "01000", new Integer( 512 ) },
+ { "1234L", new Integer( 1234 ) },
+ { "12.34", new Double( 12.34 ) },
+ { ".1234", new Double( .12340000000000 ) },
+ { "12.34f", Double.valueOf( 12.34 ) },
+ { "12.", new Double( 12 ) },
+ { "12e+1d", new Double( 120 ) },
+ { "'x'", new Character( 'x' ) },
+ { "'\\n'", new Character( '\n' ) },
+ { "'\\u048c'", new Character( '\u048c' ) },
+ { "'\\47'", new Character( '\47' ) },
+ { "'\\367'", new Character( '\367' ) },
+ { "'\\367", ExpressionSyntaxException.class },
+ { "'\\x'", ExpressionSyntaxException.class },
+ { "\"hello world\"", "hello world" },
+ { "\"\\u00a0\\u0068ell\\'o\\\\\\n\\r\\f\\t\\b\\\"\\167orld\\\"\"", "\u00a0hell'o\\\n\r\f\t\b\"world\"" },
+ { "\"hello world", ExpressionSyntaxException.class },
+ { "\"hello\\x world\"", ExpressionSyntaxException.class },
+ { "null", null },
+ { "true", Boolean.TRUE },
+ { "false", Boolean.FALSE },
+ { "{ false, true, null, 0, 1. }",
+ Arrays.asList( Boolean.FALSE, Boolean.TRUE, null, new Integer( 0 ), new Double( 1 ) ) },
+ { "'HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"'",
+ "HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"" }, };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][0] + " (" + TESTS[i][1] + ")";
+ tmp[1] = null;
+ tmp[2] = TESTS[i][0];
+ tmp[3] = TESTS[i][1];
+ tmp[4] = null;
+ tmp[5] = null;
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public ConstantTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
+ Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+
+ @Before
+ @Override
+ public void setUp()
+ {
+ super.setUp();
+ _context.put( "x", "1" );
+ _context.put( "y", new BigDecimal( 1 ) );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/ConstantTreeTest.java b/src/test/java/org/apache/commons/ognl/test/ConstantTreeTest.java
index 349a00d..5ccc2c9 100644
--- a/src/test/java/org/apache/commons/ognl/test/ConstantTreeTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/ConstantTreeTest.java
@@ -1,93 +1,92 @@
-/*
- * $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.test;
-
-import static junit.framework.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import junit.framework.Assert;
-import org.apache.commons.ognl.Ognl;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(value = Parameterized.class)
-public class ConstantTreeTest
- extends OgnlTestCase
-{
-
- public static int nonFinalStaticVariable = 15;
-
- private static final Object[][] TESTS = { { "true", Boolean.TRUE }, { "55", Boolean.TRUE },
- { "@java.awt.Color@black", Boolean.TRUE },
- { "@org.apache.commons.ognl.test.ConstantTreeTest@nonFinalStaticVariable", Boolean.FALSE },
- { "@org.apache.commons.ognl.test.ConstantTreeTest@nonFinalStaticVariable + 10", Boolean.FALSE },
- { "55 + 24 + @java.awt.Event@ALT_MASK", Boolean.TRUE }, { "name", Boolean.FALSE },
- { "name[i]", Boolean.FALSE }, { "name[i].property", Boolean.FALSE }, { "name.{? foo }", Boolean.FALSE },
- { "name.{ foo }", Boolean.FALSE }, { "name.{ 25 }", Boolean.FALSE }
-
- };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][0] + " (" + TESTS[i][1] + ")";
- tmp[1] = null;
- tmp[2] = TESTS[i][0];
- tmp[3] = TESTS[i][1];
- tmp[4] = null;
- tmp[5] = null;
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Overridden methods
- * ===================================================================
- */
- @Override
- public void runTest()
- throws Exception
- {
- Assert.assertEquals(Ognl.isConstant(getExpression(), _context), ((Boolean) getExpectedResult()).booleanValue());
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public ConstantTreeTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
- Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-}
+/*
+ * 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.test;
+
+import static junit.framework.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import junit.framework.Assert;
+import org.apache.commons.ognl.Ognl;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
+public class ConstantTreeTest
+ extends OgnlTestCase
+{
+
+ public static int nonFinalStaticVariable = 15;
+
+ private static final Object[][] TESTS = { { "true", Boolean.TRUE }, { "55", Boolean.TRUE },
+ { "@java.awt.Color@black", Boolean.TRUE },
+ { "@org.apache.commons.ognl.test.ConstantTreeTest@nonFinalStaticVariable", Boolean.FALSE },
+ { "@org.apache.commons.ognl.test.ConstantTreeTest@nonFinalStaticVariable + 10", Boolean.FALSE },
+ { "55 + 24 + @java.awt.Event@ALT_MASK", Boolean.TRUE }, { "name", Boolean.FALSE },
+ { "name[i]", Boolean.FALSE }, { "name[i].property", Boolean.FALSE }, { "name.{? foo }", Boolean.FALSE },
+ { "name.{ foo }", Boolean.FALSE }, { "name.{ 25 }", Boolean.FALSE }
+
+ };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][0] + " (" + TESTS[i][1] + ")";
+ tmp[1] = null;
+ tmp[2] = TESTS[i][0];
+ tmp[3] = TESTS[i][1];
+ tmp[4] = null;
+ tmp[5] = null;
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Overridden methods
+ * ===================================================================
+ */
+ @Override
+ public void runTest()
+ throws Exception
+ {
+ Assert.assertEquals(Ognl.isConstant(getExpression(), _context), ((Boolean) getExpectedResult()).booleanValue());
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public ConstantTreeTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
+ Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/ContextVariableTest.java b/src/test/java/org/apache/commons/ognl/test/ContextVariableTest.java
index 9801751..d84fd1e 100644
--- a/src/test/java/org/apache/commons/ognl/test/ContextVariableTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/ContextVariableTest.java
@@ -1,75 +1,74 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.test.objects.Simple;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class ContextVariableTest
- extends OgnlTestCase
-{
-
- private static final Object ROOT = new Simple();
-
- private static final Object[][] TESTS = {
- // Naming and referring to names
- { "#root", ROOT }, // Special root reference
- { "#this", ROOT }, // Special this reference
- { "#f=5, #s=6, #f + #s", new Integer( 11 ) }, { "#six=(#five=5, 6), #five + #six", new Integer( 11 ) }, };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][0] + " (" + TESTS[i][1] + ")";
- tmp[1] = ROOT;
- tmp[2] = TESTS[i][0];
- tmp[3] = TESTS[i][1];
- tmp[4] = null;
- tmp[5] = null;
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public ContextVariableTest( String name, Object root, String expressionString, Object expectedResult,
- Object setValue, Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.test.objects.Simple;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class ContextVariableTest
+ extends OgnlTestCase
+{
+
+ private static final Object ROOT = new Simple();
+
+ private static final Object[][] TESTS = {
+ // Naming and referring to names
+ { "#root", ROOT }, // Special root reference
+ { "#this", ROOT }, // Special this reference
+ { "#f=5, #s=6, #f + #s", new Integer( 11 ) }, { "#six=(#five=5, 6), #five + #six", new Integer( 11 ) }, };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][0] + " (" + TESTS[i][1] + ")";
+ tmp[1] = ROOT;
+ tmp[2] = TESTS[i][0];
+ tmp[3] = TESTS[i][1];
+ tmp[4] = null;
+ tmp[5] = null;
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public ContextVariableTest( String name, Object root, String expressionString, Object expectedResult,
+ Object setValue, Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/CorrectedObjectNullHandler.java b/src/test/java/org/apache/commons/ognl/test/CorrectedObjectNullHandler.java
index e6ad4dc..9efbbe4 100644
--- a/src/test/java/org/apache/commons/ognl/test/CorrectedObjectNullHandler.java
+++ b/src/test/java/org/apache/commons/ognl/test/CorrectedObjectNullHandler.java
@@ -1,62 +1,61 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.NullHandler;
-
-import java.util.Map;
-
-public class CorrectedObjectNullHandler
- extends Object
- implements NullHandler
-{
- private final String defaultValue;
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public CorrectedObjectNullHandler( String defaultValue )
- {
- this.defaultValue = defaultValue;
- }
-
- /*
- * =================================================================== TypeConverter interface (overridden)
- * ===================================================================
- */
- public Object nullMethodResult( Map context, Object target, String methodName, Object[] args )
- {
- if ( methodName.equals( "getStringValue" ) )
- {
- return defaultValue;
- }
- return null;
- }
-
- public Object nullPropertyValue( Map context, Object target, Object property )
- {
- if ( property.equals( "stringValue" ) )
- {
- return defaultValue;
- }
- return 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.test;
+
+import org.apache.commons.ognl.NullHandler;
+
+import java.util.Map;
+
+public class CorrectedObjectNullHandler
+ extends Object
+ implements NullHandler
+{
+ private final String defaultValue;
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public CorrectedObjectNullHandler( String defaultValue )
+ {
+ this.defaultValue = defaultValue;
+ }
+
+ /*
+ * =================================================================== TypeConverter interface (overridden)
+ * ===================================================================
+ */
+ public Object nullMethodResult( Map context, Object target, String methodName, Object[] args )
+ {
+ if ( methodName.equals( "getStringValue" ) )
+ {
+ return defaultValue;
+ }
+ return null;
+ }
+
+ public Object nullPropertyValue( Map context, Object target, Object property )
+ {
+ if ( property.equals( "stringValue" ) )
+ {
+ return defaultValue;
+ }
+ return null;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/GenericsTest.java b/src/test/java/org/apache/commons/ognl/test/GenericsTest.java
index 8a2fd54..8cc80e6 100644
--- a/src/test/java/org/apache/commons/ognl/test/GenericsTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/GenericsTest.java
@@ -1,74 +1,73 @@
-/*
- * $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.test;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.apache.commons.ognl.test.objects.BaseGeneric;
-import org.apache.commons.ognl.test.objects.GameGeneric;
-import org.apache.commons.ognl.test.objects.GameGenericObject;
-import org.apache.commons.ognl.test.objects.GenericRoot;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-/**
- * Tests java >= 1.5 generics support in ognl.
- */
-@RunWith(value = Parameterized.class)
-public class GenericsTest
- extends OgnlTestCase
-{
- static GenericRoot ROOT = new GenericRoot();
-
- static BaseGeneric<GameGenericObject, Long> GENERIC = new GameGeneric();
-
- static Object[][] TESTS = {
- /* { ROOT, "cracker.param", null, new Integer(2), new Integer(2)}, */
- { GENERIC, "ids", null, new Long[] { 1l, 101l }, new Long[] { 1l, 101l } },
- /* { GENERIC, "ids", new Long[] {1l, 101l}, new String[] {"2", "34"}, new Long[]{2l, 34l}}, */
- };
-
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][1] + " (" + TESTS[i][2] + ")";
- tmp[1] = TESTS[i][0];
- tmp[2] = TESTS[i][1];
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- tmp[5] = TESTS[i][4];
-
- data.add( tmp );
- }
- return data;
- }
-
- public GenericsTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
- Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-}
+/*
+ * 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.test;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.commons.ognl.test.objects.BaseGeneric;
+import org.apache.commons.ognl.test.objects.GameGeneric;
+import org.apache.commons.ognl.test.objects.GameGenericObject;
+import org.apache.commons.ognl.test.objects.GenericRoot;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * Tests java >= 1.5 generics support in ognl.
+ */
+@RunWith(value = Parameterized.class)
+public class GenericsTest
+ extends OgnlTestCase
+{
+ static GenericRoot ROOT = new GenericRoot();
+
+ static BaseGeneric<GameGenericObject, Long> GENERIC = new GameGeneric();
+
+ static Object[][] TESTS = {
+ /* { ROOT, "cracker.param", null, new Integer(2), new Integer(2)}, */
+ { GENERIC, "ids", null, new Long[] { 1l, 101l }, new Long[] { 1l, 101l } },
+ /* { GENERIC, "ids", new Long[] {1l, 101l}, new String[] {"2", "34"}, new Long[]{2l, 34l}}, */
+ };
+
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][1] + " (" + TESTS[i][2] + ")";
+ tmp[1] = TESTS[i][0];
+ tmp[2] = TESTS[i][1];
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ tmp[5] = TESTS[i][4];
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ public GenericsTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
+ Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/IndexAccessTest.java b/src/test/java/org/apache/commons/ognl/test/IndexAccessTest.java
index dcac773..6ec636c 100644
--- a/src/test/java/org/apache/commons/ognl/test/IndexAccessTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/IndexAccessTest.java
@@ -1,98 +1,97 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.MethodFailedException;
-import org.apache.commons.ognl.NoSuchPropertyException;
-import org.apache.commons.ognl.test.objects.IndexedSetObject;
-import org.apache.commons.ognl.test.objects.Root;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class IndexAccessTest
- extends OgnlTestCase
-{
-
- private static final Root ROOT = new Root();
-
- private static final IndexedSetObject INDEXED_SET = new IndexedSetObject();
-
- private static final Object[][] TESTS =
- {
- { ROOT, "list[index]", ROOT.getList().get( ROOT.getIndex() ) },
- { ROOT, "list[objectIndex]", ROOT.getList().get( ROOT.getObjectIndex().intValue() ) },
- { ROOT, "array[objectIndex]", ROOT.getArray()[ROOT.getObjectIndex().intValue()] },
- { ROOT, "array[getObjectIndex()]", ROOT.getArray()[ROOT.getObjectIndex().intValue()] },
- { ROOT, "array[genericIndex]", ROOT.getArray()[( (Integer) ROOT.getGenericIndex() ).intValue()] },
- { ROOT, "booleanArray[self.objectIndex]", Boolean.FALSE },
- { ROOT, "booleanArray[getObjectIndex()]", Boolean.FALSE },
- { ROOT, "booleanArray[nullIndex]", NoSuchPropertyException.class },
- { ROOT, "list[size() - 1]", MethodFailedException.class },
- { ROOT, "(index == (array.length - 3)) ? 'toggle toggleSelected' : 'toggle'", "toggle toggleSelected" },
- { ROOT, "\"return toggleDisplay('excdisplay\"+index+\"', this)\"",
- "return toggleDisplay('excdisplay1', this)" }, { ROOT, "map[mapKey].split('=')[0]", "StringStuff" },
- { ROOT, "booleanValues[index1][index2]", Boolean.FALSE },
- { ROOT, "tab.searchCriteria[index1].displayName", "Woodland creatures" },
- { ROOT, "tab.searchCriteriaSelections[index1][index2]", Boolean.TRUE },
- { ROOT, "tab.searchCriteriaSelections[index1][index2]", Boolean.TRUE, Boolean.FALSE, Boolean.FALSE },
- { ROOT, "map['bar'].value", 100, 50, 50 }, { INDEXED_SET, "thing[\"x\"].val", 1, 2, 2 } };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][1];
- tmp[1] = TESTS[i][0];
- tmp[2] = TESTS[i][1];
- tmp[3] = TESTS[i][2];
-
- if ( TESTS[i].length == 5 )
- {
- tmp[4] = TESTS[i][3];
- tmp[5] = TESTS[i][4];
- }
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public IndexAccessTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
- Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.MethodFailedException;
+import org.apache.commons.ognl.NoSuchPropertyException;
+import org.apache.commons.ognl.test.objects.IndexedSetObject;
+import org.apache.commons.ognl.test.objects.Root;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class IndexAccessTest
+ extends OgnlTestCase
+{
+
+ private static final Root ROOT = new Root();
+
+ private static final IndexedSetObject INDEXED_SET = new IndexedSetObject();
+
+ private static final Object[][] TESTS =
+ {
+ { ROOT, "list[index]", ROOT.getList().get( ROOT.getIndex() ) },
+ { ROOT, "list[objectIndex]", ROOT.getList().get( ROOT.getObjectIndex().intValue() ) },
+ { ROOT, "array[objectIndex]", ROOT.getArray()[ROOT.getObjectIndex().intValue()] },
+ { ROOT, "array[getObjectIndex()]", ROOT.getArray()[ROOT.getObjectIndex().intValue()] },
+ { ROOT, "array[genericIndex]", ROOT.getArray()[( (Integer) ROOT.getGenericIndex() ).intValue()] },
+ { ROOT, "booleanArray[self.objectIndex]", Boolean.FALSE },
+ { ROOT, "booleanArray[getObjectIndex()]", Boolean.FALSE },
+ { ROOT, "booleanArray[nullIndex]", NoSuchPropertyException.class },
+ { ROOT, "list[size() - 1]", MethodFailedException.class },
+ { ROOT, "(index == (array.length - 3)) ? 'toggle toggleSelected' : 'toggle'", "toggle toggleSelected" },
+ { ROOT, "\"return toggleDisplay('excdisplay\"+index+\"', this)\"",
+ "return toggleDisplay('excdisplay1', this)" }, { ROOT, "map[mapKey].split('=')[0]", "StringStuff" },
+ { ROOT, "booleanValues[index1][index2]", Boolean.FALSE },
+ { ROOT, "tab.searchCriteria[index1].displayName", "Woodland creatures" },
+ { ROOT, "tab.searchCriteriaSelections[index1][index2]", Boolean.TRUE },
+ { ROOT, "tab.searchCriteriaSelections[index1][index2]", Boolean.TRUE, Boolean.FALSE, Boolean.FALSE },
+ { ROOT, "map['bar'].value", 100, 50, 50 }, { INDEXED_SET, "thing[\"x\"].val", 1, 2, 2 } };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][1];
+ tmp[1] = TESTS[i][0];
+ tmp[2] = TESTS[i][1];
+ tmp[3] = TESTS[i][2];
+
+ if ( TESTS[i].length == 5 )
+ {
+ tmp[4] = TESTS[i][3];
+ tmp[5] = TESTS[i][4];
+ }
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public IndexAccessTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
+ Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/IndexedPropertyTest.java b/src/test/java/org/apache/commons/ognl/test/IndexedPropertyTest.java
index 157c963..a67e20f 100644
--- a/src/test/java/org/apache/commons/ognl/test/IndexedPropertyTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/IndexedPropertyTest.java
@@ -1,107 +1,106 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.test.objects.Indexed;
-import org.apache.commons.ognl.test.objects.Root;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class IndexedPropertyTest
- extends OgnlTestCase
-{
-
- private static final Indexed INDEXED = new Indexed();
-
- private static final Root ROOT = new Root();
-
- private static final Object[][] TESTS = {
- // Indexed properties
- { INDEXED, "getValues", INDEXED.getValues() }, // gets String[]
- { INDEXED, "[\"values\"]", INDEXED.getValues() }, // String[]
- { INDEXED.getValues(), "[0]", INDEXED.getValues()[0] }, // "foo"
- { INDEXED, "getValues()[0]", INDEXED.getValues()[0] }, // "foo" directly from array
- { INDEXED, "values[0]", INDEXED.getValues( 0 ) }, // "foo" + "xxx"
- { INDEXED, "values[^]", INDEXED.getValues( 0 ) }, // "foo" + "xxx"
- { INDEXED, "values[|]", INDEXED.getValues( 1 ) }, // "bar" + "xxx"
- { INDEXED, "values[$]", INDEXED.getValues( 2 ) }, // "baz" + "xxx"
- { INDEXED, "values[1]", "bar" + "xxx", "xxxx" + "xxx", "xxxx" + "xxx" }, // set through setValues(int, String)
- { INDEXED, "values[1]", "xxxx" + "xxx" }, // getValues(int) again to check if setValues(int, String) was called
- { INDEXED, "setValues(2, \"xxxx\")", null }, // was "baz" -> "xxxx"
- { INDEXED, "getTitle(list.size)", "Title count 3" }, { INDEXED, "source.total", 1 },
- { ROOT, "indexer.line[index]", "line:1" }, { INDEXED, "list[2].longValue()", (long) 3 },
- { ROOT, "map.value.id", (long) 1 }, { INDEXED, "property['hoodak']", null, "random string", "random string" } };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][1];
- tmp[1] = TESTS[i][0];
- tmp[2] = TESTS[i][1];
-
- switch ( TESTS[i].length )
- {
- case 3:
- tmp[3] = TESTS[i][2];
- break;
-
- case 4:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- break;
-
- case 5:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- tmp[5] = TESTS[i][4];
- break;
-
- default:
- throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
- }
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public IndexedPropertyTest( String name, Object root, String expressionString, Object expectedResult,
- Object setValue, Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.test.objects.Indexed;
+import org.apache.commons.ognl.test.objects.Root;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class IndexedPropertyTest
+ extends OgnlTestCase
+{
+
+ private static final Indexed INDEXED = new Indexed();
+
+ private static final Root ROOT = new Root();
+
+ private static final Object[][] TESTS = {
+ // Indexed properties
+ { INDEXED, "getValues", INDEXED.getValues() }, // gets String[]
+ { INDEXED, "[\"values\"]", INDEXED.getValues() }, // String[]
+ { INDEXED.getValues(), "[0]", INDEXED.getValues()[0] }, // "foo"
+ { INDEXED, "getValues()[0]", INDEXED.getValues()[0] }, // "foo" directly from array
+ { INDEXED, "values[0]", INDEXED.getValues( 0 ) }, // "foo" + "xxx"
+ { INDEXED, "values[^]", INDEXED.getValues( 0 ) }, // "foo" + "xxx"
+ { INDEXED, "values[|]", INDEXED.getValues( 1 ) }, // "bar" + "xxx"
+ { INDEXED, "values[$]", INDEXED.getValues( 2 ) }, // "baz" + "xxx"
+ { INDEXED, "values[1]", "bar" + "xxx", "xxxx" + "xxx", "xxxx" + "xxx" }, // set through setValues(int, String)
+ { INDEXED, "values[1]", "xxxx" + "xxx" }, // getValues(int) again to check if setValues(int, String) was called
+ { INDEXED, "setValues(2, \"xxxx\")", null }, // was "baz" -> "xxxx"
+ { INDEXED, "getTitle(list.size)", "Title count 3" }, { INDEXED, "source.total", 1 },
+ { ROOT, "indexer.line[index]", "line:1" }, { INDEXED, "list[2].longValue()", (long) 3 },
+ { ROOT, "map.value.id", (long) 1 }, { INDEXED, "property['hoodak']", null, "random string", "random string" } };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][1];
+ tmp[1] = TESTS[i][0];
+ tmp[2] = TESTS[i][1];
+
+ switch ( TESTS[i].length )
+ {
+ case 3:
+ tmp[3] = TESTS[i][2];
+ break;
+
+ case 4:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ break;
+
+ case 5:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ tmp[5] = TESTS[i][4];
+ break;
+
+ default:
+ throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+ }
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public IndexedPropertyTest( String name, Object root, String expressionString, Object expectedResult,
+ Object setValue, Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/InheritedMethodsTest.java b/src/test/java/org/apache/commons/ognl/test/InheritedMethodsTest.java
index 868e963..4124090 100644
--- a/src/test/java/org/apache/commons/ognl/test/InheritedMethodsTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/InheritedMethodsTest.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.test;
-
-import junit.framework.TestCase;
-import org.apache.commons.ognl.Node;
-import org.apache.commons.ognl.Ognl;
-import org.apache.commons.ognl.OgnlContext;
-import org.apache.commons.ognl.test.objects.BaseBean;
-import org.apache.commons.ognl.test.objects.FirstBean;
-import org.apache.commons.ognl.test.objects.Root;
-import org.apache.commons.ognl.test.objects.SecondBean;
-
-/**
- * Tests functionality of casting inherited method expressions.
- */
-public class InheritedMethodsTest
- extends TestCase
-{
-
- private static final Root ROOT = new Root();
-
- public void test_Base_Inheritance()
- throws Exception
- {
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
- String expression = "map.bean.name";
- BaseBean first = new FirstBean();
- BaseBean second = new SecondBean();
-
- ROOT.getMap().put( "bean", first );
-
- Node node = Ognl.compileExpression( context, ROOT, expression );
-
- assertEquals( first.getName(), node.getAccessor().get( context, ROOT ) );
-
- ROOT.getMap().put( "bean", second );
-
- assertEquals( second.getName(), node.getAccessor().get( context, ROOT ) );
- }
-}
+/*
+ * 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.test;
+
+import junit.framework.TestCase;
+import org.apache.commons.ognl.Node;
+import org.apache.commons.ognl.Ognl;
+import org.apache.commons.ognl.OgnlContext;
+import org.apache.commons.ognl.test.objects.BaseBean;
+import org.apache.commons.ognl.test.objects.FirstBean;
+import org.apache.commons.ognl.test.objects.Root;
+import org.apache.commons.ognl.test.objects.SecondBean;
+
+/**
+ * Tests functionality of casting inherited method expressions.
+ */
+public class InheritedMethodsTest
+ extends TestCase
+{
+
+ private static final Root ROOT = new Root();
+
+ public void test_Base_Inheritance()
+ throws Exception
+ {
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+ String expression = "map.bean.name";
+ BaseBean first = new FirstBean();
+ BaseBean second = new SecondBean();
+
+ ROOT.getMap().put( "bean", first );
+
+ Node node = Ognl.compileExpression( context, ROOT, expression );
+
+ assertEquals( first.getName(), node.getAccessor().get( context, ROOT ) );
+
+ ROOT.getMap().put( "bean", second );
+
+ assertEquals( second.getName(), node.getAccessor().get( context, ROOT ) );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/InterfaceInheritanceTest.java b/src/test/java/org/apache/commons/ognl/test/InterfaceInheritanceTest.java
index d64ca51..5875856 100644
--- a/src/test/java/org/apache/commons/ognl/test/InterfaceInheritanceTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/InterfaceInheritanceTest.java
@@ -1,139 +1,138 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.OgnlRuntime;
-import org.apache.commons.ognl.test.objects.Bean1;
-import org.apache.commons.ognl.test.objects.BeanProvider;
-import org.apache.commons.ognl.test.objects.BeanProviderAccessor;
-import org.apache.commons.ognl.test.objects.EvenOdd;
-import org.apache.commons.ognl.test.objects.ListSourceImpl;
-import org.apache.commons.ognl.test.objects.Root;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-@RunWith(value = Parameterized.class)
-public class InterfaceInheritanceTest
- extends OgnlTestCase
-{
-
- private static final Root ROOT = new Root();
-
- static
- {
- ROOT.getBeans().setBean( "testBean", new Bean1() );
- ROOT.getBeans().setBean( "evenOdd", new EvenOdd() );
-
- List list = new ListSourceImpl();
- list.add( "test1" );
-
- ROOT.getMap().put( "customList", list );
- }
-
- private static final Object[][] TESTS = { { ROOT, "myMap", ROOT.getMyMap() }, { ROOT, "myMap.test", ROOT },
- { ROOT.getMyMap(), "list", ROOT.getList() }, { ROOT, "myMap.array[0]", new Integer( ROOT.getArray()[0] ) },
- { ROOT, "myMap.list[1]", ROOT.getList().get( 1 ) }, { ROOT, "myMap[^]", new Integer( 99 ) },
- { ROOT, "myMap[$]", null },
- { ROOT.getMyMap(), "array[$]", new Integer( ROOT.getArray()[ROOT.getArray().length - 1] ) },
- { ROOT, "[\"myMap\"]", ROOT.getMyMap() }, { ROOT, "myMap[null]", null }, { ROOT, "myMap[#x = null]", null },
- { ROOT, "myMap.(null,test)", ROOT }, { ROOT, "myMap[null] = 25", new Integer( 25 ) },
- { ROOT, "myMap[null]", new Integer( 25 ), new Integer( 50 ), new Integer( 50 ) },
- { ROOT, "beans.testBean", ROOT.getBeans().getBean( "testBean" ) }, { ROOT, "beans.evenOdd.next", "even" },
- { ROOT, "map.comp.form.clientId", "form1" }, { ROOT, "map.comp.getCount(genericIndex)", Integer.valueOf( 0 ) },
- { ROOT, "map.customList.total", Integer.valueOf( 1 ) }, { ROOT, "myTest.theMap['key']", "value" },
- { ROOT, "contentProvider.hasChildren(property)", Boolean.TRUE },
- { ROOT, "objectIndex instanceof java.lang.Object", Boolean.TRUE } };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][1];
- tmp[1] = TESTS[i][0];
- tmp[2] = TESTS[i][1];
-
- switch ( TESTS[i].length )
- {
- case 3:
- tmp[3] = TESTS[i][2];
- break;
-
- case 4:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- break;
-
- case 5:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- tmp[5] = TESTS[i][4];
- break;
-
- default:
- throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
- }
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public InterfaceInheritanceTest( String name, Object root, String expressionString, Object expectedResult,
- Object setValue, Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-
- @Override
- @Before
- public void setUp()
- {
- super.setUp();
-
- OgnlRuntime.setPropertyAccessor( BeanProvider.class, new BeanProviderAccessor() );
- }
-
- @Override
- @Test
-
- public void runTest()
- throws Exception
- {
- super.runTest();
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.OgnlRuntime;
+import org.apache.commons.ognl.test.objects.Bean1;
+import org.apache.commons.ognl.test.objects.BeanProvider;
+import org.apache.commons.ognl.test.objects.BeanProviderAccessor;
+import org.apache.commons.ognl.test.objects.EvenOdd;
+import org.apache.commons.ognl.test.objects.ListSourceImpl;
+import org.apache.commons.ognl.test.objects.Root;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+@RunWith(value = Parameterized.class)
+public class InterfaceInheritanceTest
+ extends OgnlTestCase
+{
+
+ private static final Root ROOT = new Root();
+
+ static
+ {
+ ROOT.getBeans().setBean( "testBean", new Bean1() );
+ ROOT.getBeans().setBean( "evenOdd", new EvenOdd() );
+
+ List list = new ListSourceImpl();
+ list.add( "test1" );
+
+ ROOT.getMap().put( "customList", list );
+ }
+
+ private static final Object[][] TESTS = { { ROOT, "myMap", ROOT.getMyMap() }, { ROOT, "myMap.test", ROOT },
+ { ROOT.getMyMap(), "list", ROOT.getList() }, { ROOT, "myMap.array[0]", new Integer( ROOT.getArray()[0] ) },
+ { ROOT, "myMap.list[1]", ROOT.getList().get( 1 ) }, { ROOT, "myMap[^]", new Integer( 99 ) },
+ { ROOT, "myMap[$]", null },
+ { ROOT.getMyMap(), "array[$]", new Integer( ROOT.getArray()[ROOT.getArray().length - 1] ) },
+ { ROOT, "[\"myMap\"]", ROOT.getMyMap() }, { ROOT, "myMap[null]", null }, { ROOT, "myMap[#x = null]", null },
+ { ROOT, "myMap.(null,test)", ROOT }, { ROOT, "myMap[null] = 25", new Integer( 25 ) },
+ { ROOT, "myMap[null]", new Integer( 25 ), new Integer( 50 ), new Integer( 50 ) },
+ { ROOT, "beans.testBean", ROOT.getBeans().getBean( "testBean" ) }, { ROOT, "beans.evenOdd.next", "even" },
+ { ROOT, "map.comp.form.clientId", "form1" }, { ROOT, "map.comp.getCount(genericIndex)", Integer.valueOf( 0 ) },
+ { ROOT, "map.customList.total", Integer.valueOf( 1 ) }, { ROOT, "myTest.theMap['key']", "value" },
+ { ROOT, "contentProvider.hasChildren(property)", Boolean.TRUE },
+ { ROOT, "objectIndex instanceof java.lang.Object", Boolean.TRUE } };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][1];
+ tmp[1] = TESTS[i][0];
+ tmp[2] = TESTS[i][1];
+
+ switch ( TESTS[i].length )
+ {
+ case 3:
+ tmp[3] = TESTS[i][2];
+ break;
+
+ case 4:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ break;
+
+ case 5:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ tmp[5] = TESTS[i][4];
+ break;
+
+ default:
+ throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+ }
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public InterfaceInheritanceTest( String name, Object root, String expressionString, Object expectedResult,
+ Object setValue, Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+
+ @Override
+ @Before
+ public void setUp()
+ {
+ super.setUp();
+
+ OgnlRuntime.setPropertyAccessor( BeanProvider.class, new BeanProviderAccessor() );
+ }
+
+ @Override
+ @Test
+
+ public void runTest()
+ throws Exception
+ {
+ super.runTest();
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/LambdaExpressionTest.java b/src/test/java/org/apache/commons/ognl/test/LambdaExpressionTest.java
index 3fc983b..b4f1f22 100644
--- a/src/test/java/org/apache/commons/ognl/test/LambdaExpressionTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/LambdaExpressionTest.java
@@ -1,89 +1,88 @@
-/*
- * $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.test;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class LambdaExpressionTest
- extends OgnlTestCase
-{
-
- private static final Object[][] TESTS = {
- // Lambda expressions
- { null, "#a=:[33](20).longValue().{0}.toArray().length", new Integer( 33 ) },
- { null, "#fact=:[#this<=1? 1 : #fact(#this-1) * #this], #fact(30)", new Integer( 1409286144 ) },
- { null, "#fact=:[#this<=1? 1 : #fact(#this-1) * #this], #fact(30L)", new Long( -8764578968847253504L ) },
- { null, "#fact=:[#this<=1? 1 : #fact(#this-1) * #this], #fact(30h)",
- new BigInteger( "265252859812191058636308480000000" ) },
- { null, "#bump = :[ #this.{ #this + 1 } ], (#bump)({ 1, 2, 3 })",
- new ArrayList( Arrays.asList( new Integer( 2 ), new Integer( 3 ), new Integer( 4 ) ) ) },
- { null, "#call = :[ \"calling \" + [0] + \" on \" + [1] ], (#call)({ \"x\", \"y\" })", "calling x on y" },
-
- };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][1];
- tmp[1] = TESTS[i][0];
- tmp[2] = TESTS[i][1];
- tmp[3] = TESTS[i][2];
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public LambdaExpressionTest( String name, Object root, String expressionString, Object expectedResult,
- Object setValue, Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-
- @Test
-
- @Override
- public void runTest()
- throws Exception
- {
- super.runTest();
- }
-}
+/*
+ * 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.test;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class LambdaExpressionTest
+ extends OgnlTestCase
+{
+
+ private static final Object[][] TESTS = {
+ // Lambda expressions
+ { null, "#a=:[33](20).longValue().{0}.toArray().length", new Integer( 33 ) },
+ { null, "#fact=:[#this<=1? 1 : #fact(#this-1) * #this], #fact(30)", new Integer( 1409286144 ) },
+ { null, "#fact=:[#this<=1? 1 : #fact(#this-1) * #this], #fact(30L)", new Long( -8764578968847253504L ) },
+ { null, "#fact=:[#this<=1? 1 : #fact(#this-1) * #this], #fact(30h)",
+ new BigInteger( "265252859812191058636308480000000" ) },
+ { null, "#bump = :[ #this.{ #this + 1 } ], (#bump)({ 1, 2, 3 })",
+ new ArrayList( Arrays.asList( new Integer( 2 ), new Integer( 3 ), new Integer( 4 ) ) ) },
+ { null, "#call = :[ \"calling \" + [0] + \" on \" + [1] ], (#call)({ \"x\", \"y\" })", "calling x on y" },
+
+ };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][1];
+ tmp[1] = TESTS[i][0];
+ tmp[2] = TESTS[i][1];
+ tmp[3] = TESTS[i][2];
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public LambdaExpressionTest( String name, Object root, String expressionString, Object expectedResult,
+ Object setValue, Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+
+ @Test
+
+ @Override
+ public void runTest()
+ throws Exception
+ {
+ super.runTest();
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/MapCreationTest.java b/src/test/java/org/apache/commons/ognl/test/MapCreationTest.java
index 0317b62..9c4fcc6 100644
--- a/src/test/java/org/apache/commons/ognl/test/MapCreationTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/MapCreationTest.java
@@ -1,124 +1,123 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.test.objects.Root;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.util.*;
-
-@RunWith(value = Parameterized.class)
-public class MapCreationTest
- extends OgnlTestCase
-{
-
- private static final Root ROOT = new Root();
-
- private static final Map FOO_BAR_MAP_1;
-
- private static final Map FOO_BAR_MAP_2;
-
- private static final Map FOO_BAR_MAP_3;
-
- private static final Map FOO_BAR_MAP_4;
-
- private static final Map FOO_BAR_MAP_5;
-
- static
- {
- FOO_BAR_MAP_1 = new HashMap();
- FOO_BAR_MAP_1.put( "foo", "bar" );
- FOO_BAR_MAP_2 = new HashMap();
- FOO_BAR_MAP_2.put( "foo", "bar" );
- FOO_BAR_MAP_2.put( "bar", "baz" );
- FOO_BAR_MAP_3 = new HashMap();
- FOO_BAR_MAP_3.put( "foo", null );
- FOO_BAR_MAP_3.put( "bar", "baz" );
- FOO_BAR_MAP_4 = new LinkedHashMap();
- FOO_BAR_MAP_4.put( "foo", "bar" );
- FOO_BAR_MAP_4.put( "bar", "baz" );
- FOO_BAR_MAP_5 = new TreeMap();
- FOO_BAR_MAP_5.put( "foo", "bar" );
- FOO_BAR_MAP_5.put( "bar", "baz" );
- }
-
- private static final Object[][] TESTS = {
- // Map creation
- { ROOT, "#{ \"foo\" : \"bar\" }", FOO_BAR_MAP_1 },
- { ROOT, "#{ \"foo\" : \"bar\", \"bar\" : \"baz\" }", FOO_BAR_MAP_2 },
- { ROOT, "#{ \"foo\", \"bar\" : \"baz\" }", FOO_BAR_MAP_3 },
- { ROOT, "#@java.util.LinkedHashMap@{ \"foo\" : \"bar\", \"bar\" : \"baz\" }", FOO_BAR_MAP_4 },
- { ROOT, "#@java.util.TreeMap@{ \"foo\" : \"bar\", \"bar\" : \"baz\" }", FOO_BAR_MAP_5 },
-
- };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][1];
- tmp[1] = TESTS[i][0];
- tmp[2] = TESTS[i][1];
-
- switch ( TESTS[i].length )
- {
- case 3:
- tmp[3] = TESTS[i][2];
- break;
-
- case 4:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- break;
-
- case 5:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- tmp[5] = TESTS[i][4];
- break;
-
- default:
- throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
- }
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public MapCreationTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
- Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.test.objects.Root;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.*;
+
+@RunWith(value = Parameterized.class)
+public class MapCreationTest
+ extends OgnlTestCase
+{
+
+ private static final Root ROOT = new Root();
+
+ private static final Map FOO_BAR_MAP_1;
+
+ private static final Map FOO_BAR_MAP_2;
+
+ private static final Map FOO_BAR_MAP_3;
+
+ private static final Map FOO_BAR_MAP_4;
+
+ private static final Map FOO_BAR_MAP_5;
+
+ static
+ {
+ FOO_BAR_MAP_1 = new HashMap();
+ FOO_BAR_MAP_1.put( "foo", "bar" );
+ FOO_BAR_MAP_2 = new HashMap();
+ FOO_BAR_MAP_2.put( "foo", "bar" );
+ FOO_BAR_MAP_2.put( "bar", "baz" );
+ FOO_BAR_MAP_3 = new HashMap();
+ FOO_BAR_MAP_3.put( "foo", null );
+ FOO_BAR_MAP_3.put( "bar", "baz" );
+ FOO_BAR_MAP_4 = new LinkedHashMap();
+ FOO_BAR_MAP_4.put( "foo", "bar" );
+ FOO_BAR_MAP_4.put( "bar", "baz" );
+ FOO_BAR_MAP_5 = new TreeMap();
+ FOO_BAR_MAP_5.put( "foo", "bar" );
+ FOO_BAR_MAP_5.put( "bar", "baz" );
+ }
+
+ private static final Object[][] TESTS = {
+ // Map creation
+ { ROOT, "#{ \"foo\" : \"bar\" }", FOO_BAR_MAP_1 },
+ { ROOT, "#{ \"foo\" : \"bar\", \"bar\" : \"baz\" }", FOO_BAR_MAP_2 },
+ { ROOT, "#{ \"foo\", \"bar\" : \"baz\" }", FOO_BAR_MAP_3 },
+ { ROOT, "#@java.util.LinkedHashMap@{ \"foo\" : \"bar\", \"bar\" : \"baz\" }", FOO_BAR_MAP_4 },
+ { ROOT, "#@java.util.TreeMap@{ \"foo\" : \"bar\", \"bar\" : \"baz\" }", FOO_BAR_MAP_5 },
+
+ };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][1];
+ tmp[1] = TESTS[i][0];
+ tmp[2] = TESTS[i][1];
+
+ switch ( TESTS[i].length )
+ {
+ case 3:
+ tmp[3] = TESTS[i][2];
+ break;
+
+ case 4:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ break;
+
+ case 5:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ tmp[5] = TESTS[i][4];
+ break;
+
+ default:
+ throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+ }
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public MapCreationTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
+ Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/MemberAccessTest.java b/src/test/java/org/apache/commons/ognl/test/MemberAccessTest.java
index 3da98ba..7ea89bb 100644
--- a/src/test/java/org/apache/commons/ognl/test/MemberAccessTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/MemberAccessTest.java
@@ -1,121 +1,120 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.DefaultMemberAccess;
-import org.apache.commons.ognl.OgnlException;
-import org.apache.commons.ognl.test.objects.Simple;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
-
-@RunWith(value = Parameterized.class)
-public class MemberAccessTest
- extends OgnlTestCase
-{
-
- private static final Simple ROOT = new Simple();
-
- private static final Object[][] TESTS = { { "@Runtime@getRuntime()", OgnlException.class },
- { "@System@getProperty('java.specification.version')", System.getProperty( "java.specification.version" ) },
- { "bigIntValue", OgnlException.class },
- { "bigIntValue", OgnlException.class, 25, OgnlException.class },
- { "getBigIntValue()", OgnlException.class }, { "stringValue", ROOT.getStringValue() }, };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( Object[] TEST : TESTS )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TEST[0] + " (" + TEST[1] + ")";
- tmp[1] = ROOT;
- tmp[2] = TEST[0];
- tmp[3] = TEST[1];
- tmp[4] = null;
- tmp[5] = null;
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public MemberAccessTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
- Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-
- /*
- * =================================================================== Overridden methods
- * ===================================================================
- */
- @Override
- @Before
- public void setUp()
- {
- super.setUp();
-
- /* Should allow access at all to the Simple class except for the bigIntValue property */
- _context.setMemberAccess( new DefaultMemberAccess( false )
- {
-
- @Override
- public boolean isAccessible( Map context, Object target, Member member, String propertyName )
- {
- if ( target == Runtime.class )
- {
- return false;
- }
- if ( target instanceof Simple )
- {
- if ( propertyName != null )
- {
- return !propertyName.equals( "bigIntValue" )
- && super.isAccessible( context, target, member, propertyName );
- }
- if ( member instanceof Method )
- {
- return !member.getName().equals( "getBigIntValue" )
- && !member.getName().equals( "setBigIntValue" )
- && super.isAccessible( context, target, member, propertyName );
- }
- }
- return super.isAccessible( context, target, member, propertyName );
- }
- } );
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.DefaultMemberAccess;
+import org.apache.commons.ognl.OgnlException;
+import org.apache.commons.ognl.test.objects.Simple;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+
+@RunWith(value = Parameterized.class)
+public class MemberAccessTest
+ extends OgnlTestCase
+{
+
+ private static final Simple ROOT = new Simple();
+
+ private static final Object[][] TESTS = { { "@Runtime@getRuntime()", OgnlException.class },
+ { "@System@getProperty('java.specification.version')", System.getProperty( "java.specification.version" ) },
+ { "bigIntValue", OgnlException.class },
+ { "bigIntValue", OgnlException.class, 25, OgnlException.class },
+ { "getBigIntValue()", OgnlException.class }, { "stringValue", ROOT.getStringValue() }, };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( Object[] TEST : TESTS )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TEST[0] + " (" + TEST[1] + ")";
+ tmp[1] = ROOT;
+ tmp[2] = TEST[0];
+ tmp[3] = TEST[1];
+ tmp[4] = null;
+ tmp[5] = null;
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public MemberAccessTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
+ Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+
+ /*
+ * =================================================================== Overridden methods
+ * ===================================================================
+ */
+ @Override
+ @Before
+ public void setUp()
+ {
+ super.setUp();
+
+ /* Should allow access at all to the Simple class except for the bigIntValue property */
+ _context.setMemberAccess( new DefaultMemberAccess( false )
+ {
+
+ @Override
+ public boolean isAccessible( Map context, Object target, Member member, String propertyName )
+ {
+ if ( target == Runtime.class )
+ {
+ return false;
+ }
+ if ( target instanceof Simple )
+ {
+ if ( propertyName != null )
+ {
+ return !propertyName.equals( "bigIntValue" )
+ && super.isAccessible( context, target, member, propertyName );
+ }
+ if ( member instanceof Method )
+ {
+ return !member.getName().equals( "getBigIntValue" )
+ && !member.getName().equals( "setBigIntValue" )
+ && super.isAccessible( context, target, member, propertyName );
+ }
+ }
+ return super.isAccessible( context, target, member, propertyName );
+ }
+ } );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/MethodTest.java b/src/test/java/org/apache/commons/ognl/test/MethodTest.java
index a8365bb..15a7c1d 100644
--- a/src/test/java/org/apache/commons/ognl/test/MethodTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/MethodTest.java
@@ -1,108 +1,107 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.test.objects.*;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class MethodTest
- extends OgnlTestCase
-{
-
- private static final Simple ROOT = new Simple();
-
- private static final ListSource LIST = new ListSourceImpl();
-
- private static final BaseGeneric<GameGenericObject, Long> GENERIC = new GameGeneric();
-
- private static final Object[][] TESTS = {
- { "hashCode()", new Integer( ROOT.hashCode() ) },
- { "getBooleanValue() ? \"here\" : \"\"", "" }, { "getValueIsTrue(!false) ? \"\" : \"here\" ", "" },
- { "messages.format('ShowAllCount', new Object[]{one,two})", "foo" },
- { "messages.format('ShowAllCount', one)", "first" },
- { "getTestValue(@org.apache.commons.ognl.test.objects.SimpleEnum@ONE.value)", new Integer( 2 ) },
- { "@org.apache.commons.ognl.test.MethodTest@getA().isProperty()", Boolean.FALSE },
- { "isDisabled()", Boolean.TRUE }, { "isEditorDisabled()", Boolean.FALSE },
- { LIST, "addValue(name)", Boolean.TRUE }, { "getDisplayValue(methodsTest.allowDisplay)", "test" },
- { "isThisVarArgsWorking(three, rootValue)", Boolean.TRUE },
- { GENERIC, "service.getFullMessageFor(value, null)", "Halo 3" }
- };
-
- public static class A
- {
- public boolean isProperty()
- {
- return false;
- }
- }
-
- public static A getA()
- {
- return new A();
- }
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
-
- if ( TESTS[i].length == 3 )
- {
- tmp[0] = TESTS[i][1] + " (" + TESTS[i][2] + ")";
- tmp[1] = TESTS[i][0];
- tmp[2] = TESTS[i][1];
- tmp[3] = TESTS[i][2];
- }
- else
- {
- tmp[0] = TESTS[i][0] + " (" + TESTS[i][1] + ")";
- tmp[1] = ROOT;
- tmp[2] = TESTS[i][0];
- tmp[3] = TESTS[i][1];
- }
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public MethodTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
- Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.test.objects.*;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class MethodTest
+ extends OgnlTestCase
+{
+
+ private static final Simple ROOT = new Simple();
+
+ private static final ListSource LIST = new ListSourceImpl();
+
+ private static final BaseGeneric<GameGenericObject, Long> GENERIC = new GameGeneric();
+
+ private static final Object[][] TESTS = {
+ { "hashCode()", new Integer( ROOT.hashCode() ) },
+ { "getBooleanValue() ? \"here\" : \"\"", "" }, { "getValueIsTrue(!false) ? \"\" : \"here\" ", "" },
+ { "messages.format('ShowAllCount', new Object[]{one,two})", "foo" },
+ { "messages.format('ShowAllCount', one)", "first" },
+ { "getTestValue(@org.apache.commons.ognl.test.objects.SimpleEnum@ONE.value)", new Integer( 2 ) },
+ { "@org.apache.commons.ognl.test.MethodTest@getA().isProperty()", Boolean.FALSE },
+ { "isDisabled()", Boolean.TRUE }, { "isEditorDisabled()", Boolean.FALSE },
+ { LIST, "addValue(name)", Boolean.TRUE }, { "getDisplayValue(methodsTest.allowDisplay)", "test" },
+ { "isThisVarArgsWorking(three, rootValue)", Boolean.TRUE },
+ { GENERIC, "service.getFullMessageFor(value, null)", "Halo 3" }
+ };
+
+ public static class A
+ {
+ public boolean isProperty()
+ {
+ return false;
+ }
+ }
+
+ public static A getA()
+ {
+ return new A();
+ }
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+
+ if ( TESTS[i].length == 3 )
+ {
+ tmp[0] = TESTS[i][1] + " (" + TESTS[i][2] + ")";
+ tmp[1] = TESTS[i][0];
+ tmp[2] = TESTS[i][1];
+ tmp[3] = TESTS[i][2];
+ }
+ else
+ {
+ tmp[0] = TESTS[i][0] + " (" + TESTS[i][1] + ")";
+ tmp[1] = ROOT;
+ tmp[2] = TESTS[i][0];
+ tmp[3] = TESTS[i][1];
+ }
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public MethodTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
+ Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/MethodWithConversionTest.java b/src/test/java/org/apache/commons/ognl/test/MethodWithConversionTest.java
index 7891ed0..aaacabb 100644
--- a/src/test/java/org/apache/commons/ognl/test/MethodWithConversionTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/MethodWithConversionTest.java
@@ -1,105 +1,104 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.test.objects.Simple;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class MethodWithConversionTest
- extends OgnlTestCase
-{
-
- private static final Simple SIMPLE = new Simple();
-
- private static final Object[][] TESTS = {
- // Method call with conversion
- { SIMPLE, "setValues(new Integer(10), \"10.56\", new Double(34.225))", null }, { SIMPLE, "stringValue", "10" },
- { SIMPLE, "stringValue", "10", new Character( 'x' ), "x" },
- { SIMPLE, "setStringValue('x')", null }, // set by calling setStringValue() directly
- { SIMPLE, "floatValue", new Float( 10.56 ) }, { SIMPLE, "getValueIsTrue(rootValue)", Boolean.TRUE },
- { SIMPLE, "messages.format('Testing', one, two, three)", "blah" } };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][1];
- tmp[1] = TESTS[i][0];
- tmp[2] = TESTS[i][1];
-
- switch ( TESTS[i].length )
- {
- case 3:
- tmp[3] = TESTS[i][2];
- break;
-
- case 4:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- break;
-
- case 5:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- tmp[5] = TESTS[i][4];
- break;
-
- default:
- throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
- }
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public MethodWithConversionTest( String name, Object root, String expressionString, Object expectedResult,
- Object setValue, Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-
- @Test
-
- @Override
- public void runTest()
- throws Exception
- {
- super.runTest();
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.test.objects.Simple;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class MethodWithConversionTest
+ extends OgnlTestCase
+{
+
+ private static final Simple SIMPLE = new Simple();
+
+ private static final Object[][] TESTS = {
+ // Method call with conversion
+ { SIMPLE, "setValues(new Integer(10), \"10.56\", new Double(34.225))", null }, { SIMPLE, "stringValue", "10" },
+ { SIMPLE, "stringValue", "10", new Character( 'x' ), "x" },
+ { SIMPLE, "setStringValue('x')", null }, // set by calling setStringValue() directly
+ { SIMPLE, "floatValue", new Float( 10.56 ) }, { SIMPLE, "getValueIsTrue(rootValue)", Boolean.TRUE },
+ { SIMPLE, "messages.format('Testing', one, two, three)", "blah" } };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][1];
+ tmp[1] = TESTS[i][0];
+ tmp[2] = TESTS[i][1];
+
+ switch ( TESTS[i].length )
+ {
+ case 3:
+ tmp[3] = TESTS[i][2];
+ break;
+
+ case 4:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ break;
+
+ case 5:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ tmp[5] = TESTS[i][4];
+ break;
+
+ default:
+ throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+ }
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public MethodWithConversionTest( String name, Object root, String expressionString, Object expectedResult,
+ Object setValue, Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+
+ @Test
+
+ @Override
+ public void runTest()
+ throws Exception
+ {
+ super.runTest();
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/NestedMethodTest.java b/src/test/java/org/apache/commons/ognl/test/NestedMethodTest.java
index ecbe6a8..302a328 100644
--- a/src/test/java/org/apache/commons/ognl/test/NestedMethodTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/NestedMethodTest.java
@@ -1,104 +1,103 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.test.objects.Component;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class NestedMethodTest
- extends OgnlTestCase
-{
-
- private static final Component COMPONENT = new Component();
-
- private static final Object[][] TESTS = {
- // Expression in a method call argument
- { COMPONENT, "toDisplay.pictureUrl", COMPONENT.getToDisplay().getPictureUrl() },
- { COMPONENT, "page.createRelativeAsset(toDisplay.pictureUrl)",
- COMPONENT.getPage().createRelativeAsset( COMPONENT.getToDisplay().getPictureUrl() ) }, };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][1];
- tmp[1] = TESTS[i][0];
- tmp[2] = TESTS[i][1];
-
- switch ( TESTS[i].length )
- {
- case 3:
- tmp[3] = TESTS[i][2];
- break;
-
- case 4:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- break;
-
- case 5:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- tmp[5] = TESTS[i][4];
- break;
-
- default:
- throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
- }
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public NestedMethodTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
- Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-
- @Test
-
- @Override
- public void runTest()
- throws Exception
- {
- super.runTest();
- }
-
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.test.objects.Component;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class NestedMethodTest
+ extends OgnlTestCase
+{
+
+ private static final Component COMPONENT = new Component();
+
+ private static final Object[][] TESTS = {
+ // Expression in a method call argument
+ { COMPONENT, "toDisplay.pictureUrl", COMPONENT.getToDisplay().getPictureUrl() },
+ { COMPONENT, "page.createRelativeAsset(toDisplay.pictureUrl)",
+ COMPONENT.getPage().createRelativeAsset( COMPONENT.getToDisplay().getPictureUrl() ) }, };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][1];
+ tmp[1] = TESTS[i][0];
+ tmp[2] = TESTS[i][1];
+
+ switch ( TESTS[i].length )
+ {
+ case 3:
+ tmp[3] = TESTS[i][2];
+ break;
+
+ case 4:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ break;
+
+ case 5:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ tmp[5] = TESTS[i][4];
+ break;
+
+ default:
+ throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+ }
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public NestedMethodTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
+ Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+
+ @Test
+
+ @Override
+ public void runTest()
+ throws Exception
+ {
+ super.runTest();
+ }
+
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/NullHandlerTest.java b/src/test/java/org/apache/commons/ognl/test/NullHandlerTest.java
index d97ffa2..0af5bf0 100644
--- a/src/test/java/org/apache/commons/ognl/test/NullHandlerTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/NullHandlerTest.java
@@ -1,116 +1,115 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.OgnlRuntime;
-import org.apache.commons.ognl.test.objects.CorrectedObject;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class NullHandlerTest
- extends OgnlTestCase
-{
- private static final CorrectedObject CORRECTED = new CorrectedObject();
-
- private static final Object[][] TESTS = {
- // NullHandler
- { CORRECTED, "stringValue", "corrected" }, { CORRECTED, "getStringValue()", "corrected" },
- { CORRECTED, "#root.stringValue", "corrected" }, { CORRECTED, "#root.getStringValue()", "corrected" }, };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][1];
- tmp[1] = TESTS[i][0];
- tmp[2] = TESTS[i][1];
-
- switch ( TESTS[i].length )
- {
- case 3:
- tmp[3] = TESTS[i][2];
- break;
-
- case 4:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- break;
-
- case 5:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- tmp[5] = TESTS[i][4];
- break;
-
- default:
- throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
- }
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public NullHandlerTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
- Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-
- /*
- * =================================================================== Overridden methods
- * ===================================================================
- */
- @Override
- @Before
- public void setUp()
- {
- super.setUp();
- _compileExpressions = false;
- OgnlRuntime.setNullHandler( CorrectedObject.class, new CorrectedObjectNullHandler( "corrected" ) );
- }
-
- @Test
-
- @Override
- public void runTest()
- throws Exception
- {
- super.runTest();
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.OgnlRuntime;
+import org.apache.commons.ognl.test.objects.CorrectedObject;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class NullHandlerTest
+ extends OgnlTestCase
+{
+ private static final CorrectedObject CORRECTED = new CorrectedObject();
+
+ private static final Object[][] TESTS = {
+ // NullHandler
+ { CORRECTED, "stringValue", "corrected" }, { CORRECTED, "getStringValue()", "corrected" },
+ { CORRECTED, "#root.stringValue", "corrected" }, { CORRECTED, "#root.getStringValue()", "corrected" }, };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][1];
+ tmp[1] = TESTS[i][0];
+ tmp[2] = TESTS[i][1];
+
+ switch ( TESTS[i].length )
+ {
+ case 3:
+ tmp[3] = TESTS[i][2];
+ break;
+
+ case 4:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ break;
+
+ case 5:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ tmp[5] = TESTS[i][4];
+ break;
+
+ default:
+ throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+ }
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public NullHandlerTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
+ Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+
+ /*
+ * =================================================================== Overridden methods
+ * ===================================================================
+ */
+ @Override
+ @Before
+ public void setUp()
+ {
+ super.setUp();
+ _compileExpressions = false;
+ OgnlRuntime.setNullHandler( CorrectedObject.class, new CorrectedObjectNullHandler( "corrected" ) );
+ }
+
+ @Test
+
+ @Override
+ public void runTest()
+ throws Exception
+ {
+ super.runTest();
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/NullStringCatenationTest.java b/src/test/java/org/apache/commons/ognl/test/NullStringCatenationTest.java
index 8408c2d..a09627b 100644
--- a/src/test/java/org/apache/commons/ognl/test/NullStringCatenationTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/NullStringCatenationTest.java
@@ -1,92 +1,91 @@
-/*
- * $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.test;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.apache.commons.ognl.test.objects.Root;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(value = Parameterized.class)
-public class NullStringCatenationTest
- extends OgnlTestCase
-{
-
- public static final String MESSAGE = "blarney";
-
- private static final Root ROOT = new Root();
-
- private static final Object[][] TESTS =
- {
- // Null string catenation
- { ROOT, "\"bar\" + null", "barnull" }, // Catenate null to a string
- { ROOT, "\"bar\" + nullObject", "barnull" }, // Catenate null to a string
- { ROOT, "20.56 + nullObject", NullPointerException.class }, // Catenate null to a number
- { ROOT, "(true ? 'tabHeader' : '') + (false ? 'tabHeader' : '')", "tabHeader" },
- { ROOT, "theInt == 0 ? '5%' : theInt + '%'", "6%" },
- { ROOT, "'width:' + width + ';'", "width:238px;" },
- { ROOT, "theLong + '_' + index", "4_1" },
- { ROOT, "'javascript:' + @org.apache.commons.ognl.test.NullStringCatenationTest@MESSAGE", "javascript:blarney" },
- { ROOT, "printDelivery ? '' : 'javascript:deliverySelected(' + property.carrier + ',' + currentDeliveryId + ')'", "" },
- { ROOT, "bean2.id + '_' + theInt", "1_6" }
- };
-
-
- /**
- * Setup parameters for this test which are used to call this class constructor
- * @return the collection of paramaters
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[4];
- tmp[0] = TESTS[i][1];
- tmp[1] = TESTS[i][0];
- tmp[2] = TESTS[i][1];
- tmp[3] = TESTS[i][2];
-
- data.add( tmp );
- }
- return data;
- }
-
- /**
- * Constructor: size of the Object[] returned by the @Parameter annotated method must match
- * the number of arguments in this constructor
- */
- public NullStringCatenationTest( String name, Object root, String expressionString, Object expectedResult)
- {
- super( name, root, expressionString, expectedResult );
- }
-
- @Test
- @Override
- public void runTest() throws Exception
- {
- super.runTest();
- }
-}
+/*
+ * 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.test;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.commons.ognl.test.objects.Root;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
+public class NullStringCatenationTest
+ extends OgnlTestCase
+{
+
+ public static final String MESSAGE = "blarney";
+
+ private static final Root ROOT = new Root();
+
+ private static final Object[][] TESTS =
+ {
+ // Null string catenation
+ { ROOT, "\"bar\" + null", "barnull" }, // Catenate null to a string
+ { ROOT, "\"bar\" + nullObject", "barnull" }, // Catenate null to a string
+ { ROOT, "20.56 + nullObject", NullPointerException.class }, // Catenate null to a number
+ { ROOT, "(true ? 'tabHeader' : '') + (false ? 'tabHeader' : '')", "tabHeader" },
+ { ROOT, "theInt == 0 ? '5%' : theInt + '%'", "6%" },
+ { ROOT, "'width:' + width + ';'", "width:238px;" },
+ { ROOT, "theLong + '_' + index", "4_1" },
+ { ROOT, "'javascript:' + @org.apache.commons.ognl.test.NullStringCatenationTest@MESSAGE", "javascript:blarney" },
+ { ROOT, "printDelivery ? '' : 'javascript:deliverySelected(' + property.carrier + ',' + currentDeliveryId + ')'", "" },
+ { ROOT, "bean2.id + '_' + theInt", "1_6" }
+ };
+
+
+ /**
+ * Setup parameters for this test which are used to call this class constructor
+ * @return the collection of paramaters
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[4];
+ tmp[0] = TESTS[i][1];
+ tmp[1] = TESTS[i][0];
+ tmp[2] = TESTS[i][1];
+ tmp[3] = TESTS[i][2];
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /**
+ * Constructor: size of the Object[] returned by the @Parameter annotated method must match
+ * the number of arguments in this constructor
+ */
+ public NullStringCatenationTest( String name, Object root, String expressionString, Object expectedResult)
+ {
+ super( name, root, expressionString, expectedResult );
+ }
+
+ @Test
+ @Override
+ public void runTest() throws Exception
+ {
+ super.runTest();
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/NumberFormatExceptionTest.java b/src/test/java/org/apache/commons/ognl/test/NumberFormatExceptionTest.java
index 7720c2d..de9959e 100644
--- a/src/test/java/org/apache/commons/ognl/test/NumberFormatExceptionTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/NumberFormatExceptionTest.java
@@ -1,112 +1,111 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.OgnlException;
-import org.apache.commons.ognl.test.objects.Simple;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class NumberFormatExceptionTest
- extends OgnlTestCase
-{
- private static final Simple SIMPLE = new Simple();
-
- private static final Object[][] TESTS = {
- // NumberFormatException handling (default is to throw NumberFormatException on bad string conversions)
- { SIMPLE, "floatValue", 0f, 10f, 10f },
- { SIMPLE, "floatValue", 10f, "x10x", OgnlException.class },
-
- { SIMPLE, "intValue", 0, 34, 34 },
- { SIMPLE, "intValue", 34, "foobar", OgnlException.class },
- { SIMPLE, "intValue", 34, "", OgnlException.class },
- { SIMPLE, "intValue", 34, " \t", OgnlException.class },
- { SIMPLE, "intValue", 34, " \t1234\t\t", 1234 },
-
- { SIMPLE, "bigIntValue", BigInteger.valueOf( 0 ), BigInteger.valueOf( 34 ), BigInteger.valueOf( 34 ) },
- { SIMPLE, "bigIntValue", BigInteger.valueOf( 34 ), null, null },
- { SIMPLE, "bigIntValue", null, "", OgnlException.class },
- { SIMPLE, "bigIntValue", null, "foobar", OgnlException.class },
-
- { SIMPLE, "bigDecValue", new BigDecimal( 0.0 ), new BigDecimal( 34.55 ), new BigDecimal( 34.55 ) },
- { SIMPLE, "bigDecValue", new BigDecimal( 34.55 ), null, null },
- { SIMPLE, "bigDecValue", null, "", OgnlException.class },
- { SIMPLE, "bigDecValue", null, "foobar", OgnlException.class }
-
- };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( Object[] TEST : TESTS )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TEST[1];
- tmp[1] = TEST[0];
- tmp[2] = TEST[1];
-
- switch ( TEST.length )
- {
- case 3:
- tmp[3] = TEST[2];
- break;
-
- case 4:
- tmp[3] = TEST[2];
- tmp[4] = TEST[3];
- break;
-
- case 5:
- tmp[3] = TEST[2];
- tmp[4] = TEST[3];
- tmp[5] = TEST[4];
- break;
-
- default:
- throw new RuntimeException( "don't understand TEST format with length " + TEST.length );
- }
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public NumberFormatExceptionTest( String name, Object root, String expressionString, Object expectedResult,
- Object setValue, Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, true, expectedAfterSetResult, 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.test;
+
+import org.apache.commons.ognl.OgnlException;
+import org.apache.commons.ognl.test.objects.Simple;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class NumberFormatExceptionTest
+ extends OgnlTestCase
+{
+ private static final Simple SIMPLE = new Simple();
+
+ private static final Object[][] TESTS = {
+ // NumberFormatException handling (default is to throw NumberFormatException on bad string conversions)
+ { SIMPLE, "floatValue", 0f, 10f, 10f },
+ { SIMPLE, "floatValue", 10f, "x10x", OgnlException.class },
+
+ { SIMPLE, "intValue", 0, 34, 34 },
+ { SIMPLE, "intValue", 34, "foobar", OgnlException.class },
+ { SIMPLE, "intValue", 34, "", OgnlException.class },
+ { SIMPLE, "intValue", 34, " \t", OgnlException.class },
+ { SIMPLE, "intValue", 34, " \t1234\t\t", 1234 },
+
+ { SIMPLE, "bigIntValue", BigInteger.valueOf( 0 ), BigInteger.valueOf( 34 ), BigInteger.valueOf( 34 ) },
+ { SIMPLE, "bigIntValue", BigInteger.valueOf( 34 ), null, null },
+ { SIMPLE, "bigIntValue", null, "", OgnlException.class },
+ { SIMPLE, "bigIntValue", null, "foobar", OgnlException.class },
+
+ { SIMPLE, "bigDecValue", new BigDecimal( 0.0 ), new BigDecimal( 34.55 ), new BigDecimal( 34.55 ) },
+ { SIMPLE, "bigDecValue", new BigDecimal( 34.55 ), null, null },
+ { SIMPLE, "bigDecValue", null, "", OgnlException.class },
+ { SIMPLE, "bigDecValue", null, "foobar", OgnlException.class }
+
+ };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( Object[] TEST : TESTS )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TEST[1];
+ tmp[1] = TEST[0];
+ tmp[2] = TEST[1];
+
+ switch ( TEST.length )
+ {
+ case 3:
+ tmp[3] = TEST[2];
+ break;
+
+ case 4:
+ tmp[3] = TEST[2];
+ tmp[4] = TEST[3];
+ break;
+
+ case 5:
+ tmp[3] = TEST[2];
+ tmp[4] = TEST[3];
+ tmp[5] = TEST[4];
+ break;
+
+ default:
+ throw new RuntimeException( "don't understand TEST format with length " + TEST.length );
+ }
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public NumberFormatExceptionTest( String name, Object root, String expressionString, Object expectedResult,
+ Object setValue, Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, true, expectedAfterSetResult, true );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/NumericConversionTest.java b/src/test/java/org/apache/commons/ognl/test/NumericConversionTest.java
index a78d8fb..fe8c3eb 100644
--- a/src/test/java/org/apache/commons/ognl/test/NumericConversionTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/NumericConversionTest.java
@@ -1,225 +1,224 @@
-/*
- * $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.test;
-
-import static junit.framework.Assert.assertTrue;
-import static junit.framework.Assert.fail;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Collection;
-
-import junit.framework.Assert;
-import org.apache.commons.ognl.OgnlException;
-import org.apache.commons.ognl.OgnlOps;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith( value = Parameterized.class )
-public class NumericConversionTest
- extends OgnlTestCase
-{
-
- private static final Object[][] TESTS = {
- /* To Integer.class */
- { "55", Integer.class, new Integer( 55 ) }, { new Integer( 55 ), Integer.class, new Integer( 55 ) },
- { new Double( 55 ), Integer.class, new Integer( 55 ) }, { Boolean.TRUE, Integer.class, new Integer( 1 ) },
- { new Byte( (byte) 55 ), Integer.class, new Integer( 55 ) },
- { new Character( (char) 55 ), Integer.class, new Integer( 55 ) },
- { new Short( (short) 55 ), Integer.class, new Integer( 55 ) },
- { new Long( 55 ), Integer.class, new Integer( 55 ) }, { new Float( 55 ), Integer.class, new Integer( 55 ) },
- { new BigInteger( "55" ), Integer.class, new Integer( 55 ) },
- { new BigDecimal( "55" ), Integer.class, new Integer( 55 ) },
-
- /* To Double.class */
- { "55.1234", Double.class, new Double( 55.1234 ) }, { new Integer( 55 ), Double.class, new Double( 55 ) },
- { new Double( 55.1234 ), Double.class, new Double( 55.1234 ) },
- { Boolean.TRUE, Double.class, new Double( 1 ) }, { new Byte( (byte) 55 ), Double.class, new Double( 55 ) },
- { new Character( (char) 55 ), Double.class, new Double( 55 ) },
- { new Short( (short) 55 ), Double.class, new Double( 55 ) },
- { new Long( 55 ), Double.class, new Double( 55 ) },
- { new Float( 55.1234 ), Double.class, new Double( 55.1234 ), new Integer( 4 ) },
- { new BigInteger( "55" ), Double.class, new Double( 55 ) },
- { new BigDecimal( "55.1234" ), Double.class, new Double( 55.1234 ) },
-
- /* To Boolean.class */
- { "true", Boolean.class, Boolean.TRUE }, { new Integer( 55 ), Boolean.class, Boolean.TRUE },
- { new Double( 55 ), Boolean.class, Boolean.TRUE }, { Boolean.TRUE, Boolean.class, Boolean.TRUE },
- { new Byte( (byte) 55 ), Boolean.class, Boolean.TRUE },
- { new Character( (char) 55 ), Boolean.class, Boolean.TRUE },
- { new Short( (short) 55 ), Boolean.class, Boolean.TRUE }, { new Long( 55 ), Boolean.class, Boolean.TRUE },
- { new Float( 55 ), Boolean.class, Boolean.TRUE }, { new BigInteger( "55" ), Boolean.class, Boolean.TRUE },
- { new BigDecimal( "55" ), Boolean.class, Boolean.TRUE },
-
- /* To Byte.class */
- { "55", Byte.class, new Byte( (byte) 55 ) }, { new Integer( 55 ), Byte.class, new Byte( (byte) 55 ) },
- { new Double( 55 ), Byte.class, new Byte( (byte) 55 ) }, { Boolean.TRUE, Byte.class, new Byte( (byte) 1 ) },
- { new Byte( (byte) 55 ), Byte.class, new Byte( (byte) 55 ) },
- { new Character( (char) 55 ), Byte.class, new Byte( (byte) 55 ) },
- { new Short( (short) 55 ), Byte.class, new Byte( (byte) 55 ) },
- { new Long( 55 ), Byte.class, new Byte( (byte) 55 ) }, { new Float( 55 ), Byte.class, new Byte( (byte) 55 ) },
- { new BigInteger( "55" ), Byte.class, new Byte( (byte) 55 ) },
- { new BigDecimal( "55" ), Byte.class, new Byte( (byte) 55 ) },
-
- /* To Character.class */
- { "55", Character.class, new Character( (char) 55 ) },
- { new Integer( 55 ), Character.class, new Character( (char) 55 ) },
- { new Double( 55 ), Character.class, new Character( (char) 55 ) },
- { Boolean.TRUE, Character.class, new Character( (char) 1 ) },
- { new Byte( (byte) 55 ), Character.class, new Character( (char) 55 ) },
- { new Character( (char) 55 ), Character.class, new Character( (char) 55 ) },
- { new Short( (short) 55 ), Character.class, new Character( (char) 55 ) },
- { new Long( 55 ), Character.class, new Character( (char) 55 ) },
- { new Float( 55 ), Character.class, new Character( (char) 55 ) },
- { new BigInteger( "55" ), Character.class, new Character( (char) 55 ) },
- { new BigDecimal( "55" ), Character.class, new Character( (char) 55 ) },
-
- /* To Short.class */
- { "55", Short.class, new Short( (short) 55 ) }, { new Integer( 55 ), Short.class, new Short( (short) 55 ) },
- { new Double( 55 ), Short.class, new Short( (short) 55 ) },
- { Boolean.TRUE, Short.class, new Short( (short) 1 ) },
- { new Byte( (byte) 55 ), Short.class, new Short( (short) 55 ) },
- { new Character( (char) 55 ), Short.class, new Short( (short) 55 ) },
- { new Short( (short) 55 ), Short.class, new Short( (short) 55 ) },
- { new Long( 55 ), Short.class, new Short( (short) 55 ) },
- { new Float( 55 ), Short.class, new Short( (short) 55 ) },
- { new BigInteger( "55" ), Short.class, new Short( (short) 55 ) },
- { new BigDecimal( "55" ), Short.class, new Short( (short) 55 ) },
-
- /* To Long.class */
- { "55", Long.class, new Long( 55 ) }, { new Integer( 55 ), Long.class, new Long( 55 ) },
- { new Double( 55 ), Long.class, new Long( 55 ) }, { Boolean.TRUE, Long.class, new Long( 1 ) },
- { new Byte( (byte) 55 ), Long.class, new Long( 55 ) },
- { new Character( (char) 55 ), Long.class, new Long( 55 ) },
- { new Short( (short) 55 ), Long.class, new Long( 55 ) }, { new Long( 55 ), Long.class, new Long( 55 ) },
- { new Float( 55 ), Long.class, new Long( 55 ) }, { new BigInteger( "55" ), Long.class, new Long( 55 ) },
- { new BigDecimal( "55" ), Long.class, new Long( 55 ) },
-
- /* To Float.class */
- { "55.1234", Float.class, new Float( 55.1234 ) }, { new Integer( 55 ), Float.class, new Float( 55 ) },
- { new Double( 55.1234 ), Float.class, new Float( 55.1234 ) }, { Boolean.TRUE, Float.class, new Float( 1 ) },
- { new Byte( (byte) 55 ), Float.class, new Float( 55 ) },
- { new Character( (char) 55 ), Float.class, new Float( 55 ) },
- { new Short( (short) 55 ), Float.class, new Float( 55 ) }, { new Long( 55 ), Float.class, new Float( 55 ) },
- { new Float( 55.1234 ), Float.class, new Float( 55.1234 ) },
- { new BigInteger( "55" ), Float.class, new Float( 55 ) },
- { new BigDecimal( "55.1234" ), Float.class, new Float( 55.1234 ) },
-
- /* To BigInteger.class */
- { "55", BigInteger.class, new BigInteger( "55" ) },
- { new Integer( 55 ), BigInteger.class, new BigInteger( "55" ) },
- { new Double( 55 ), BigInteger.class, new BigInteger( "55" ) },
- { Boolean.TRUE, BigInteger.class, new BigInteger( "1" ) },
- { new Byte( (byte) 55 ), BigInteger.class, new BigInteger( "55" ) },
- { new Character( (char) 55 ), BigInteger.class, new BigInteger( "55" ) },
- { new Short( (short) 55 ), BigInteger.class, new BigInteger( "55" ) },
- { new Long( 55 ), BigInteger.class, new BigInteger( "55" ) },
- { new Float( 55 ), BigInteger.class, new BigInteger( "55" ) },
- { new BigInteger( "55" ), BigInteger.class, new BigInteger( "55" ) },
- { new BigDecimal( "55" ), BigInteger.class, new BigInteger( "55" ) },
-
- /* To BigDecimal.class */
- { "55.1234", BigDecimal.class, new BigDecimal( "55.1234" ) },
- { new Integer( 55 ), BigDecimal.class, new BigDecimal( "55" ) },
- { new Double( 55.1234 ), BigDecimal.class, new BigDecimal( "55.1234" ), new Integer( 4 ) },
- { Boolean.TRUE, BigDecimal.class, new BigDecimal( "1" ) },
- { new Byte( (byte) 55 ), BigDecimal.class, new BigDecimal( "55" ) },
- { new Character( (char) 55 ), BigDecimal.class, new BigDecimal( "55" ) },
- { new Short( (short) 55 ), BigDecimal.class, new BigDecimal( "55" ) },
- { new Long( 55 ), BigDecimal.class, new BigDecimal( "55" ) },
- { new Float( 55.1234 ), BigDecimal.class, new BigDecimal( "55.1234" ), new Integer( 4 ) },
- { new BigInteger( "55" ), BigDecimal.class, new BigDecimal( "55" ) },
- { new BigDecimal( "55.1234" ), BigDecimal.class, new BigDecimal( "55.1234" ) }, };
-
- private final Object value;
-
- private final Class<? extends Number> toClass;
-
- private final Object expectedValue;
-
- private final int scale;
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[4];
- tmp[0] = TESTS[i][0];
- tmp[1] = TESTS[i][1];
- tmp[2] = TESTS[i][2];
- tmp[3] = ( TESTS[i].length > 3 ) ? ( (Integer) TESTS[i][3] ).intValue() : -1 ;
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public NumericConversionTest( Object value, Class<? extends Number> toClass, Object expectedValue, int scale )
- {
- super( value + " [" + value.getClass().getName() + "] -> " + toClass.getName() + " == " + expectedValue + " ["
- + expectedValue.getClass().getName() + "]"
- + ( ( scale >= 0 ) ? ( " (to within " + scale + " decimal places)" ) : "" ), null, null, null, null, null );
- this.value = value;
- this.toClass = toClass;
- this.expectedValue = expectedValue;
- this.scale = scale;
- }
-
- /*
- * =================================================================== Overridden methods
- * ===================================================================
- */
- @Test
- @Override
- public void runTest()
- throws OgnlException
- {
- Object result;
-
- result = OgnlOps.convertValue( value, toClass );
- if ( !isEqual( result, expectedValue ) )
- {
- if ( scale >= 0 )
- {
- double scalingFactor = Math.pow( 10, scale ), v1 = ( (Number) value ).doubleValue() * scalingFactor, v2 =
- ( (Number) expectedValue ).doubleValue() * scalingFactor;
-
- Assert.assertEquals((int) v1, (int) v2);
- }
- else
- {
- fail();
- }
- }
- }
-}
+/*
+ * 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.test;
+
+import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.fail;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import junit.framework.Assert;
+import org.apache.commons.ognl.OgnlException;
+import org.apache.commons.ognl.OgnlOps;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith( value = Parameterized.class )
+public class NumericConversionTest
+ extends OgnlTestCase
+{
+
+ private static final Object[][] TESTS = {
+ /* To Integer.class */
+ { "55", Integer.class, new Integer( 55 ) }, { new Integer( 55 ), Integer.class, new Integer( 55 ) },
+ { new Double( 55 ), Integer.class, new Integer( 55 ) }, { Boolean.TRUE, Integer.class, new Integer( 1 ) },
+ { new Byte( (byte) 55 ), Integer.class, new Integer( 55 ) },
+ { new Character( (char) 55 ), Integer.class, new Integer( 55 ) },
+ { new Short( (short) 55 ), Integer.class, new Integer( 55 ) },
+ { new Long( 55 ), Integer.class, new Integer( 55 ) }, { new Float( 55 ), Integer.class, new Integer( 55 ) },
+ { new BigInteger( "55" ), Integer.class, new Integer( 55 ) },
+ { new BigDecimal( "55" ), Integer.class, new Integer( 55 ) },
+
+ /* To Double.class */
+ { "55.1234", Double.class, new Double( 55.1234 ) }, { new Integer( 55 ), Double.class, new Double( 55 ) },
+ { new Double( 55.1234 ), Double.class, new Double( 55.1234 ) },
+ { Boolean.TRUE, Double.class, new Double( 1 ) }, { new Byte( (byte) 55 ), Double.class, new Double( 55 ) },
+ { new Character( (char) 55 ), Double.class, new Double( 55 ) },
+ { new Short( (short) 55 ), Double.class, new Double( 55 ) },
+ { new Long( 55 ), Double.class, new Double( 55 ) },
+ { new Float( 55.1234 ), Double.class, new Double( 55.1234 ), new Integer( 4 ) },
+ { new BigInteger( "55" ), Double.class, new Double( 55 ) },
+ { new BigDecimal( "55.1234" ), Double.class, new Double( 55.1234 ) },
+
+ /* To Boolean.class */
+ { "true", Boolean.class, Boolean.TRUE }, { new Integer( 55 ), Boolean.class, Boolean.TRUE },
+ { new Double( 55 ), Boolean.class, Boolean.TRUE }, { Boolean.TRUE, Boolean.class, Boolean.TRUE },
+ { new Byte( (byte) 55 ), Boolean.class, Boolean.TRUE },
+ { new Character( (char) 55 ), Boolean.class, Boolean.TRUE },
+ { new Short( (short) 55 ), Boolean.class, Boolean.TRUE }, { new Long( 55 ), Boolean.class, Boolean.TRUE },
+ { new Float( 55 ), Boolean.class, Boolean.TRUE }, { new BigInteger( "55" ), Boolean.class, Boolean.TRUE },
+ { new BigDecimal( "55" ), Boolean.class, Boolean.TRUE },
+
+ /* To Byte.class */
+ { "55", Byte.class, new Byte( (byte) 55 ) }, { new Integer( 55 ), Byte.class, new Byte( (byte) 55 ) },
+ { new Double( 55 ), Byte.class, new Byte( (byte) 55 ) }, { Boolean.TRUE, Byte.class, new Byte( (byte) 1 ) },
+ { new Byte( (byte) 55 ), Byte.class, new Byte( (byte) 55 ) },
+ { new Character( (char) 55 ), Byte.class, new Byte( (byte) 55 ) },
+ { new Short( (short) 55 ), Byte.class, new Byte( (byte) 55 ) },
+ { new Long( 55 ), Byte.class, new Byte( (byte) 55 ) }, { new Float( 55 ), Byte.class, new Byte( (byte) 55 ) },
+ { new BigInteger( "55" ), Byte.class, new Byte( (byte) 55 ) },
+ { new BigDecimal( "55" ), Byte.class, new Byte( (byte) 55 ) },
+
+ /* To Character.class */
+ { "55", Character.class, new Character( (char) 55 ) },
+ { new Integer( 55 ), Character.class, new Character( (char) 55 ) },
+ { new Double( 55 ), Character.class, new Character( (char) 55 ) },
+ { Boolean.TRUE, Character.class, new Character( (char) 1 ) },
+ { new Byte( (byte) 55 ), Character.class, new Character( (char) 55 ) },
+ { new Character( (char) 55 ), Character.class, new Character( (char) 55 ) },
+ { new Short( (short) 55 ), Character.class, new Character( (char) 55 ) },
+ { new Long( 55 ), Character.class, new Character( (char) 55 ) },
+ { new Float( 55 ), Character.class, new Character( (char) 55 ) },
+ { new BigInteger( "55" ), Character.class, new Character( (char) 55 ) },
+ { new BigDecimal( "55" ), Character.class, new Character( (char) 55 ) },
+
+ /* To Short.class */
+ { "55", Short.class, new Short( (short) 55 ) }, { new Integer( 55 ), Short.class, new Short( (short) 55 ) },
+ { new Double( 55 ), Short.class, new Short( (short) 55 ) },
+ { Boolean.TRUE, Short.class, new Short( (short) 1 ) },
+ { new Byte( (byte) 55 ), Short.class, new Short( (short) 55 ) },
+ { new Character( (char) 55 ), Short.class, new Short( (short) 55 ) },
+ { new Short( (short) 55 ), Short.class, new Short( (short) 55 ) },
+ { new Long( 55 ), Short.class, new Short( (short) 55 ) },
+ { new Float( 55 ), Short.class, new Short( (short) 55 ) },
+ { new BigInteger( "55" ), Short.class, new Short( (short) 55 ) },
+ { new BigDecimal( "55" ), Short.class, new Short( (short) 55 ) },
+
+ /* To Long.class */
+ { "55", Long.class, new Long( 55 ) }, { new Integer( 55 ), Long.class, new Long( 55 ) },
+ { new Double( 55 ), Long.class, new Long( 55 ) }, { Boolean.TRUE, Long.class, new Long( 1 ) },
+ { new Byte( (byte) 55 ), Long.class, new Long( 55 ) },
+ { new Character( (char) 55 ), Long.class, new Long( 55 ) },
+ { new Short( (short) 55 ), Long.class, new Long( 55 ) }, { new Long( 55 ), Long.class, new Long( 55 ) },
+ { new Float( 55 ), Long.class, new Long( 55 ) }, { new BigInteger( "55" ), Long.class, new Long( 55 ) },
+ { new BigDecimal( "55" ), Long.class, new Long( 55 ) },
+
+ /* To Float.class */
+ { "55.1234", Float.class, new Float( 55.1234 ) }, { new Integer( 55 ), Float.class, new Float( 55 ) },
+ { new Double( 55.1234 ), Float.class, new Float( 55.1234 ) }, { Boolean.TRUE, Float.class, new Float( 1 ) },
+ { new Byte( (byte) 55 ), Float.class, new Float( 55 ) },
+ { new Character( (char) 55 ), Float.class, new Float( 55 ) },
+ { new Short( (short) 55 ), Float.class, new Float( 55 ) }, { new Long( 55 ), Float.class, new Float( 55 ) },
+ { new Float( 55.1234 ), Float.class, new Float( 55.1234 ) },
+ { new BigInteger( "55" ), Float.class, new Float( 55 ) },
+ { new BigDecimal( "55.1234" ), Float.class, new Float( 55.1234 ) },
+
+ /* To BigInteger.class */
+ { "55", BigInteger.class, new BigInteger( "55" ) },
+ { new Integer( 55 ), BigInteger.class, new BigInteger( "55" ) },
+ { new Double( 55 ), BigInteger.class, new BigInteger( "55" ) },
+ { Boolean.TRUE, BigInteger.class, new BigInteger( "1" ) },
+ { new Byte( (byte) 55 ), BigInteger.class, new BigInteger( "55" ) },
+ { new Character( (char) 55 ), BigInteger.class, new BigInteger( "55" ) },
+ { new Short( (short) 55 ), BigInteger.class, new BigInteger( "55" ) },
+ { new Long( 55 ), BigInteger.class, new BigInteger( "55" ) },
+ { new Float( 55 ), BigInteger.class, new BigInteger( "55" ) },
+ { new BigInteger( "55" ), BigInteger.class, new BigInteger( "55" ) },
+ { new BigDecimal( "55" ), BigInteger.class, new BigInteger( "55" ) },
+
+ /* To BigDecimal.class */
+ { "55.1234", BigDecimal.class, new BigDecimal( "55.1234" ) },
+ { new Integer( 55 ), BigDecimal.class, new BigDecimal( "55" ) },
+ { new Double( 55.1234 ), BigDecimal.class, new BigDecimal( "55.1234" ), new Integer( 4 ) },
+ { Boolean.TRUE, BigDecimal.class, new BigDecimal( "1" ) },
+ { new Byte( (byte) 55 ), BigDecimal.class, new BigDecimal( "55" ) },
+ { new Character( (char) 55 ), BigDecimal.class, new BigDecimal( "55" ) },
+ { new Short( (short) 55 ), BigDecimal.class, new BigDecimal( "55" ) },
+ { new Long( 55 ), BigDecimal.class, new BigDecimal( "55" ) },
+ { new Float( 55.1234 ), BigDecimal.class, new BigDecimal( "55.1234" ), new Integer( 4 ) },
+ { new BigInteger( "55" ), BigDecimal.class, new BigDecimal( "55" ) },
+ { new BigDecimal( "55.1234" ), BigDecimal.class, new BigDecimal( "55.1234" ) }, };
+
+ private final Object value;
+
+ private final Class<? extends Number> toClass;
+
+ private final Object expectedValue;
+
+ private final int scale;
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[4];
+ tmp[0] = TESTS[i][0];
+ tmp[1] = TESTS[i][1];
+ tmp[2] = TESTS[i][2];
+ tmp[3] = ( TESTS[i].length > 3 ) ? ( (Integer) TESTS[i][3] ).intValue() : -1 ;
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public NumericConversionTest( Object value, Class<? extends Number> toClass, Object expectedValue, int scale )
+ {
+ super( value + " [" + value.getClass().getName() + "] -> " + toClass.getName() + " == " + expectedValue + " ["
+ + expectedValue.getClass().getName() + "]"
+ + ( ( scale >= 0 ) ? ( " (to within " + scale + " decimal places)" ) : "" ), null, null, null, null, null );
+ this.value = value;
+ this.toClass = toClass;
+ this.expectedValue = expectedValue;
+ this.scale = scale;
+ }
+
+ /*
+ * =================================================================== Overridden methods
+ * ===================================================================
+ */
+ @Test
+ @Override
+ public void runTest()
+ throws OgnlException
+ {
+ Object result;
+
+ result = OgnlOps.convertValue( value, toClass );
+ if ( !isEqual( result, expectedValue ) )
+ {
+ if ( scale >= 0 )
+ {
+ double scalingFactor = Math.pow( 10, scale ), v1 = ( (Number) value ).doubleValue() * scalingFactor, v2 =
+ ( (Number) expectedValue ).doubleValue() * scalingFactor;
+
+ Assert.assertEquals((int) v1, (int) v2);
+ }
+ else
+ {
+ fail();
+ }
+ }
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/ObjectIndexedPropertyTest.java b/src/test/java/org/apache/commons/ognl/test/ObjectIndexedPropertyTest.java
index 08c6e04..f7434e4 100644
--- a/src/test/java/org/apache/commons/ognl/test/ObjectIndexedPropertyTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/ObjectIndexedPropertyTest.java
@@ -1,116 +1,115 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.OgnlException;
-import org.apache.commons.ognl.test.objects.Bean1;
-import org.apache.commons.ognl.test.objects.ObjectIndexed;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class ObjectIndexedPropertyTest
- extends OgnlTestCase
-{
-
- private static final ObjectIndexed OBJECT_INDEXED = new ObjectIndexed();
-
- private static final Bean1 ROOT = new Bean1();
-
- private static final Object[][] TESTS = {
- // Arbitrary indexed properties
- { OBJECT_INDEXED, "attributes[\"bar\"]", "baz" }, // get non-indexed property through
- // attributes Map
- { OBJECT_INDEXED, "attribute[\"foo\"]", "bar" }, // get indexed property
- { OBJECT_INDEXED, "attribute[\"bar\"]", "baz", "newValue", "newValue" }, // set
- // indexed
- // property
- { OBJECT_INDEXED, "attribute[\"bar\"]", "newValue" },// get indexed property back to
- // confirm
- { OBJECT_INDEXED, "attributes[\"bar\"]", "newValue" }, // get property back through Map
- // to confirm
- { OBJECT_INDEXED, "attribute[\"other\"].attribute[\"bar\"]", "baz" }, // get indexed
- // property from
- // indexed, then
- // through other
- { OBJECT_INDEXED, "attribute[\"other\"].attributes[\"bar\"]", "baz" }, // get property
- // back through
- // Map to
- // confirm
- { OBJECT_INDEXED, "attribute[$]", OgnlException.class }, // illegal DynamicSubscript
- // access to object indexed
- // property
- { ROOT, "bean2.bean3.indexedValue[25]", null } };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][1];
- tmp[1] = TESTS[i][0];
- tmp[2] = TESTS[i][1];
-
- switch ( TESTS[i].length )
- {
- case 3:
- tmp[3] = TESTS[i][2];
- break;
-
- case 4:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- break;
-
- case 5:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- tmp[5] = TESTS[i][4];
- break;
-
- default:
- throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
- }
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public ObjectIndexedPropertyTest( String name, Object root, String expressionString, Object expectedResult,
- Object setValue, Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.OgnlException;
+import org.apache.commons.ognl.test.objects.Bean1;
+import org.apache.commons.ognl.test.objects.ObjectIndexed;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class ObjectIndexedPropertyTest
+ extends OgnlTestCase
+{
+
+ private static final ObjectIndexed OBJECT_INDEXED = new ObjectIndexed();
+
+ private static final Bean1 ROOT = new Bean1();
+
+ private static final Object[][] TESTS = {
+ // Arbitrary indexed properties
+ { OBJECT_INDEXED, "attributes[\"bar\"]", "baz" }, // get non-indexed property through
+ // attributes Map
+ { OBJECT_INDEXED, "attribute[\"foo\"]", "bar" }, // get indexed property
+ { OBJECT_INDEXED, "attribute[\"bar\"]", "baz", "newValue", "newValue" }, // set
+ // indexed
+ // property
+ { OBJECT_INDEXED, "attribute[\"bar\"]", "newValue" },// get indexed property back to
+ // confirm
+ { OBJECT_INDEXED, "attributes[\"bar\"]", "newValue" }, // get property back through Map
+ // to confirm
+ { OBJECT_INDEXED, "attribute[\"other\"].attribute[\"bar\"]", "baz" }, // get indexed
+ // property from
+ // indexed, then
+ // through other
+ { OBJECT_INDEXED, "attribute[\"other\"].attributes[\"bar\"]", "baz" }, // get property
+ // back through
+ // Map to
+ // confirm
+ { OBJECT_INDEXED, "attribute[$]", OgnlException.class }, // illegal DynamicSubscript
+ // access to object indexed
+ // property
+ { ROOT, "bean2.bean3.indexedValue[25]", null } };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][1];
+ tmp[1] = TESTS[i][0];
+ tmp[2] = TESTS[i][1];
+
+ switch ( TESTS[i].length )
+ {
+ case 3:
+ tmp[3] = TESTS[i][2];
+ break;
+
+ case 4:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ break;
+
+ case 5:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ tmp[5] = TESTS[i][4];
+ break;
+
+ default:
+ throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+ }
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public ObjectIndexedPropertyTest( String name, Object root, String expressionString, Object expectedResult,
+ Object setValue, Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/ObjectIndexedTest.java b/src/test/java/org/apache/commons/ognl/test/ObjectIndexedTest.java
index e4ec4f3..5cb8e9c 100644
--- a/src/test/java/org/apache/commons/ognl/test/ObjectIndexedTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/ObjectIndexedTest.java
@@ -1,261 +1,260 @@
-/*
- * $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.test;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.apache.commons.ognl.Ognl;
-import org.apache.commons.ognl.OgnlContext;
-import org.apache.commons.ognl.OgnlException;
-import org.apache.commons.ognl.OgnlRuntime;
-import org.apache.commons.ognl.SimpleNode;
-import org.junit.Before;
-
-public class ObjectIndexedTest
- extends TestCase
-{
- protected OgnlContext context;
-
- /*
- * =================================================================== Public static classes
- * ===================================================================
- */
- public interface TestInterface
- {
- String getSunk( String index );
-
- void setSunk( String index, String sunk );
- }
-
- public static class Test1
- extends Object
- implements TestInterface
- {
- public String getSunk( String index )
- {
- return "foo";
- }
-
- public void setSunk( String index, String sunk )
- {
- /* do nothing */
- }
- }
-
- public static class Test2
- extends Test1
- {
- public String getSunk( String index )
- {
- return "foo";
- }
-
- public void setSunk( String index, String sunk )
- {
- /* do nothing */
- }
- }
-
- public static class Test3
- extends Test1
- {
- public String getSunk( String index )
- {
- return "foo";
- }
-
- public void setSunk( String index, String sunk )
- {
- /* do nothing */
- }
-
- public String getSunk( Object index )
- {
- return null;
- }
- }
-
- public static class Test4
- extends Test1
- {
- public String getSunk( String index )
- {
- return "foo";
- }
-
- public void setSunk( String index, String sunk )
- {
- /* do nothing */
- }
-
- public void setSunk( Object index, String sunk )
- {
- /* do nothing */
- }
- }
-
- public static class Test5
- extends Test1
- {
- public String getSunk( String index )
- {
- return "foo";
- }
-
- public void setSunk( String index, String sunk )
- {
- /* do nothing */
- }
-
- public String getSunk( Object index )
- {
- return null;
- }
-
- public void setSunk( Object index, String sunk )
- {
- /* do nothing */
- }
- }
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- public static TestSuite suite()
- {
- return new TestSuite( ObjectIndexedTest.class );
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public ObjectIndexedTest()
- {
- }
-
- public ObjectIndexedTest( String name )
- {
- super( name );
- }
-
- /*
- * =================================================================== Public methods
- * ===================================================================
- */
- public void testPropertyDescriptorReflection()
- throws Exception
- {
- OgnlRuntime.getPropertyDescriptor( java.util.AbstractList.class, "" );
- OgnlRuntime.getPropertyDescriptor( java.util.AbstractSequentialList.class, "" );
- OgnlRuntime.getPropertyDescriptor( java.lang.reflect.Array.class, "" );
- OgnlRuntime.getPropertyDescriptor( java.util.ArrayList.class, "" );
- OgnlRuntime.getPropertyDescriptor( java.util.BitSet.class, "" );
- OgnlRuntime.getPropertyDescriptor( java.util.Calendar.class, "" );
- OgnlRuntime.getPropertyDescriptor( java.lang.reflect.Field.class, "" );
- OgnlRuntime.getPropertyDescriptor( java.util.LinkedList.class, "" );
- OgnlRuntime.getPropertyDescriptor( java.util.List.class, "" );
- OgnlRuntime.getPropertyDescriptor( java.util.Iterator.class, "" );
- OgnlRuntime.getPropertyDescriptor( java.lang.ThreadLocal.class, "" );
- OgnlRuntime.getPropertyDescriptor( java.net.URL.class, "" );
- OgnlRuntime.getPropertyDescriptor( java.util.Vector.class, "" );
- }
-
- public void testObjectIndexAccess()
- throws OgnlException
- {
- SimpleNode expression = (SimpleNode) Ognl.parseExpression( "#ka.sunk[#root]" );
-
- context.put( "ka", new Test1() );
- Ognl.getValue( expression, context, "aksdj" );
- }
-
- public void testObjectIndexInSubclass()
- throws OgnlException
- {
- SimpleNode expression = (SimpleNode) Ognl.parseExpression( "#ka.sunk[#root]" );
-
- context.put( "ka", new Test2() );
- Ognl.getValue( expression, context, "aksdj" );
- }
-
- public void testMultipleObjectIndexGetters()
- throws OgnlException
- {
- SimpleNode expression = (SimpleNode) Ognl.parseExpression( "#ka.sunk[#root]" );
-
- context.put( "ka", new Test3() );
- try
- {
- Ognl.getValue( expression, context, new Test3() );
- fail();
- }
- catch ( OgnlException ex )
- {
- /* Should throw */
- }
- }
-
- public void testMultipleObjectIndexSetters()
- throws OgnlException
- {
- SimpleNode expression = (SimpleNode) Ognl.parseExpression( "#ka.sunk[#root]" );
-
- context.put( "ka", new Test4() );
- try
- {
- Ognl.getValue( expression, context, "aksdj" );
- fail();
- }
- catch ( OgnlException ex )
- {
- /* Should throw */
- }
- }
-
- public void testMultipleObjectIndexMethodPairs()
- throws OgnlException
- {
- SimpleNode expression = (SimpleNode) Ognl.parseExpression( "#ka.sunk[#root]" );
-
- context.put( "ka", new Test5() );
- try
- {
- Ognl.getValue( expression, context, "aksdj" );
- fail();
- }
- catch ( OgnlException ex )
- {
- /* Should throw */
- }
- }
-
- /*
- * =================================================================== Overridden methods
- * ===================================================================
- */
- @Override
- @Before
- protected void setUp()
- {
- context = (OgnlContext) Ognl.createDefaultContext( 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.test;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.apache.commons.ognl.Ognl;
+import org.apache.commons.ognl.OgnlContext;
+import org.apache.commons.ognl.OgnlException;
+import org.apache.commons.ognl.OgnlRuntime;
+import org.apache.commons.ognl.SimpleNode;
+import org.junit.Before;
+
+public class ObjectIndexedTest
+ extends TestCase
+{
+ protected OgnlContext context;
+
+ /*
+ * =================================================================== Public static classes
+ * ===================================================================
+ */
+ public interface TestInterface
+ {
+ String getSunk( String index );
+
+ void setSunk( String index, String sunk );
+ }
+
+ public static class Test1
+ extends Object
+ implements TestInterface
+ {
+ public String getSunk( String index )
+ {
+ return "foo";
+ }
+
+ public void setSunk( String index, String sunk )
+ {
+ /* do nothing */
+ }
+ }
+
+ public static class Test2
+ extends Test1
+ {
+ public String getSunk( String index )
+ {
+ return "foo";
+ }
+
+ public void setSunk( String index, String sunk )
+ {
+ /* do nothing */
+ }
+ }
+
+ public static class Test3
+ extends Test1
+ {
+ public String getSunk( String index )
+ {
+ return "foo";
+ }
+
+ public void setSunk( String index, String sunk )
+ {
+ /* do nothing */
+ }
+
+ public String getSunk( Object index )
+ {
+ return null;
+ }
+ }
+
+ public static class Test4
+ extends Test1
+ {
+ public String getSunk( String index )
+ {
+ return "foo";
+ }
+
+ public void setSunk( String index, String sunk )
+ {
+ /* do nothing */
+ }
+
+ public void setSunk( Object index, String sunk )
+ {
+ /* do nothing */
+ }
+ }
+
+ public static class Test5
+ extends Test1
+ {
+ public String getSunk( String index )
+ {
+ return "foo";
+ }
+
+ public void setSunk( String index, String sunk )
+ {
+ /* do nothing */
+ }
+
+ public String getSunk( Object index )
+ {
+ return null;
+ }
+
+ public void setSunk( Object index, String sunk )
+ {
+ /* do nothing */
+ }
+ }
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ public static TestSuite suite()
+ {
+ return new TestSuite( ObjectIndexedTest.class );
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public ObjectIndexedTest()
+ {
+ }
+
+ public ObjectIndexedTest( String name )
+ {
+ super( name );
+ }
+
+ /*
+ * =================================================================== Public methods
+ * ===================================================================
+ */
+ public void testPropertyDescriptorReflection()
+ throws Exception
+ {
+ OgnlRuntime.getPropertyDescriptor( java.util.AbstractList.class, "" );
+ OgnlRuntime.getPropertyDescriptor( java.util.AbstractSequentialList.class, "" );
+ OgnlRuntime.getPropertyDescriptor( java.lang.reflect.Array.class, "" );
+ OgnlRuntime.getPropertyDescriptor( java.util.ArrayList.class, "" );
+ OgnlRuntime.getPropertyDescriptor( java.util.BitSet.class, "" );
+ OgnlRuntime.getPropertyDescriptor( java.util.Calendar.class, "" );
+ OgnlRuntime.getPropertyDescriptor( java.lang.reflect.Field.class, "" );
+ OgnlRuntime.getPropertyDescriptor( java.util.LinkedList.class, "" );
+ OgnlRuntime.getPropertyDescriptor( java.util.List.class, "" );
+ OgnlRuntime.getPropertyDescriptor( java.util.Iterator.class, "" );
+ OgnlRuntime.getPropertyDescriptor( java.lang.ThreadLocal.class, "" );
+ OgnlRuntime.getPropertyDescriptor( java.net.URL.class, "" );
+ OgnlRuntime.getPropertyDescriptor( java.util.Vector.class, "" );
+ }
+
+ public void testObjectIndexAccess()
+ throws OgnlException
+ {
+ SimpleNode expression = (SimpleNode) Ognl.parseExpression( "#ka.sunk[#root]" );
+
+ context.put( "ka", new Test1() );
+ Ognl.getValue( expression, context, "aksdj" );
+ }
+
+ public void testObjectIndexInSubclass()
+ throws OgnlException
+ {
+ SimpleNode expression = (SimpleNode) Ognl.parseExpression( "#ka.sunk[#root]" );
+
+ context.put( "ka", new Test2() );
+ Ognl.getValue( expression, context, "aksdj" );
+ }
+
+ public void testMultipleObjectIndexGetters()
+ throws OgnlException
+ {
+ SimpleNode expression = (SimpleNode) Ognl.parseExpression( "#ka.sunk[#root]" );
+
+ context.put( "ka", new Test3() );
+ try
+ {
+ Ognl.getValue( expression, context, new Test3() );
+ fail();
+ }
+ catch ( OgnlException ex )
+ {
+ /* Should throw */
+ }
+ }
+
+ public void testMultipleObjectIndexSetters()
+ throws OgnlException
+ {
+ SimpleNode expression = (SimpleNode) Ognl.parseExpression( "#ka.sunk[#root]" );
+
+ context.put( "ka", new Test4() );
+ try
+ {
+ Ognl.getValue( expression, context, "aksdj" );
+ fail();
+ }
+ catch ( OgnlException ex )
+ {
+ /* Should throw */
+ }
+ }
+
+ public void testMultipleObjectIndexMethodPairs()
+ throws OgnlException
+ {
+ SimpleNode expression = (SimpleNode) Ognl.parseExpression( "#ka.sunk[#root]" );
+
+ context.put( "ka", new Test5() );
+ try
+ {
+ Ognl.getValue( expression, context, "aksdj" );
+ fail();
+ }
+ catch ( OgnlException ex )
+ {
+ /* Should throw */
+ }
+ }
+
+ /*
+ * =================================================================== Overridden methods
+ * ===================================================================
+ */
+ @Override
+ @Before
+ protected void setUp()
+ {
+ context = (OgnlContext) Ognl.createDefaultContext( null );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/OgnlTestCase.java b/src/test/java/org/apache/commons/ognl/test/OgnlTestCase.java
index 8a39e4f..ff193a6 100644
--- a/src/test/java/org/apache/commons/ognl/test/OgnlTestCase.java
+++ b/src/test/java/org/apache/commons/ognl/test/OgnlTestCase.java
@@ -1,249 +1,248 @@
-/*
- * $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.test;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.reflect.Array;
-
-import org.apache.commons.ognl.Ognl;
-import org.apache.commons.ognl.OgnlContext;
-import org.apache.commons.ognl.SimpleNode;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-public abstract class OgnlTestCase
-{
-
- protected OgnlContext _context;
-
- private final String _expressionString;
-
- private SimpleNode _expression;
-
- private final Object _expectedResult;
-
- private final Object _root;
-
- protected boolean _compileExpressions = true;
-
- private final boolean hasSetValue;
-
- private final Object setValue;
-
- private final boolean hasExpectedAfterSetResult;
-
- private final Object expectedAfterSetResult;
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
-
- /**
- * Returns true if object1 is equal to object2 in either the sense that they are the same object or, if both are
- * non-null if they are equal in the <CODE>equals()</CODE> sense.
- */
- public static boolean isEqual( Object object1, Object object2 )
- {
- boolean result = false;
-
- if ( object1 == object2 )
- {
- result = true;
- }
- else
- {
- if ( ( object1 != null ) && object1.getClass().isArray() )
- {
- if ( ( object2 != null ) && object2.getClass().isArray() && ( object2.getClass() == object1.getClass() ) )
- {
- result = ( Array.getLength( object1 ) == Array.getLength( object2 ) );
- if ( result )
- {
- for ( int i = 0, icount = Array.getLength( object1 ); result && ( i < icount ); i++ )
- {
- result = isEqual( Array.get( object1, i ), Array.get( object2, i ) );
- }
- }
- }
- }
- else
- {
- result = ( object1 != null ) && ( object2 != null ) && object1.equals( object2 );
- }
- }
- return result;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public OgnlTestCase(String name, Object root, String expressionString, Object expectedResult)
- {
- this( name, root, expressionString, expectedResult, null, false, null, false);
- }
-
- public OgnlTestCase( String name, Object root, String expressionString, Object expectedResult, Object setValue,
- Object expectedAfterSetResult )
- {
- this( name, root, expressionString, expectedResult, setValue, setValue != null, expectedAfterSetResult,
- expectedAfterSetResult != null );
- }
-
- public OgnlTestCase( String name, Object root, String expressionString, Object expectedResult, Object setValue,
- boolean hasSetValue, Object expectedAfterSetResult, boolean hasExpectedAfterSetResult )
- {
- this._root = root;
- this._expressionString = expressionString;
- this._expectedResult = expectedResult;
-
- this.hasExpectedAfterSetResult = hasExpectedAfterSetResult;
- this.expectedAfterSetResult = expectedAfterSetResult;
- this.hasSetValue = hasSetValue;
- this.setValue = setValue;
-
- }
-
- /*
- * =================================================================== Public methods
- * ===================================================================
- */
- public String getExpressionDump( SimpleNode node )
- {
- StringWriter writer = new StringWriter();
-
- node.dump( new PrintWriter( writer ), " " );
- return writer.toString();
- }
-
- public String getExpressionString()
- {
- return _expressionString;
- }
-
- public SimpleNode getExpression()
- throws Exception
- {
- if ( _expression == null )
- {
- _expression = (SimpleNode) Ognl.parseExpression( _expressionString );
- }
-
- if ( _compileExpressions )
- {
- _expression = (SimpleNode) Ognl.compileExpression( _context, _root, _expressionString );
- }
-
- return _expression;
- }
-
- public Object getExpectedResult()
- {
- return _expectedResult;
- }
-
- public static void assertEquals( Object expected, Object actual )
- {
- if ( expected != null && expected.getClass().isArray() && actual != null && actual.getClass().isArray() )
- {
-
- Assert.assertEquals( Array.getLength( expected ), Array.getLength( actual ) );
-
- int length = Array.getLength( expected );
-
- for ( int i = 0; i < length; i++ )
- {
- Object aexpected = Array.get( expected, i );
- Object aactual = Array.get( actual, i );
-
- if ( aexpected != null && aactual != null && Boolean.class.isAssignableFrom( aexpected.getClass() ) )
- {
- Assert.assertEquals( aexpected.toString(), aactual.toString() );
- }
- else
- OgnlTestCase.assertEquals( aexpected, aactual );
- }
- }
- else if ( expected != null && actual != null && Character.class.isInstance( expected )
- && Character.class.isInstance( actual ) )
- {
-
- Assert.assertEquals( ( (Character) expected ).charValue(), ( (Character) actual ).charValue() );
- }
- else
- {
-
- Assert.assertEquals( expected, actual );
- }
- }
-
- /*
- * =================================================================== Overridden methods
- * ===================================================================
- */
- @Test
- public void runTest()
- throws Exception
- {
- Object testedResult = null;
-
- try
- {
- SimpleNode expr;
-
- testedResult = _expectedResult;
- expr = getExpression();
-
- assertEquals( _expectedResult, Ognl.getValue( expr, _context, _root ) );
-
- if ( hasSetValue )
- {
- testedResult = hasExpectedAfterSetResult ? expectedAfterSetResult : setValue;
- Ognl.setValue( expr, _context, _root, setValue );
-
- assertEquals( testedResult, Ognl.getValue( expr, _context, _root ) );
- }
-
- }
- catch ( Exception ex )
- {
- if ( RuntimeException.class.isInstance( ex ) && ex.getCause() != null
- && Exception.class.isAssignableFrom( ex.getCause().getClass() ) )
- {
- ex = (Exception) ex.getCause();
- }
-
- if ( !(testedResult instanceof Class) ) {
- throw ex;
- }
- Assert.assertTrue( Exception.class.isAssignableFrom( (Class<?>) testedResult ) );
- }
- }
-
- @Before
- public void setUp()
- {
- _context = (OgnlContext) Ognl.createDefaultContext( 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.test;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.Array;
+
+import org.apache.commons.ognl.Ognl;
+import org.apache.commons.ognl.OgnlContext;
+import org.apache.commons.ognl.SimpleNode;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public abstract class OgnlTestCase
+{
+
+ protected OgnlContext _context;
+
+ private final String _expressionString;
+
+ private SimpleNode _expression;
+
+ private final Object _expectedResult;
+
+ private final Object _root;
+
+ protected boolean _compileExpressions = true;
+
+ private final boolean hasSetValue;
+
+ private final Object setValue;
+
+ private final boolean hasExpectedAfterSetResult;
+
+ private final Object expectedAfterSetResult;
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+
+ /**
+ * Returns true if object1 is equal to object2 in either the sense that they are the same object or, if both are
+ * non-null if they are equal in the <CODE>equals()</CODE> sense.
+ */
+ public static boolean isEqual( Object object1, Object object2 )
+ {
+ boolean result = false;
+
+ if ( object1 == object2 )
+ {
+ result = true;
+ }
+ else
+ {
+ if ( ( object1 != null ) && object1.getClass().isArray() )
+ {
+ if ( ( object2 != null ) && object2.getClass().isArray() && ( object2.getClass() == object1.getClass() ) )
+ {
+ result = ( Array.getLength( object1 ) == Array.getLength( object2 ) );
+ if ( result )
+ {
+ for ( int i = 0, icount = Array.getLength( object1 ); result && ( i < icount ); i++ )
+ {
+ result = isEqual( Array.get( object1, i ), Array.get( object2, i ) );
+ }
+ }
+ }
+ }
+ else
+ {
+ result = ( object1 != null ) && ( object2 != null ) && object1.equals( object2 );
+ }
+ }
+ return result;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public OgnlTestCase(String name, Object root, String expressionString, Object expectedResult)
+ {
+ this( name, root, expressionString, expectedResult, null, false, null, false);
+ }
+
+ public OgnlTestCase( String name, Object root, String expressionString, Object expectedResult, Object setValue,
+ Object expectedAfterSetResult )
+ {
+ this( name, root, expressionString, expectedResult, setValue, setValue != null, expectedAfterSetResult,
+ expectedAfterSetResult != null );
+ }
+
+ public OgnlTestCase( String name, Object root, String expressionString, Object expectedResult, Object setValue,
+ boolean hasSetValue, Object expectedAfterSetResult, boolean hasExpectedAfterSetResult )
+ {
+ this._root = root;
+ this._expressionString = expressionString;
+ this._expectedResult = expectedResult;
+
+ this.hasExpectedAfterSetResult = hasExpectedAfterSetResult;
+ this.expectedAfterSetResult = expectedAfterSetResult;
+ this.hasSetValue = hasSetValue;
+ this.setValue = setValue;
+
+ }
+
+ /*
+ * =================================================================== Public methods
+ * ===================================================================
+ */
+ public String getExpressionDump( SimpleNode node )
+ {
+ StringWriter writer = new StringWriter();
+
+ node.dump( new PrintWriter( writer ), " " );
+ return writer.toString();
+ }
+
+ public String getExpressionString()
+ {
+ return _expressionString;
+ }
+
+ public SimpleNode getExpression()
+ throws Exception
+ {
+ if ( _expression == null )
+ {
+ _expression = (SimpleNode) Ognl.parseExpression( _expressionString );
+ }
+
+ if ( _compileExpressions )
+ {
+ _expression = (SimpleNode) Ognl.compileExpression( _context, _root, _expressionString );
+ }
+
+ return _expression;
+ }
+
+ public Object getExpectedResult()
+ {
+ return _expectedResult;
+ }
+
+ public static void assertEquals( Object expected, Object actual )
+ {
+ if ( expected != null && expected.getClass().isArray() && actual != null && actual.getClass().isArray() )
+ {
+
+ Assert.assertEquals( Array.getLength( expected ), Array.getLength( actual ) );
+
+ int length = Array.getLength( expected );
+
+ for ( int i = 0; i < length; i++ )
+ {
+ Object aexpected = Array.get( expected, i );
+ Object aactual = Array.get( actual, i );
+
+ if ( aexpected != null && aactual != null && Boolean.class.isAssignableFrom( aexpected.getClass() ) )
+ {
+ Assert.assertEquals( aexpected.toString(), aactual.toString() );
+ }
+ else
+ OgnlTestCase.assertEquals( aexpected, aactual );
+ }
+ }
+ else if ( expected != null && actual != null && Character.class.isInstance( expected )
+ && Character.class.isInstance( actual ) )
+ {
+
+ Assert.assertEquals( ( (Character) expected ).charValue(), ( (Character) actual ).charValue() );
+ }
+ else
+ {
+
+ Assert.assertEquals( expected, actual );
+ }
+ }
+
+ /*
+ * =================================================================== Overridden methods
+ * ===================================================================
+ */
+ @Test
+ public void runTest()
+ throws Exception
+ {
+ Object testedResult = null;
+
+ try
+ {
+ SimpleNode expr;
+
+ testedResult = _expectedResult;
+ expr = getExpression();
+
+ assertEquals( _expectedResult, Ognl.getValue( expr, _context, _root ) );
+
+ if ( hasSetValue )
+ {
+ testedResult = hasExpectedAfterSetResult ? expectedAfterSetResult : setValue;
+ Ognl.setValue( expr, _context, _root, setValue );
+
+ assertEquals( testedResult, Ognl.getValue( expr, _context, _root ) );
+ }
+
+ }
+ catch ( Exception ex )
+ {
+ if ( RuntimeException.class.isInstance( ex ) && ex.getCause() != null
+ && Exception.class.isAssignableFrom( ex.getCause().getClass() ) )
+ {
+ ex = (Exception) ex.getCause();
+ }
+
+ if ( !(testedResult instanceof Class) ) {
+ throw ex;
+ }
+ Assert.assertTrue( Exception.class.isAssignableFrom( (Class<?>) testedResult ) );
+ }
+ }
+
+ @Before
+ public void setUp()
+ {
+ _context = (OgnlContext) Ognl.createDefaultContext( null );
+ }
+
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/OperatorTest.java b/src/test/java/org/apache/commons/ognl/test/OperatorTest.java
index 8221467..5ed64bc 100644
--- a/src/test/java/org/apache/commons/ognl/test/OperatorTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/OperatorTest.java
@@ -1,92 +1,91 @@
-/*
- * $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.test;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class OperatorTest
- extends OgnlTestCase
-{
- private static final Object[][] TESTS = { { null, "\"one\" > \"two\"", Boolean.FALSE },
- { null, "\"one\" >= \"two\"", Boolean.FALSE }, { null, "\"one\" < \"two\"", Boolean.TRUE },
- { null, "\"one\" <= \"two\"", Boolean.TRUE }, { null, "\"one\" == \"two\"", Boolean.FALSE },
- { null, "\"o\" > \"o\"", Boolean.FALSE }, { null, "\"o\" gt \"o\"", Boolean.FALSE },
- { null, "\"o\" >= \"o\"", Boolean.TRUE }, { null, "\"o\" gte \"o\"", Boolean.TRUE },
- { null, "\"o\" < \"o\"", Boolean.FALSE }, { null, "\"o\" lt \"o\"", Boolean.FALSE },
- { null, "\"o\" <= \"o\"", Boolean.TRUE }, { null, "\"o\" lte \"o\"", Boolean.TRUE },
- { null, "\"o\" == \"o\"", Boolean.TRUE }, { null, "\"o\" eq \"o\"", Boolean.TRUE }, };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][1];
- tmp[1] = TESTS[i][0];
- tmp[2] = TESTS[i][1];
-
- switch ( TESTS[i].length )
- {
- case 3:
- tmp[3] = TESTS[i][2];
- break;
-
- case 4:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- break;
-
- case 5:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- tmp[5] = TESTS[i][4];
- break;
-
- default:
- throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
- }
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public OperatorTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
- Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-}
+/*
+ * 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.test;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class OperatorTest
+ extends OgnlTestCase
+{
+ private static final Object[][] TESTS = { { null, "\"one\" > \"two\"", Boolean.FALSE },
+ { null, "\"one\" >= \"two\"", Boolean.FALSE }, { null, "\"one\" < \"two\"", Boolean.TRUE },
+ { null, "\"one\" <= \"two\"", Boolean.TRUE }, { null, "\"one\" == \"two\"", Boolean.FALSE },
+ { null, "\"o\" > \"o\"", Boolean.FALSE }, { null, "\"o\" gt \"o\"", Boolean.FALSE },
+ { null, "\"o\" >= \"o\"", Boolean.TRUE }, { null, "\"o\" gte \"o\"", Boolean.TRUE },
+ { null, "\"o\" < \"o\"", Boolean.FALSE }, { null, "\"o\" lt \"o\"", Boolean.FALSE },
+ { null, "\"o\" <= \"o\"", Boolean.TRUE }, { null, "\"o\" lte \"o\"", Boolean.TRUE },
+ { null, "\"o\" == \"o\"", Boolean.TRUE }, { null, "\"o\" eq \"o\"", Boolean.TRUE }, };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][1];
+ tmp[1] = TESTS[i][0];
+ tmp[2] = TESTS[i][1];
+
+ switch ( TESTS[i].length )
+ {
+ case 3:
+ tmp[3] = TESTS[i][2];
+ break;
+
+ case 4:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ break;
+
+ case 5:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ tmp[5] = TESTS[i][4];
+ break;
+
+ default:
+ throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+ }
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public OperatorTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
+ Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/Performance.java b/src/test/java/org/apache/commons/ognl/test/Performance.java
index 697cf94..1eb711f 100644
--- a/src/test/java/org/apache/commons/ognl/test/Performance.java
+++ b/src/test/java/org/apache/commons/ognl/test/Performance.java
@@ -1,477 +1,476 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.Ognl;
-import org.apache.commons.ognl.OgnlContext;
-import org.apache.commons.ognl.OgnlException;
-import org.apache.commons.ognl.SimpleNode;
-import org.apache.commons.ognl.test.objects.Bean1;
-
-import java.lang.reflect.Method;
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
-
-public class Performance
-{
-
- private static int MAX_ITERATIONS = -1;
-
- private static boolean ITERATIONS_MODE;
-
- private static long MAX_TIME = -1L;
-
- private static boolean TIME_MODE;
-
- private static final NumberFormat FACTOR_FORMAT = new DecimalFormat( "0.000" );
-
- private final String _name;
-
- private final OgnlContext _context = (OgnlContext) Ognl.createDefaultContext( null );
-
- private final Bean1 _root = new Bean1();
-
- private SimpleNode _expression;
-
- private SimpleNode _compiledExpression;
-
- private final Method _method;
-
- private int _iterations;
-
- private final String _expressionString;
-
- private boolean _isMvel = false;
-
- private long t0;
-
- private long t1;
-
- /*
- * =================================================================== Private static classes
- * ===================================================================
- */
- private static class Results
- {
-
- int iterations;
-
- long time;
-
- boolean mvel;
-
- public Results( int iterations, long time, boolean mvel )
- {
- this.iterations = iterations;
- this.time = time;
- this.mvel = mvel;
- }
-
- public String getFactor( Results otherResults )
- {
- String ret;
-
- if ( TIME_MODE )
- {
- float factor;
-
- if ( iterations < otherResults.iterations )
- {
- factor =
- Math.max( (float) otherResults.iterations, (float) iterations )
- / Math.min( (float) otherResults.iterations, (float) iterations );
- }
- else
- {
- factor =
- Math.min( (float) otherResults.iterations, (float) iterations )
- / Math.max( (float) otherResults.iterations, (float) iterations );
- }
-
- ret = FACTOR_FORMAT.format( factor );
- if ( iterations > otherResults.iterations )
- ret += " times faster than ";
- else
- ret += " times slower than ";
-
- }
- else
- {
- float factor =
- Math.max( (float) otherResults.time, (float) time )
- / Math.min( (float) otherResults.time, (float) time );
-
- ret = FACTOR_FORMAT.format( factor );
- if ( time < otherResults.time )
- ret += " times faster than ";
- else
- ret += " times slower than ";
- }
-
- return ret;
- }
- }
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- public static void main( String[] args )
- {
- for ( int i = 0; i < args.length; i++ )
- {
- if ( args[i].equals( "-time" ) )
- {
- TIME_MODE = true;
- MAX_TIME = Long.parseLong( args[++i] );
- }
- else if ( args[i].equals( "-iterations" ) )
- {
- ITERATIONS_MODE = true;
- MAX_ITERATIONS = Integer.parseInt( args[++i] );
- }
- }
- if ( !TIME_MODE && !ITERATIONS_MODE )
- {
- TIME_MODE = true;
- MAX_TIME = 1500;
- }
-
- try
- {
- Performance[] tests =
- new Performance[] {
- new Performance( "Constant", "100 + 20 * 5", "testConstantExpression" ),
- // new Performance("Constant", "100 + 20 * 5", "testConstantExpression", false),
- new Performance( "Single Property", "bean2", "testSinglePropertyExpression" ),
- new Performance( "Property Navigation", "bean2.bean3.value", "testPropertyNavigationExpression" ),
- /*
- * new Performance("Property Setting with context key", "bean2.bean3.nullValue",
- * "testPropertyNavigationSetting"), new Performance("Property Setting with context key",
- * "bean2.bean3.nullValue", "testPropertyNavigationSetting", true),
- */
- new Performance( "Property Navigation and Comparison", "bean2.bean3.value <= 24",
- "testPropertyNavigationAndComparisonExpression" ),
- /*
- * new Performance("Property Navigation with Indexed Access", "bean2.bean3.indexedValue[25]",
- * "testIndexedPropertyNavigationExpression"), new
- * Performance("Property Navigation with Indexed Access", "bean2.bean3.indexedValue[25]",
- * "testIndexedPropertyNavigationExpression", true),
- */
- new Performance( "Property Navigation with Map Access", "bean2.bean3.map['foo']",
- "testPropertyNavigationWithMapExpression" ),
- /*
- * new Performance("Property Navigation with Map value set", "bean2.bean3.map['foo']",
- * "testPropertyNavigationWithMapSetting"), new Performance("Property Navigation with Map value set",
- * "bean2.bean3.map['foo']", "testPropertyNavigationWithMapSetting", true)
- */
- };
-
- boolean timeMode = TIME_MODE;
- boolean iterMode = ITERATIONS_MODE;
- long maxTime = MAX_TIME;
- int maxIterations = MAX_ITERATIONS;
-
- // TIME_MODE = false;
- // ITERATIONS_MODE = true;
- // maxIterations = 1000;
-
- runTests( tests, false );
-
- TIME_MODE = timeMode;
- ITERATIONS_MODE = iterMode;
- MAX_TIME = maxTime;
- MAX_ITERATIONS = maxIterations;
-
- System.out.println( "\n\n============================================================================\n" );
-
- Thread.sleep( 2500 );
- runTests( tests, true );
-
- // Thread.sleep(2000);
-
- System.out.println( "\n\n============================================================================\n" );
- // runTests(tests);
-
- }
- catch ( Exception ex )
- {
- ex.printStackTrace();
- }
- }
-
- static void runTests( Performance[] tests, boolean output )
- throws Exception
- {
- for ( Performance perf : tests )
- {
- try
- {
-
- Results javaResults = perf.testJava( ), interpretedResults = perf.testExpression( false ),
- compiledResults = perf.testExpression( true );
-
- if ( !output )
- {
- return;
- }
-
- System.out.println( ( compiledResults.mvel ? "MVEL" : "OGNL" ) + " " + perf.getName( ) + ": "
- + perf.getExpression( ) );
- System.out.println(
- " java: " + javaResults.iterations + " iterations in " + javaResults.time + " ms" );
-
- System.out.println(
- " compiled: " + compiledResults.iterations + " iterations in " + compiledResults.time + " ms ("
- + compiledResults.getFactor( javaResults ) + "java)" );
-
- System.out.println(
- "interpreted: " + interpretedResults.iterations + " iterations in " + interpretedResults.time
- + " ms (" + interpretedResults.getFactor( javaResults ) + "java)" );
-
- System.out.println( );
-
- }
- catch ( OgnlException ex )
- {
- ex.printStackTrace( );
- }
- }
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public Performance( String name, String expressionString, String javaMethodName )
- throws Exception
- {
- this( name, expressionString, javaMethodName, false );
- }
-
- public Performance( String name, String expressionString, String javaMethodName, boolean mvel )
- throws Exception
- {
- _name = name;
- _isMvel = mvel;
- _expressionString = expressionString;
-
- try
- {
- _method = getClass().getMethod( javaMethodName );
- }
- catch ( Exception ex )
- {
- throw new OgnlException( "java method not found", ex );
- }
-
- if ( !_isMvel )
- {
- _expression = (SimpleNode) Ognl.parseExpression( expressionString );
- _compiledExpression = (SimpleNode) Ognl.compileExpression( _context, _root, expressionString );
- Ognl.getValue( _expression, _context, _root );
- _context.put( "contextValue", "cvalue" );
- }
- else
- {
- // _mvelCompiled = MVEL.compileExpression(expressionString);
- }
- }
-
- /*
- * =================================================================== Protected methods
- * ===================================================================
- */
- protected void startTest()
- {
- _iterations = 0;
- t0 = t1 = System.currentTimeMillis();
- }
-
- protected Results endTest()
- {
- return new Results( _iterations, t1 - t0, _isMvel );
- }
-
- protected boolean done()
- {
- _iterations++;
- t1 = System.currentTimeMillis();
-
- if ( TIME_MODE )
- {
- return ( t1 - t0 ) >= MAX_TIME;
- }
- if ( ITERATIONS_MODE )
- {
- return _iterations >= MAX_ITERATIONS;
- }
- throw new RuntimeException( "no maximums specified" );
- }
-
- /*
- * =================================================================== Public methods
- * ===================================================================
- */
- public String getName()
- {
- return _name;
- }
-
- public String getExpression()
- {
- return _expressionString;
- }
-
- public Results testExpression( boolean compiled )
- throws Exception
- {
- startTest();
- do
- {
- if ( !_isMvel )
- {
- if ( compiled )
- Ognl.getValue( _compiledExpression.getAccessor(), _context, _root );
- else
- Ognl.getValue( _expression, _context, _root );
- }
- else
- {
- /*
- * if (compiled) MVEL.executeExpression(_mvelCompiled, _root); else MVEL.eval(_expressionString, _root);
- */
- }
- }
- while ( !done() );
- return endTest();
- }
-
- public Results testJava()
- throws OgnlException
- {
- try
- {
- return (Results) _method.invoke( this );
- }
- catch ( Exception ex )
- {
- throw new OgnlException( "invoking java method '" + _method.getName() + "'", ex );
- }
- }
-
- public Results testConstantExpression()
- throws OgnlException
- {
- startTest();
- do
- {
- @SuppressWarnings( "unused" )
- int result = 100 + 20 * 5;
- }
- while ( !done() );
- return endTest();
- }
-
- public Results testSinglePropertyExpression()
- throws OgnlException
- {
- startTest();
- do
- {
- _root.getBean2();
- }
- while ( !done() );
- return endTest();
- }
-
- public Results testPropertyNavigationExpression()
- throws OgnlException
- {
- startTest();
- do
- {
- _root.getBean2().getBean3().getValue();
- }
- while ( !done() );
- return endTest();
- }
-
- public Results testPropertyNavigationSetting()
- throws OgnlException
- {
- startTest();
- do
- {
- _root.getBean2().getBean3().setNullValue( "a value" );
- }
- while ( !done() );
- return endTest();
- }
-
- public Results testPropertyNavigationAndComparisonExpression()
- throws OgnlException
- {
- startTest();
- do
- {
- @SuppressWarnings( "unused" )
- boolean result = _root.getBean2().getBean3().getValue() < 24;
- }
- while ( !done() );
- return endTest();
- }
-
- public Results testIndexedPropertyNavigationExpression()
- throws OgnlException
- {
- startTest();
- do
- {
- _root.getBean2().getBean3().getIndexedValue( 25 );
- }
- while ( !done() );
- return endTest();
- }
-
- public Results testPropertyNavigationWithMapSetting()
- throws OgnlException
- {
- startTest();
- do
- {
- _root.getBean2().getBean3().getMap().put( "bam", "bam" );
- }
- while ( !done() );
- return endTest();
- }
-
- public Results testPropertyNavigationWithMapExpression()
- throws OgnlException
- {
- startTest();
- do
- {
- _root.getBean2().getBean3().getMap().get( "foo" );
- }
- while ( !done() );
- return endTest();
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.Ognl;
+import org.apache.commons.ognl.OgnlContext;
+import org.apache.commons.ognl.OgnlException;
+import org.apache.commons.ognl.SimpleNode;
+import org.apache.commons.ognl.test.objects.Bean1;
+
+import java.lang.reflect.Method;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+
+public class Performance
+{
+
+ private static int MAX_ITERATIONS = -1;
+
+ private static boolean ITERATIONS_MODE;
+
+ private static long MAX_TIME = -1L;
+
+ private static boolean TIME_MODE;
+
+ private static final NumberFormat FACTOR_FORMAT = new DecimalFormat( "0.000" );
+
+ private final String _name;
+
+ private final OgnlContext _context = (OgnlContext) Ognl.createDefaultContext( null );
+
+ private final Bean1 _root = new Bean1();
+
+ private SimpleNode _expression;
+
+ private SimpleNode _compiledExpression;
+
+ private final Method _method;
+
+ private int _iterations;
+
+ private final String _expressionString;
+
+ private boolean _isMvel = false;
+
+ private long t0;
+
+ private long t1;
+
+ /*
+ * =================================================================== Private static classes
+ * ===================================================================
+ */
+ private static class Results
+ {
+
+ int iterations;
+
+ long time;
+
+ boolean mvel;
+
+ public Results( int iterations, long time, boolean mvel )
+ {
+ this.iterations = iterations;
+ this.time = time;
+ this.mvel = mvel;
+ }
+
+ public String getFactor( Results otherResults )
+ {
+ String ret;
+
+ if ( TIME_MODE )
+ {
+ float factor;
+
+ if ( iterations < otherResults.iterations )
+ {
+ factor =
+ Math.max( (float) otherResults.iterations, (float) iterations )
+ / Math.min( (float) otherResults.iterations, (float) iterations );
+ }
+ else
+ {
+ factor =
+ Math.min( (float) otherResults.iterations, (float) iterations )
+ / Math.max( (float) otherResults.iterations, (float) iterations );
+ }
+
+ ret = FACTOR_FORMAT.format( factor );
+ if ( iterations > otherResults.iterations )
+ ret += " times faster than ";
+ else
+ ret += " times slower than ";
+
+ }
+ else
+ {
+ float factor =
+ Math.max( (float) otherResults.time, (float) time )
+ / Math.min( (float) otherResults.time, (float) time );
+
+ ret = FACTOR_FORMAT.format( factor );
+ if ( time < otherResults.time )
+ ret += " times faster than ";
+ else
+ ret += " times slower than ";
+ }
+
+ return ret;
+ }
+ }
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ public static void main( String[] args )
+ {
+ for ( int i = 0; i < args.length; i++ )
+ {
+ if ( args[i].equals( "-time" ) )
+ {
+ TIME_MODE = true;
+ MAX_TIME = Long.parseLong( args[++i] );
+ }
+ else if ( args[i].equals( "-iterations" ) )
+ {
+ ITERATIONS_MODE = true;
+ MAX_ITERATIONS = Integer.parseInt( args[++i] );
+ }
+ }
+ if ( !TIME_MODE && !ITERATIONS_MODE )
+ {
+ TIME_MODE = true;
+ MAX_TIME = 1500;
+ }
+
+ try
+ {
+ Performance[] tests =
+ new Performance[] {
+ new Performance( "Constant", "100 + 20 * 5", "testConstantExpression" ),
+ // new Performance("Constant", "100 + 20 * 5", "testConstantExpression", false),
+ new Performance( "Single Property", "bean2", "testSinglePropertyExpression" ),
+ new Performance( "Property Navigation", "bean2.bean3.value", "testPropertyNavigationExpression" ),
+ /*
+ * new Performance("Property Setting with context key", "bean2.bean3.nullValue",
+ * "testPropertyNavigationSetting"), new Performance("Property Setting with context key",
+ * "bean2.bean3.nullValue", "testPropertyNavigationSetting", true),
+ */
+ new Performance( "Property Navigation and Comparison", "bean2.bean3.value <= 24",
+ "testPropertyNavigationAndComparisonExpression" ),
+ /*
+ * new Performance("Property Navigation with Indexed Access", "bean2.bean3.indexedValue[25]",
+ * "testIndexedPropertyNavigationExpression"), new
+ * Performance("Property Navigation with Indexed Access", "bean2.bean3.indexedValue[25]",
+ * "testIndexedPropertyNavigationExpression", true),
+ */
+ new Performance( "Property Navigation with Map Access", "bean2.bean3.map['foo']",
+ "testPropertyNavigationWithMapExpression" ),
+ /*
+ * new Performance("Property Navigation with Map value set", "bean2.bean3.map['foo']",
+ * "testPropertyNavigationWithMapSetting"), new Performance("Property Navigation with Map value set",
+ * "bean2.bean3.map['foo']", "testPropertyNavigationWithMapSetting", true)
+ */
+ };
+
+ boolean timeMode = TIME_MODE;
+ boolean iterMode = ITERATIONS_MODE;
+ long maxTime = MAX_TIME;
+ int maxIterations = MAX_ITERATIONS;
+
+ // TIME_MODE = false;
+ // ITERATIONS_MODE = true;
+ // maxIterations = 1000;
+
+ runTests( tests, false );
+
+ TIME_MODE = timeMode;
+ ITERATIONS_MODE = iterMode;
+ MAX_TIME = maxTime;
+ MAX_ITERATIONS = maxIterations;
+
+ System.out.println( "\n\n============================================================================\n" );
+
+ Thread.sleep( 2500 );
+ runTests( tests, true );
+
+ // Thread.sleep(2000);
+
+ System.out.println( "\n\n============================================================================\n" );
+ // runTests(tests);
+
+ }
+ catch ( Exception ex )
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ static void runTests( Performance[] tests, boolean output )
+ throws Exception
+ {
+ for ( Performance perf : tests )
+ {
+ try
+ {
+
+ Results javaResults = perf.testJava( ), interpretedResults = perf.testExpression( false ),
+ compiledResults = perf.testExpression( true );
+
+ if ( !output )
+ {
+ return;
+ }
+
+ System.out.println( ( compiledResults.mvel ? "MVEL" : "OGNL" ) + " " + perf.getName( ) + ": "
+ + perf.getExpression( ) );
+ System.out.println(
+ " java: " + javaResults.iterations + " iterations in " + javaResults.time + " ms" );
+
+ System.out.println(
+ " compiled: " + compiledResults.iterations + " iterations in " + compiledResults.time + " ms ("
+ + compiledResults.getFactor( javaResults ) + "java)" );
+
+ System.out.println(
+ "interpreted: " + interpretedResults.iterations + " iterations in " + interpretedResults.time
+ + " ms (" + interpretedResults.getFactor( javaResults ) + "java)" );
+
+ System.out.println( );
+
+ }
+ catch ( OgnlException ex )
+ {
+ ex.printStackTrace( );
+ }
+ }
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public Performance( String name, String expressionString, String javaMethodName )
+ throws Exception
+ {
+ this( name, expressionString, javaMethodName, false );
+ }
+
+ public Performance( String name, String expressionString, String javaMethodName, boolean mvel )
+ throws Exception
+ {
+ _name = name;
+ _isMvel = mvel;
+ _expressionString = expressionString;
+
+ try
+ {
+ _method = getClass().getMethod( javaMethodName );
+ }
+ catch ( Exception ex )
+ {
+ throw new OgnlException( "java method not found", ex );
+ }
+
+ if ( !_isMvel )
+ {
+ _expression = (SimpleNode) Ognl.parseExpression( expressionString );
+ _compiledExpression = (SimpleNode) Ognl.compileExpression( _context, _root, expressionString );
+ Ognl.getValue( _expression, _context, _root );
+ _context.put( "contextValue", "cvalue" );
+ }
+ else
+ {
+ // _mvelCompiled = MVEL.compileExpression(expressionString);
+ }
+ }
+
+ /*
+ * =================================================================== Protected methods
+ * ===================================================================
+ */
+ protected void startTest()
+ {
+ _iterations = 0;
+ t0 = t1 = System.currentTimeMillis();
+ }
+
+ protected Results endTest()
+ {
+ return new Results( _iterations, t1 - t0, _isMvel );
+ }
+
+ protected boolean done()
+ {
+ _iterations++;
+ t1 = System.currentTimeMillis();
+
+ if ( TIME_MODE )
+ {
+ return ( t1 - t0 ) >= MAX_TIME;
+ }
+ if ( ITERATIONS_MODE )
+ {
+ return _iterations >= MAX_ITERATIONS;
+ }
+ throw new RuntimeException( "no maximums specified" );
+ }
+
+ /*
+ * =================================================================== Public methods
+ * ===================================================================
+ */
+ public String getName()
+ {
+ return _name;
+ }
+
+ public String getExpression()
+ {
+ return _expressionString;
+ }
+
+ public Results testExpression( boolean compiled )
+ throws Exception
+ {
+ startTest();
+ do
+ {
+ if ( !_isMvel )
+ {
+ if ( compiled )
+ Ognl.getValue( _compiledExpression.getAccessor(), _context, _root );
+ else
+ Ognl.getValue( _expression, _context, _root );
+ }
+ else
+ {
+ /*
+ * if (compiled) MVEL.executeExpression(_mvelCompiled, _root); else MVEL.eval(_expressionString, _root);
+ */
+ }
+ }
+ while ( !done() );
+ return endTest();
+ }
+
+ public Results testJava()
+ throws OgnlException
+ {
+ try
+ {
+ return (Results) _method.invoke( this );
+ }
+ catch ( Exception ex )
+ {
+ throw new OgnlException( "invoking java method '" + _method.getName() + "'", ex );
+ }
+ }
+
+ public Results testConstantExpression()
+ throws OgnlException
+ {
+ startTest();
+ do
+ {
+ @SuppressWarnings( "unused" )
+ int result = 100 + 20 * 5;
+ }
+ while ( !done() );
+ return endTest();
+ }
+
+ public Results testSinglePropertyExpression()
+ throws OgnlException
+ {
+ startTest();
+ do
+ {
+ _root.getBean2();
+ }
+ while ( !done() );
+ return endTest();
+ }
+
+ public Results testPropertyNavigationExpression()
+ throws OgnlException
+ {
+ startTest();
+ do
+ {
+ _root.getBean2().getBean3().getValue();
+ }
+ while ( !done() );
+ return endTest();
+ }
+
+ public Results testPropertyNavigationSetting()
+ throws OgnlException
+ {
+ startTest();
+ do
+ {
+ _root.getBean2().getBean3().setNullValue( "a value" );
+ }
+ while ( !done() );
+ return endTest();
+ }
+
+ public Results testPropertyNavigationAndComparisonExpression()
+ throws OgnlException
+ {
+ startTest();
+ do
+ {
+ @SuppressWarnings( "unused" )
+ boolean result = _root.getBean2().getBean3().getValue() < 24;
+ }
+ while ( !done() );
+ return endTest();
+ }
+
+ public Results testIndexedPropertyNavigationExpression()
+ throws OgnlException
+ {
+ startTest();
+ do
+ {
+ _root.getBean2().getBean3().getIndexedValue( 25 );
+ }
+ while ( !done() );
+ return endTest();
+ }
+
+ public Results testPropertyNavigationWithMapSetting()
+ throws OgnlException
+ {
+ startTest();
+ do
+ {
+ _root.getBean2().getBean3().getMap().put( "bam", "bam" );
+ }
+ while ( !done() );
+ return endTest();
+ }
+
+ public Results testPropertyNavigationWithMapExpression()
+ throws OgnlException
+ {
+ startTest();
+ do
+ {
+ _root.getBean2().getBean3().getMap().get( "foo" );
+ }
+ while ( !done() );
+ return endTest();
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/PrimitiveArrayTest.java b/src/test/java/org/apache/commons/ognl/test/PrimitiveArrayTest.java
index 3cffce4..502fc86 100644
--- a/src/test/java/org/apache/commons/ognl/test/PrimitiveArrayTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/PrimitiveArrayTest.java
@@ -1,101 +1,100 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.test.objects.Root;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class PrimitiveArrayTest
- extends OgnlTestCase
-{
- private static final Root ROOT = new Root();
-
- private static final Object[][] TESTS = {
- // Primitive array creation
- { ROOT, "new boolean[5]", new boolean[5] },
- { ROOT, "new boolean[] { true, false }", new boolean[] { true, false } },
- { ROOT, "new boolean[] { 0, 1, 5.5 }", new boolean[] { false, true, true } },
- { ROOT, "new char[] { 'a', 'b' }", new char[] { 'a', 'b' } },
- { ROOT, "new char[] { 10, 11 }", new char[] { (char) 10, (char) 11 } },
- { ROOT, "new byte[] { 1, 2 }", new byte[] { 1, 2 } }, { ROOT, "new short[] { 1, 2 }", new short[] { 1, 2 } },
- { ROOT, "new int[six]", new int[ROOT.six] }, { ROOT, "new int[#root.six]", new int[ROOT.six] },
- { ROOT, "new int[6]", new int[6] }, { ROOT, "new int[] { 1, 2 }", new int[] { 1, 2 } },
- { ROOT, "new long[] { 1, 2 }", new long[] { 1, 2 } }, { ROOT, "new float[] { 1, 2 }", new float[] { 1, 2 } },
- { ROOT, "new double[] { 1, 2 }", new double[] { 1, 2 } },
-
- };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( Object[] TEST : TESTS )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TEST[1];
- tmp[1] = TEST[0];
- tmp[2] = TEST[1];
-
- switch ( TEST.length )
- {
- case 3:
- tmp[3] = TEST[2];
- break;
-
- case 4:
- tmp[3] = TEST[2];
- tmp[4] = TEST[3];
- break;
-
- case 5:
- tmp[3] = TEST[2];
- tmp[4] = TEST[3];
- tmp[5] = TEST[4];
- break;
-
- default:
- throw new RuntimeException( "don't understand TEST format with length " + TEST.length );
- }
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public PrimitiveArrayTest( String name, Object root, String expressionString, Object expectedResult,
- Object setValue, Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.test.objects.Root;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class PrimitiveArrayTest
+ extends OgnlTestCase
+{
+ private static final Root ROOT = new Root();
+
+ private static final Object[][] TESTS = {
+ // Primitive array creation
+ { ROOT, "new boolean[5]", new boolean[5] },
+ { ROOT, "new boolean[] { true, false }", new boolean[] { true, false } },
+ { ROOT, "new boolean[] { 0, 1, 5.5 }", new boolean[] { false, true, true } },
+ { ROOT, "new char[] { 'a', 'b' }", new char[] { 'a', 'b' } },
+ { ROOT, "new char[] { 10, 11 }", new char[] { (char) 10, (char) 11 } },
+ { ROOT, "new byte[] { 1, 2 }", new byte[] { 1, 2 } }, { ROOT, "new short[] { 1, 2 }", new short[] { 1, 2 } },
+ { ROOT, "new int[six]", new int[ROOT.six] }, { ROOT, "new int[#root.six]", new int[ROOT.six] },
+ { ROOT, "new int[6]", new int[6] }, { ROOT, "new int[] { 1, 2 }", new int[] { 1, 2 } },
+ { ROOT, "new long[] { 1, 2 }", new long[] { 1, 2 } }, { ROOT, "new float[] { 1, 2 }", new float[] { 1, 2 } },
+ { ROOT, "new double[] { 1, 2 }", new double[] { 1, 2 } },
+
+ };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( Object[] TEST : TESTS )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TEST[1];
+ tmp[1] = TEST[0];
+ tmp[2] = TEST[1];
+
+ switch ( TEST.length )
+ {
+ case 3:
+ tmp[3] = TEST[2];
+ break;
+
+ case 4:
+ tmp[3] = TEST[2];
+ tmp[4] = TEST[3];
+ break;
+
+ case 5:
+ tmp[3] = TEST[2];
+ tmp[4] = TEST[3];
+ tmp[5] = TEST[4];
+ break;
+
+ default:
+ throw new RuntimeException( "don't understand TEST format with length " + TEST.length );
+ }
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public PrimitiveArrayTest( String name, Object root, String expressionString, Object expectedResult,
+ Object setValue, Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/PrimitiveNullHandlingTest.java b/src/test/java/org/apache/commons/ognl/test/PrimitiveNullHandlingTest.java
index 04a4338..f89d128 100644
--- a/src/test/java/org/apache/commons/ognl/test/PrimitiveNullHandlingTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/PrimitiveNullHandlingTest.java
@@ -1,109 +1,108 @@
-/*
- * $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.test;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.apache.commons.ognl.test.objects.Simple;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(value = Parameterized.class)
-public class PrimitiveNullHandlingTest
- extends OgnlTestCase
-{
-
- private static final Simple SIMPLE = new Simple();
-
- static
- {
- SIMPLE.setFloatValue( 10.56f );
- SIMPLE.setIntValue( 34 );
- }
-
- private static final Object[][] TESTS = {
- // Primitive null handling
- { SIMPLE, "floatValue", new Float( 10.56f ), null, new Float( 0f ) }, // set float to
- // null, should
- // yield 0.0f
- { SIMPLE, "intValue", new Integer( 34 ), null, new Integer( 0 ) },// set int to null,
- // should yield 0
- { SIMPLE, "booleanValue", Boolean.FALSE, Boolean.TRUE, Boolean.TRUE },// set boolean
- // to TRUE,
- // should yield
- // true
- { SIMPLE, "booleanValue", Boolean.TRUE, null, Boolean.FALSE }, // set boolean to null,
- // should yield false
-
- };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][1];
- tmp[1] = TESTS[i][0];
- tmp[2] = TESTS[i][1];
-
- switch ( TESTS[i].length )
- {
- case 3:
- tmp[3] = TESTS[i][2];
- break;
-
- case 4:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- break;
-
- case 5:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- tmp[5] = TESTS[i][4];
- break;
-
- default:
- throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
- }
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public PrimitiveNullHandlingTest( String name, Object root, String expressionString, Object expectedResult,
- Object setValue, Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-}
+/*
+ * 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.test;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.commons.ognl.test.objects.Simple;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
+public class PrimitiveNullHandlingTest
+ extends OgnlTestCase
+{
+
+ private static final Simple SIMPLE = new Simple();
+
+ static
+ {
+ SIMPLE.setFloatValue( 10.56f );
+ SIMPLE.setIntValue( 34 );
+ }
+
+ private static final Object[][] TESTS = {
+ // Primitive null handling
+ { SIMPLE, "floatValue", new Float( 10.56f ), null, new Float( 0f ) }, // set float to
+ // null, should
+ // yield 0.0f
+ { SIMPLE, "intValue", new Integer( 34 ), null, new Integer( 0 ) },// set int to null,
+ // should yield 0
+ { SIMPLE, "booleanValue", Boolean.FALSE, Boolean.TRUE, Boolean.TRUE },// set boolean
+ // to TRUE,
+ // should yield
+ // true
+ { SIMPLE, "booleanValue", Boolean.TRUE, null, Boolean.FALSE }, // set boolean to null,
+ // should yield false
+
+ };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][1];
+ tmp[1] = TESTS[i][0];
+ tmp[2] = TESTS[i][1];
+
+ switch ( TESTS[i].length )
+ {
+ case 3:
+ tmp[3] = TESTS[i][2];
+ break;
+
+ case 4:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ break;
+
+ case 5:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ tmp[5] = TESTS[i][4];
+ break;
+
+ default:
+ throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+ }
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public PrimitiveNullHandlingTest( String name, Object root, String expressionString, Object expectedResult,
+ Object setValue, Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/PrivateAccessorTest.java b/src/test/java/org/apache/commons/ognl/test/PrivateAccessorTest.java
index 8e38be2..e9a8537 100644
--- a/src/test/java/org/apache/commons/ognl/test/PrivateAccessorTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/PrivateAccessorTest.java
@@ -1,124 +1,123 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.DefaultMemberAccess;
-import org.apache.commons.ognl.test.objects.Root;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class PrivateAccessorTest
- extends OgnlTestCase
-{
-
- private static final Root ROOT = new Root();
-
- private static final Object[][] TESTS = {
- // Using private get/set methods
- { ROOT, "getPrivateAccessorIntValue()", new Integer( 67 ) },
- { ROOT, "privateAccessorIntValue", new Integer( 67 ) },
- { ROOT, "privateAccessorIntValue", new Integer( 67 ), new Integer( 100 ) },
- { ROOT, "privateAccessorIntValue2", new Integer( 67 ) },
- { ROOT, "privateAccessorIntValue2", new Integer( 67 ), new Integer( 100 ) },
- { ROOT, "privateAccessorIntValue3", new Integer( 67 ) },
- { ROOT, "privateAccessorIntValue3", new Integer( 67 ), new Integer( 100 ) },
- { ROOT, "privateAccessorBooleanValue", Boolean.TRUE },
- { ROOT, "privateAccessorBooleanValue", Boolean.TRUE, Boolean.FALSE }, };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][1];
- tmp[1] = TESTS[i][0];
- tmp[2] = TESTS[i][1];
-
- switch ( TESTS[i].length )
- {
- case 3:
- tmp[3] = TESTS[i][2];
- break;
-
- case 4:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- break;
-
- case 5:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- tmp[5] = TESTS[i][4];
- break;
-
- default:
- throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
- }
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public PrivateAccessorTest( String name, Object root, String expressionString, Object expectedResult,
- Object setValue, Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-
- /*
- * =================================================================== Overridden methods
- * ===================================================================
- */
- @Before
- @Override
- public void setUp()
- {
- super.setUp();
- _context.setMemberAccess( new DefaultMemberAccess( true ) );
- _compileExpressions = false;
- }
-
- @Test
-
- @Override
- public void runTest()
- throws Exception
- {
- super.runTest();
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.DefaultMemberAccess;
+import org.apache.commons.ognl.test.objects.Root;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class PrivateAccessorTest
+ extends OgnlTestCase
+{
+
+ private static final Root ROOT = new Root();
+
+ private static final Object[][] TESTS = {
+ // Using private get/set methods
+ { ROOT, "getPrivateAccessorIntValue()", new Integer( 67 ) },
+ { ROOT, "privateAccessorIntValue", new Integer( 67 ) },
+ { ROOT, "privateAccessorIntValue", new Integer( 67 ), new Integer( 100 ) },
+ { ROOT, "privateAccessorIntValue2", new Integer( 67 ) },
+ { ROOT, "privateAccessorIntValue2", new Integer( 67 ), new Integer( 100 ) },
+ { ROOT, "privateAccessorIntValue3", new Integer( 67 ) },
+ { ROOT, "privateAccessorIntValue3", new Integer( 67 ), new Integer( 100 ) },
+ { ROOT, "privateAccessorBooleanValue", Boolean.TRUE },
+ { ROOT, "privateAccessorBooleanValue", Boolean.TRUE, Boolean.FALSE }, };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][1];
+ tmp[1] = TESTS[i][0];
+ tmp[2] = TESTS[i][1];
+
+ switch ( TESTS[i].length )
+ {
+ case 3:
+ tmp[3] = TESTS[i][2];
+ break;
+
+ case 4:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ break;
+
+ case 5:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ tmp[5] = TESTS[i][4];
+ break;
+
+ default:
+ throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+ }
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public PrivateAccessorTest( String name, Object root, String expressionString, Object expectedResult,
+ Object setValue, Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+
+ /*
+ * =================================================================== Overridden methods
+ * ===================================================================
+ */
+ @Before
+ @Override
+ public void setUp()
+ {
+ super.setUp();
+ _context.setMemberAccess( new DefaultMemberAccess( true ) );
+ _compileExpressions = false;
+ }
+
+ @Test
+
+ @Override
+ public void runTest()
+ throws Exception
+ {
+ super.runTest();
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/PrivateMemberTest.java b/src/test/java/org/apache/commons/ognl/test/PrivateMemberTest.java
index 728c5a6..135ca1b 100644
--- a/src/test/java/org/apache/commons/ognl/test/PrivateMemberTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/PrivateMemberTest.java
@@ -1,90 +1,89 @@
-/*
- * $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.test;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.apache.commons.ognl.DefaultMemberAccess;
-import org.apache.commons.ognl.Ognl;
-import org.apache.commons.ognl.OgnlContext;
-import org.apache.commons.ognl.OgnlException;
-import org.junit.Before;
-
-/**
- * This is a test program for private access in OGNL. shows the failures and a summary.
- */
-public class PrivateMemberTest
- extends TestCase
-{
- private final String _privateProperty = "private value";
-
- protected OgnlContext context;
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- public static TestSuite suite()
- {
- return new TestSuite( PrivateMemberTest.class );
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public PrivateMemberTest( String name )
- {
- super( name );
- }
-
- /*
- * =================================================================== Public methods
- * ===================================================================
- */
- private String getPrivateProperty()
- {
- return _privateProperty;
- }
-
- public void testPrivateAccessor()
- throws OgnlException
- {
- assertEquals( Ognl.getValue( "privateProperty", context, this ), getPrivateProperty() );
- }
-
- public void testPrivateField()
- throws OgnlException
- {
- assertEquals( Ognl.getValue( "_privateProperty", context, this ), _privateProperty );
- }
-
- /*
- * =================================================================== Overridden methods
- * ===================================================================
- */
- @Before
- @Override
- public void setUp()
- {
- context = (OgnlContext) Ognl.createDefaultContext( null );
- context.setMemberAccess( new DefaultMemberAccess( 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.test;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.apache.commons.ognl.DefaultMemberAccess;
+import org.apache.commons.ognl.Ognl;
+import org.apache.commons.ognl.OgnlContext;
+import org.apache.commons.ognl.OgnlException;
+import org.junit.Before;
+
+/**
+ * This is a test program for private access in OGNL. shows the failures and a summary.
+ */
+public class PrivateMemberTest
+ extends TestCase
+{
+ private final String _privateProperty = "private value";
+
+ protected OgnlContext context;
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ public static TestSuite suite()
+ {
+ return new TestSuite( PrivateMemberTest.class );
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public PrivateMemberTest( String name )
+ {
+ super( name );
+ }
+
+ /*
+ * =================================================================== Public methods
+ * ===================================================================
+ */
+ private String getPrivateProperty()
+ {
+ return _privateProperty;
+ }
+
+ public void testPrivateAccessor()
+ throws OgnlException
+ {
+ assertEquals( Ognl.getValue( "privateProperty", context, this ), getPrivateProperty() );
+ }
+
+ public void testPrivateField()
+ throws OgnlException
+ {
+ assertEquals( Ognl.getValue( "_privateProperty", context, this ), _privateProperty );
+ }
+
+ /*
+ * =================================================================== Overridden methods
+ * ===================================================================
+ */
+ @Before
+ @Override
+ public void setUp()
+ {
+ context = (OgnlContext) Ognl.createDefaultContext( null );
+ context.setMemberAccess( new DefaultMemberAccess( true ) );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/ProjectionSelectionTest.java b/src/test/java/org/apache/commons/ognl/test/ProjectionSelectionTest.java
index 094e444..d5d9f42 100644
--- a/src/test/java/org/apache/commons/ognl/test/ProjectionSelectionTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/ProjectionSelectionTest.java
@@ -1,79 +1,78 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.test.objects.Root;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class ProjectionSelectionTest
- extends OgnlTestCase
-{
- private static final Root ROOT = new Root();
-
- private static final Object[][] TESTS = {
- // Projection, selection
- { ROOT, "array.{class}",
- Arrays.asList( Integer.class, Integer.class, Integer.class, Integer.class ) },
- { ROOT, "map.array.{? #this > 2 }", Arrays.asList( new Integer( 3 ), new Integer( 4 ) ) },
- { ROOT, "map.array.{^ #this > 2 }", Arrays.asList( new Integer( 3 ) ) },
- { ROOT, "map.array.{$ #this > 2 }", Arrays.asList( new Integer( 4 ) ) },
- { ROOT, "map.array[*].{?true} instanceof java.util.Collection", Boolean.TRUE },
- { null, "#fact=1, 30H.{? #fact = #fact * (#this+1), false }, #fact",
- new BigInteger( "265252859812191058636308480000000" ) }, };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][1];
- tmp[1] = TESTS[i][0];
- tmp[2] = TESTS[i][1];
- tmp[3] = TESTS[i][2];
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public ProjectionSelectionTest( String name, Object root, String expressionString, Object expectedResult,
- Object setValue, Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.test.objects.Root;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class ProjectionSelectionTest
+ extends OgnlTestCase
+{
+ private static final Root ROOT = new Root();
+
+ private static final Object[][] TESTS = {
+ // Projection, selection
+ { ROOT, "array.{class}",
+ Arrays.asList( Integer.class, Integer.class, Integer.class, Integer.class ) },
+ { ROOT, "map.array.{? #this > 2 }", Arrays.asList( new Integer( 3 ), new Integer( 4 ) ) },
+ { ROOT, "map.array.{^ #this > 2 }", Arrays.asList( new Integer( 3 ) ) },
+ { ROOT, "map.array.{$ #this > 2 }", Arrays.asList( new Integer( 4 ) ) },
+ { ROOT, "map.array[*].{?true} instanceof java.util.Collection", Boolean.TRUE },
+ { null, "#fact=1, 30H.{? #fact = #fact * (#this+1), false }, #fact",
+ new BigInteger( "265252859812191058636308480000000" ) }, };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][1];
+ tmp[1] = TESTS[i][0];
+ tmp[2] = TESTS[i][1];
+ tmp[3] = TESTS[i][2];
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public ProjectionSelectionTest( String name, Object root, String expressionString, Object expectedResult,
+ Object setValue, Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/PropertyArithmeticAndLogicalOperatorsTest.java b/src/test/java/org/apache/commons/ognl/test/PropertyArithmeticAndLogicalOperatorsTest.java
index a206dd1..0d17170 100644
--- a/src/test/java/org/apache/commons/ognl/test/PropertyArithmeticAndLogicalOperatorsTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/PropertyArithmeticAndLogicalOperatorsTest.java
@@ -1,106 +1,105 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.test.objects.Root;
-import org.apache.commons.ognl.test.objects.SimpleNumeric;
-import org.apache.commons.ognl.test.objects.TestModel;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-
-/**
- *
- */
-@RunWith(value = Parameterized.class)
-public class PropertyArithmeticAndLogicalOperatorsTest
- extends OgnlTestCase
-{
-
- private static final Root ROOT = new Root();
-
- private static final TestModel MODEL = new TestModel();
-
- private static final SimpleNumeric NUMERIC = new SimpleNumeric();
-
- private static final Object[][] TESTS = {
- { ROOT, "objectIndex > 0", Boolean.TRUE },
- { ROOT, "false", Boolean.FALSE },
- { ROOT, "!false || true", Boolean.TRUE },
- { ROOT, "property.bean3.value >= 24", Boolean.TRUE },
- { ROOT, "genericIndex-1", new Integer( 1 ) },
- { ROOT, "((renderNavigation ? 0 : 1) + map.size) * theInt",
- new Integer( ( ( ROOT.getRenderNavigation() ? 0 : 1 ) + ROOT.getMap().size() ) * ROOT.getTheInt() ) },
- { ROOT, "{theInt + 1}", Arrays.asList( new Integer( ROOT.getTheInt() + 1 ) ) },
- { MODEL, "(unassignedCopyModel.optionCount > 0 && canApproveCopy) || entry.copy.size() > 0", Boolean.TRUE },
- { ROOT, " !(printDelivery || @Boolean@FALSE)", Boolean.FALSE },
- { ROOT, "(getIndexedProperty('nested').size - 1) > genericIndex", Boolean.FALSE },
- { ROOT, "(getIndexedProperty('nested').size + 1) >= genericIndex", Boolean.TRUE },
- { ROOT, "(getIndexedProperty('nested').size + 1) == genericIndex", Boolean.TRUE },
- { ROOT, "(getIndexedProperty('nested').size + 1) < genericIndex", Boolean.FALSE },
- { ROOT, "map.size * genericIndex",
- new Integer( ROOT.getMap().size() * ( (Integer) ROOT.getGenericIndex() ).intValue() ) },
- { ROOT, "property == property", Boolean.TRUE }, { ROOT, "property.bean3.value % 2 == 0", Boolean.TRUE },
- { ROOT, "genericIndex % 3 == 0", Boolean.FALSE },
- { ROOT, "genericIndex % theInt == property.bean3.value", Boolean.FALSE },
- { ROOT, "theInt / 100.0", ROOT.getTheInt() / 100.0 },
- { ROOT, "@java.lang.Long@valueOf('100') == @java.lang.Long@valueOf('100')", Boolean.TRUE },
- { NUMERIC, "budget - timeBilled", new Double( NUMERIC.getBudget() - NUMERIC.getTimeBilled() ) },
- { NUMERIC, "(budget % tableSize) == 0", Boolean.TRUE } };
-
-
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][1];
- tmp[1] = TESTS[i][0];
- tmp[2] = TESTS[i][1];
- tmp[3] = TESTS[i][2];
-
- if ( TESTS[i].length == 5 )
- {
- tmp[4] = TESTS[i][3];
- tmp[5] = TESTS[i][4];
- }
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public PropertyArithmeticAndLogicalOperatorsTest( String name, Object root, String expressionString,
- Object expectedResult, Object setValue,
- Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.test.objects.Root;
+import org.apache.commons.ognl.test.objects.SimpleNumeric;
+import org.apache.commons.ognl.test.objects.TestModel;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+
+/**
+ *
+ */
+@RunWith(value = Parameterized.class)
+public class PropertyArithmeticAndLogicalOperatorsTest
+ extends OgnlTestCase
+{
+
+ private static final Root ROOT = new Root();
+
+ private static final TestModel MODEL = new TestModel();
+
+ private static final SimpleNumeric NUMERIC = new SimpleNumeric();
+
+ private static final Object[][] TESTS = {
+ { ROOT, "objectIndex > 0", Boolean.TRUE },
+ { ROOT, "false", Boolean.FALSE },
+ { ROOT, "!false || true", Boolean.TRUE },
+ { ROOT, "property.bean3.value >= 24", Boolean.TRUE },
+ { ROOT, "genericIndex-1", new Integer( 1 ) },
+ { ROOT, "((renderNavigation ? 0 : 1) + map.size) * theInt",
+ new Integer( ( ( ROOT.getRenderNavigation() ? 0 : 1 ) + ROOT.getMap().size() ) * ROOT.getTheInt() ) },
+ { ROOT, "{theInt + 1}", Arrays.asList( new Integer( ROOT.getTheInt() + 1 ) ) },
+ { MODEL, "(unassignedCopyModel.optionCount > 0 && canApproveCopy) || entry.copy.size() > 0", Boolean.TRUE },
+ { ROOT, " !(printDelivery || @Boolean@FALSE)", Boolean.FALSE },
+ { ROOT, "(getIndexedProperty('nested').size - 1) > genericIndex", Boolean.FALSE },
+ { ROOT, "(getIndexedProperty('nested').size + 1) >= genericIndex", Boolean.TRUE },
+ { ROOT, "(getIndexedProperty('nested').size + 1) == genericIndex", Boolean.TRUE },
+ { ROOT, "(getIndexedProperty('nested').size + 1) < genericIndex", Boolean.FALSE },
+ { ROOT, "map.size * genericIndex",
+ new Integer( ROOT.getMap().size() * ( (Integer) ROOT.getGenericIndex() ).intValue() ) },
+ { ROOT, "property == property", Boolean.TRUE }, { ROOT, "property.bean3.value % 2 == 0", Boolean.TRUE },
+ { ROOT, "genericIndex % 3 == 0", Boolean.FALSE },
+ { ROOT, "genericIndex % theInt == property.bean3.value", Boolean.FALSE },
+ { ROOT, "theInt / 100.0", ROOT.getTheInt() / 100.0 },
+ { ROOT, "@java.lang.Long@valueOf('100') == @java.lang.Long@valueOf('100')", Boolean.TRUE },
+ { NUMERIC, "budget - timeBilled", new Double( NUMERIC.getBudget() - NUMERIC.getTimeBilled() ) },
+ { NUMERIC, "(budget % tableSize) == 0", Boolean.TRUE } };
+
+
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][1];
+ tmp[1] = TESTS[i][0];
+ tmp[2] = TESTS[i][1];
+ tmp[3] = TESTS[i][2];
+
+ if ( TESTS[i].length == 5 )
+ {
+ tmp[4] = TESTS[i][3];
+ tmp[5] = TESTS[i][4];
+ }
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public PropertyArithmeticAndLogicalOperatorsTest( String name, Object root, String expressionString,
+ Object expectedResult, Object setValue,
+ Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/PropertyNotFoundTest.java b/src/test/java/org/apache/commons/ognl/test/PropertyNotFoundTest.java
index b6599c9..1b00d95 100644
--- a/src/test/java/org/apache/commons/ognl/test/PropertyNotFoundTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/PropertyNotFoundTest.java
@@ -1,162 +1,161 @@
-/*
- * $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.test;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
-
-import org.apache.commons.ognl.OgnlContext;
-import org.apache.commons.ognl.OgnlException;
-import org.apache.commons.ognl.OgnlRuntime;
-import org.apache.commons.ognl.PropertyAccessor;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(value = Parameterized.class)
-public class PropertyNotFoundTest
- extends OgnlTestCase
-{
- private static final Blah BLAH = new Blah();
-
- private static final Object[][] TESTS = { { BLAH, "webwork.token.name", OgnlException.class, "W value",
- OgnlException.class }, };
-
- /*
- * =================================================================== Public static classes
- * ===================================================================
- */
- public static class Blah
- {
- String x;
-
- String y;
-
- public String getX()
- {
- return x;
- }
-
- public void setX( String x )
- {
- this.x = x;
- }
-
- public String getY()
- {
- return y;
- }
-
- public void setY( String y )
- {
- this.y = y;
- }
- }
-
- public static class BlahPropertyAccessor
- implements PropertyAccessor
- {
- public void setProperty( Map<String, Object> context, Object target, Object name, Object value )
- throws OgnlException
- {
- }
-
- public Object getProperty( Map<String, Object> context, Object target, Object name )
- throws OgnlException
- {
- if ( "x".equals( name ) || "y".equals( name ) )
- {
- return OgnlRuntime.getProperty( (OgnlContext) context, target, name );
- }
- return null;
- }
-
- public String getSourceAccessor( OgnlContext context, Object target, Object index )
- {
- return index.toString();
- }
-
- public String getSourceSetter( OgnlContext context, Object target, Object index )
- {
- return index.toString();
- }
- }
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][1];
- tmp[1] = TESTS[i][0];
- tmp[2] = TESTS[i][1];
-
- switch ( TESTS[i].length )
- {
- case 3:
- tmp[3] = TESTS[i][2];
- break;
-
- case 4:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- break;
-
- case 5:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- tmp[5] = TESTS[i][4];
- break;
-
- default:
- throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
- }
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public PropertyNotFoundTest( String name, Object root, String expressionString, Object expectedResult,
- Object setValue, Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-
- @Before
- @Override
- public void setUp()
- {
- super.setUp();
- OgnlRuntime.setPropertyAccessor( Blah.class, new BlahPropertyAccessor() );
- }
-}
+/*
+ * 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.test;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.commons.ognl.OgnlContext;
+import org.apache.commons.ognl.OgnlException;
+import org.apache.commons.ognl.OgnlRuntime;
+import org.apache.commons.ognl.PropertyAccessor;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
+public class PropertyNotFoundTest
+ extends OgnlTestCase
+{
+ private static final Blah BLAH = new Blah();
+
+ private static final Object[][] TESTS = { { BLAH, "webwork.token.name", OgnlException.class, "W value",
+ OgnlException.class }, };
+
+ /*
+ * =================================================================== Public static classes
+ * ===================================================================
+ */
+ public static class Blah
+ {
+ String x;
+
+ String y;
+
+ public String getX()
+ {
+ return x;
+ }
+
+ public void setX( String x )
+ {
+ this.x = x;
+ }
+
+ public String getY()
+ {
+ return y;
+ }
+
+ public void setY( String y )
+ {
+ this.y = y;
+ }
+ }
+
+ public static class BlahPropertyAccessor
+ implements PropertyAccessor
+ {
+ public void setProperty( Map<String, Object> context, Object target, Object name, Object value )
+ throws OgnlException
+ {
+ }
+
+ public Object getProperty( Map<String, Object> context, Object target, Object name )
+ throws OgnlException
+ {
+ if ( "x".equals( name ) || "y".equals( name ) )
+ {
+ return OgnlRuntime.getProperty( (OgnlContext) context, target, name );
+ }
+ return null;
+ }
+
+ public String getSourceAccessor( OgnlContext context, Object target, Object index )
+ {
+ return index.toString();
+ }
+
+ public String getSourceSetter( OgnlContext context, Object target, Object index )
+ {
+ return index.toString();
+ }
+ }
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][1];
+ tmp[1] = TESTS[i][0];
+ tmp[2] = TESTS[i][1];
+
+ switch ( TESTS[i].length )
+ {
+ case 3:
+ tmp[3] = TESTS[i][2];
+ break;
+
+ case 4:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ break;
+
+ case 5:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ tmp[5] = TESTS[i][4];
+ break;
+
+ default:
+ throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+ }
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public PropertyNotFoundTest( String name, Object root, String expressionString, Object expectedResult,
+ Object setValue, Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+
+ @Before
+ @Override
+ public void setUp()
+ {
+ super.setUp();
+ OgnlRuntime.setPropertyAccessor( Blah.class, new BlahPropertyAccessor() );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/PropertySetterTest.java b/src/test/java/org/apache/commons/ognl/test/PropertySetterTest.java
index 83368d1..c596d8f 100644
--- a/src/test/java/org/apache/commons/ognl/test/PropertySetterTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/PropertySetterTest.java
@@ -1,116 +1,115 @@
-/*
- * $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.test;
-
-import junit.framework.TestCase;
-import org.apache.commons.ognl.Node;
-import org.apache.commons.ognl.Ognl;
-import org.apache.commons.ognl.OgnlContext;
-
-import java.util.Map;
-
-/**
- * Tests being able to set property on object with interface that doesn't define setter. See OGNL-115.
- */
-public class PropertySetterTest
- extends TestCase
-{
-
- private Map<String, String> map;
-
- private final TestObject testObject = new TestObject( "propertyValue" );
-
- private final String propertyKey = "property";
-
- public interface TestInterface
- {
- String getProperty();
- }
-
- public class TestObject
- implements TestInterface
- {
-
- private String property;
-
- private final Integer integerProperty = 1;
-
- public TestObject( String property )
- {
- this.property = property;
- }
-
- public String getProperty()
- {
- return property;
- }
-
- public void setProperty( String property )
- {
- this.property = property;
- }
-
- public Integer getIntegerProperty()
- {
- return integerProperty;
- }
- }
-
- public Map<String, String> getMap()
- {
- return map;
- }
-
- public String getKey()
- {
- return "key";
- }
-
- public TestObject getObject()
- {
- return testObject;
- }
-
- public TestInterface getInterfaceObject()
- {
- return testObject;
- }
-
- public String getPropertyKey()
- {
- return propertyKey;
- }
-
- public void testEnhancedOgnl()
- throws Exception
- {
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
- Node expression = Ognl.compileExpression( context, this, "interfaceObject.property" );
- Ognl.setValue( expression, context, this, "hello" );
- assertEquals( "hello", getObject().getProperty() );
-
- // Fails if an interface is defined, but succeeds if not
- context.clear();
-
- expression = Ognl.compileExpression( context, this.getObject(), "property" );
- Ognl.setValue( expression, context, this.getObject(), "hello" );
- assertEquals( "hello", getObject().getProperty() );
- }
-}
+/*
+ * 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.test;
+
+import junit.framework.TestCase;
+import org.apache.commons.ognl.Node;
+import org.apache.commons.ognl.Ognl;
+import org.apache.commons.ognl.OgnlContext;
+
+import java.util.Map;
+
+/**
+ * Tests being able to set property on object with interface that doesn't define setter. See OGNL-115.
+ */
+public class PropertySetterTest
+ extends TestCase
+{
+
+ private Map<String, String> map;
+
+ private final TestObject testObject = new TestObject( "propertyValue" );
+
+ private final String propertyKey = "property";
+
+ public interface TestInterface
+ {
+ String getProperty();
+ }
+
+ public class TestObject
+ implements TestInterface
+ {
+
+ private String property;
+
+ private final Integer integerProperty = 1;
+
+ public TestObject( String property )
+ {
+ this.property = property;
+ }
+
+ public String getProperty()
+ {
+ return property;
+ }
+
+ public void setProperty( String property )
+ {
+ this.property = property;
+ }
+
+ public Integer getIntegerProperty()
+ {
+ return integerProperty;
+ }
+ }
+
+ public Map<String, String> getMap()
+ {
+ return map;
+ }
+
+ public String getKey()
+ {
+ return "key";
+ }
+
+ public TestObject getObject()
+ {
+ return testObject;
+ }
+
+ public TestInterface getInterfaceObject()
+ {
+ return testObject;
+ }
+
+ public String getPropertyKey()
+ {
+ return propertyKey;
+ }
+
+ public void testEnhancedOgnl()
+ throws Exception
+ {
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+ Node expression = Ognl.compileExpression( context, this, "interfaceObject.property" );
+ Ognl.setValue( expression, context, this, "hello" );
+ assertEquals( "hello", getObject().getProperty() );
+
+ // Fails if an interface is defined, but succeeds if not
+ context.clear();
+
+ expression = Ognl.compileExpression( context, this.getObject(), "property" );
+ Ognl.setValue( expression, context, this.getObject(), "hello" );
+ assertEquals( "hello", getObject().getProperty() );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/PropertyTest.java b/src/test/java/org/apache/commons/ognl/test/PropertyTest.java
index b773874..4630d64 100644
--- a/src/test/java/org/apache/commons/ognl/test/PropertyTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/PropertyTest.java
@@ -1,172 +1,171 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.test.objects.BaseBean;
-import org.apache.commons.ognl.test.objects.Bean2;
-import org.apache.commons.ognl.test.objects.FirstBean;
-import org.apache.commons.ognl.test.objects.PropertyHolder;
-import org.apache.commons.ognl.test.objects.Root;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class PropertyTest
- extends OgnlTestCase
-{
-
- public static final SimpleDateFormat DATETIME_FORMAT = new SimpleDateFormat( "MM/dd/yyyy hh:mm a 'CST'" );
-
- public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat( "MM/dd/yyyy" );
-
- public static final String VALUE = "foo";
-
- private static final Root ROOT = new Root();
-
- private static final BaseBean BEAN = new FirstBean();
-
- private static final PropertyHolder PROPERTY = new PropertyHolder();
-
- private static final Object[][] TESTS =
- {
- { ROOT, "testString != null && !false", Boolean.TRUE },
- { ROOT, "!getRenderNavigation() and !getReadonly()", Boolean.TRUE },
- { ROOT, "!bean2.pageBreakAfter", Boolean.TRUE },
- { ROOT, "map", ROOT.getMap() },
- { ROOT, "map.test", ROOT },
- { ROOT, "map[\"test\"]", ROOT },
- { ROOT, "map[\"te\" + \"st\"]", ROOT },
- { ROOT, "map[(\"s\" + \"i\") + \"ze\"]", ROOT.getMap().get( Root.SIZE_STRING ) },
- { ROOT, "map[\"size\"]", ROOT.getMap().get( Root.SIZE_STRING ) },
- { ROOT, "map[@org.apache.commons.ognl.test.objects.Root@SIZE_STRING]", ROOT.getMap().get( Root.SIZE_STRING ) },
- { ROOT, "stringValue != null && stringValue.length() > 0", Boolean.FALSE },
- { ROOT, "indexedStringValue != null && indexedStringValue.length() > 0", Boolean.TRUE },
- { ROOT.getMap(), "list", ROOT.getList() },
- { ROOT, "map.array[0]", new Integer( ROOT.getArray()[0] ) },
- { ROOT, "map.list[1]", ROOT.getList().get( 1 ) },
- { ROOT, "map[^]", new Integer( 99 ) },
- { ROOT, "map[$]", null },
- { ROOT.getMap(), "array[$]", new Integer( ROOT.getArray()[ROOT.getArray().length - 1] ) },
- { ROOT, "[\"map\"]", ROOT.getMap() },
- { ROOT.getArray(), "length", new Integer( ROOT.getArray().length ) },
- { ROOT, "getMap().list[|]", ROOT.getList().get( ROOT.getList().size() / 2 ) },
- { ROOT, "map.(array[2] + size())", new Integer( ROOT.getArray()[2] + ROOT.getMap().size() ) },
- { ROOT, "map.(#this)", ROOT.getMap() },
- { ROOT, "map.(#this != null ? #this['size'] : null)", ROOT.getMap().get( Root.SIZE_STRING ) },
- { ROOT, "map[^].(#this == null ? 'empty' : #this)", new Integer( 99 ) },
- { ROOT, "map[$].(#this == null ? 'empty' : #this)", "empty" },
- { ROOT, "map[$].(#root == null ? 'empty' : #root)", ROOT },
- { ROOT, "((selected != null) && (currLocale.toString() == selected.toString())) ? 'first' : 'second'",
- "first" },
- { ROOT, "{stringValue, getMap()}", Arrays.asList( ROOT.getStringValue(), ROOT.getMap() ) },
- { ROOT, "{'stringValue', map[\"test\"].map[\"size\"]}",
- Arrays.asList( "stringValue", ROOT.getMap().get( "size" ) ) },
- { ROOT, "property.bean3.value + '(this.checked)'", "100(this.checked)" },
- { ROOT, "getIndexedProperty(property.bean3.map[\"bar\"])", ROOT.getArray() },
- { ROOT, "getProperty().getBean3()", ( (Bean2) ROOT.getProperty() ).getBean3() },
- { ROOT, "intValue", new Integer( 0 ), new Integer( 2 ), new Integer( 2 ) },
- { ROOT, "! booleanValue", Boolean.TRUE },
- { ROOT, "booleanValue", Boolean.FALSE, Boolean.TRUE, Boolean.TRUE },
- { ROOT, "! disabled", new Boolean( false ) },
- { ROOT, "disabled || readonly", Boolean.TRUE },
- { ROOT, "property.bean3.value != null", Boolean.TRUE },
- { ROOT, "\"background-color:blue; width:\" + (currentLocaleVerbosity / 2) + \"px\"",
- "background-color:blue; width:43px" },
- { ROOT, "renderNavigation ? '' : 'noborder'", "noborder" },
- { ROOT, "format('key', array)", "formatted" },
- { ROOT, "format('key', intValue)", "formatted" },
- { ROOT, "format('key', map.size)", "formatted" },
- { ROOT,
- "'disableButton(this,\"' + map.get('button-testing') + '\");clearElement("testFtpMessage")'",
- "disableButton(this,'null');clearElement('testFtpMessage')" },
- { ROOT.getMap(), "!disableWarning", Boolean.TRUE },
- { ROOT.getMap(), "get('value').bean3.value",
- new Integer( ( (Bean2) ROOT.getMap().get( "value" ) ).getBean3().getValue() ) },
- { ROOT.getMap(), "\"Tapestry\".toCharArray()[2]", new Character( 'p' ) },
- { ROOT.getMap(), "nested.deep.last", Boolean.TRUE },
- { ROOT, "'last ' + getCurrentClass(@org.apache.commons.ognl.test.PropertyTest@VALUE)", "last foo stop" },
- { ROOT, "@org.apache.commons.ognl.test.PropertyTest@formatValue(property.millis, true, true)",
- formatValue( (int) ( (Bean2) ROOT.getProperty() ).getMillis(), true, true ) },
- { ROOT, "nullObject || !readonly", Boolean.TRUE },
- { ROOT,
- "testDate == null ? '-' : @org.apache.commons.ognl.test.PropertyTest@DATETIME_FORMAT.format(testDate)",
- DATETIME_FORMAT.format( ROOT.getTestDate() ) },
- { ROOT, "disabled ? 'disabled' : 'othernot'", "disabled" },
- { BEAN, "two.getMessage(active ? 'ACT' : 'INA')", "[ACT]" },
- { BEAN, "hasChildren('aaa')", Boolean.TRUE },
- { BEAN, "two.hasChildren('aa')", Boolean.FALSE },
- { BEAN, "two.hasChildren('a')", Boolean.FALSE },
- { ROOT, "sorted ? (readonly ? 'currentSortDesc' : 'currentSortAsc') : 'currentSortNone'", "currentSortAsc" },
- { ROOT, "getAsset( (width?'Yes':'No')+'Icon' )", "YesIcon" },
- { ROOT, "flyingMonkey", Boolean.TRUE },
- { ROOT,
- "expiration == null ? '' : @org.apache.commons.ognl.test.PropertyTest@DATE_FORMAT.format(expiration)",
- "" }, { ROOT, "printDelivery ? 'javascript:toggle(' + bean2.id + ');' : ''", "javascript:toggle(1);" },
- { ROOT, "openTransitionWin", Boolean.FALSE }, { ROOT, "b.methodOfB(a.methodOfA(b)-1)", new Integer( 0 ) },
- { ROOT, "disabled", Boolean.TRUE }, { PROPERTY, "value", "" }, { PROPERTY, "search", "foo" } };
-
- public static String formatValue( int millis, boolean b1, boolean b2 )
- {
- return millis + "-formatted";
- }
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][1];
- tmp[1] = TESTS[i][0];
- tmp[2] = TESTS[i][1];
- tmp[3] = TESTS[i][2];
-
- if ( TESTS[i].length == 5 )
- {
- tmp[4] = TESTS[i][3];
- tmp[5] = TESTS[i][4];
- }
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public PropertyTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
- Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.test.objects.BaseBean;
+import org.apache.commons.ognl.test.objects.Bean2;
+import org.apache.commons.ognl.test.objects.FirstBean;
+import org.apache.commons.ognl.test.objects.PropertyHolder;
+import org.apache.commons.ognl.test.objects.Root;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class PropertyTest
+ extends OgnlTestCase
+{
+
+ public static final SimpleDateFormat DATETIME_FORMAT = new SimpleDateFormat( "MM/dd/yyyy hh:mm a 'CST'" );
+
+ public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat( "MM/dd/yyyy" );
+
+ public static final String VALUE = "foo";
+
+ private static final Root ROOT = new Root();
+
+ private static final BaseBean BEAN = new FirstBean();
+
+ private static final PropertyHolder PROPERTY = new PropertyHolder();
+
+ private static final Object[][] TESTS =
+ {
+ { ROOT, "testString != null && !false", Boolean.TRUE },
+ { ROOT, "!getRenderNavigation() and !getReadonly()", Boolean.TRUE },
+ { ROOT, "!bean2.pageBreakAfter", Boolean.TRUE },
+ { ROOT, "map", ROOT.getMap() },
+ { ROOT, "map.test", ROOT },
+ { ROOT, "map[\"test\"]", ROOT },
+ { ROOT, "map[\"te\" + \"st\"]", ROOT },
+ { ROOT, "map[(\"s\" + \"i\") + \"ze\"]", ROOT.getMap().get( Root.SIZE_STRING ) },
+ { ROOT, "map[\"size\"]", ROOT.getMap().get( Root.SIZE_STRING ) },
+ { ROOT, "map[@org.apache.commons.ognl.test.objects.Root@SIZE_STRING]", ROOT.getMap().get( Root.SIZE_STRING ) },
+ { ROOT, "stringValue != null && stringValue.length() > 0", Boolean.FALSE },
+ { ROOT, "indexedStringValue != null && indexedStringValue.length() > 0", Boolean.TRUE },
+ { ROOT.getMap(), "list", ROOT.getList() },
+ { ROOT, "map.array[0]", new Integer( ROOT.getArray()[0] ) },
+ { ROOT, "map.list[1]", ROOT.getList().get( 1 ) },
+ { ROOT, "map[^]", new Integer( 99 ) },
+ { ROOT, "map[$]", null },
+ { ROOT.getMap(), "array[$]", new Integer( ROOT.getArray()[ROOT.getArray().length - 1] ) },
+ { ROOT, "[\"map\"]", ROOT.getMap() },
+ { ROOT.getArray(), "length", new Integer( ROOT.getArray().length ) },
+ { ROOT, "getMap().list[|]", ROOT.getList().get( ROOT.getList().size() / 2 ) },
+ { ROOT, "map.(array[2] + size())", new Integer( ROOT.getArray()[2] + ROOT.getMap().size() ) },
+ { ROOT, "map.(#this)", ROOT.getMap() },
+ { ROOT, "map.(#this != null ? #this['size'] : null)", ROOT.getMap().get( Root.SIZE_STRING ) },
+ { ROOT, "map[^].(#this == null ? 'empty' : #this)", new Integer( 99 ) },
+ { ROOT, "map[$].(#this == null ? 'empty' : #this)", "empty" },
+ { ROOT, "map[$].(#root == null ? 'empty' : #root)", ROOT },
+ { ROOT, "((selected != null) && (currLocale.toString() == selected.toString())) ? 'first' : 'second'",
+ "first" },
+ { ROOT, "{stringValue, getMap()}", Arrays.asList( ROOT.getStringValue(), ROOT.getMap() ) },
+ { ROOT, "{'stringValue', map[\"test\"].map[\"size\"]}",
+ Arrays.asList( "stringValue", ROOT.getMap().get( "size" ) ) },
+ { ROOT, "property.bean3.value + '(this.checked)'", "100(this.checked)" },
+ { ROOT, "getIndexedProperty(property.bean3.map[\"bar\"])", ROOT.getArray() },
+ { ROOT, "getProperty().getBean3()", ( (Bean2) ROOT.getProperty() ).getBean3() },
+ { ROOT, "intValue", new Integer( 0 ), new Integer( 2 ), new Integer( 2 ) },
+ { ROOT, "! booleanValue", Boolean.TRUE },
+ { ROOT, "booleanValue", Boolean.FALSE, Boolean.TRUE, Boolean.TRUE },
+ { ROOT, "! disabled", new Boolean( false ) },
+ { ROOT, "disabled || readonly", Boolean.TRUE },
+ { ROOT, "property.bean3.value != null", Boolean.TRUE },
+ { ROOT, "\"background-color:blue; width:\" + (currentLocaleVerbosity / 2) + \"px\"",
+ "background-color:blue; width:43px" },
+ { ROOT, "renderNavigation ? '' : 'noborder'", "noborder" },
+ { ROOT, "format('key', array)", "formatted" },
+ { ROOT, "format('key', intValue)", "formatted" },
+ { ROOT, "format('key', map.size)", "formatted" },
+ { ROOT,
+ "'disableButton(this,\"' + map.get('button-testing') + '\");clearElement("testFtpMessage")'",
+ "disableButton(this,'null');clearElement('testFtpMessage')" },
+ { ROOT.getMap(), "!disableWarning", Boolean.TRUE },
+ { ROOT.getMap(), "get('value').bean3.value",
+ new Integer( ( (Bean2) ROOT.getMap().get( "value" ) ).getBean3().getValue() ) },
+ { ROOT.getMap(), "\"Tapestry\".toCharArray()[2]", new Character( 'p' ) },
+ { ROOT.getMap(), "nested.deep.last", Boolean.TRUE },
+ { ROOT, "'last ' + getCurrentClass(@org.apache.commons.ognl.test.PropertyTest@VALUE)", "last foo stop" },
+ { ROOT, "@org.apache.commons.ognl.test.PropertyTest@formatValue(property.millis, true, true)",
+ formatValue( (int) ( (Bean2) ROOT.getProperty() ).getMillis(), true, true ) },
+ { ROOT, "nullObject || !readonly", Boolean.TRUE },
+ { ROOT,
+ "testDate == null ? '-' : @org.apache.commons.ognl.test.PropertyTest@DATETIME_FORMAT.format(testDate)",
+ DATETIME_FORMAT.format( ROOT.getTestDate() ) },
+ { ROOT, "disabled ? 'disabled' : 'othernot'", "disabled" },
+ { BEAN, "two.getMessage(active ? 'ACT' : 'INA')", "[ACT]" },
+ { BEAN, "hasChildren('aaa')", Boolean.TRUE },
+ { BEAN, "two.hasChildren('aa')", Boolean.FALSE },
+ { BEAN, "two.hasChildren('a')", Boolean.FALSE },
+ { ROOT, "sorted ? (readonly ? 'currentSortDesc' : 'currentSortAsc') : 'currentSortNone'", "currentSortAsc" },
+ { ROOT, "getAsset( (width?'Yes':'No')+'Icon' )", "YesIcon" },
+ { ROOT, "flyingMonkey", Boolean.TRUE },
+ { ROOT,
+ "expiration == null ? '' : @org.apache.commons.ognl.test.PropertyTest@DATE_FORMAT.format(expiration)",
+ "" }, { ROOT, "printDelivery ? 'javascript:toggle(' + bean2.id + ');' : ''", "javascript:toggle(1);" },
+ { ROOT, "openTransitionWin", Boolean.FALSE }, { ROOT, "b.methodOfB(a.methodOfA(b)-1)", new Integer( 0 ) },
+ { ROOT, "disabled", Boolean.TRUE }, { PROPERTY, "value", "" }, { PROPERTY, "search", "foo" } };
+
+ public static String formatValue( int millis, boolean b1, boolean b2 )
+ {
+ return millis + "-formatted";
+ }
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][1];
+ tmp[1] = TESTS[i][0];
+ tmp[2] = TESTS[i][1];
+ tmp[3] = TESTS[i][2];
+
+ if ( TESTS[i].length == 5 )
+ {
+ tmp[4] = TESTS[i][3];
+ tmp[5] = TESTS[i][4];
+ }
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public PropertyTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
+ Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/ProtectedInnerClassTest.java b/src/test/java/org/apache/commons/ognl/test/ProtectedInnerClassTest.java
index cf0bac6..3002041 100644
--- a/src/test/java/org/apache/commons/ognl/test/ProtectedInnerClassTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/ProtectedInnerClassTest.java
@@ -1,73 +1,72 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.test.objects.Root;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class ProtectedInnerClassTest
- extends OgnlTestCase
-{
-
- private static final Root ROOT = new Root();
-
- private static final Object[][] TESTS = {
- // member access of inner class (Arrays.asList() returned protected inner class)
- { ROOT, "list.size()", ROOT.getList().size() },
- { ROOT, "list[0]", ROOT.getList().get( 0 ) }
- };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( Object[] TEST : TESTS )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TEST[1];
- tmp[1] = TEST[0];
- tmp[2] = TEST[1];
- tmp[3] = TEST[2];
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public ProtectedInnerClassTest( String name, Object root, String expressionString, Object expectedResult,
- Object setValue, Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.test.objects.Root;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class ProtectedInnerClassTest
+ extends OgnlTestCase
+{
+
+ private static final Root ROOT = new Root();
+
+ private static final Object[][] TESTS = {
+ // member access of inner class (Arrays.asList() returned protected inner class)
+ { ROOT, "list.size()", ROOT.getList().size() },
+ { ROOT, "list[0]", ROOT.getList().get( 0 ) }
+ };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( Object[] TEST : TESTS )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TEST[1];
+ tmp[1] = TEST[0];
+ tmp[2] = TEST[1];
+ tmp[3] = TEST[2];
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public ProtectedInnerClassTest( String name, Object root, String expressionString, Object expectedResult,
+ Object setValue, Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/QuotingTest.java b/src/test/java/org/apache/commons/ognl/test/QuotingTest.java
index 53e2ae8..81c5e1c 100644
--- a/src/test/java/org/apache/commons/ognl/test/QuotingTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/QuotingTest.java
@@ -1,99 +1,98 @@
-/*
- * $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.test;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class QuotingTest
- extends OgnlTestCase
-{
- private static final Object[][] TESTS = {
- // Quoting
- { null, "`c`", new Character( 'c' ) }, { null, "'s'", new Character( 's' ) }, { null, "'string'", "string" },
- { null, "\"string\"", "string" }, { null, "'' + 'bar'", "bar" },
- { null, "'yyyy\u539Add\u5EA6'", "yyyy\u539Add\u5EA6" } };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][1];
- tmp[1] = TESTS[i][0];
- tmp[2] = TESTS[i][1];
-
- switch ( TESTS[i].length )
- {
- case 3:
- tmp[3] = TESTS[i][2];
- break;
-
- case 4:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- break;
-
- case 5:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- tmp[5] = TESTS[i][4];
- break;
-
- default:
- throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
- }
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public QuotingTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
- Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-
- @Test
-
- @Override
- public void runTest()
- throws Exception
- {
- super.runTest();
- }
-}
+/*
+ * 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.test;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class QuotingTest
+ extends OgnlTestCase
+{
+ private static final Object[][] TESTS = {
+ // Quoting
+ { null, "`c`", new Character( 'c' ) }, { null, "'s'", new Character( 's' ) }, { null, "'string'", "string" },
+ { null, "\"string\"", "string" }, { null, "'' + 'bar'", "bar" },
+ { null, "'yyyy\u539Add\u5EA6'", "yyyy\u539Add\u5EA6" } };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][1];
+ tmp[1] = TESTS[i][0];
+ tmp[2] = TESTS[i][1];
+
+ switch ( TESTS[i].length )
+ {
+ case 3:
+ tmp[3] = TESTS[i][2];
+ break;
+
+ case 4:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ break;
+
+ case 5:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ tmp[5] = TESTS[i][4];
+ break;
+
+ default:
+ throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+ }
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public QuotingTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
+ Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+
+ @Test
+
+ @Override
+ public void runTest()
+ throws Exception
+ {
+ super.runTest();
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/SetterTest.java b/src/test/java/org/apache/commons/ognl/test/SetterTest.java
index 2eb5caf..06dc515 100644
--- a/src/test/java/org/apache/commons/ognl/test/SetterTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/SetterTest.java
@@ -1,119 +1,118 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.InappropriateExpressionException;
-import org.apache.commons.ognl.NoSuchPropertyException;
-import org.apache.commons.ognl.test.objects.Root;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.util.*;
-
-@RunWith(value = Parameterized.class)
-public class SetterTest
- extends OgnlTestCase
-{
- private static final Root ROOT = new Root();
-
- static Set<String> _list = new HashSet<String>();
- static
- {
- _list.add( "Test1" );
- }
-
- private static final Object[][] TESTS = {
- // Setting values
- { ROOT.getMap(), "newValue", null, new Integer( 101 ) },
- { ROOT, "settableList[0]", "foo", "quux" }, // absolute indexes
- { ROOT, "settableList[0]", "quux" },
- { ROOT, "settableList[2]", "baz", "quux" },
- { ROOT, "settableList[2]", "quux" },
- { ROOT, "settableList[$]", "quux", "oompa" }, // special indexes
- { ROOT, "settableList[$]", "oompa" },
- { ROOT, "settableList[^]", "quux", "oompa" },
- { ROOT, "settableList[^]", "oompa" },
- { ROOT, "settableList[|]", "bar", "oompa" },
- { ROOT, "settableList[|]", "oompa" },
- { ROOT, "map.newValue", new Integer( 101 ), new Integer( 555 ) },
- { ROOT, "map", ROOT.getMap(), new HashMap<String, String>(), NoSuchPropertyException.class },
- { ROOT.getMap(), "newValue2 || put(\"newValue2\",987), newValue2", new Integer( 987 ), new Integer( 1002 ) },
- { ROOT, "map.(someMissingKey || newValue)", new Integer( 555 ), new Integer( 666 ) },
- { ROOT.getMap(), "newValue || someMissingKey", new Integer( 666 ), new Integer( 666 ) }, // no setting happens!
- { ROOT, "map.(newValue && aKey)", null, new Integer( 54321 ) },
- { ROOT, "map.(someMissingKey && newValue)", null, null }, // again, no setting
- { null, "0", new Integer( 0 ), null, InappropriateExpressionException.class }, // illegal for setting, no
- // property
- { ROOT, "map[0]=\"map.newValue\", map[0](#this)", new Integer( 666 ), new Integer( 888 ) },
- { ROOT, "selectedList", null, _list, IllegalArgumentException.class },
- { ROOT, "openTransitionWin", Boolean.FALSE, Boolean.TRUE } };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][1];
- tmp[1] = TESTS[i][0];
- tmp[2] = TESTS[i][1];
-
- switch ( TESTS[i].length )
- {
- case 3:
- tmp[3] = TESTS[i][2];
- break;
-
- case 4:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- break;
-
- case 5:
- tmp[3] = TESTS[i][2];
- tmp[4] = TESTS[i][3];
- tmp[5] = TESTS[i][4];
- break;
-
- default:
- throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
- }
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public SetterTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
- Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.InappropriateExpressionException;
+import org.apache.commons.ognl.NoSuchPropertyException;
+import org.apache.commons.ognl.test.objects.Root;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.*;
+
+@RunWith(value = Parameterized.class)
+public class SetterTest
+ extends OgnlTestCase
+{
+ private static final Root ROOT = new Root();
+
+ static Set<String> _list = new HashSet<String>();
+ static
+ {
+ _list.add( "Test1" );
+ }
+
+ private static final Object[][] TESTS = {
+ // Setting values
+ { ROOT.getMap(), "newValue", null, new Integer( 101 ) },
+ { ROOT, "settableList[0]", "foo", "quux" }, // absolute indexes
+ { ROOT, "settableList[0]", "quux" },
+ { ROOT, "settableList[2]", "baz", "quux" },
+ { ROOT, "settableList[2]", "quux" },
+ { ROOT, "settableList[$]", "quux", "oompa" }, // special indexes
+ { ROOT, "settableList[$]", "oompa" },
+ { ROOT, "settableList[^]", "quux", "oompa" },
+ { ROOT, "settableList[^]", "oompa" },
+ { ROOT, "settableList[|]", "bar", "oompa" },
+ { ROOT, "settableList[|]", "oompa" },
+ { ROOT, "map.newValue", new Integer( 101 ), new Integer( 555 ) },
+ { ROOT, "map", ROOT.getMap(), new HashMap<String, String>(), NoSuchPropertyException.class },
+ { ROOT.getMap(), "newValue2 || put(\"newValue2\",987), newValue2", new Integer( 987 ), new Integer( 1002 ) },
+ { ROOT, "map.(someMissingKey || newValue)", new Integer( 555 ), new Integer( 666 ) },
+ { ROOT.getMap(), "newValue || someMissingKey", new Integer( 666 ), new Integer( 666 ) }, // no setting happens!
+ { ROOT, "map.(newValue && aKey)", null, new Integer( 54321 ) },
+ { ROOT, "map.(someMissingKey && newValue)", null, null }, // again, no setting
+ { null, "0", new Integer( 0 ), null, InappropriateExpressionException.class }, // illegal for setting, no
+ // property
+ { ROOT, "map[0]=\"map.newValue\", map[0](#this)", new Integer( 666 ), new Integer( 888 ) },
+ { ROOT, "selectedList", null, _list, IllegalArgumentException.class },
+ { ROOT, "openTransitionWin", Boolean.FALSE, Boolean.TRUE } };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][1];
+ tmp[1] = TESTS[i][0];
+ tmp[2] = TESTS[i][1];
+
+ switch ( TESTS[i].length )
+ {
+ case 3:
+ tmp[3] = TESTS[i][2];
+ break;
+
+ case 4:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ break;
+
+ case 5:
+ tmp[3] = TESTS[i][2];
+ tmp[4] = TESTS[i][3];
+ tmp[5] = TESTS[i][4];
+ break;
+
+ default:
+ throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+ }
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public SetterTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
+ Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/SetterWithConversionTest.java b/src/test/java/org/apache/commons/ognl/test/SetterWithConversionTest.java
index 1191af1..2c1f3da 100644
--- a/src/test/java/org/apache/commons/ognl/test/SetterWithConversionTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/SetterWithConversionTest.java
@@ -1,101 +1,100 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.test.objects.Root;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class SetterWithConversionTest
- extends OgnlTestCase
-{
- private static final Root ROOT = new Root();
-
- private static final Object[][] TESTS = {
- // Property set with conversion
- { ROOT, "intValue", new Integer( 0 ), new Double( 6.5 ), new Integer( 6 ) },
- { ROOT, "intValue", new Integer( 6 ), new Double( 1025.87645 ), new Integer( 1025 ) },
- { ROOT, "intValue", new Integer( 1025 ), "654", new Integer( 654 ) },
- { ROOT, "stringValue", null, new Integer( 25 ), "25" },
- { ROOT, "stringValue", "25", new Float( 100.25 ), "100.25" },
- { ROOT, "anotherStringValue", "foo", new Integer( 0 ), "0" },
- { ROOT, "anotherStringValue", "0", new Double( 0.5 ), "0.5" },
- { ROOT, "anotherIntValue", new Integer( 123 ), "5", new Integer( 5 ) },
- { ROOT, "anotherIntValue", new Integer( 5 ), new Double( 100.25 ), new Integer( 100 ) },
- // { ROOT, "anotherIntValue", new Integer(100), new String[] { "55" }, new Integer(55)},
- // { ROOT, "yetAnotherIntValue", new Integer(46), new String[] { "55" }, new Integer(55)},
-
- };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( Object[] TEST : TESTS )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TEST[1];
- tmp[1] = TEST[0];
- tmp[2] = TEST[1];
-
- switch (TEST.length) {
- case 3:
- tmp[3] = TEST[2];
- break;
-
- case 4:
- tmp[3] = TEST[2];
- tmp[4] = TEST[3];
- break;
-
- case 5:
- tmp[3] = TEST[2];
- tmp[4] = TEST[3];
- tmp[5] = TEST[4];
- break;
-
- default:
- throw new RuntimeException("don't understand TEST format with length " + TEST.length);
- }
-
- data.add(tmp);
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public SetterWithConversionTest( String name, Object root, String expressionString, Object expectedResult,
- Object setValue, Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.test.objects.Root;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class SetterWithConversionTest
+ extends OgnlTestCase
+{
+ private static final Root ROOT = new Root();
+
+ private static final Object[][] TESTS = {
+ // Property set with conversion
+ { ROOT, "intValue", new Integer( 0 ), new Double( 6.5 ), new Integer( 6 ) },
+ { ROOT, "intValue", new Integer( 6 ), new Double( 1025.87645 ), new Integer( 1025 ) },
+ { ROOT, "intValue", new Integer( 1025 ), "654", new Integer( 654 ) },
+ { ROOT, "stringValue", null, new Integer( 25 ), "25" },
+ { ROOT, "stringValue", "25", new Float( 100.25 ), "100.25" },
+ { ROOT, "anotherStringValue", "foo", new Integer( 0 ), "0" },
+ { ROOT, "anotherStringValue", "0", new Double( 0.5 ), "0.5" },
+ { ROOT, "anotherIntValue", new Integer( 123 ), "5", new Integer( 5 ) },
+ { ROOT, "anotherIntValue", new Integer( 5 ), new Double( 100.25 ), new Integer( 100 ) },
+ // { ROOT, "anotherIntValue", new Integer(100), new String[] { "55" }, new Integer(55)},
+ // { ROOT, "yetAnotherIntValue", new Integer(46), new String[] { "55" }, new Integer(55)},
+
+ };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( Object[] TEST : TESTS )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TEST[1];
+ tmp[1] = TEST[0];
+ tmp[2] = TEST[1];
+
+ switch (TEST.length) {
+ case 3:
+ tmp[3] = TEST[2];
+ break;
+
+ case 4:
+ tmp[3] = TEST[2];
+ tmp[4] = TEST[3];
+ break;
+
+ case 5:
+ tmp[3] = TEST[2];
+ tmp[4] = TEST[3];
+ tmp[5] = TEST[4];
+ break;
+
+ default:
+ throw new RuntimeException("don't understand TEST format with length " + TEST.length);
+ }
+
+ data.add(tmp);
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public SetterWithConversionTest( String name, Object root, String expressionString, Object expectedResult,
+ Object setValue, Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/ShortCircuitingExpressionTest.java b/src/test/java/org/apache/commons/ognl/test/ShortCircuitingExpressionTest.java
index 80d5e13..71201e2 100644
--- a/src/test/java/org/apache/commons/ognl/test/ShortCircuitingExpressionTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/ShortCircuitingExpressionTest.java
@@ -1,72 +1,71 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.NoSuchPropertyException;
-import org.apache.commons.ognl.OgnlException;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class ShortCircuitingExpressionTest
- extends OgnlTestCase
-{
- private static final Object[][] TESTS = { { "#root ? someProperty : 99", new Integer( 99 ) },
- { "#root ? 99 : someProperty", OgnlException.class },
- { "(#x=99)? #x.someProperty : #x", NoSuchPropertyException.class },
- { "#xyzzy.doubleValue()", NullPointerException.class }, { "#xyzzy && #xyzzy.doubleValue()", null },
- { "(#x=99) && #x.doubleValue()", new Double( 99 ) }, { "#xyzzy || 101", new Integer( 101 ) },
- { "99 || 101", new Integer( 99 ) }, };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][0] + " (" + TESTS[i][1] + ")";
- tmp[1] = null;
- tmp[2] = TESTS[i][0];
- tmp[3] = TESTS[i][1];
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public ShortCircuitingExpressionTest( String name, Object root, String expressionString, Object expectedResult,
- Object setValue, Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.NoSuchPropertyException;
+import org.apache.commons.ognl.OgnlException;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class ShortCircuitingExpressionTest
+ extends OgnlTestCase
+{
+ private static final Object[][] TESTS = { { "#root ? someProperty : 99", new Integer( 99 ) },
+ { "#root ? 99 : someProperty", OgnlException.class },
+ { "(#x=99)? #x.someProperty : #x", NoSuchPropertyException.class },
+ { "#xyzzy.doubleValue()", NullPointerException.class }, { "#xyzzy && #xyzzy.doubleValue()", null },
+ { "(#x=99) && #x.doubleValue()", new Double( 99 ) }, { "#xyzzy || 101", new Integer( 101 ) },
+ { "99 || 101", new Integer( 99 ) }, };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][0] + " (" + TESTS[i][1] + ")";
+ tmp[1] = null;
+ tmp[2] = TESTS[i][0];
+ tmp[3] = TESTS[i][1];
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public ShortCircuitingExpressionTest( String name, Object root, String expressionString, Object expectedResult,
+ Object setValue, Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/SimpleNavigationChainTreeTest.java b/src/test/java/org/apache/commons/ognl/test/SimpleNavigationChainTreeTest.java
index a2171de..fc06bf1 100644
--- a/src/test/java/org/apache/commons/ognl/test/SimpleNavigationChainTreeTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/SimpleNavigationChainTreeTest.java
@@ -1,84 +1,83 @@
-/*
- * $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.test;
-
-import static junit.framework.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import junit.framework.Assert;
-import org.apache.commons.ognl.Ognl;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(value = Parameterized.class)
-public class SimpleNavigationChainTreeTest
- extends OgnlTestCase
-{
-
- private static final Object[][] TESTS = { { "name", Boolean.TRUE }, { "name[i]", Boolean.FALSE },
- { "name + foo", Boolean.FALSE }, { "name.foo", Boolean.TRUE } };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][0] + " (" + TESTS[i][1] + ")";
- tmp[1] = null;
- tmp[2] = TESTS[i][0];
- tmp[3] = TESTS[i][1];
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public SimpleNavigationChainTreeTest( String name, Object root, String expressionString, Object expectedResult,
- Object setValue, Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-
- /*
- * =================================================================== Overridden methods
- * ===================================================================
- */
- @Test
- @Override
- public void runTest()
- throws Exception
- {
- Assert.assertEquals(Ognl.isSimpleNavigationChain(getExpression(), _context), ((Boolean) getExpectedResult()).booleanValue());
- }
-}
+/*
+ * 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.test;
+
+import static junit.framework.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import junit.framework.Assert;
+import org.apache.commons.ognl.Ognl;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
+public class SimpleNavigationChainTreeTest
+ extends OgnlTestCase
+{
+
+ private static final Object[][] TESTS = { { "name", Boolean.TRUE }, { "name[i]", Boolean.FALSE },
+ { "name + foo", Boolean.FALSE }, { "name.foo", Boolean.TRUE } };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][0] + " (" + TESTS[i][1] + ")";
+ tmp[1] = null;
+ tmp[2] = TESTS[i][0];
+ tmp[3] = TESTS[i][1];
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public SimpleNavigationChainTreeTest( String name, Object root, String expressionString, Object expectedResult,
+ Object setValue, Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+
+ /*
+ * =================================================================== Overridden methods
+ * ===================================================================
+ */
+ @Test
+ @Override
+ public void runTest()
+ throws Exception
+ {
+ Assert.assertEquals(Ognl.isSimpleNavigationChain(getExpression(), _context), ((Boolean) getExpectedResult()).booleanValue());
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/SimplePropertyTreeTest.java b/src/test/java/org/apache/commons/ognl/test/SimplePropertyTreeTest.java
index 989c3b8..b4d8411 100644
--- a/src/test/java/org/apache/commons/ognl/test/SimplePropertyTreeTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/SimplePropertyTreeTest.java
@@ -1,84 +1,83 @@
-/*
- * $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.test;
-
-import static junit.framework.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import junit.framework.Assert;
-import org.apache.commons.ognl.Ognl;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(value = Parameterized.class)
-public class SimplePropertyTreeTest
- extends OgnlTestCase
-{
- private static final Object[][] TESTS = { { "name", Boolean.TRUE }, { "foo", Boolean.TRUE },
- { "name[i]", Boolean.FALSE }, { "name + foo", Boolean.FALSE }, { "name.foo", Boolean.FALSE },
- { "name.foo.bar", Boolean.FALSE }, { "name.{? foo }", Boolean.FALSE }, { "name.( foo )", Boolean.FALSE } };
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( int i = 0; i < TESTS.length; i++ )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TESTS[i][0] + " (" + TESTS[i][1] + ")";
- tmp[1] = null;
- tmp[2] = TESTS[i][0];
- tmp[3] = TESTS[i][1];
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public SimplePropertyTreeTest( String name, Object root, String expressionString, Object expectedResult,
- Object setValue, Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-
- /*
- * =================================================================== Overridden methods
- * ===================================================================
- */
- @Before
- @Override
- public void runTest()
- throws Exception
- {
- Assert.assertEquals(Ognl.isSimpleProperty(getExpression(), _context), ((Boolean) getExpectedResult()).booleanValue());
- }
-}
+/*
+ * 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.test;
+
+import static junit.framework.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import junit.framework.Assert;
+import org.apache.commons.ognl.Ognl;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
+public class SimplePropertyTreeTest
+ extends OgnlTestCase
+{
+ private static final Object[][] TESTS = { { "name", Boolean.TRUE }, { "foo", Boolean.TRUE },
+ { "name[i]", Boolean.FALSE }, { "name + foo", Boolean.FALSE }, { "name.foo", Boolean.FALSE },
+ { "name.foo.bar", Boolean.FALSE }, { "name.{? foo }", Boolean.FALSE }, { "name.( foo )", Boolean.FALSE } };
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( int i = 0; i < TESTS.length; i++ )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TESTS[i][0] + " (" + TESTS[i][1] + ")";
+ tmp[1] = null;
+ tmp[2] = TESTS[i][0];
+ tmp[3] = TESTS[i][1];
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public SimplePropertyTreeTest( String name, Object root, String expressionString, Object expectedResult,
+ Object setValue, Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+
+ /*
+ * =================================================================== Overridden methods
+ * ===================================================================
+ */
+ @Before
+ @Override
+ public void runTest()
+ throws Exception
+ {
+ Assert.assertEquals(Ognl.isSimpleProperty(getExpression(), _context), ((Boolean) getExpectedResult()).booleanValue());
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/StaticsAndConstructorsTest.java b/src/test/java/org/apache/commons/ognl/test/StaticsAndConstructorsTest.java
index 2605402..806323d 100644
--- a/src/test/java/org/apache/commons/ognl/test/StaticsAndConstructorsTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/StaticsAndConstructorsTest.java
@@ -1,193 +1,192 @@
-/*
- * $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.test;
-
-import org.apache.commons.ognl.test.objects.Root;
-import org.apache.commons.ognl.test.objects.Simple;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-@RunWith(value = Parameterized.class)
-public class StaticsAndConstructorsTest
- extends OgnlTestCase
-{
- private static final Root ROOT = new Root();
-
- private static final Object[][] TESTS =
- {
- { "@java.lang.Class@forName(\"java.lang.Object\")", Object.class },
- { "@java.lang.Integer@MAX_VALUE", Integer.MAX_VALUE },
- { "@@max(3,4)", 4 },
- { "new java.lang.StringBuilder().append(55).toString()", "55" },
- { "class", ROOT.getClass() },
- { "@org.apache.commons.ognl.test.objects.Root@class", ROOT.getClass() },
- { "class.getName()", ROOT.getClass().getName() },
- { "@org.apache.commons.ognl.test.objects.Root@class.getName()", ROOT.getClass().getName() },
- { "@org.apache.commons.ognl.test.objects.Root@class.name", ROOT.getClass().getName() },
- { "class.getSuperclass()", ROOT.getClass().getSuperclass() },
- { "class.superclass", ROOT.getClass().getSuperclass() },
- { "class.name", ROOT.getClass().getName() },
- { "getStaticInt()", Root.getStaticInt() },
- { "@org.apache.commons.ognl.test.objects.Root@getStaticInt()", Root.getStaticInt() },
- { "new org.apache.commons.ognl.test.objects.Simple(property).getStringValue()",
- new Simple().getStringValue() },
- { "new org.apache.commons.ognl.test.objects.Simple(map['test'].property).getStringValue()",
- new Simple().getStringValue() },
- { "map.test.getCurrentClass(@org.apache.commons.ognl.test.StaticsAndConstructorsTest@KEY.toString())",
- "size stop" },
- { "new org.apache.commons.ognl.test.StaticsAndConstructorsTest$IntWrapper(index)",
- new IntWrapper( ROOT.getIndex() ) },
- { "new org.apache.commons.ognl.test.StaticsAndConstructorsTest$IntObjectWrapper(index)",
- new IntObjectWrapper( ROOT.getIndex() ) },
- { "new org.apache.commons.ognl.test.StaticsAndConstructorsTest$A(#root)", new A( ROOT ) },
- { "@org.apache.commons.ognl.test.StaticsAndConstructorsTest$Animals@values().length != 2", Boolean.TRUE },
- { "isOk(@org.apache.commons.ognl.test.objects.SimpleEnum@ONE, null)", Boolean.TRUE }, };
-
- public static final String KEY = "size";
-
- public static class IntWrapper
- {
- public IntWrapper( int value )
- {
- this.value = value;
- }
-
- private final int value;
-
- public String toString()
- {
- return Integer.toString( value );
- }
-
- public boolean equals( Object o )
- {
- if ( this == o )
- return true;
- if ( o == null || getClass() != o.getClass() )
- return false;
-
- IntWrapper that = (IntWrapper) o;
-
- return value == that.value;
- }
- }
-
- public static class IntObjectWrapper
- {
-
- public IntObjectWrapper( Integer value )
- {
- this.value = value;
- }
-
- private final Integer value;
-
- public String toString()
- {
- return value.toString();
- }
-
- public boolean equals( Object o )
- {
- if ( this == o )
- return true;
- if ( o == null || getClass() != o.getClass() )
- return false;
-
- IntObjectWrapper that = (IntObjectWrapper) o;
-
- return value.equals( that.value );
- }
- }
-
- public static class A
- {
- String key = "A";
-
- public A( Root root )
- {
-
- }
-
- public boolean equals( Object o )
- {
- if ( this == o )
- return true;
- if ( o == null || getClass() != o.getClass() )
- return false;
-
- A a = (A) o;
-
- return !( key != null ? !key.equals( a.key ) : a.key != null );
-
- }
- }
-
- public enum Animals
- {
-
- Dog, Cat, Wallabee, Bear
- }
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- @Parameters
- public static Collection<Object[]> data()
- {
- Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
- for ( Object[] TEST : TESTS )
- {
- Object[] tmp = new Object[6];
- tmp[0] = TEST[0] + " (" + TEST[1] + ")";
- tmp[1] = ROOT;
- tmp[2] = TEST[0];
- tmp[3] = TEST[1];
-
- data.add( tmp );
- }
- return data;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public StaticsAndConstructorsTest( String name, Object root, String expressionString, Object expectedResult,
- Object setValue, Object expectedAfterSetResult )
- {
- super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
- }
-
- @Test
-
- @Override
- public void runTest()
- throws Exception
- {
- super.runTest();
- }
-}
+/*
+ * 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.test;
+
+import org.apache.commons.ognl.test.objects.Root;
+import org.apache.commons.ognl.test.objects.Simple;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
+public class StaticsAndConstructorsTest
+ extends OgnlTestCase
+{
+ private static final Root ROOT = new Root();
+
+ private static final Object[][] TESTS =
+ {
+ { "@java.lang.Class@forName(\"java.lang.Object\")", Object.class },
+ { "@java.lang.Integer@MAX_VALUE", Integer.MAX_VALUE },
+ { "@@max(3,4)", 4 },
+ { "new java.lang.StringBuilder().append(55).toString()", "55" },
+ { "class", ROOT.getClass() },
+ { "@org.apache.commons.ognl.test.objects.Root@class", ROOT.getClass() },
+ { "class.getName()", ROOT.getClass().getName() },
+ { "@org.apache.commons.ognl.test.objects.Root@class.getName()", ROOT.getClass().getName() },
+ { "@org.apache.commons.ognl.test.objects.Root@class.name", ROOT.getClass().getName() },
+ { "class.getSuperclass()", ROOT.getClass().getSuperclass() },
+ { "class.superclass", ROOT.getClass().getSuperclass() },
+ { "class.name", ROOT.getClass().getName() },
+ { "getStaticInt()", Root.getStaticInt() },
+ { "@org.apache.commons.ognl.test.objects.Root@getStaticInt()", Root.getStaticInt() },
+ { "new org.apache.commons.ognl.test.objects.Simple(property).getStringValue()",
+ new Simple().getStringValue() },
+ { "new org.apache.commons.ognl.test.objects.Simple(map['test'].property).getStringValue()",
+ new Simple().getStringValue() },
+ { "map.test.getCurrentClass(@org.apache.commons.ognl.test.StaticsAndConstructorsTest@KEY.toString())",
+ "size stop" },
+ { "new org.apache.commons.ognl.test.StaticsAndConstructorsTest$IntWrapper(index)",
+ new IntWrapper( ROOT.getIndex() ) },
+ { "new org.apache.commons.ognl.test.StaticsAndConstructorsTest$IntObjectWrapper(index)",
+ new IntObjectWrapper( ROOT.getIndex() ) },
+ { "new org.apache.commons.ognl.test.StaticsAndConstructorsTest$A(#root)", new A( ROOT ) },
+ { "@org.apache.commons.ognl.test.StaticsAndConstructorsTest$Animals@values().length != 2", Boolean.TRUE },
+ { "isOk(@org.apache.commons.ognl.test.objects.SimpleEnum@ONE, null)", Boolean.TRUE }, };
+
+ public static final String KEY = "size";
+
+ public static class IntWrapper
+ {
+ public IntWrapper( int value )
+ {
+ this.value = value;
+ }
+
+ private final int value;
+
+ public String toString()
+ {
+ return Integer.toString( value );
+ }
+
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ return true;
+ if ( o == null || getClass() != o.getClass() )
+ return false;
+
+ IntWrapper that = (IntWrapper) o;
+
+ return value == that.value;
+ }
+ }
+
+ public static class IntObjectWrapper
+ {
+
+ public IntObjectWrapper( Integer value )
+ {
+ this.value = value;
+ }
+
+ private final Integer value;
+
+ public String toString()
+ {
+ return value.toString();
+ }
+
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ return true;
+ if ( o == null || getClass() != o.getClass() )
+ return false;
+
+ IntObjectWrapper that = (IntObjectWrapper) o;
+
+ return value.equals( that.value );
+ }
+ }
+
+ public static class A
+ {
+ String key = "A";
+
+ public A( Root root )
+ {
+
+ }
+
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ return true;
+ if ( o == null || getClass() != o.getClass() )
+ return false;
+
+ A a = (A) o;
+
+ return !( key != null ? !key.equals( a.key ) : a.key != null );
+
+ }
+ }
+
+ public enum Animals
+ {
+
+ Dog, Cat, Wallabee, Bear
+ }
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ @Parameters
+ public static Collection<Object[]> data()
+ {
+ Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+ for ( Object[] TEST : TESTS )
+ {
+ Object[] tmp = new Object[6];
+ tmp[0] = TEST[0] + " (" + TEST[1] + ")";
+ tmp[1] = ROOT;
+ tmp[2] = TEST[0];
+ tmp[3] = TEST[1];
+
+ data.add( tmp );
+ }
+ return data;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public StaticsAndConstructorsTest( String name, Object root, String expressionString, Object expectedResult,
+ Object setValue, Object expectedAfterSetResult )
+ {
+ super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
+ }
+
+ @Test
+
+ @Override
+ public void runTest()
+ throws Exception
+ {
+ super.runTest();
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/accessors/ListPropertyAccessorTest.java b/src/test/java/org/apache/commons/ognl/test/accessors/ListPropertyAccessorTest.java
index 57738d7..547291c 100644
--- a/src/test/java/org/apache/commons/ognl/test/accessors/ListPropertyAccessorTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/accessors/ListPropertyAccessorTest.java
@@ -1,100 +1,99 @@
-/*
- * $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.test.accessors;
-
-import org.apache.commons.ognl.ListPropertyAccessor;
-import org.apache.commons.ognl.Ognl;
-import org.apache.commons.ognl.OgnlContext;
-import org.apache.commons.ognl.enhance.ExpressionCompiler;
-import org.apache.commons.ognl.test.objects.ListSource;
-import org.apache.commons.ognl.test.objects.ListSourceImpl;
-import org.apache.commons.ognl.test.objects.Root;
-import org.junit.Test;
-
-import java.util.List;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNull;
-
-/**
- * Tests functionality of various built in object accessors.
- */
-public class ListPropertyAccessorTest
-{
-
- @Test
- public void test_Get_Source_String_Number_Index()
- {
- ListPropertyAccessor pa = new ListPropertyAccessor();
-
- Root root = new Root();
-
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
- context.setRoot( root );
- context.setCurrentObject( root );
- context.setCurrentType( Integer.TYPE );
-
- assertEquals( ".get(0)", pa.getSourceAccessor( context, root.getList(), "0" ) );
-
- assertEquals( List.class, context.getCurrentAccessor() );
- assertEquals( Object.class, context.getCurrentType() );
- assertEquals( Integer.TYPE, context.getPreviousType() );
- assertNull(context.getPreviousAccessor());
- }
-
- @Test
- public void test_Get_Source_Object_Number_Index()
- {
- ListPropertyAccessor pa = new ListPropertyAccessor();
-
- Root root = new Root();
-
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
- context.setRoot( root );
- context.setCurrentObject( root );
- context.setCurrentType( Integer.class );
-
- assertEquals( ".get(indexValue.intValue())", pa.getSourceAccessor( context, root.getList(), "indexValue" ) );
-
- assertEquals( List.class, context.getCurrentAccessor() );
- assertEquals( Object.class, context.getCurrentType() );
- assertEquals( Integer.class, context.getPreviousType() );
- assertNull(context.getPreviousAccessor());
- }
-
- @Test
- public void test_List_To_Object_Property_Accessor_Read()
- throws Exception
- {
- ListPropertyAccessor pa = new ListPropertyAccessor();
-
- ListSource list = new ListSourceImpl();
-
- OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
- context.setRoot( list );
- context.setCurrentObject( list );
-
- assertEquals( ".getTotal()", pa.getSourceAccessor( context, list, "total" ) );
-
- assertNull( context.get( ExpressionCompiler.PRE_CAST ) );
- assertEquals( int.class, context.getCurrentType() );
- assertEquals( ListSource.class, context.getCurrentAccessor() );
- }
-}
+/*
+ * 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.test.accessors;
+
+import org.apache.commons.ognl.ListPropertyAccessor;
+import org.apache.commons.ognl.Ognl;
+import org.apache.commons.ognl.OgnlContext;
+import org.apache.commons.ognl.enhance.ExpressionCompiler;
+import org.apache.commons.ognl.test.objects.ListSource;
+import org.apache.commons.ognl.test.objects.ListSourceImpl;
+import org.apache.commons.ognl.test.objects.Root;
+import org.junit.Test;
+
+import java.util.List;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNull;
+
+/**
+ * Tests functionality of various built in object accessors.
+ */
+public class ListPropertyAccessorTest
+{
+
+ @Test
+ public void test_Get_Source_String_Number_Index()
+ {
+ ListPropertyAccessor pa = new ListPropertyAccessor();
+
+ Root root = new Root();
+
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+ context.setRoot( root );
+ context.setCurrentObject( root );
+ context.setCurrentType( Integer.TYPE );
+
+ assertEquals( ".get(0)", pa.getSourceAccessor( context, root.getList(), "0" ) );
+
+ assertEquals( List.class, context.getCurrentAccessor() );
+ assertEquals( Object.class, context.getCurrentType() );
+ assertEquals( Integer.TYPE, context.getPreviousType() );
+ assertNull(context.getPreviousAccessor());
+ }
+
+ @Test
+ public void test_Get_Source_Object_Number_Index()
+ {
+ ListPropertyAccessor pa = new ListPropertyAccessor();
+
+ Root root = new Root();
+
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+ context.setRoot( root );
+ context.setCurrentObject( root );
+ context.setCurrentType( Integer.class );
+
+ assertEquals( ".get(indexValue.intValue())", pa.getSourceAccessor( context, root.getList(), "indexValue" ) );
+
+ assertEquals( List.class, context.getCurrentAccessor() );
+ assertEquals( Object.class, context.getCurrentType() );
+ assertEquals( Integer.class, context.getPreviousType() );
+ assertNull(context.getPreviousAccessor());
+ }
+
+ @Test
+ public void test_List_To_Object_Property_Accessor_Read()
+ throws Exception
+ {
+ ListPropertyAccessor pa = new ListPropertyAccessor();
+
+ ListSource list = new ListSourceImpl();
+
+ OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
+ context.setRoot( list );
+ context.setCurrentObject( list );
+
+ assertEquals( ".getTotal()", pa.getSourceAccessor( context, list, "total" ) );
+
+ assertNull( context.get( ExpressionCompiler.PRE_CAST ) );
+ assertEquals( int.class, context.getCurrentType() );
+ assertEquals( ListSource.class, context.getCurrentAccessor() );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/enhance/TestExpressionCompiler.java b/src/test/java/org/apache/commons/ognl/test/enhance/TestExpressionCompiler.java
index a28152c..cfd60cf 100644
--- a/src/test/java/org/apache/commons/ognl/test/enhance/TestExpressionCompiler.java
+++ b/src/test/java/org/apache/commons/ognl/test/enhance/TestExpressionCompiler.java
@@ -1,253 +1,252 @@
-/*
- * $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.test.enhance;
-
-import org.apache.commons.ognl.Node;
-import org.apache.commons.ognl.Ognl;
-import org.apache.commons.ognl.OgnlContext;
-import org.apache.commons.ognl.enhance.ExpressionCompiler;
-import org.apache.commons.ognl.enhance.OgnlExpressionCompiler;
-import org.apache.commons.ognl.test.objects.Bean1;
-import org.apache.commons.ognl.test.objects.GenericRoot;
-import org.apache.commons.ognl.test.objects.IndexedMapObject;
-import org.apache.commons.ognl.test.objects.Inherited;
-import org.apache.commons.ognl.test.objects.Root;
-import org.apache.commons.ognl.test.objects.TestInherited1;
-import org.apache.commons.ognl.test.objects.TestInherited2;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import static junit.framework.Assert.*;
-
-/**
- * Tests functionality of {@link ExpressionCompiler}.
- */
-public class TestExpressionCompiler
-{
- OgnlExpressionCompiler _compiler;
-
- OgnlContext _context = (OgnlContext) Ognl.createDefaultContext( null );
-
- @Before
- public void setUp()
- {
- _compiler = new ExpressionCompiler();
- }
-
- @Test
- public void test_Get_Property_Access()
- throws Throwable
- {
- Node expr = (Node) Ognl.parseExpression( "bean2" );
- Bean1 root = new Bean1();
-
- _compiler.compileExpression( _context, expr, root );
-
- assertNotNull( expr.getAccessor().get( _context, root ) );
- }
-
- @Test
- public void test_Get_Indexed_Property()
- throws Throwable
- {
- Node expr = (Node) Ognl.parseExpression( "bean2.bean3.indexedValue[25]" );
- Bean1 root = new Bean1();
-
- assertNull( Ognl.getValue( expr, _context, root ) );
-
- _compiler.compileExpression( _context, expr, root );
-
- assertNull( expr.getAccessor().get( _context, root ) );
- }
-
- @Test
- public void test_Set_Indexed_Property()
- throws Throwable
- {
- Node expr = (Node) Ognl.parseExpression( "bean2.bean3.indexedValue[25]" );
- Bean1 root = new Bean1();
-
- assertNull( Ognl.getValue( expr, _context, root ) );
-
- _compiler.compileExpression( _context, expr, root );
-
- expr.getAccessor().set( _context, root, "test string" );
-
- assertEquals( "test string", expr.getAccessor().get( _context, root ) );
- }
-
- @Test
- public void test_Expression()
- throws Throwable
- {
- Node expr = (Node) Ognl.parseExpression( "bean2.bean3.value <= 24" );
- Bean1 root = new Bean1();
-
- assertEquals( Boolean.FALSE, Ognl.getValue( expr, _context, root ) );
-
- _compiler.compileExpression( _context, expr, root );
-
- assertEquals( Boolean.FALSE, expr.getAccessor().get( _context, root ) );
- }
-
- @Test
- public void test_Get_Context_Property()
- throws Throwable
- {
- _context.put( "key", "foo" );
- Node expr = (Node) Ognl.parseExpression( "bean2.bean3.map[#key]" );
- Bean1 root = new Bean1();
-
- assertEquals( "bar", Ognl.getValue( expr, _context, root ) );
-
- _compiler.compileExpression( _context, expr, root );
-
- assertEquals( "bar", expr.getAccessor().get( _context, root ) );
-
- _context.put( "key", "bar" );
-
- assertEquals( "baz", Ognl.getValue( expr, _context, root ) );
- assertEquals( "baz", expr.getAccessor().get( _context, root ) );
- }
-
- @Test
- public void test_Set_Context_Property()
- throws Throwable
- {
- _context.put( "key", "foo" );
- Node expr = (Node) Ognl.parseExpression( "bean2.bean3.map[#key]" );
- Bean1 root = new Bean1();
-
- _compiler.compileExpression( _context, expr, root );
-
- assertEquals( "bar", expr.getAccessor().get( _context, root ) );
-
- _context.put( "key", "bar" );
- assertEquals( "baz", expr.getAccessor().get( _context, root ) );
-
- expr.getAccessor().set( _context, root, "bam" );
- assertEquals( "bam", expr.getAccessor().get( _context, root ) );
- }
-
- @Test
- public void test_Property_Index()
- throws Throwable
- {
- Root root = new Root();
- Node expr = Ognl.compileExpression( _context, root, "{index + 1}" );
-
- Object ret = expr.getAccessor().get( _context, root );
-
- assertTrue( Collection.class.isInstance( ret ) );
- }
-
- @Test
- public void test_Root_Expression_Inheritance()
- throws Throwable
- {
- Inherited obj1 = new TestInherited1();
- Inherited obj2 = new TestInherited2();
-
- Node expr = Ognl.compileExpression( _context, obj1, "myString" );
-
- assertEquals( expr.getAccessor().get( _context, obj1 ), "inherited1" );
- assertEquals( expr.getAccessor().get( _context, obj2 ), "inherited2" );
- }
-
- @Test
- public void test_Create_Empty_Collection()
- throws Throwable
- {
- Node expr = Ognl.compileExpression( _context, null, "{}" );
-
- Object ret = expr.getAccessor().get( _context, null );
-
- assertNotNull( ret );
- assertTrue( Collection.class.isAssignableFrom( ret.getClass() ) );
- }
-
- public String getKey()
- {
- return "key";
- }
-
- @Test
- public void test_Indexed_Property()
- throws Throwable
- {
- Map<String,String> map = new HashMap<String,String>();
- map.put( "key", "value" );
-
- Node expression = Ognl.compileExpression( _context, this, "key" );
- assertEquals( "key", expression.getAccessor().get( _context, this ) );
- }
-
- IndexedMapObject mapObject = new IndexedMapObject( "propertyValue" );
-
- public IndexedMapObject getObject()
- {
- return mapObject;
- }
-
- public String getPropertyKey()
- {
- return "property";
- }
-
- @Test
- public void test_Indexed_Map_Property()
- throws Throwable
- {
- assertEquals( "propertyValue", Ognl.getValue( "object[propertyKey]", this ) );
-
- _context.clear();
- Node expression = Ognl.compileExpression( _context, this, "object[#this.propertyKey]" );
- assertEquals( "propertyValue", expression.getAccessor().get( _context, this ) );
-
- _context.clear();
- expression = Ognl.compileExpression( _context, this, "object[propertyKey]" );
- assertEquals( "propertyValue", expression.getAccessor().get( _context, this ) );
- }
-
- @Test
- public void test_Set_Generic_Property()
- throws Exception
- {
- _context.clear();
-
- GenericRoot root = new GenericRoot();
-
- Node node = Ognl.compileExpression( _context, root, "cracker.param" );
- assertNull(node.getAccessor().get(_context, root));
-
- node.getAccessor().set( _context, root, 0 );
- assertEquals( 0, node.getAccessor().get( _context, root ) );
-
- node.getAccessor().set( _context, root, 12 );
- assertEquals( 12, node.getAccessor().get( _context, root ) );
- }
-}
+/*
+ * 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.test.enhance;
+
+import org.apache.commons.ognl.Node;
+import org.apache.commons.ognl.Ognl;
+import org.apache.commons.ognl.OgnlContext;
+import org.apache.commons.ognl.enhance.ExpressionCompiler;
+import org.apache.commons.ognl.enhance.OgnlExpressionCompiler;
+import org.apache.commons.ognl.test.objects.Bean1;
+import org.apache.commons.ognl.test.objects.GenericRoot;
+import org.apache.commons.ognl.test.objects.IndexedMapObject;
+import org.apache.commons.ognl.test.objects.Inherited;
+import org.apache.commons.ognl.test.objects.Root;
+import org.apache.commons.ognl.test.objects.TestInherited1;
+import org.apache.commons.ognl.test.objects.TestInherited2;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import static junit.framework.Assert.*;
+
+/**
+ * Tests functionality of {@link ExpressionCompiler}.
+ */
+public class TestExpressionCompiler
+{
+ OgnlExpressionCompiler _compiler;
+
+ OgnlContext _context = (OgnlContext) Ognl.createDefaultContext( null );
+
+ @Before
+ public void setUp()
+ {
+ _compiler = new ExpressionCompiler();
+ }
+
+ @Test
+ public void test_Get_Property_Access()
+ throws Throwable
+ {
+ Node expr = (Node) Ognl.parseExpression( "bean2" );
+ Bean1 root = new Bean1();
+
+ _compiler.compileExpression( _context, expr, root );
+
+ assertNotNull( expr.getAccessor().get( _context, root ) );
+ }
+
+ @Test
+ public void test_Get_Indexed_Property()
+ throws Throwable
+ {
+ Node expr = (Node) Ognl.parseExpression( "bean2.bean3.indexedValue[25]" );
+ Bean1 root = new Bean1();
+
+ assertNull( Ognl.getValue( expr, _context, root ) );
+
+ _compiler.compileExpression( _context, expr, root );
+
+ assertNull( expr.getAccessor().get( _context, root ) );
+ }
+
+ @Test
+ public void test_Set_Indexed_Property()
+ throws Throwable
+ {
+ Node expr = (Node) Ognl.parseExpression( "bean2.bean3.indexedValue[25]" );
+ Bean1 root = new Bean1();
+
+ assertNull( Ognl.getValue( expr, _context, root ) );
+
+ _compiler.compileExpression( _context, expr, root );
+
+ expr.getAccessor().set( _context, root, "test string" );
+
+ assertEquals( "test string", expr.getAccessor().get( _context, root ) );
+ }
+
+ @Test
+ public void test_Expression()
+ throws Throwable
+ {
+ Node expr = (Node) Ognl.parseExpression( "bean2.bean3.value <= 24" );
+ Bean1 root = new Bean1();
+
+ assertEquals( Boolean.FALSE, Ognl.getValue( expr, _context, root ) );
+
+ _compiler.compileExpression( _context, expr, root );
+
+ assertEquals( Boolean.FALSE, expr.getAccessor().get( _context, root ) );
+ }
+
+ @Test
+ public void test_Get_Context_Property()
+ throws Throwable
+ {
+ _context.put( "key", "foo" );
+ Node expr = (Node) Ognl.parseExpression( "bean2.bean3.map[#key]" );
+ Bean1 root = new Bean1();
+
+ assertEquals( "bar", Ognl.getValue( expr, _context, root ) );
+
+ _compiler.compileExpression( _context, expr, root );
+
+ assertEquals( "bar", expr.getAccessor().get( _context, root ) );
+
+ _context.put( "key", "bar" );
+
+ assertEquals( "baz", Ognl.getValue( expr, _context, root ) );
+ assertEquals( "baz", expr.getAccessor().get( _context, root ) );
+ }
+
+ @Test
+ public void test_Set_Context_Property()
+ throws Throwable
+ {
+ _context.put( "key", "foo" );
+ Node expr = (Node) Ognl.parseExpression( "bean2.bean3.map[#key]" );
+ Bean1 root = new Bean1();
+
+ _compiler.compileExpression( _context, expr, root );
+
+ assertEquals( "bar", expr.getAccessor().get( _context, root ) );
+
+ _context.put( "key", "bar" );
+ assertEquals( "baz", expr.getAccessor().get( _context, root ) );
+
+ expr.getAccessor().set( _context, root, "bam" );
+ assertEquals( "bam", expr.getAccessor().get( _context, root ) );
+ }
+
+ @Test
+ public void test_Property_Index()
+ throws Throwable
+ {
+ Root root = new Root();
+ Node expr = Ognl.compileExpression( _context, root, "{index + 1}" );
+
+ Object ret = expr.getAccessor().get( _context, root );
+
+ assertTrue( Collection.class.isInstance( ret ) );
+ }
+
+ @Test
+ public void test_Root_Expression_Inheritance()
+ throws Throwable
+ {
+ Inherited obj1 = new TestInherited1();
+ Inherited obj2 = new TestInherited2();
+
+ Node expr = Ognl.compileExpression( _context, obj1, "myString" );
+
+ assertEquals( expr.getAccessor().get( _context, obj1 ), "inherited1" );
+ assertEquals( expr.getAccessor().get( _context, obj2 ), "inherited2" );
+ }
+
+ @Test
+ public void test_Create_Empty_Collection()
+ throws Throwable
+ {
+ Node expr = Ognl.compileExpression( _context, null, "{}" );
+
+ Object ret = expr.getAccessor().get( _context, null );
+
+ assertNotNull( ret );
+ assertTrue( Collection.class.isAssignableFrom( ret.getClass() ) );
+ }
+
+ public String getKey()
+ {
+ return "key";
+ }
+
+ @Test
+ public void test_Indexed_Property()
+ throws Throwable
+ {
+ Map<String,String> map = new HashMap<String,String>();
+ map.put( "key", "value" );
+
+ Node expression = Ognl.compileExpression( _context, this, "key" );
+ assertEquals( "key", expression.getAccessor().get( _context, this ) );
+ }
+
+ IndexedMapObject mapObject = new IndexedMapObject( "propertyValue" );
+
+ public IndexedMapObject getObject()
+ {
+ return mapObject;
+ }
+
+ public String getPropertyKey()
+ {
+ return "property";
+ }
+
+ @Test
+ public void test_Indexed_Map_Property()
+ throws Throwable
+ {
+ assertEquals( "propertyValue", Ognl.getValue( "object[propertyKey]", this ) );
+
+ _context.clear();
+ Node expression = Ognl.compileExpression( _context, this, "object[#this.propertyKey]" );
+ assertEquals( "propertyValue", expression.getAccessor().get( _context, this ) );
+
+ _context.clear();
+ expression = Ognl.compileExpression( _context, this, "object[propertyKey]" );
+ assertEquals( "propertyValue", expression.getAccessor().get( _context, this ) );
+ }
+
+ @Test
+ public void test_Set_Generic_Property()
+ throws Exception
+ {
+ _context.clear();
+
+ GenericRoot root = new GenericRoot();
+
+ Node node = Ognl.compileExpression( _context, root, "cracker.param" );
+ assertNull(node.getAccessor().get(_context, root));
+
+ node.getAccessor().set( _context, root, 0 );
+ assertEquals( 0, node.getAccessor().get( _context, root ) );
+
+ node.getAccessor().set( _context, root, 12 );
+ assertEquals( 12, node.getAccessor().get( _context, root ) );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/BaseBean.java b/src/test/java/org/apache/commons/ognl/test/objects/BaseBean.java
index 14d6d95..be1b0c3 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/BaseBean.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/BaseBean.java
@@ -1,57 +1,56 @@
-/*
- * $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.test.objects;
-
-/**
- * Base class used to test inheritance class casting.
- */
-public abstract class BaseBean
-{
-
- public abstract String getName();
-
- public boolean getActive()
- {
- return true;
- }
-
- public boolean isActive2()
- {
- return true;
- }
-
- public Two getTwo()
- {
- return new Two();
- }
-
- public String getMessage( String mes )
- {
- return "[" + mes + "]";
- }
-
- public boolean hasChildren( String name )
- {
- return name.length() > 2;
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ * Base class used to test inheritance class casting.
+ */
+public abstract class BaseBean
+{
+
+ public abstract String getName();
+
+ public boolean getActive()
+ {
+ return true;
+ }
+
+ public boolean isActive2()
+ {
+ return true;
+ }
+
+ public Two getTwo()
+ {
+ return new Two();
+ }
+
+ public String getMessage( String mes )
+ {
+ return "[" + mes + "]";
+ }
+
+ public boolean hasChildren( String name )
+ {
+ return name.length() > 2;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/BaseGeneric.java b/src/test/java/org/apache/commons/ognl/test/objects/BaseGeneric.java
index 3c40d6a..622f7a2 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/BaseGeneric.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/BaseGeneric.java
@@ -1,70 +1,69 @@
-/*
- * $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.test.objects;
-
-import java.io.Serializable;
-
-/**
- * Used to test ognl handling of java generics.
- */
-public class BaseGeneric<E extends GenericObject, I extends Serializable>
-{
-
- E _value;
-
- GenericService _service;
-
- protected I[] ids;
-
- public BaseGeneric()
- {
- _service = new GenericServiceImpl();
- }
-
- public void setIds( I[] ids )
- {
- this.ids = ids;
- }
-
- public I[] getIds()
- {
- return this.ids;
- }
-
- public String getMessage()
- {
- return "Message";
- }
-
- public E getValue()
- {
- return _value;
- }
-
- public GenericService getService()
- {
- return _service;
- }
-
- public String format( Object value )
- {
- return value.toString();
- }
-}
+/*
+ * 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.test.objects;
+
+import java.io.Serializable;
+
+/**
+ * Used to test ognl handling of java generics.
+ */
+public class BaseGeneric<E extends GenericObject, I extends Serializable>
+{
+
+ E _value;
+
+ GenericService _service;
+
+ protected I[] ids;
+
+ public BaseGeneric()
+ {
+ _service = new GenericServiceImpl();
+ }
+
+ public void setIds( I[] ids )
+ {
+ this.ids = ids;
+ }
+
+ public I[] getIds()
+ {
+ return this.ids;
+ }
+
+ public String getMessage()
+ {
+ return "Message";
+ }
+
+ public E getValue()
+ {
+ return _value;
+ }
+
+ public GenericService getService()
+ {
+ return _service;
+ }
+
+ public String format( Object value )
+ {
+ return value.toString();
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/BaseIndexed.java b/src/test/java/org/apache/commons/ognl/test/objects/BaseIndexed.java
index 5c236e3..169415c 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/BaseIndexed.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/BaseIndexed.java
@@ -1,32 +1,31 @@
-/*
- * $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.test.objects;
-
-/**
- * Class used to test inheritance.
- */
-public class BaseIndexed
-{
-
- public Object getLine( int index )
- {
- return "line:" + index;
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ * Class used to test inheritance.
+ */
+public class BaseIndexed
+{
+
+ public Object getLine( int index )
+ {
+ return "line:" + index;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/BaseObjectIndexed.java b/src/test/java/org/apache/commons/ognl/test/objects/BaseObjectIndexed.java
index 4ec1fa0..a05b3d5 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/BaseObjectIndexed.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/BaseObjectIndexed.java
@@ -1,64 +1,63 @@
-/*
- * $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.test.objects;
-
-import java.util.*;
-
-public class BaseObjectIndexed
- extends Object
-{
- private final Map attributes = new HashMap();
-
- public BaseObjectIndexed()
- {
- }
-
- public Map getAttributes()
- {
- return attributes;
- }
-
- public Object getAttribute( String name )
- {
- return attributes.get( name );
- }
-
- public void setAttribute( String name, Object value )
- {
- attributes.put( name, value );
- }
-
- /* allow testing property name where types do not match */
- public Object getOtherAttribute( String name )
- {
- return null;
- }
-
- public void setOtherAttribute( Object someObject, Object foo )
- {
- /* do nothing */
- }
-
- /* test whether get only is found */
- public Object getSecondaryAttribute( Object name )
- {
- return attributes.get( name );
- }
-}
+/*
+ * 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.test.objects;
+
+import java.util.*;
+
+public class BaseObjectIndexed
+ extends Object
+{
+ private final Map attributes = new HashMap();
+
+ public BaseObjectIndexed()
+ {
+ }
+
+ public Map getAttributes()
+ {
+ return attributes;
+ }
+
+ public Object getAttribute( String name )
+ {
+ return attributes.get( name );
+ }
+
+ public void setAttribute( String name, Object value )
+ {
+ attributes.put( name, value );
+ }
+
+ /* allow testing property name where types do not match */
+ public Object getOtherAttribute( String name )
+ {
+ return null;
+ }
+
+ public void setOtherAttribute( Object someObject, Object foo )
+ {
+ /* do nothing */
+ }
+
+ /* test whether get only is found */
+ public Object getSecondaryAttribute( Object name )
+ {
+ return attributes.get( name );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/BaseSyntheticObject.java b/src/test/java/org/apache/commons/ognl/test/objects/BaseSyntheticObject.java
index 529cf7a..85888f8 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/BaseSyntheticObject.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/BaseSyntheticObject.java
@@ -1,35 +1,34 @@
-/*
- * $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.test.objects;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Used to test OGNL-136 use of synthetic methods.
- */
-public abstract class BaseSyntheticObject
-{
-
- protected List getList()
- {
- return new ArrayList();
- }
-}
+/*
+ * 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.test.objects;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Used to test OGNL-136 use of synthetic methods.
+ */
+public abstract class BaseSyntheticObject
+{
+
+ protected List getList()
+ {
+ return new ArrayList();
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/Bean1.java b/src/test/java/org/apache/commons/ognl/test/objects/Bean1.java
index 4553cb3..5fa20fc 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/Bean1.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/Bean1.java
@@ -1,30 +1,29 @@
-/*
- * $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.test.objects;
-
-public class Bean1
-{
- private final Bean2 bean2 = new Bean2();
-
- public Bean2 getBean2()
- {
- return bean2;
- }
-}
+/*
+ * 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.test.objects;
+
+public class Bean1
+{
+ private final Bean2 bean2 = new Bean2();
+
+ public Bean2 getBean2()
+ {
+ return bean2;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/Bean2.java b/src/test/java/org/apache/commons/ognl/test/objects/Bean2.java
index ac5739b..7a372be 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/Bean2.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/Bean2.java
@@ -1,80 +1,79 @@
-/*
- * $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.test.objects;
-
-public class Bean2
-{
- private final Bean3 bean3 = new Bean3();
-
- private boolean _pageBreakAfter = false;
-
- public Long getId()
- {
- return 1l;
- }
-
- public Bean3 getBean3()
- {
- return bean3;
- }
-
- public long getMillis()
- {
- return 1000 * 60 * 2;
- }
-
- public boolean isCarrier()
- {
- return false;
- }
-
- public boolean isPageBreakAfter()
- {
- return _pageBreakAfter;
- }
-
- public void setPageBreakAfter( boolean value )
- {
- _pageBreakAfter = value;
- }
-
- public void togglePageBreakAfter()
- {
- _pageBreakAfter ^= true;
- }
-
- public boolean equals( Object o )
- {
- if ( this == o )
- return true;
- if ( o == null || getClass() != o.getClass() )
- return false;
-
- Bean2 bean2 = (Bean2) o;
-
- return _pageBreakAfter == bean2._pageBreakAfter;
-
- }
-
- public int hashCode()
- {
- return ( _pageBreakAfter ? 1 : 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.test.objects;
+
+public class Bean2
+{
+ private final Bean3 bean3 = new Bean3();
+
+ private boolean _pageBreakAfter = false;
+
+ public Long getId()
+ {
+ return 1l;
+ }
+
+ public Bean3 getBean3()
+ {
+ return bean3;
+ }
+
+ public long getMillis()
+ {
+ return 1000 * 60 * 2;
+ }
+
+ public boolean isCarrier()
+ {
+ return false;
+ }
+
+ public boolean isPageBreakAfter()
+ {
+ return _pageBreakAfter;
+ }
+
+ public void setPageBreakAfter( boolean value )
+ {
+ _pageBreakAfter = value;
+ }
+
+ public void togglePageBreakAfter()
+ {
+ _pageBreakAfter ^= true;
+ }
+
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ return true;
+ if ( o == null || getClass() != o.getClass() )
+ return false;
+
+ Bean2 bean2 = (Bean2) o;
+
+ return _pageBreakAfter == bean2._pageBreakAfter;
+
+ }
+
+ public int hashCode()
+ {
+ return ( _pageBreakAfter ? 1 : 0 );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/Bean3.java b/src/test/java/org/apache/commons/ognl/test/objects/Bean3.java
index 989de1c..563f302 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/Bean3.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/Bean3.java
@@ -1,5 +1,4 @@
/*
- * $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
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/BeanProvider.java b/src/test/java/org/apache/commons/ognl/test/objects/BeanProvider.java
index 0b982dc..4942392 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/BeanProvider.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/BeanProvider.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.test.objects;
-
-/**
- * Test interface to be used with a custom propery accessor.
- */
-public interface BeanProvider
-{
-
- /**
- * Gets a bean by name.
- *
- * @param name
- * @return the related bean by name
- */
- Object getBean( String name );
-
- /**
- * Sets a new bean mapping.
- *
- * @param name
- * @param bean
- */
- void setBean( String name, Object bean );
-}
+/*
+ * 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.test.objects;
+
+/**
+ * Test interface to be used with a custom propery accessor.
+ */
+public interface BeanProvider
+{
+
+ /**
+ * Gets a bean by name.
+ *
+ * @param name
+ * @return the related bean by name
+ */
+ Object getBean( String name );
+
+ /**
+ * Sets a new bean mapping.
+ *
+ * @param name
+ * @param bean
+ */
+ void setBean( String name, Object bean );
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/BeanProviderAccessor.java b/src/test/java/org/apache/commons/ognl/test/objects/BeanProviderAccessor.java
index b07ee9b..6f3803f 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/BeanProviderAccessor.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/BeanProviderAccessor.java
@@ -1,93 +1,92 @@
-/*
- * $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.test.objects;
-
-import org.apache.commons.ognl.ObjectPropertyAccessor;
-import org.apache.commons.ognl.OgnlContext;
-import org.apache.commons.ognl.OgnlException;
-import org.apache.commons.ognl.OgnlRuntime;
-import org.apache.commons.ognl.PropertyAccessor;
-import org.apache.commons.ognl.enhance.ExpressionCompiler;
-import org.apache.commons.ognl.enhance.UnsupportedCompilationException;
-
-import java.util.Map;
-
-/**
- * Implementation of provider that works with {@link BeanProvider} instances.
- */
-public class BeanProviderAccessor
- extends ObjectPropertyAccessor
- implements PropertyAccessor
-{
- @Override
- public Object getProperty( Map<String, Object> context, Object target, Object name )
- throws OgnlException
- {
- BeanProvider provider = (BeanProvider) target;
- String beanName = (String) name;
-
- return provider.getBean( beanName );
- }
-
- /**
- * Returns true if the name matches a bean provided by the provider. Otherwise invokes the super implementation.
- **/
-
- @Override
- public boolean hasGetProperty( Map<String, Object> context, Object target, Object oname )
- throws OgnlException
- {
- BeanProvider provider = (BeanProvider) target;
- String beanName = ( (String) oname ).replace( "\"", "" );
-
- return provider.getBean( beanName ) != null;
- }
-
- @Override
- public String getSourceAccessor( OgnlContext context, Object target, Object name )
- {
- BeanProvider provider = (BeanProvider) target;
- String beanName = ( (String) name ).replace( "\"", "" );
-
- if ( provider.getBean( beanName ) != null )
- {
- context.setCurrentAccessor( BeanProvider.class );
- context.setCurrentType( provider.getBean( beanName ).getClass() );
-
- ExpressionCompiler.addCastString( context,
- "(("
- + OgnlRuntime.getCompiler( context ).getInterfaceClass( provider.getBean( beanName ).getClass() ).getName()
- + ")" );
-
- return ".getBean(\"" + beanName + "\"))";
- }
-
- return super.getSourceAccessor( context, target, name );
- }
-
- @Override
- public String getSourceSetter( OgnlContext context, Object target, Object name )
- {
- throw new UnsupportedCompilationException( "Can't set beans on BeanProvider." );
- }
-}
+/*
+ * 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.test.objects;
+
+import org.apache.commons.ognl.ObjectPropertyAccessor;
+import org.apache.commons.ognl.OgnlContext;
+import org.apache.commons.ognl.OgnlException;
+import org.apache.commons.ognl.OgnlRuntime;
+import org.apache.commons.ognl.PropertyAccessor;
+import org.apache.commons.ognl.enhance.ExpressionCompiler;
+import org.apache.commons.ognl.enhance.UnsupportedCompilationException;
+
+import java.util.Map;
+
+/**
+ * Implementation of provider that works with {@link BeanProvider} instances.
+ */
+public class BeanProviderAccessor
+ extends ObjectPropertyAccessor
+ implements PropertyAccessor
+{
+ @Override
+ public Object getProperty( Map<String, Object> context, Object target, Object name )
+ throws OgnlException
+ {
+ BeanProvider provider = (BeanProvider) target;
+ String beanName = (String) name;
+
+ return provider.getBean( beanName );
+ }
+
+ /**
+ * Returns true if the name matches a bean provided by the provider. Otherwise invokes the super implementation.
+ **/
+
+ @Override
+ public boolean hasGetProperty( Map<String, Object> context, Object target, Object oname )
+ throws OgnlException
+ {
+ BeanProvider provider = (BeanProvider) target;
+ String beanName = ( (String) oname ).replace( "\"", "" );
+
+ return provider.getBean( beanName ) != null;
+ }
+
+ @Override
+ public String getSourceAccessor( OgnlContext context, Object target, Object name )
+ {
+ BeanProvider provider = (BeanProvider) target;
+ String beanName = ( (String) name ).replace( "\"", "" );
+
+ if ( provider.getBean( beanName ) != null )
+ {
+ context.setCurrentAccessor( BeanProvider.class );
+ context.setCurrentType( provider.getBean( beanName ).getClass() );
+
+ ExpressionCompiler.addCastString( context,
+ "(("
+ + OgnlRuntime.getCompiler( context ).getInterfaceClass( provider.getBean( beanName ).getClass() ).getName()
+ + ")" );
+
+ return ".getBean(\"" + beanName + "\"))";
+ }
+
+ return super.getSourceAccessor( context, target, name );
+ }
+
+ @Override
+ public String getSourceSetter( OgnlContext context, Object target, Object name )
+ {
+ throw new UnsupportedCompilationException( "Can't set beans on BeanProvider." );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/BeanProviderImpl.java b/src/test/java/org/apache/commons/ognl/test/objects/BeanProviderImpl.java
index 85d31cc..aedcf97 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/BeanProviderImpl.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/BeanProviderImpl.java
@@ -1,50 +1,49 @@
-/*
- * $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.test.objects;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Implementation of {@link BeanProvider}.
- */
-public class BeanProviderImpl
- implements Serializable, BeanProvider
-{
- private final Map _map = new HashMap();
-
- public BeanProviderImpl()
- {
- }
-
- public Object getBean( String name )
- {
- return _map.get( name );
- }
-
- public void setBean( String name, Object bean )
- {
- _map.put( name, bean );
- }
-}
+/*
+ * 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.test.objects;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Implementation of {@link BeanProvider}.
+ */
+public class BeanProviderImpl
+ implements Serializable, BeanProvider
+{
+ private final Map _map = new HashMap();
+
+ public BeanProviderImpl()
+ {
+ }
+
+ public Object getBean( String name )
+ {
+ return _map.get( name );
+ }
+
+ public void setBean( String name, Object bean )
+ {
+ _map.put( name, bean );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/Component.java b/src/test/java/org/apache/commons/ognl/test/objects/Component.java
index 077c6da..66e3f50 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/Component.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/Component.java
@@ -1,77 +1,76 @@
-/*
- * $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.test.objects;
-
-public class Component
- extends Object
-{
- private URLStorage toDisplay = new URLStorage();
-
- private Page page = new Page();
-
- public static class URLStorage
- extends Object
- {
- private String pictureUrl = "http://www.picturespace.com/pictures/100";
-
- public String getPictureUrl()
- {
- return pictureUrl;
- }
-
- public void setPictureUrl( String value )
- {
- pictureUrl = value;
- }
- }
-
- public static class Page
- extends Object
- {
- public Object createRelativeAsset( String value )
- {
- return "/toplevel/" + value;
- }
- }
-
- public Component()
- {
- }
-
- public Page getPage()
- {
- return page;
- }
-
- public void setPage( Page value )
- {
- page = value;
- }
-
- public URLStorage getToDisplay()
- {
- return toDisplay;
- }
-
- public void setToDisplay( URLStorage value )
- {
- toDisplay = value;
- }
-}
+/*
+ * 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.test.objects;
+
+public class Component
+ extends Object
+{
+ private URLStorage toDisplay = new URLStorage();
+
+ private Page page = new Page();
+
+ public static class URLStorage
+ extends Object
+ {
+ private String pictureUrl = "http://www.picturespace.com/pictures/100";
+
+ public String getPictureUrl()
+ {
+ return pictureUrl;
+ }
+
+ public void setPictureUrl( String value )
+ {
+ pictureUrl = value;
+ }
+ }
+
+ public static class Page
+ extends Object
+ {
+ public Object createRelativeAsset( String value )
+ {
+ return "/toplevel/" + value;
+ }
+ }
+
+ public Component()
+ {
+ }
+
+ public Page getPage()
+ {
+ return page;
+ }
+
+ public void setPage( Page value )
+ {
+ page = value;
+ }
+
+ public URLStorage getToDisplay()
+ {
+ return toDisplay;
+ }
+
+ public void setToDisplay( URLStorage value )
+ {
+ toDisplay = value;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/ComponentImpl.java b/src/test/java/org/apache/commons/ognl/test/objects/ComponentImpl.java
index 571bafd..60a0bef 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/ComponentImpl.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/ComponentImpl.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.test.objects;
-
-/**
- *
- */
-public class ComponentImpl
- implements IComponent
-{
-
- String _clientId;
-
- int _count = 0;
-
- public String getClientId()
- {
- return _clientId;
- }
-
- public void setClientId( String id )
- {
- _clientId = id;
- }
-
- public int getCount( String index )
- {
- return _count;
- }
-
- public void setCount( String index, int count )
- {
- _count = count;
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public class ComponentImpl
+ implements IComponent
+{
+
+ String _clientId;
+
+ int _count = 0;
+
+ public String getClientId()
+ {
+ return _clientId;
+ }
+
+ public void setClientId( String id )
+ {
+ _clientId = id;
+ }
+
+ public int getCount( String index )
+ {
+ return _count;
+ }
+
+ public void setCount( String index, int count )
+ {
+ _count = count;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/ComponentSubclass.java b/src/test/java/org/apache/commons/ognl/test/objects/ComponentSubclass.java
index 970ade4..76fb2de 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/ComponentSubclass.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/ComponentSubclass.java
@@ -1,40 +1,39 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public class ComponentSubclass
- extends ComponentImpl
-{
-
- int _count = 0;
-
- public int getCount()
- {
- return _count;
- }
-
- public void setCount( int count )
- {
- _count = count;
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public class ComponentSubclass
+ extends ComponentImpl
+{
+
+ int _count = 0;
+
+ public int getCount()
+ {
+ return _count;
+ }
+
+ public void setCount( int count )
+ {
+ _count = count;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/Copy.java b/src/test/java/org/apache/commons/ognl/test/objects/Copy.java
index 03ca66d..506724f 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/Copy.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/Copy.java
@@ -1,32 +1,31 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public class Copy
-{
-
- public int size()
- {
- return 1;
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public class Copy
+{
+
+ public int size()
+ {
+ return 1;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/CorrectedObject.java b/src/test/java/org/apache/commons/ognl/test/objects/CorrectedObject.java
index 07ef507..87db080 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/CorrectedObject.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/CorrectedObject.java
@@ -1,45 +1,44 @@
-/*
- * $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.test.objects;
-
-public class CorrectedObject
-{
- public CorrectedObject()
- {
- }
-
- public void setStringValue( String value )
- {
- }
-
- public String getStringValue()
- {
- return null;
- }
-
- public String getIndexedStringValue( String key )
- {
- return null;
- }
-
- public void setIndexedStringValue( String key, String value )
- {
- }
-}
+/*
+ * 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.test.objects;
+
+public class CorrectedObject
+{
+ public CorrectedObject()
+ {
+ }
+
+ public void setStringValue( String value )
+ {
+ }
+
+ public String getStringValue()
+ {
+ return null;
+ }
+
+ public String getIndexedStringValue( String key )
+ {
+ return null;
+ }
+
+ public void setIndexedStringValue( String key, String value )
+ {
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/Cracker.java b/src/test/java/org/apache/commons/ognl/test/objects/Cracker.java
index 9d14b12..08f717b 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/Cracker.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/Cracker.java
@@ -1,33 +1,32 @@
-/*
- * $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.test.objects;
-
-import java.io.Serializable;
-
-/**
- * Generic test object.
- */
-public interface Cracker<T extends Serializable>
-{
-
- T getParam();
-
- void setParam( T param );
-}
+/*
+ * 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.test.objects;
+
+import java.io.Serializable;
+
+/**
+ * Generic test object.
+ */
+public interface Cracker<T extends Serializable>
+{
+
+ T getParam();
+
+ void setParam( T param );
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/Entry.java b/src/test/java/org/apache/commons/ognl/test/objects/Entry.java
index 608d23a..428d9e6 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/Entry.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/Entry.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.test.objects;
-
-/**
- *
- */
-public class Entry
-{
-
- private final int _size = 1;
-
- public int size()
- {
- return _size;
- }
-
- public Copy getCopy()
- {
- return new Copy();
- }
-
- public boolean equals( Object o )
- {
- if ( this == o )
- return true;
- if ( o == null || getClass() != o.getClass() )
- return false;
-
- Entry entry = (Entry) o;
- return _size == entry._size;
- }
-
- public int hashCode()
- {
- return _size;
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public class Entry
+{
+
+ private final int _size = 1;
+
+ public int size()
+ {
+ return _size;
+ }
+
+ public Copy getCopy()
+ {
+ return new Copy();
+ }
+
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ return true;
+ if ( o == null || getClass() != o.getClass() )
+ return false;
+
+ Entry entry = (Entry) o;
+ return _size == entry._size;
+ }
+
+ public int hashCode()
+ {
+ return _size;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/EvenOdd.java b/src/test/java/org/apache/commons/ognl/test/objects/EvenOdd.java
index 2ff9068..6cc54af 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/EvenOdd.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/EvenOdd.java
@@ -1,56 +1,55 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public class EvenOdd
-{
-
- private boolean even = true;
-
- /**
- * Returns "even" or "odd". Whatever it returns on one invocation, it will return the opposite on the next. By
- * default, the first value returned is "even".
- */
- public String getNext()
- {
- String result = even ? "even" : "odd";
-
- even = !even;
-
- return result;
- }
-
- public boolean isEven()
- {
- return even;
- }
-
- /**
- * Overrides the even flag.
- */
-
- public void setEven( boolean value )
- {
- even = value;
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public class EvenOdd
+{
+
+ private boolean even = true;
+
+ /**
+ * Returns "even" or "odd". Whatever it returns on one invocation, it will return the opposite on the next. By
+ * default, the first value returned is "even".
+ */
+ public String getNext()
+ {
+ String result = even ? "even" : "odd";
+
+ even = !even;
+
+ return result;
+ }
+
+ public boolean isEven()
+ {
+ return even;
+ }
+
+ /**
+ * Overrides the even flag.
+ */
+
+ public void setEven( boolean value )
+ {
+ even = value;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/FirstBean.java b/src/test/java/org/apache/commons/ognl/test/objects/FirstBean.java
index 4c1918e..5be46d3 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/FirstBean.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/FirstBean.java
@@ -1,36 +1,35 @@
-/*
- * $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.test.objects;
-
-/**
- */
-public class FirstBean
- extends BaseBean
-{
-
- public String getName()
- {
- return "FirstBean";
- }
-
-}
+/*
+ * 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.test.objects;
+
+/**
+ */
+public class FirstBean
+ extends BaseBean
+{
+
+ public String getName()
+ {
+ return "FirstBean";
+ }
+
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/FormComponentImpl.java b/src/test/java/org/apache/commons/ognl/test/objects/FormComponentImpl.java
index 507ee02..013be17 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/FormComponentImpl.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/FormComponentImpl.java
@@ -1,41 +1,40 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public class FormComponentImpl
- extends ComponentImpl
- implements IFormComponent
-{
-
- IForm _form;
-
- public IForm getForm()
- {
- return _form;
- }
-
- public void setForm( IForm form )
- {
- _form = form;
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public class FormComponentImpl
+ extends ComponentImpl
+ implements IFormComponent
+{
+
+ IForm _form;
+
+ public IForm getForm()
+ {
+ return _form;
+ }
+
+ public void setForm( IForm form )
+ {
+ _form = form;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/FormImpl.java b/src/test/java/org/apache/commons/ognl/test/objects/FormImpl.java
index 8620a1e..5407cad 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/FormImpl.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/FormImpl.java
@@ -1,30 +1,29 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public class FormImpl
- extends ComponentImpl
- implements IForm
-{
-
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public class FormImpl
+ extends ComponentImpl
+ implements IForm
+{
+
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/GameGeneric.java b/src/test/java/org/apache/commons/ognl/test/objects/GameGeneric.java
index 22cfa6b..dc9ffa9 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/GameGeneric.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/GameGeneric.java
@@ -1,33 +1,32 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public class GameGeneric
- extends BaseGeneric<GameGenericObject, Long>
-{
-
- public GameGeneric()
- {
- _value = new GameGenericObject();
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public class GameGeneric
+ extends BaseGeneric<GameGenericObject, Long>
+{
+
+ public GameGeneric()
+ {
+ _value = new GameGenericObject();
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/GameGenericObject.java b/src/test/java/org/apache/commons/ognl/test/objects/GameGenericObject.java
index ef25d4e..b7778b2 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/GameGenericObject.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/GameGenericObject.java
@@ -1,47 +1,46 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public class GameGenericObject
- implements GenericObject
-{
-
- public GameGenericObject()
- {
- }
-
- public int getId()
- {
- return 20;
- }
-
- public String getDisplayName()
- {
- return "Halo 3";
- }
-
- public String getHappy()
- {
- return "happy";
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public class GameGenericObject
+ implements GenericObject
+{
+
+ public GameGenericObject()
+ {
+ }
+
+ public int getId()
+ {
+ return 20;
+ }
+
+ public String getDisplayName()
+ {
+ return "Halo 3";
+ }
+
+ public String getHappy()
+ {
+ return "happy";
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/GenericCracker.java b/src/test/java/org/apache/commons/ognl/test/objects/GenericCracker.java
index 173b2a1..467bc4f 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/GenericCracker.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/GenericCracker.java
@@ -1,40 +1,39 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public class GenericCracker
- implements Cracker<Integer>
-{
-
- Integer _param;
-
- public Integer getParam()
- {
- return _param;
- }
-
- public void setParam( Integer param )
- {
- _param = param;
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public class GenericCracker
+ implements Cracker<Integer>
+{
+
+ Integer _param;
+
+ public Integer getParam()
+ {
+ return _param;
+ }
+
+ public void setParam( Integer param )
+ {
+ _param = param;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/GenericObject.java b/src/test/java/org/apache/commons/ognl/test/objects/GenericObject.java
index 585d91d..5e5e173 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/GenericObject.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/GenericObject.java
@@ -1,31 +1,30 @@
-/*
- * $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.test.objects;
-
-/**
- * Used by {@link BaseGeneric} to reference a class type.
- */
-public interface GenericObject
-{
-
- int getId();
-
- String getDisplayName();
-}
+/*
+ * 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.test.objects;
+
+/**
+ * Used by {@link BaseGeneric} to reference a class type.
+ */
+public interface GenericObject
+{
+
+ int getId();
+
+ String getDisplayName();
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/GenericRoot.java b/src/test/java/org/apache/commons/ognl/test/objects/GenericRoot.java
index 35c6c22..67b86ba 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/GenericRoot.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/GenericRoot.java
@@ -1,51 +1,50 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public class GenericRoot
-{
-
- Root _root = new Root();
-
- GenericCracker _cracker = new GenericCracker();
-
- public Root getRoot()
- {
- return _root;
- }
-
- public void setRoot( Root root )
- {
- _root = root;
- }
-
- public GenericCracker getCracker()
- {
- return _cracker;
- }
-
- public void setCracker( GenericCracker cracker )
- {
- _cracker = cracker;
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public class GenericRoot
+{
+
+ Root _root = new Root();
+
+ GenericCracker _cracker = new GenericCracker();
+
+ public Root getRoot()
+ {
+ return _root;
+ }
+
+ public void setRoot( Root root )
+ {
+ _root = root;
+ }
+
+ public GenericCracker getCracker()
+ {
+ return _cracker;
+ }
+
+ public void setCracker( GenericCracker cracker )
+ {
+ _cracker = cracker;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/GenericService.java b/src/test/java/org/apache/commons/ognl/test/objects/GenericService.java
index a111780..4002c0f 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/GenericService.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/GenericService.java
@@ -1,31 +1,30 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public interface GenericService
-{
-
- String getFullMessageFor( PersonGenericObject person, Object... arguments );
-
- String getFullMessageFor( GameGenericObject game, Object... arguments );
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public interface GenericService
+{
+
+ String getFullMessageFor( PersonGenericObject person, Object... arguments );
+
+ String getFullMessageFor( GameGenericObject game, Object... arguments );
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/GenericServiceImpl.java b/src/test/java/org/apache/commons/ognl/test/objects/GenericServiceImpl.java
index b308db0..927e75d 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/GenericServiceImpl.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/GenericServiceImpl.java
@@ -1,40 +1,39 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public class GenericServiceImpl
- implements GenericService
-{
-
- public String getFullMessageFor( GameGenericObject game, Object... arguments )
- {
- game.getHappy();
-
- return game.getDisplayName();
- }
-
- public String getFullMessageFor( PersonGenericObject person, Object... arguments )
- {
- return person.getDisplayName();
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public class GenericServiceImpl
+ implements GenericService
+{
+
+ public String getFullMessageFor( GameGenericObject game, Object... arguments )
+ {
+ game.getHappy();
+
+ return game.getDisplayName();
+ }
+
+ public String getFullMessageFor( PersonGenericObject person, Object... arguments )
+ {
+ return person.getDisplayName();
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/GetterMethods.java b/src/test/java/org/apache/commons/ognl/test/objects/GetterMethods.java
index 0ff0329..bacea47 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/GetterMethods.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/GetterMethods.java
@@ -1,44 +1,43 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public class GetterMethods
-{
-
- private int theInt = 1;
-
- public boolean isAllowDisplay( Object something )
- {
- return true;
- }
-
- public int getAllowDisplay()
- {
- return theInt;
- }
-
- public void setAllowDisplay( int val )
- {
- theInt = val;
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public class GetterMethods
+{
+
+ private int theInt = 1;
+
+ public boolean isAllowDisplay( Object something )
+ {
+ return true;
+ }
+
+ public int getAllowDisplay()
+ {
+ return theInt;
+ }
+
+ public void setAllowDisplay( int val )
+ {
+ theInt = val;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/IComponent.java b/src/test/java/org/apache/commons/ognl/test/objects/IComponent.java
index bca84ab..50a5fc8 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/IComponent.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/IComponent.java
@@ -1,35 +1,34 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public interface IComponent
-{
-
- String getClientId();
-
- void setClientId( String id );
-
- int getCount( String index );
-
- void setCount( String index, int count );
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public interface IComponent
+{
+
+ String getClientId();
+
+ void setClientId( String id );
+
+ int getCount( String index );
+
+ void setCount( String index, int count );
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/IContentProvider.java b/src/test/java/org/apache/commons/ognl/test/objects/IContentProvider.java
index 33a8339..6051df2 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/IContentProvider.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/IContentProvider.java
@@ -1,31 +1,30 @@
-/*
- * $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.test.objects;
-
-import java.util.List;
-
-/**
- *
- */
-public interface IContentProvider
-{
-
- List getElements();
-}
+/*
+ * 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.test.objects;
+
+import java.util.List;
+
+/**
+ *
+ */
+public interface IContentProvider
+{
+
+ List getElements();
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/IForm.java b/src/test/java/org/apache/commons/ognl/test/objects/IForm.java
index fbc5868..ab69bf4 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/IForm.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/IForm.java
@@ -1,29 +1,28 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public interface IForm
- extends IComponent
-{
-
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public interface IForm
+ extends IComponent
+{
+
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/IFormComponent.java b/src/test/java/org/apache/commons/ognl/test/objects/IFormComponent.java
index 523cd26..db2bf69 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/IFormComponent.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/IFormComponent.java
@@ -1,34 +1,33 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public interface IFormComponent
- extends IComponent
-{
-
- String getClientId();
-
- IForm getForm();
-
- void setForm( IForm form );
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public interface IFormComponent
+ extends IComponent
+{
+
+ String getClientId();
+
+ IForm getForm();
+
+ void setForm( IForm form );
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/ITreeContentProvider.java b/src/test/java/org/apache/commons/ognl/test/objects/ITreeContentProvider.java
index ea9deff..216270b 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/ITreeContentProvider.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/ITreeContentProvider.java
@@ -1,34 +1,33 @@
-/*
- * $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.test.objects;
-
-import java.util.Collection;
-
-/**
- *
- */
-public interface ITreeContentProvider
- extends IContentProvider
-{
-
- Collection getChildren( Object parentElement );
-
- boolean hasChildren( Object parentElement );
-}
+/*
+ * 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.test.objects;
+
+import java.util.Collection;
+
+/**
+ *
+ */
+public interface ITreeContentProvider
+ extends IContentProvider
+{
+
+ Collection getChildren( Object parentElement );
+
+ boolean hasChildren( Object parentElement );
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/Indexed.java b/src/test/java/org/apache/commons/ognl/test/objects/Indexed.java
index e6bfb59..2d03b5d 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/Indexed.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/Indexed.java
@@ -1,105 +1,104 @@
-/*
- * $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.test.objects;
-
-import java.util.*;
-
-public class Indexed
- extends BaseIndexed
-{
- private String[] _values = new String[] { "foo", "bar", "baz" };
-
- private final List _list = new ArrayList();
-
- private final ListSource _source = new ListSourceImpl();
-
- private final Map _props = new HashMap();
-
- public Indexed()
- {
- _list.add( new Integer( 1 ) );
- _list.add( new Integer( 2 ) );
- _list.add( new Integer( 3 ) );
-
- _source.addValue( new Bean2() );
- }
-
- public Indexed( String[] values )
- {
- _values = values;
- }
-
- /* Indexed property "_values" */
- public String[] getValues()
- {
- return _values;
- }
-
- public void setValues( String[] value )
- {
- _values = value;
- }
-
- /**
- * This method returns the string from the array and appends "xxx" to distinguish the "get" method from the direct
- * array access.
- */
- public String getValues( int index )
- {
- return _values[index] + "xxx";
- }
-
- public void setValues( int index, String value )
- {
- if ( value.endsWith( "xxx" ) )
- {
- _values[index] = value.substring( 0, value.length() - 3 );
- }
- else
- {
- _values[index] = value;
- }
- }
-
- public Collection getList()
- {
- return _list;
- }
-
- public String getTitle( int count )
- {
- return "Title count " + count;
- }
-
- public ListSource getSource()
- {
- return _source;
- }
-
- public void setProperty( String property, Object value )
- {
- _props.put( property, value );
- }
-
- public Object getProperty( String property )
- {
- return _props.get( property );
- }
-}
+/*
+ * 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.test.objects;
+
+import java.util.*;
+
+public class Indexed
+ extends BaseIndexed
+{
+ private String[] _values = new String[] { "foo", "bar", "baz" };
+
+ private final List _list = new ArrayList();
+
+ private final ListSource _source = new ListSourceImpl();
+
+ private final Map _props = new HashMap();
+
+ public Indexed()
+ {
+ _list.add( new Integer( 1 ) );
+ _list.add( new Integer( 2 ) );
+ _list.add( new Integer( 3 ) );
+
+ _source.addValue( new Bean2() );
+ }
+
+ public Indexed( String[] values )
+ {
+ _values = values;
+ }
+
+ /* Indexed property "_values" */
+ public String[] getValues()
+ {
+ return _values;
+ }
+
+ public void setValues( String[] value )
+ {
+ _values = value;
+ }
+
+ /**
+ * This method returns the string from the array and appends "xxx" to distinguish the "get" method from the direct
+ * array access.
+ */
+ public String getValues( int index )
+ {
+ return _values[index] + "xxx";
+ }
+
+ public void setValues( int index, String value )
+ {
+ if ( value.endsWith( "xxx" ) )
+ {
+ _values[index] = value.substring( 0, value.length() - 3 );
+ }
+ else
+ {
+ _values[index] = value;
+ }
+ }
+
+ public Collection getList()
+ {
+ return _list;
+ }
+
+ public String getTitle( int count )
+ {
+ return "Title count " + count;
+ }
+
+ public ListSource getSource()
+ {
+ return _source;
+ }
+
+ public void setProperty( String property, Object value )
+ {
+ _props.put( property, value );
+ }
+
+ public Object getProperty( String property )
+ {
+ return _props.get( property );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/IndexedMapObject.java b/src/test/java/org/apache/commons/ognl/test/objects/IndexedMapObject.java
index e2d43d1..0bbc080 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/IndexedMapObject.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/IndexedMapObject.java
@@ -1,39 +1,38 @@
-/*
- * $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.test.objects;
-
-/**
- * Simple object used to test indexed map references using "#this" references.
- */
-public class IndexedMapObject
-{
-
- String property;
-
- public IndexedMapObject( String property )
- {
- this.property = property;
- }
-
- public String getProperty()
- {
- return property;
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ * Simple object used to test indexed map references using "#this" references.
+ */
+public class IndexedMapObject
+{
+
+ String property;
+
+ public IndexedMapObject( String property )
+ {
+ this.property = property;
+ }
+
+ public String getProperty()
+ {
+ return property;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/IndexedSetObject.java b/src/test/java/org/apache/commons/ognl/test/objects/IndexedSetObject.java
index 8f172e1..82a3919 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/IndexedSetObject.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/IndexedSetObject.java
@@ -1,66 +1,65 @@
-/*
- * $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.test.objects;
-
-import java.util.HashMap;
-
-/**
- * Test for OGNL-119.
- */
-public class IndexedSetObject
-{
-
- private final HashMap<String, Object> things = new HashMap<String, Object>();
-
- public IndexedSetObject()
- {
- things.put( "x", new Container( 1 ) );
- }
-
- public Object getThing( String index )
- {
- return things.get( index );
- }
-
- public void setThing( String index, Object value )
- {
- things.put( index, value );
- }
-
- public static class Container
- {
- private int val;
-
- public Container( int val )
- {
- this.val = val;
- }
-
- public int getVal()
- {
- return val;
- }
-
- public void setVal( int val )
- {
- this.val = val;
- }
- }
-}
+/*
+ * 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.test.objects;
+
+import java.util.HashMap;
+
+/**
+ * Test for OGNL-119.
+ */
+public class IndexedSetObject
+{
+
+ private final HashMap<String, Object> things = new HashMap<String, Object>();
+
+ public IndexedSetObject()
+ {
+ things.put( "x", new Container( 1 ) );
+ }
+
+ public Object getThing( String index )
+ {
+ return things.get( index );
+ }
+
+ public void setThing( String index, Object value )
+ {
+ things.put( index, value );
+ }
+
+ public static class Container
+ {
+ private int val;
+
+ public Container( int val )
+ {
+ this.val = val;
+ }
+
+ public int getVal()
+ {
+ return val;
+ }
+
+ public void setVal( int val )
+ {
+ this.val = val;
+ }
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/Inherited.java b/src/test/java/org/apache/commons/ognl/test/objects/Inherited.java
index 1ae78c0..ae3998c 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/Inherited.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/Inherited.java
@@ -1,29 +1,28 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public interface Inherited
-{
-
- String getMyString();
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public interface Inherited
+{
+
+ String getMyString();
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/ListSource.java b/src/test/java/org/apache/commons/ognl/test/objects/ListSource.java
index 3afea68..4e67aec 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/ListSource.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/ListSource.java
@@ -1,33 +1,32 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public interface ListSource
-{
-
- int getTotal();
-
- Object addValue( Object value );
-
- Object getName();
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public interface ListSource
+{
+
+ int getTotal();
+
+ Object addValue( Object value );
+
+ Object getName();
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/ListSourceImpl.java b/src/test/java/org/apache/commons/ognl/test/objects/ListSourceImpl.java
index 9ed6371..ac0f470 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/ListSourceImpl.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/ListSourceImpl.java
@@ -1,50 +1,49 @@
-/*
- * $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.test.objects;
-
-import java.util.ArrayList;
-
-/**
- *
- */
-public class ListSourceImpl
- extends ArrayList
- implements ListSource
-{
-
- public ListSourceImpl()
- {
- }
-
- public int getTotal()
- {
- return super.size();
- }
-
- public Object addValue( Object value )
- {
- return super.add( value );
- }
-
- public Object getName()
- {
- return 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.test.objects;
+
+import java.util.ArrayList;
+
+/**
+ *
+ */
+public class ListSourceImpl
+ extends ArrayList
+ implements ListSource
+{
+
+ public ListSourceImpl()
+ {
+ }
+
+ public int getTotal()
+ {
+ return super.size();
+ }
+
+ public Object addValue( Object value )
+ {
+ return super.add( value );
+ }
+
+ public Object getName()
+ {
+ return null;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/MenuItem.java b/src/test/java/org/apache/commons/ognl/test/objects/MenuItem.java
index cd38693..1211884 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/MenuItem.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/MenuItem.java
@@ -1,75 +1,74 @@
-/*
- * $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.test.objects;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- */
-public class MenuItem
-{
-
- private final String page;
-
- private final String label;
-
- private List<MenuItem> children = new ArrayList<MenuItem>();
-
- public MenuItem( String page, String label )
- {
- this( page, label, new ArrayList<MenuItem>() );
- }
-
- public MenuItem( String page, String label, List<MenuItem> children )
- {
- this.page = page;
- this.label = label;
- this.children = children;
- }
-
- public List<MenuItem> getChildren()
- {
- return children;
- }
-
- public String getLabel()
- {
- return label;
- }
-
- public String getPage()
- {
- return page;
- }
-
- public String toString()
- {
- return new StringBuilder( "MenuItem[" )
- .append( "page=" )
- .append( getPage() )
- .append( ",label=" )
- .append( getLabel() )
- .append( ",children=" )
- .append( getChildren().size() )
- .append( "]" ).toString();
- }
-}
+/*
+ * 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.test.objects;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ */
+public class MenuItem
+{
+
+ private final String page;
+
+ private final String label;
+
+ private List<MenuItem> children = new ArrayList<MenuItem>();
+
+ public MenuItem( String page, String label )
+ {
+ this( page, label, new ArrayList<MenuItem>() );
+ }
+
+ public MenuItem( String page, String label, List<MenuItem> children )
+ {
+ this.page = page;
+ this.label = label;
+ this.children = children;
+ }
+
+ public List<MenuItem> getChildren()
+ {
+ return children;
+ }
+
+ public String getLabel()
+ {
+ return label;
+ }
+
+ public String getPage()
+ {
+ return page;
+ }
+
+ public String toString()
+ {
+ return new StringBuilder( "MenuItem[" )
+ .append( "page=" )
+ .append( getPage() )
+ .append( ",label=" )
+ .append( getLabel() )
+ .append( ",children=" )
+ .append( getChildren().size() )
+ .append( "]" ).toString();
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/Messages.java b/src/test/java/org/apache/commons/ognl/test/objects/Messages.java
index 74f526b..4d55621 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/Messages.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/Messages.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.test.objects;
-
-import java.util.Map;
-
-/**
- *
- */
-public class Messages
-{
-
- Map _source;
-
- public Messages( Map source )
- {
- _source = source;
- }
-
- public String getMessage( String key )
- {
- return (String) _source.get( key );
- }
-
- public String format( String key, Object[] params )
- {
- return "foo";
- }
-
- public String format( String key, Object param1, Object param2, Object param3 )
- {
- return "blah";
- }
-
- public String format( String key, Object param1 )
- {
- return "first";
- }
-
- public String format( String key, Object param1, Object param2 )
- {
- return "haha";
- }
-}
+/*
+ * 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.test.objects;
+
+import java.util.Map;
+
+/**
+ *
+ */
+public class Messages
+{
+
+ Map _source;
+
+ public Messages( Map source )
+ {
+ _source = source;
+ }
+
+ public String getMessage( String key )
+ {
+ return (String) _source.get( key );
+ }
+
+ public String format( String key, Object[] params )
+ {
+ return "foo";
+ }
+
+ public String format( String key, Object param1, Object param2, Object param3 )
+ {
+ return "blah";
+ }
+
+ public String format( String key, Object param1 )
+ {
+ return "first";
+ }
+
+ public String format( String key, Object param1, Object param2 )
+ {
+ return "haha";
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/Model.java b/src/test/java/org/apache/commons/ognl/test/objects/Model.java
index ce9fec2..a2eb44f 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/Model.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/Model.java
@@ -1,32 +1,31 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public class Model
-{
-
- public int getOptionCount()
- {
- return 1;
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public class Model
+{
+
+ public int getOptionCount()
+ {
+ return 1;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/MyMap.java b/src/test/java/org/apache/commons/ognl/test/objects/MyMap.java
index 5b801f9..cc0ef43 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/MyMap.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/MyMap.java
@@ -1,32 +1,31 @@
-/*
- * $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.test.objects;
-
-import java.util.*;
-
-/**
- * This tests the interface inheritence test. This is a subinterface of Map and therefore should inherit the Map
- * property accessor.
- */
-public interface MyMap
- extends Map
-{
- String getDescription();
-}
+/*
+ * 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.test.objects;
+
+import java.util.*;
+
+/**
+ * This tests the interface inheritence test. This is a subinterface of Map and therefore should inherit the Map
+ * property accessor.
+ */
+public interface MyMap
+ extends Map
+{
+ String getDescription();
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/MyMapImpl.java b/src/test/java/org/apache/commons/ognl/test/objects/MyMapImpl.java
index 0965c10..9270eac 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/MyMapImpl.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/MyMapImpl.java
@@ -1,108 +1,107 @@
-/*
- * $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.test.objects;
-
-import java.util.*;
-
-/**
- * This tests the interface inheritence test. This test implements MyMap->Map but extends Object, therefore should be
- * coded using MapPropertyAccessor instead of ObjectPropertyAccessor.
- */
-public class MyMapImpl
- extends Object
- implements MyMap
-{
- private final Map map = new HashMap();
-
- public void clear()
- {
- map.clear();
- }
-
- public boolean containsKey( Object key )
- {
- return map.containsKey( key );
- }
-
- public boolean containsValue( Object value )
- {
- return map.containsValue( value );
- }
-
- public Set entrySet()
- {
- return map.entrySet();
- }
-
- public boolean equals( Object o )
- {
- return map.equals( o );
- }
-
- public Object get( Object key )
- {
- return map.get( key );
- }
-
- public int hashCode()
- {
- return map.hashCode();
- }
-
- public boolean isEmpty()
- {
- return map.isEmpty();
- }
-
- public Set keySet()
- {
- return map.keySet();
- }
-
- public Object put( Object key, Object value )
- {
- return map.put( key, value );
- }
-
- public void putAll( Map t )
- {
- map.putAll( t );
- }
-
- public Object remove( Object key )
- {
- return map.remove( key );
- }
-
- public int size()
- {
- return map.size();
- }
-
- public Collection values()
- {
- return map.values();
- }
-
- public String getDescription()
- {
- return "MyMap implementation";
- }
-}
+/*
+ * 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.test.objects;
+
+import java.util.*;
+
+/**
+ * This tests the interface inheritence test. This test implements MyMap->Map but extends Object, therefore should be
+ * coded using MapPropertyAccessor instead of ObjectPropertyAccessor.
+ */
+public class MyMapImpl
+ extends Object
+ implements MyMap
+{
+ private final Map map = new HashMap();
+
+ public void clear()
+ {
+ map.clear();
+ }
+
+ public boolean containsKey( Object key )
+ {
+ return map.containsKey( key );
+ }
+
+ public boolean containsValue( Object value )
+ {
+ return map.containsValue( value );
+ }
+
+ public Set entrySet()
+ {
+ return map.entrySet();
+ }
+
+ public boolean equals( Object o )
+ {
+ return map.equals( o );
+ }
+
+ public Object get( Object key )
+ {
+ return map.get( key );
+ }
+
+ public int hashCode()
+ {
+ return map.hashCode();
+ }
+
+ public boolean isEmpty()
+ {
+ return map.isEmpty();
+ }
+
+ public Set keySet()
+ {
+ return map.keySet();
+ }
+
+ public Object put( Object key, Object value )
+ {
+ return map.put( key, value );
+ }
+
+ public void putAll( Map t )
+ {
+ map.putAll( t );
+ }
+
+ public Object remove( Object key )
+ {
+ return map.remove( key );
+ }
+
+ public int size()
+ {
+ return map.size();
+ }
+
+ public Collection values()
+ {
+ return map.values();
+ }
+
+ public String getDescription()
+ {
+ return "MyMap implementation";
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/ObjectIndexed.java b/src/test/java/org/apache/commons/ognl/test/objects/ObjectIndexed.java
index f0bf123..5fef8dc 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/ObjectIndexed.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/ObjectIndexed.java
@@ -1,31 +1,30 @@
-/*
- * $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.test.objects;
-
-public class ObjectIndexed
- extends BaseObjectIndexed
-{
- public ObjectIndexed()
- {
- setAttribute( "foo", "bar" );
- setAttribute( "bar", "baz" );
- setAttribute( "other", new OtherObjectIndexed() );
- }
-}
+/*
+ * 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.test.objects;
+
+public class ObjectIndexed
+ extends BaseObjectIndexed
+{
+ public ObjectIndexed()
+ {
+ setAttribute( "foo", "bar" );
+ setAttribute( "bar", "baz" );
+ setAttribute( "other", new OtherObjectIndexed() );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/OtherObjectIndexed.java b/src/test/java/org/apache/commons/ognl/test/objects/OtherObjectIndexed.java
index cff6341..ae5fd5c 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/OtherObjectIndexed.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/OtherObjectIndexed.java
@@ -1,30 +1,29 @@
-/*
- * $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.test.objects;
-
-public class OtherObjectIndexed
- extends BaseObjectIndexed
-{
- public OtherObjectIndexed()
- {
- setAttribute( "foo", "bar" );
- setAttribute( "bar", "baz" );
- }
-}
+/*
+ * 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.test.objects;
+
+public class OtherObjectIndexed
+ extends BaseObjectIndexed
+{
+ public OtherObjectIndexed()
+ {
+ setAttribute( "foo", "bar" );
+ setAttribute( "bar", "baz" );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/PersonGenericObject.java b/src/test/java/org/apache/commons/ognl/test/objects/PersonGenericObject.java
index aa6e5b0..7122d04 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/PersonGenericObject.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/PersonGenericObject.java
@@ -1,38 +1,37 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public class PersonGenericObject
- implements GenericObject
-{
-
- public int getId()
- {
- return 1;
- }
-
- public String getDisplayName()
- {
- return "Henry Collins";
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public class PersonGenericObject
+ implements GenericObject
+{
+
+ public int getId()
+ {
+ return 1;
+ }
+
+ public String getDisplayName()
+ {
+ return "Henry Collins";
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/PropertyHolder.java b/src/test/java/org/apache/commons/ognl/test/objects/PropertyHolder.java
index df56e5c..6c9664c 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/PropertyHolder.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/PropertyHolder.java
@@ -1,60 +1,59 @@
-/*
- * $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.test.objects;
-
-/**
- * Simple class used to test various kind of property resolutions.
- */
-public class PropertyHolder
-{
-
- String _value = "";
-
- String _search = "foo";
-
- public String getValue()
- {
- return _value;
- }
-
- public void setValue( String value )
- {
- _value = value;
- }
-
- public boolean hasValue()
- {
- return _value != null && !_value.isEmpty();
- }
-
- public void setSearch( String value )
- {
- _search = value;
- }
-
- public String getSearch()
- {
- return _search;
- }
-
- public void search()
- {
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ * Simple class used to test various kind of property resolutions.
+ */
+public class PropertyHolder
+{
+
+ String _value = "";
+
+ String _search = "foo";
+
+ public String getValue()
+ {
+ return _value;
+ }
+
+ public void setValue( String value )
+ {
+ _value = value;
+ }
+
+ public boolean hasValue()
+ {
+ return _value != null && !_value.isEmpty();
+ }
+
+ public void setSearch( String value )
+ {
+ _search = value;
+ }
+
+ public String getSearch()
+ {
+ return _search;
+ }
+
+ public void search()
+ {
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/Root.java b/src/test/java/org/apache/commons/ognl/test/objects/Root.java
index 0b80266..424d478 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/Root.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/Root.java
@@ -1,591 +1,590 @@
-/*
- * $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.test.objects;
-
-import org.apache.commons.ognl.DynamicSubscript;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-public class Root
-{
- public static final String SIZE_STRING = "size";
-
- public static final int STATIC_INT = 23;
-
- private int[] array = { 1, 2, 3, 4 };
-
- private final Map map = new HashMap( 23 );
-
- private final MyMap myMap = new MyMapImpl();
-
- private final List list = Arrays.asList( null, this, array );
-
- private final List settableList = new ArrayList( Arrays.asList( "foo", "bar", "baz" ) );
-
- private final int index = 1;
-
- private int intValue = 0;
-
- private String stringValue;
-
- private final int yetAnotherIntValue = 46;
-
- private boolean privateAccessorBooleanValue = true;
-
- private int privateAccessorIntValue = 67;
-
- private int privateAccessorIntValue2 = 67;
-
- private int privateAccessorIntValue3 = 67;
-
- public String anotherStringValue = "foo";
-
- public int anotherIntValue = 123;
-
- public int six = 6;
-
- private boolean _disabled;
-
- private Locale _selected = Locale.getDefault();
-
- private final List<List<Boolean>> _booleanValues = new ArrayList<List<Boolean>>();
-
- private final boolean[] _booleanArray = { true, false, true, true };
-
- private List _list;
-
- private final int verbosity = 87;
-
- private final BeanProvider _beanProvider = new BeanProviderImpl();
-
- private boolean _render;
-
- private Boolean _readOnly = Boolean.FALSE;
-
- private final Integer _objIndex = new Integer( 1 );
-
- private final Object _genericObjIndex = new Integer( 2 );
-
- private final Date _date = new Date();
-
- private boolean _openWindow = false;
-
- private final ITreeContentProvider _contentProvider = new TreeContentProvider();
-
- private final Indexed _indexed = new Indexed();
-
- private SearchTab _tab = new SearchTab();
-
- /*
- * =================================================================== Public static methods
- * ===================================================================
- */
- public static int getStaticInt()
- {
- return STATIC_INT;
- }
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public Root()
- {
- }
-
- /*
- * =================================================================== Private methods
- * ===================================================================
- */
- {
- map.put( "test", this );
- map.put( "array", array );
- map.put( "list", list );
- map.put( "size", new Integer( 5000 ) );
- map.put( DynamicSubscript.first, new Integer( 99 ) );
- map.put( "baz", array );
- map.put( "value", new Bean2() );
- map.put( "bar", new Bean3() );
- map.put( new Long( 82 ), "StringStuff=someValue" );
-
- IFormComponent comp = new FormComponentImpl();
- comp.setClientId( "formComponent" );
-
- IForm form = new FormImpl();
- form.setClientId( "form1" );
- comp.setForm( form );
-
- map.put( "comp", comp );
-
- Map newMap = new HashMap();
- Map chain = new HashMap();
- newMap.put( "deep", chain );
-
- chain.put( "last", Boolean.TRUE );
-
- map.put( "nested", newMap );
-
- /* make myMap identical */
- myMap.putAll( map );
-
- List<Boolean> bool1 = new ArrayList<Boolean>();
- bool1.add( Boolean.TRUE );
- bool1.add( Boolean.FALSE );
- bool1.add( Boolean.TRUE );
-
- _booleanValues.add( bool1 );
-
- List<Boolean> bool2 = new ArrayList<Boolean>();
- bool2.add( Boolean.TRUE );
- bool2.add( Boolean.FALSE );
- bool2.add( Boolean.TRUE );
-
- _booleanValues.add( bool2 );
- }
-
- private boolean isPrivateAccessorBooleanValue()
- {
- return privateAccessorBooleanValue;
- }
-
- private void setPrivateAccessorBooleanValue( boolean value )
- {
- privateAccessorBooleanValue = value;
- }
-
- private int getPrivateAccessorIntValue()
- {
- return privateAccessorIntValue;
- }
-
- private void setPrivateAccessorIntValue( int value )
- {
- privateAccessorIntValue = value;
- }
-
- /*
- * =================================================================== Protected methods
- * ===================================================================
- */
- protected int getPrivateAccessorIntValue2()
- {
- return privateAccessorIntValue2;
- }
-
- protected void setPrivateAccessorIntValue2( int value )
- {
- privateAccessorIntValue2 = value;
- }
-
- /*
- * =================================================================== Package protected methods
- * ===================================================================
- */
- int getPrivateAccessorIntValue3()
- {
- return privateAccessorIntValue3;
- }
-
- void setPrivateAccessorIntValue3( int value )
- {
- privateAccessorIntValue3 = value;
- }
-
- /*
- * =================================================================== Public methods
- * ===================================================================
- */
- public int[] getArray()
- {
- return array;
- }
-
- public boolean[] getBooleanArray()
- {
- return _booleanArray;
- }
-
- public void setArray( int[] value )
- {
- array = value;
- }
-
- public String format( String key, Object value )
- {
- return format( key, new Object[] { value } );
- }
-
- public String format( String key, Object[] value )
- {
- return "formatted";
- }
-
- public String getCurrentClass( String value )
- {
- return value + " stop";
- }
-
- public Messages getMessages()
- {
- return new Messages( map );
- }
-
- public Map getMap()
- {
- return map;
- }
-
- public MyMap getMyMap()
- {
- return myMap;
- }
-
- public List getList()
- {
- return list;
- }
-
- public Object getAsset( String key )
- {
- return key;
- }
-
- public List getSettableList()
- {
- return settableList;
- }
-
- public int getIndex()
- {
- return index;
- }
-
- public Integer getObjectIndex()
- {
- return _objIndex;
- }
-
- public Integer getNullIndex()
- {
- return null;
- }
-
- public Object getGenericIndex()
- {
- return _genericObjIndex;
- }
-
- public int getIntValue()
- {
- return intValue;
- }
-
- public void setIntValue( int value )
- {
- intValue = value;
- }
-
- public int getTheInt()
- {
- return six;
- }
-
- public String getStringValue()
- {
- return stringValue;
- }
-
- public void setStringValue( String value )
- {
- stringValue = value;
- }
-
- public String getIndexedStringValue()
- {
- return "array";
- }
-
- public Object getNullObject()
- {
- return null;
- }
-
- public String getTestString()
- {
- return "wiggle";
- }
-
- public Object getProperty()
- {
- return new Bean2();
- }
-
- public Bean2 getBean2()
- {
- return new Bean2();
- }
-
- public Object getIndexedProperty( String name )
- {
- return myMap.get( name );
- }
-
- public Indexed getIndexer()
- {
- return _indexed;
- }
-
- public BeanProvider getBeans()
- {
- return _beanProvider;
- }
-
- public boolean getBooleanValue()
- {
- return _disabled;
- }
-
- public void setBooleanValue( boolean value )
- {
- _disabled = value;
- }
-
- public boolean getDisabled()
- {
- return _disabled;
- }
-
- public void setDisabled( boolean disabled )
- {
- _disabled = disabled;
- }
-
- public Locale getSelected()
- {
- return _selected;
- }
-
- public void setSelected( Locale locale )
- {
- _selected = locale;
- }
-
- public Locale getCurrLocale()
- {
- return Locale.getDefault();
- }
-
- public int getCurrentLocaleVerbosity()
- {
- return verbosity;
- }
-
- public boolean getRenderNavigation()
- {
- return _render;
- }
-
- public void setSelectedList( List selected )
- {
- _list = selected;
- }
-
- public List getSelectedList()
- {
- return _list;
- }
-
- public Boolean getReadonly()
- {
- return _readOnly;
- }
-
- public void setReadonly( Boolean value )
- {
- _readOnly = value;
- }
-
- public Object getSelf()
- {
- return this;
- }
-
- public Date getTestDate()
- {
- return _date;
- }
-
- public String getWidth()
- {
- return "238px";
- }
-
- public Long getTheLong()
- {
- return new Long( 4 );
- }
-
- public boolean isSorted()
- {
- return true;
- }
-
- public TestClass getMyTest()
- {
- return new TestImpl();
- }
-
- public ITreeContentProvider getContentProvider()
- {
- return _contentProvider;
- }
-
- public boolean isPrintDelivery()
- {
- return true;
- }
-
- public Long getCurrentDeliveryId()
- {
- return 1l;
- }
-
- public Boolean isFlyingMonkey()
- {
- return Boolean.TRUE;
- }
-
- public Boolean isDumb()
- {
- return Boolean.FALSE;
- }
-
- public Date getExpiration()
- {
- return null;
- }
-
- public Long getMapKey()
- {
- return new Long( 82 );
- }
-
- public Object getArrayValue()
- {
- return new Object[] { new Integer( "2" ), new Integer( "2" ) };
- }
-
- public List getResult()
- {
- List list = new ArrayList();
- list.add( new Object[] { new Integer( "2" ), new Integer( "2" ) } );
- list.add( new Object[] { new Integer( "2" ), new Integer( "2" ) } );
- list.add( new Object[] { new Integer( "2" ), new Integer( "2" ) } );
-
- return list;
- }
-
- public boolean isEditorDisabled()
- {
- return false;
- }
-
- public boolean isDisabled()
- {
- return true;
- }
-
- public boolean isOpenTransitionWin()
- {
- return _openWindow;
- }
-
- public void setOpenTransitionWin( boolean value )
- {
- _openWindow = value;
- }
-
- public boolean isOk( SimpleEnum value, String otherValue )
- {
- return true;
- }
-
- public List<List<Boolean>> getBooleanValues()
- {
- return _booleanValues;
- }
-
- public int getIndex1()
- {
- return 1;
- }
-
- public int getIndex2()
- {
- return 1;
- }
-
- public SearchTab getTab()
- {
- return _tab;
- }
-
- public void setTab( SearchTab tab )
- {
- _tab = tab;
- }
-
- public static class A
- {
- public int methodOfA( B b )
- {
- return 0;
- }
-
- public int getIntValue()
- {
- return 1;
- }
- }
-
- public static class B
- {
- public int methodOfB( int i )
- {
- return 0;
- }
- }
-
- public A getA()
- {
- return new A();
- }
-
- public B getB()
- {
- return new B();
- }
-}
+/*
+ * 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.test.objects;
+
+import org.apache.commons.ognl.DynamicSubscript;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+public class Root
+{
+ public static final String SIZE_STRING = "size";
+
+ public static final int STATIC_INT = 23;
+
+ private int[] array = { 1, 2, 3, 4 };
+
+ private final Map map = new HashMap( 23 );
+
+ private final MyMap myMap = new MyMapImpl();
+
+ private final List list = Arrays.asList( null, this, array );
+
+ private final List settableList = new ArrayList( Arrays.asList( "foo", "bar", "baz" ) );
+
+ private final int index = 1;
+
+ private int intValue = 0;
+
+ private String stringValue;
+
+ private final int yetAnotherIntValue = 46;
+
+ private boolean privateAccessorBooleanValue = true;
+
+ private int privateAccessorIntValue = 67;
+
+ private int privateAccessorIntValue2 = 67;
+
+ private int privateAccessorIntValue3 = 67;
+
+ public String anotherStringValue = "foo";
+
+ public int anotherIntValue = 123;
+
+ public int six = 6;
+
+ private boolean _disabled;
+
+ private Locale _selected = Locale.getDefault();
+
+ private final List<List<Boolean>> _booleanValues = new ArrayList<List<Boolean>>();
+
+ private final boolean[] _booleanArray = { true, false, true, true };
+
+ private List _list;
+
+ private final int verbosity = 87;
+
+ private final BeanProvider _beanProvider = new BeanProviderImpl();
+
+ private boolean _render;
+
+ private Boolean _readOnly = Boolean.FALSE;
+
+ private final Integer _objIndex = new Integer( 1 );
+
+ private final Object _genericObjIndex = new Integer( 2 );
+
+ private final Date _date = new Date();
+
+ private boolean _openWindow = false;
+
+ private final ITreeContentProvider _contentProvider = new TreeContentProvider();
+
+ private final Indexed _indexed = new Indexed();
+
+ private SearchTab _tab = new SearchTab();
+
+ /*
+ * =================================================================== Public static methods
+ * ===================================================================
+ */
+ public static int getStaticInt()
+ {
+ return STATIC_INT;
+ }
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public Root()
+ {
+ }
+
+ /*
+ * =================================================================== Private methods
+ * ===================================================================
+ */
+ {
+ map.put( "test", this );
+ map.put( "array", array );
+ map.put( "list", list );
+ map.put( "size", new Integer( 5000 ) );
+ map.put( DynamicSubscript.first, new Integer( 99 ) );
+ map.put( "baz", array );
+ map.put( "value", new Bean2() );
+ map.put( "bar", new Bean3() );
+ map.put( new Long( 82 ), "StringStuff=someValue" );
+
+ IFormComponent comp = new FormComponentImpl();
+ comp.setClientId( "formComponent" );
+
+ IForm form = new FormImpl();
+ form.setClientId( "form1" );
+ comp.setForm( form );
+
+ map.put( "comp", comp );
+
+ Map newMap = new HashMap();
+ Map chain = new HashMap();
+ newMap.put( "deep", chain );
+
+ chain.put( "last", Boolean.TRUE );
+
+ map.put( "nested", newMap );
+
+ /* make myMap identical */
+ myMap.putAll( map );
+
+ List<Boolean> bool1 = new ArrayList<Boolean>();
+ bool1.add( Boolean.TRUE );
+ bool1.add( Boolean.FALSE );
+ bool1.add( Boolean.TRUE );
+
+ _booleanValues.add( bool1 );
+
+ List<Boolean> bool2 = new ArrayList<Boolean>();
+ bool2.add( Boolean.TRUE );
+ bool2.add( Boolean.FALSE );
+ bool2.add( Boolean.TRUE );
+
+ _booleanValues.add( bool2 );
+ }
+
+ private boolean isPrivateAccessorBooleanValue()
+ {
+ return privateAccessorBooleanValue;
+ }
+
+ private void setPrivateAccessorBooleanValue( boolean value )
+ {
+ privateAccessorBooleanValue = value;
+ }
+
+ private int getPrivateAccessorIntValue()
+ {
+ return privateAccessorIntValue;
+ }
+
+ private void setPrivateAccessorIntValue( int value )
+ {
+ privateAccessorIntValue = value;
+ }
+
+ /*
+ * =================================================================== Protected methods
+ * ===================================================================
+ */
+ protected int getPrivateAccessorIntValue2()
+ {
+ return privateAccessorIntValue2;
+ }
+
+ protected void setPrivateAccessorIntValue2( int value )
+ {
+ privateAccessorIntValue2 = value;
+ }
+
+ /*
+ * =================================================================== Package protected methods
+ * ===================================================================
+ */
+ int getPrivateAccessorIntValue3()
+ {
+ return privateAccessorIntValue3;
+ }
+
+ void setPrivateAccessorIntValue3( int value )
+ {
+ privateAccessorIntValue3 = value;
+ }
+
+ /*
+ * =================================================================== Public methods
+ * ===================================================================
+ */
+ public int[] getArray()
+ {
+ return array;
+ }
+
+ public boolean[] getBooleanArray()
+ {
+ return _booleanArray;
+ }
+
+ public void setArray( int[] value )
+ {
+ array = value;
+ }
+
+ public String format( String key, Object value )
+ {
+ return format( key, new Object[] { value } );
+ }
+
+ public String format( String key, Object[] value )
+ {
+ return "formatted";
+ }
+
+ public String getCurrentClass( String value )
+ {
+ return value + " stop";
+ }
+
+ public Messages getMessages()
+ {
+ return new Messages( map );
+ }
+
+ public Map getMap()
+ {
+ return map;
+ }
+
+ public MyMap getMyMap()
+ {
+ return myMap;
+ }
+
+ public List getList()
+ {
+ return list;
+ }
+
+ public Object getAsset( String key )
+ {
+ return key;
+ }
+
+ public List getSettableList()
+ {
+ return settableList;
+ }
+
+ public int getIndex()
+ {
+ return index;
+ }
+
+ public Integer getObjectIndex()
+ {
+ return _objIndex;
+ }
+
+ public Integer getNullIndex()
+ {
+ return null;
+ }
+
+ public Object getGenericIndex()
+ {
+ return _genericObjIndex;
+ }
+
+ public int getIntValue()
+ {
+ return intValue;
+ }
+
+ public void setIntValue( int value )
+ {
+ intValue = value;
+ }
+
+ public int getTheInt()
+ {
+ return six;
+ }
+
+ public String getStringValue()
+ {
+ return stringValue;
+ }
+
+ public void setStringValue( String value )
+ {
+ stringValue = value;
+ }
+
+ public String getIndexedStringValue()
+ {
+ return "array";
+ }
+
+ public Object getNullObject()
+ {
+ return null;
+ }
+
+ public String getTestString()
+ {
+ return "wiggle";
+ }
+
+ public Object getProperty()
+ {
+ return new Bean2();
+ }
+
+ public Bean2 getBean2()
+ {
+ return new Bean2();
+ }
+
+ public Object getIndexedProperty( String name )
+ {
+ return myMap.get( name );
+ }
+
+ public Indexed getIndexer()
+ {
+ return _indexed;
+ }
+
+ public BeanProvider getBeans()
+ {
+ return _beanProvider;
+ }
+
+ public boolean getBooleanValue()
+ {
+ return _disabled;
+ }
+
+ public void setBooleanValue( boolean value )
+ {
+ _disabled = value;
+ }
+
+ public boolean getDisabled()
+ {
+ return _disabled;
+ }
+
+ public void setDisabled( boolean disabled )
+ {
+ _disabled = disabled;
+ }
+
+ public Locale getSelected()
+ {
+ return _selected;
+ }
+
+ public void setSelected( Locale locale )
+ {
+ _selected = locale;
+ }
+
+ public Locale getCurrLocale()
+ {
+ return Locale.getDefault();
+ }
+
+ public int getCurrentLocaleVerbosity()
+ {
+ return verbosity;
+ }
+
+ public boolean getRenderNavigation()
+ {
+ return _render;
+ }
+
+ public void setSelectedList( List selected )
+ {
+ _list = selected;
+ }
+
+ public List getSelectedList()
+ {
+ return _list;
+ }
+
+ public Boolean getReadonly()
+ {
+ return _readOnly;
+ }
+
+ public void setReadonly( Boolean value )
+ {
+ _readOnly = value;
+ }
+
+ public Object getSelf()
+ {
+ return this;
+ }
+
+ public Date getTestDate()
+ {
+ return _date;
+ }
+
+ public String getWidth()
+ {
+ return "238px";
+ }
+
+ public Long getTheLong()
+ {
+ return new Long( 4 );
+ }
+
+ public boolean isSorted()
+ {
+ return true;
+ }
+
+ public TestClass getMyTest()
+ {
+ return new TestImpl();
+ }
+
+ public ITreeContentProvider getContentProvider()
+ {
+ return _contentProvider;
+ }
+
+ public boolean isPrintDelivery()
+ {
+ return true;
+ }
+
+ public Long getCurrentDeliveryId()
+ {
+ return 1l;
+ }
+
+ public Boolean isFlyingMonkey()
+ {
+ return Boolean.TRUE;
+ }
+
+ public Boolean isDumb()
+ {
+ return Boolean.FALSE;
+ }
+
+ public Date getExpiration()
+ {
+ return null;
+ }
+
+ public Long getMapKey()
+ {
+ return new Long( 82 );
+ }
+
+ public Object getArrayValue()
+ {
+ return new Object[] { new Integer( "2" ), new Integer( "2" ) };
+ }
+
+ public List getResult()
+ {
+ List list = new ArrayList();
+ list.add( new Object[] { new Integer( "2" ), new Integer( "2" ) } );
+ list.add( new Object[] { new Integer( "2" ), new Integer( "2" ) } );
+ list.add( new Object[] { new Integer( "2" ), new Integer( "2" ) } );
+
+ return list;
+ }
+
+ public boolean isEditorDisabled()
+ {
+ return false;
+ }
+
+ public boolean isDisabled()
+ {
+ return true;
+ }
+
+ public boolean isOpenTransitionWin()
+ {
+ return _openWindow;
+ }
+
+ public void setOpenTransitionWin( boolean value )
+ {
+ _openWindow = value;
+ }
+
+ public boolean isOk( SimpleEnum value, String otherValue )
+ {
+ return true;
+ }
+
+ public List<List<Boolean>> getBooleanValues()
+ {
+ return _booleanValues;
+ }
+
+ public int getIndex1()
+ {
+ return 1;
+ }
+
+ public int getIndex2()
+ {
+ return 1;
+ }
+
+ public SearchTab getTab()
+ {
+ return _tab;
+ }
+
+ public void setTab( SearchTab tab )
+ {
+ _tab = tab;
+ }
+
+ public static class A
+ {
+ public int methodOfA( B b )
+ {
+ return 0;
+ }
+
+ public int getIntValue()
+ {
+ return 1;
+ }
+ }
+
+ public static class B
+ {
+ public int methodOfB( int i )
+ {
+ return 0;
+ }
+ }
+
+ public A getA()
+ {
+ return new A();
+ }
+
+ public B getB()
+ {
+ return new B();
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/SearchCriteria.java b/src/test/java/org/apache/commons/ognl/test/objects/SearchCriteria.java
index 0ab60d2..042679d 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/SearchCriteria.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/SearchCriteria.java
@@ -1,39 +1,38 @@
-/*
- * $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.test.objects;
-
-/**
- * Test for OGNL-131.
- */
-public class SearchCriteria
-{
-
- String _displayName;
-
- public SearchCriteria( String name )
- {
- _displayName = name;
- }
-
- public String getDisplayName()
- {
- return _displayName;
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ * Test for OGNL-131.
+ */
+public class SearchCriteria
+{
+
+ String _displayName;
+
+ public SearchCriteria( String name )
+ {
+ _displayName = name;
+ }
+
+ public String getDisplayName()
+ {
+ return _displayName;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/SearchTab.java b/src/test/java/org/apache/commons/ognl/test/objects/SearchTab.java
index 3ec971d..74319b0 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/SearchTab.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/SearchTab.java
@@ -1,85 +1,84 @@
-/*
- * $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.test.objects;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Test for OGNL-131.
- */
-public class SearchTab
-{
-
- /**
- * Flags stating which search criteria are selected
- */
- private List<List<Boolean>> searchCriteriaSelections = new ArrayList<List<Boolean>>();
- {
- searchCriteriaSelections.add( Arrays.asList( Boolean.TRUE, Boolean.FALSE, Boolean.FALSE ) );
- searchCriteriaSelections.add( Arrays.asList( Boolean.FALSE, Boolean.TRUE, Boolean.TRUE ) );
- }
-
- public List<List<Boolean>> getSearchCriteriaSelections()
- {
- return this.searchCriteriaSelections;
- }
-
- public void setSearchCriteriaSelections( List<List<Boolean>> selections )
- {
- this.searchCriteriaSelections = selections;
- }
-
- /**
- * Filters that can be applied to this tabs searches
- */
- private List<SearchCriteria> searchCriteria = new ArrayList<SearchCriteria>();
- {
- searchCriteria.add( new SearchCriteria( "Crittery critters" ) );
- searchCriteria.add( new SearchCriteria( "Woodland creatures" ) );
- }
-
- public List<SearchCriteria> getSearchCriteria()
- {
- return this.searchCriteria;
- }
-
- public void setSearchCriteria( List<SearchCriteria> searchCriteria )
- {
- this.searchCriteria = searchCriteria;
- }
-
- /**
- * 2D list of options available for each criteria
- */
- private List<List<String>> searchCriteriaOptions = new ArrayList<List<String>>();
-
- public List<List<String>> getSearchCriteriaOptions()
- {
- return this.searchCriteriaOptions;
- }
-
- public void setSearchCriteriaOptions( List<List<String>> searchCriteriaOptions )
- {
-
- this.searchCriteriaOptions = searchCriteriaOptions;
- }
-}
+/*
+ * 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.test.objects;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Test for OGNL-131.
+ */
+public class SearchTab
+{
+
+ /**
+ * Flags stating which search criteria are selected
+ */
+ private List<List<Boolean>> searchCriteriaSelections = new ArrayList<List<Boolean>>();
+ {
+ searchCriteriaSelections.add( Arrays.asList( Boolean.TRUE, Boolean.FALSE, Boolean.FALSE ) );
+ searchCriteriaSelections.add( Arrays.asList( Boolean.FALSE, Boolean.TRUE, Boolean.TRUE ) );
+ }
+
+ public List<List<Boolean>> getSearchCriteriaSelections()
+ {
+ return this.searchCriteriaSelections;
+ }
+
+ public void setSearchCriteriaSelections( List<List<Boolean>> selections )
+ {
+ this.searchCriteriaSelections = selections;
+ }
+
+ /**
+ * Filters that can be applied to this tabs searches
+ */
+ private List<SearchCriteria> searchCriteria = new ArrayList<SearchCriteria>();
+ {
+ searchCriteria.add( new SearchCriteria( "Crittery critters" ) );
+ searchCriteria.add( new SearchCriteria( "Woodland creatures" ) );
+ }
+
+ public List<SearchCriteria> getSearchCriteria()
+ {
+ return this.searchCriteria;
+ }
+
+ public void setSearchCriteria( List<SearchCriteria> searchCriteria )
+ {
+ this.searchCriteria = searchCriteria;
+ }
+
+ /**
+ * 2D list of options available for each criteria
+ */
+ private List<List<String>> searchCriteriaOptions = new ArrayList<List<String>>();
+
+ public List<List<String>> getSearchCriteriaOptions()
+ {
+ return this.searchCriteriaOptions;
+ }
+
+ public void setSearchCriteriaOptions( List<List<String>> searchCriteriaOptions )
+ {
+
+ this.searchCriteriaOptions = searchCriteriaOptions;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/SecondBean.java b/src/test/java/org/apache/commons/ognl/test/objects/SecondBean.java
index 93eec04..117dd1e 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/SecondBean.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/SecondBean.java
@@ -1,35 +1,34 @@
-/*
- * $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.test.objects;
-
-/**
- */
-public class SecondBean
- extends BaseBean
-{
- public String getName()
- {
- return "SecondBean";
- }
-
-}
+/*
+ * 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.test.objects;
+
+/**
+ */
+public class SecondBean
+ extends BaseBean
+{
+ public String getName()
+ {
+ return "SecondBean";
+ }
+
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/SetterReturns.java b/src/test/java/org/apache/commons/ognl/test/objects/SetterReturns.java
index c90aef9..ef02068 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/SetterReturns.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/SetterReturns.java
@@ -1,40 +1,39 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public class SetterReturns
-{
-
- private String _value = "";
-
- public String getValue()
- {
- return _value;
- }
-
- public SetterReturns setValue( String value )
- {
- _value += value;
- return this;
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public class SetterReturns
+{
+
+ private String _value = "";
+
+ public String getValue()
+ {
+ return _value;
+ }
+
+ public SetterReturns setValue( String value )
+ {
+ _value += value;
+ return this;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/Simple.java b/src/test/java/org/apache/commons/ognl/test/objects/Simple.java
index d56a61f..4027e42 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/Simple.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/Simple.java
@@ -1,233 +1,232 @@
-/*
- * $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.test.objects;
-
-import org.apache.commons.ognl.test.OgnlTestCase;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.HashMap;
-import java.util.Map;
-
-public class Simple
- extends Object
-{
- private String stringValue = "test";
-
- private float floatValue;
-
- private int intValue;
-
- private boolean booleanValue;
-
- private BigInteger bigIntValue = BigInteger.valueOf( 0 );
-
- private BigDecimal bigDecValue = new BigDecimal( 0.0 );
-
- private final Root root = new Root();
-
- private Bean3 _bean;
-
- private Bean2 _bean2;
-
- private Object[] _array;
-
- private Messages _messages;
-
- public Simple()
- {
- Map src = new HashMap();
- src.put( "test", "This is a test" );
-
- _messages = new Messages( src );
- }
-
- public Simple( Bean3 bean )
- {
- _bean = bean;
- }
-
- public Simple( Bean2 bean )
- {
- _bean2 = bean;
- }
-
- public Simple( Object[] values )
- {
- }
-
- public Simple( String stringValue, float floatValue, int intValue )
- {
- this.stringValue = stringValue;
- this.floatValue = floatValue;
- this.intValue = intValue;
- }
-
- public void setValues( String stringValue, float floatValue, int intValue )
- {
- this.stringValue = stringValue;
- this.floatValue = floatValue;
- this.intValue = intValue;
- }
-
- public String getStringValue()
- {
- return stringValue;
- }
-
- public void setStringValue( String value )
- {
- stringValue = value;
- }
-
- public float getFloatValue()
- {
- return floatValue;
- }
-
- public void setFloatValue( float value )
- {
- floatValue = value;
- }
-
- public int getIntValue()
- {
- return intValue;
- }
-
- public void setIntValue( int value )
- {
- intValue = value;
- }
-
- public boolean getValueIsTrue( Object currValue )
- {
- return true;
- }
-
- public boolean getBooleanValue()
- {
- return booleanValue;
- }
-
- public void setBooleanValue( boolean value )
- {
- booleanValue = value;
- }
-
- public BigInteger getBigIntValue()
- {
- return bigIntValue;
- }
-
- public void setArray( Object[] values )
- {
- _array = values;
- }
-
- public Object[] getArray()
- {
- return _array;
- }
-
- public void setBigIntValue( BigInteger value )
- {
- bigIntValue = value;
- }
-
- public BigDecimal getBigDecValue()
- {
- return bigDecValue;
- }
-
- public void setBigDecValue( BigDecimal value )
- {
- bigDecValue = value;
- }
-
- public Root getRootValue()
- {
- return root;
- }
-
- public Messages getMessages()
- {
- return _messages;
- }
-
- public int getOne()
- {
- return 1;
- }
-
- public int getTwo()
- {
- return 2;
- }
-
- public int getThree()
- {
- return 3;
- }
-
- public int getTestValue( int val )
- {
- return val + 1;
- }
-
- public boolean isEditorDisabled()
- {
- return false;
- }
-
- public boolean isDisabled()
- {
- return true;
- }
-
- public GetterMethods getMethodsTest()
- {
- return new GetterMethods();
- }
-
- public String getDisplayValue( int val )
- {
- return "test";
- }
-
- public boolean equals( Object other )
- {
- boolean result = false;
-
- if ( other instanceof Simple )
- {
- Simple os = (Simple) other;
-
- result =
- OgnlTestCase.isEqual( os.getStringValue(), getStringValue() ) && ( os.getIntValue() == getIntValue() );
- }
- return result;
- }
-
- public boolean isThisVarArgsWorking( Object... arguments )
- {
- return 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.test.objects;
+
+import org.apache.commons.ognl.test.OgnlTestCase;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.HashMap;
+import java.util.Map;
+
+public class Simple
+ extends Object
+{
+ private String stringValue = "test";
+
+ private float floatValue;
+
+ private int intValue;
+
+ private boolean booleanValue;
+
+ private BigInteger bigIntValue = BigInteger.valueOf( 0 );
+
+ private BigDecimal bigDecValue = new BigDecimal( 0.0 );
+
+ private final Root root = new Root();
+
+ private Bean3 _bean;
+
+ private Bean2 _bean2;
+
+ private Object[] _array;
+
+ private Messages _messages;
+
+ public Simple()
+ {
+ Map src = new HashMap();
+ src.put( "test", "This is a test" );
+
+ _messages = new Messages( src );
+ }
+
+ public Simple( Bean3 bean )
+ {
+ _bean = bean;
+ }
+
+ public Simple( Bean2 bean )
+ {
+ _bean2 = bean;
+ }
+
+ public Simple( Object[] values )
+ {
+ }
+
+ public Simple( String stringValue, float floatValue, int intValue )
+ {
+ this.stringValue = stringValue;
+ this.floatValue = floatValue;
+ this.intValue = intValue;
+ }
+
+ public void setValues( String stringValue, float floatValue, int intValue )
+ {
+ this.stringValue = stringValue;
+ this.floatValue = floatValue;
+ this.intValue = intValue;
+ }
+
+ public String getStringValue()
+ {
+ return stringValue;
+ }
+
+ public void setStringValue( String value )
+ {
+ stringValue = value;
+ }
+
+ public float getFloatValue()
+ {
+ return floatValue;
+ }
+
+ public void setFloatValue( float value )
+ {
+ floatValue = value;
+ }
+
+ public int getIntValue()
+ {
+ return intValue;
+ }
+
+ public void setIntValue( int value )
+ {
+ intValue = value;
+ }
+
+ public boolean getValueIsTrue( Object currValue )
+ {
+ return true;
+ }
+
+ public boolean getBooleanValue()
+ {
+ return booleanValue;
+ }
+
+ public void setBooleanValue( boolean value )
+ {
+ booleanValue = value;
+ }
+
+ public BigInteger getBigIntValue()
+ {
+ return bigIntValue;
+ }
+
+ public void setArray( Object[] values )
+ {
+ _array = values;
+ }
+
+ public Object[] getArray()
+ {
+ return _array;
+ }
+
+ public void setBigIntValue( BigInteger value )
+ {
+ bigIntValue = value;
+ }
+
+ public BigDecimal getBigDecValue()
+ {
+ return bigDecValue;
+ }
+
+ public void setBigDecValue( BigDecimal value )
+ {
+ bigDecValue = value;
+ }
+
+ public Root getRootValue()
+ {
+ return root;
+ }
+
+ public Messages getMessages()
+ {
+ return _messages;
+ }
+
+ public int getOne()
+ {
+ return 1;
+ }
+
+ public int getTwo()
+ {
+ return 2;
+ }
+
+ public int getThree()
+ {
+ return 3;
+ }
+
+ public int getTestValue( int val )
+ {
+ return val + 1;
+ }
+
+ public boolean isEditorDisabled()
+ {
+ return false;
+ }
+
+ public boolean isDisabled()
+ {
+ return true;
+ }
+
+ public GetterMethods getMethodsTest()
+ {
+ return new GetterMethods();
+ }
+
+ public String getDisplayValue( int val )
+ {
+ return "test";
+ }
+
+ public boolean equals( Object other )
+ {
+ boolean result = false;
+
+ if ( other instanceof Simple )
+ {
+ Simple os = (Simple) other;
+
+ result =
+ OgnlTestCase.isEqual( os.getStringValue(), getStringValue() ) && ( os.getIntValue() == getIntValue() );
+ }
+ return result;
+ }
+
+ public boolean isThisVarArgsWorking( Object... arguments )
+ {
+ return true;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/SimpleEnum.java b/src/test/java/org/apache/commons/ognl/test/objects/SimpleEnum.java
index b081070..1115894 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/SimpleEnum.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/SimpleEnum.java
@@ -1,41 +1,40 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public enum SimpleEnum
-{
-
- ONE( 1 );
-
- private final int _value;
-
- SimpleEnum( int value )
- {
- _value = value;
- }
-
- public int getValue()
- {
- return _value;
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public enum SimpleEnum
+{
+
+ ONE( 1 );
+
+ private final int _value;
+
+ SimpleEnum( int value )
+ {
+ _value = value;
+ }
+
+ public int getValue()
+ {
+ return _value;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/SimpleNumeric.java b/src/test/java/org/apache/commons/ognl/test/objects/SimpleNumeric.java
index 2cc0675..b21f9a6 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/SimpleNumeric.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/SimpleNumeric.java
@@ -1,42 +1,41 @@
-/*
- * $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.test.objects;
-
-/**
- * Used for {@link org.apache.commons.ognl.test.PropertyArithmeticAndLogicalOperatorsTest}.
- */
-public class SimpleNumeric
-{
-
- public double getBudget()
- {
- return 140;
- }
-
- public double getTimeBilled()
- {
- return 24.12;
- }
-
- public String getTableSize()
- {
- return "10";
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ * Used for {@link org.apache.commons.ognl.test.PropertyArithmeticAndLogicalOperatorsTest}.
+ */
+public class SimpleNumeric
+{
+
+ public double getBudget()
+ {
+ return 140;
+ }
+
+ public double getTimeBilled()
+ {
+ return 24.12;
+ }
+
+ public String getTableSize()
+ {
+ return "10";
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/SubclassSyntheticObject.java b/src/test/java/org/apache/commons/ognl/test/objects/SubclassSyntheticObject.java
index c0521a0..bb3e8f3 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/SubclassSyntheticObject.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/SubclassSyntheticObject.java
@@ -1,35 +1,34 @@
-/*
- * $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.test.objects;
-
-import java.util.ArrayList;
-
-/**
- * Simple subclass.
- */
-public class SubclassSyntheticObject
- extends BaseSyntheticObject
-{
-
- public ArrayList getList()
- {
- return new ArrayList();
- }
-}
+/*
+ * 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.test.objects;
+
+import java.util.ArrayList;
+
+/**
+ * Simple subclass.
+ */
+public class SubclassSyntheticObject
+ extends BaseSyntheticObject
+{
+
+ public ArrayList getList()
+ {
+ return new ArrayList();
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/TestClass.java b/src/test/java/org/apache/commons/ognl/test/objects/TestClass.java
index f21dfcd..fc000dc 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/TestClass.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/TestClass.java
@@ -1,28 +1,27 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public abstract class TestClass
-{
-
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public abstract class TestClass
+{
+
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/TestImpl.java b/src/test/java/org/apache/commons/ognl/test/objects/TestImpl.java
index e310d63..1b116b9 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/TestImpl.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/TestImpl.java
@@ -1,38 +1,37 @@
-/*
- * $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.test.objects;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- *
- */
-public class TestImpl
- extends TestClass
-{
-
- public Map<String, String> getTheMap()
- {
- Map<String, String> map = new HashMap();
- map.put( "key", "value" );
- return map;
- }
-}
+/*
+ * 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.test.objects;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *
+ */
+public class TestImpl
+ extends TestClass
+{
+
+ public Map<String, String> getTheMap()
+ {
+ Map<String, String> map = new HashMap();
+ map.put( "key", "value" );
+ return map;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/TestInherited1.java b/src/test/java/org/apache/commons/ognl/test/objects/TestInherited1.java
index 4e5dc3c..1a70d5b 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/TestInherited1.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/TestInherited1.java
@@ -1,33 +1,32 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public class TestInherited1
- implements Inherited
-{
-
- public String getMyString()
- {
- return "inherited1";
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public class TestInherited1
+ implements Inherited
+{
+
+ public String getMyString()
+ {
+ return "inherited1";
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/TestInherited2.java b/src/test/java/org/apache/commons/ognl/test/objects/TestInherited2.java
index 8dfc744..c5d3894 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/TestInherited2.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/TestInherited2.java
@@ -1,33 +1,32 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public class TestInherited2
- implements Inherited
-{
-
- public String getMyString()
- {
- return "inherited2";
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public class TestInherited2
+ implements Inherited
+{
+
+ public String getMyString()
+ {
+ return "inherited2";
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/TestModel.java b/src/test/java/org/apache/commons/ognl/test/objects/TestModel.java
index ccf9ef8..cd5bb97 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/TestModel.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/TestModel.java
@@ -1,47 +1,46 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public class TestModel
-{
-
- public Copy getCopy()
- {
- return new Copy();
- }
-
- public Model getUnassignedCopyModel()
- {
- return new Model();
- }
-
- public boolean isCanApproveCopy()
- {
- return true;
- }
-
- public Entry getEntry()
- {
- return new Entry();
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public class TestModel
+{
+
+ public Copy getCopy()
+ {
+ return new Copy();
+ }
+
+ public Model getUnassignedCopyModel()
+ {
+ return new Model();
+ }
+
+ public boolean isCanApproveCopy()
+ {
+ return true;
+ }
+
+ public Entry getEntry()
+ {
+ return new Entry();
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/TreeContentProvider.java b/src/test/java/org/apache/commons/ognl/test/objects/TreeContentProvider.java
index 39edf30..b6fcf07 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/TreeContentProvider.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/TreeContentProvider.java
@@ -1,47 +1,46 @@
-/*
- * $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.test.objects;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-/**
- *
- */
-public class TreeContentProvider
- implements ITreeContentProvider
-{
-
- public Collection getChildren( Object parentElement )
- {
- return Collections.EMPTY_LIST;
- }
-
- public boolean hasChildren( Object parentElement )
- {
- return true;
- }
-
- public List getElements()
- {
- return Collections.EMPTY_LIST;
- }
-}
+/*
+ * 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.test.objects;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ *
+ */
+public class TreeContentProvider
+ implements ITreeContentProvider
+{
+
+ public Collection getChildren( Object parentElement )
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ public boolean hasChildren( Object parentElement )
+ {
+ return true;
+ }
+
+ public List getElements()
+ {
+ return Collections.EMPTY_LIST;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/objects/Two.java b/src/test/java/org/apache/commons/ognl/test/objects/Two.java
index 9b0f74a..b871a82 100644
--- a/src/test/java/org/apache/commons/ognl/test/objects/Two.java
+++ b/src/test/java/org/apache/commons/ognl/test/objects/Two.java
@@ -1,37 +1,36 @@
-/*
- * $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.test.objects;
-
-/**
- *
- */
-public class Two
-{
-
- public String getMessage( String mes )
- {
- return "[" + mes + "]";
- }
-
- public boolean hasChildren( String name )
- {
- return name.length() > 2;
- }
-}
+/*
+ * 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.test.objects;
+
+/**
+ *
+ */
+public class Two
+{
+
+ public String getMessage( String mes )
+ {
+ return "[" + mes + "]";
+ }
+
+ public boolean hasChildren( String name )
+ {
+ return name.length() > 2;
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/util/ContextClassLoader.java b/src/test/java/org/apache/commons/ognl/test/util/ContextClassLoader.java
index d50735c..b9a88fe 100644
--- a/src/test/java/org/apache/commons/ognl/test/util/ContextClassLoader.java
+++ b/src/test/java/org/apache/commons/ognl/test/util/ContextClassLoader.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.test.util;
-
-import org.apache.commons.ognl.OgnlContext;
-
-public class ContextClassLoader
- extends ClassLoader
-{
- private final OgnlContext context;
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public ContextClassLoader( ClassLoader parentClassLoader, OgnlContext context )
- {
- super( parentClassLoader );
- this.context = context;
- }
-
- /*
- * =================================================================== Overridden methods
- * ===================================================================
- */
- protected Class<?> findClass( String name )
- throws ClassNotFoundException
- {
- if ( ( context != null ) && ( context.getClassResolver() != null ) )
- {
- return context.getClassResolver().classForName( name, context );
- }
- return super.findClass( name );
- }
-
-}
+/*
+ * 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.test.util;
+
+import org.apache.commons.ognl.OgnlContext;
+
+public class ContextClassLoader
+ extends ClassLoader
+{
+ private final OgnlContext context;
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public ContextClassLoader( ClassLoader parentClassLoader, OgnlContext context )
+ {
+ super( parentClassLoader );
+ this.context = context;
+ }
+
+ /*
+ * =================================================================== Overridden methods
+ * ===================================================================
+ */
+ protected Class<?> findClass( String name )
+ throws ClassNotFoundException
+ {
+ if ( ( context != null ) && ( context.getClassResolver() != null ) )
+ {
+ return context.getClassResolver().classForName( name, context );
+ }
+ return super.findClass( name );
+ }
+
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/util/EnhancedClassLoader.java b/src/test/java/org/apache/commons/ognl/test/util/EnhancedClassLoader.java
index fd381db..b1f78ef 100644
--- a/src/test/java/org/apache/commons/ognl/test/util/EnhancedClassLoader.java
+++ b/src/test/java/org/apache/commons/ognl/test/util/EnhancedClassLoader.java
@@ -1,42 +1,41 @@
-/*
- * $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.test.util;
-
-public class EnhancedClassLoader
- extends ClassLoader
-{
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public EnhancedClassLoader( ClassLoader parentClassLoader )
- {
- super( parentClassLoader );
- }
-
- /*
- * =================================================================== Overridden methods
- * ===================================================================
- */
- public Class<?> defineClass( String enhancedClassName, byte[] byteCode )
- {
- return defineClass( enhancedClassName, byteCode, 0, byteCode.length );
- }
-}
+/*
+ * 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.test.util;
+
+public class EnhancedClassLoader
+ extends ClassLoader
+{
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public EnhancedClassLoader( ClassLoader parentClassLoader )
+ {
+ super( parentClassLoader );
+ }
+
+ /*
+ * =================================================================== Overridden methods
+ * ===================================================================
+ */
+ public Class<?> defineClass( String enhancedClassName, byte[] byteCode )
+ {
+ return defineClass( enhancedClassName, byteCode, 0, byteCode.length );
+ }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/util/NameFactory.java b/src/test/java/org/apache/commons/ognl/test/util/NameFactory.java
index 4f46b5b..78f55cf 100644
--- a/src/test/java/org/apache/commons/ognl/test/util/NameFactory.java
+++ b/src/test/java/org/apache/commons/ognl/test/util/NameFactory.java
@@ -1,56 +1,55 @@
-/*
- * $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.test.util;
-
-public class NameFactory
- extends Object
-{
- private final String classBaseName;
-
- private int classNameCounter = 0;
-
- private final String variableBaseName;
-
- private int variableNameCounter = 0;
-
- /*
- * =================================================================== Constructors
- * ===================================================================
- */
- public NameFactory( String classBaseName, String variableBaseName )
- {
- this.classBaseName = classBaseName;
- this.variableBaseName = variableBaseName;
- }
-
- /*
- * =================================================================== Public methods
- * ===================================================================
- */
- public String getNewClassName()
- {
- return classBaseName + classNameCounter++;
- }
-
- public String getNewVariableName()
- {
- return variableBaseName + variableNameCounter++;
- }
-}
+/*
+ * 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.test.util;
+
+public class NameFactory
+ extends Object
+{
+ private final String classBaseName;
+
+ private int classNameCounter = 0;
+
+ private final String variableBaseName;
+
+ private int variableNameCounter = 0;
+
+ /*
+ * =================================================================== Constructors
+ * ===================================================================
+ */
+ public NameFactory( String classBaseName, String variableBaseName )
+ {
+ this.classBaseName = classBaseName;
+ this.variableBaseName = variableBaseName;
+ }
+
+ /*
+ * =================================================================== Public methods
+ * ===================================================================
+ */
+ public String getNewClassName()
+ {
+ return classBaseName + classNameCounter++;
+ }
+
+ public String getNewVariableName()
+ {
+ return variableBaseName + variableNameCounter++;
+ }
+}