├── .asf.yaml ├── .github └── workflows │ ├── codeql-analysis.yml │ ├── coverage.yml │ ├── maven.yml │ └── scorecards-analysis.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── LICENSE.txt ├── NOTICE.txt ├── README.md ├── RELEASE-NOTES.txt ├── SECURITY.md ├── findbugs-exclude-filter.xml ├── pom.xml └── src ├── benchmarks ├── java │ └── org │ │ └── apache │ │ └── commons │ │ └── ognl │ │ └── performance │ │ ├── BasePerformanceTest.java │ │ ├── PerformanceCommonsOgnlTest.java │ │ ├── PerformanceOldOgnlTest.java │ │ ├── invocation │ │ ├── CompilerInvocation.java │ │ ├── FieldInvocation.java │ │ ├── FindParameterTypesInvocation.java │ │ ├── GetConstructorsInvocation.java │ │ ├── GetDeclaredMethodsInvocation.java │ │ ├── GetMethodsInvocation.java │ │ ├── InvokeMethodInvocation.java │ │ ├── MethodParameterTypesInvocation.java │ │ ├── PermissionInvocation.java │ │ ├── PrimitiveDefaultInvocation.java │ │ └── RepeatableInvocation.java │ │ └── runtime │ │ ├── CommonsRuntimeWrapper.java │ │ ├── OldOgnlRuntimeWrapper.java │ │ └── RuntimeWrapper.java └── resources │ └── log4j.xml ├── changes └── changes.xml ├── main ├── assembly │ ├── bin.xml │ └── src.xml ├── java │ └── org │ │ └── apache │ │ └── commons │ │ └── ognl │ │ ├── ASTAdd.java │ │ ├── ASTAnd.java │ │ ├── ASTAssign.java │ │ ├── ASTBitAnd.java │ │ ├── ASTBitNegate.java │ │ ├── ASTBitOr.java │ │ ├── ASTChain.java │ │ ├── ASTConst.java │ │ ├── ASTCtor.java │ │ ├── ASTDivide.java │ │ ├── ASTEq.java │ │ ├── ASTEval.java │ │ ├── ASTGreater.java │ │ ├── ASTGreaterEq.java │ │ ├── ASTIn.java │ │ ├── ASTInstanceof.java │ │ ├── ASTKeyValue.java │ │ ├── ASTLess.java │ │ ├── ASTLessEq.java │ │ ├── ASTList.java │ │ ├── ASTMap.java │ │ ├── ASTMethod.java │ │ ├── ASTMethodUtil.java │ │ ├── ASTMultiply.java │ │ ├── ASTNegate.java │ │ ├── ASTNot.java │ │ ├── ASTNotEq.java │ │ ├── ASTNotIn.java │ │ ├── ASTOr.java │ │ ├── ASTProject.java │ │ ├── ASTProperty.java │ │ ├── ASTRemainder.java │ │ ├── ASTRootVarRef.java │ │ ├── ASTSelect.java │ │ ├── ASTSelectFirst.java │ │ ├── ASTSelectLast.java │ │ ├── ASTSequence.java │ │ ├── ASTShiftLeft.java │ │ ├── ASTShiftRight.java │ │ ├── ASTStaticField.java │ │ ├── ASTStaticMethod.java │ │ ├── ASTSubtract.java │ │ ├── ASTTest.java │ │ ├── ASTThisVarRef.java │ │ ├── ASTUnsignedShiftRight.java │ │ ├── ASTVarRef.java │ │ ├── ASTXor.java │ │ ├── ArrayElementsAccessor.java │ │ ├── ArrayPropertyAccessor.java │ │ ├── BooleanExpression.java │ │ ├── ClassCacheInspector.java │ │ ├── ClassResolver.java │ │ ├── CollectionElementsAccessor.java │ │ ├── ComparisonExpression.java │ │ ├── DefaultClassResolver.java │ │ ├── DefaultMemberAccess.java │ │ ├── DefaultTypeConverter.java │ │ ├── DynamicSubscript.java │ │ ├── ElementsAccessor.java │ │ ├── EnumerationElementsAccessor.java │ │ ├── EnumerationIterator.java │ │ ├── EnumerationPropertyAccessor.java │ │ ├── Evaluation.java │ │ ├── ExpressionNode.java │ │ ├── ExpressionSyntaxException.java │ │ ├── InappropriateExpressionException.java │ │ ├── IteratorElementsAccessor.java │ │ ├── IteratorEnumeration.java │ │ ├── IteratorPropertyAccessor.java │ │ ├── JJTOgnlParserState.java │ │ ├── JavaSource.java │ │ ├── ListPropertyAccessor.java │ │ ├── MapElementsAccessor.java │ │ ├── MapPropertyAccessor.java │ │ ├── MemberAccess.java │ │ ├── MethodAccessor.java │ │ ├── MethodFailedException.java │ │ ├── NoSuchPropertyException.java │ │ ├── Node.java │ │ ├── NodeType.java │ │ ├── NodeVisitor.java │ │ ├── NullHandler.java │ │ ├── NumberElementsAccessor.java │ │ ├── NumericCasts.java │ │ ├── NumericDefaults.java │ │ ├── NumericExpression.java │ │ ├── NumericLiterals.java │ │ ├── NumericTypes.java │ │ ├── NumericValues.java │ │ ├── ObjectElementsAccessor.java │ │ ├── ObjectIndexedPropertyDescriptor.java │ │ ├── ObjectMethodAccessor.java │ │ ├── ObjectNullHandler.java │ │ ├── ObjectPropertyAccessor.java │ │ ├── Ognl.java │ │ ├── OgnlCache.java │ │ ├── OgnlContext.java │ │ ├── OgnlException.java │ │ ├── OgnlInvokePermission.java │ │ ├── OgnlOps.java │ │ ├── OgnlParserTreeConstants.java │ │ ├── OgnlRuntime.java │ │ ├── PrimitiveDefaults.java │ │ ├── PrimitiveTypes.java │ │ ├── PrimitiveWrapperClasses.java │ │ ├── PropertyAccessor.java │ │ ├── SetPropertyAccessor.java │ │ ├── SimpleNode.java │ │ ├── ToStringVisitor.java │ │ ├── TypeConverter.java │ │ ├── enhance │ │ ├── ContextClassLoader.java │ │ ├── EnhancedClassLoader.java │ │ ├── ExpressionAccessor.java │ │ ├── ExpressionCompiler.java │ │ ├── LocalReference.java │ │ ├── LocalReferenceImpl.java │ │ ├── OgnlExpressionCompiler.java │ │ ├── OrderedReturn.java │ │ ├── UnsupportedCompilationException.java │ │ └── package-info.java │ │ ├── internal │ │ ├── Cache.java │ │ ├── CacheException.java │ │ ├── CacheFactory.java │ │ ├── ClassCache.java │ │ ├── ClassCacheHandler.java │ │ ├── ClassCacheImpl.java │ │ ├── ConcurrentHashMapCache.java │ │ ├── ConcurrentHashMapCacheFactory.java │ │ ├── ConcurrentHashMapClassCache.java │ │ ├── Entry.java │ │ ├── HashMapCache.java │ │ ├── HashMapCacheFactory.java │ │ ├── HashMapClassCache.java │ │ ├── ReentrantReadWriteLockCache.java │ │ ├── ReentrantReadWriteLockCacheFactory.java │ │ ├── ReentrantReadWriteLockClassCache.java │ │ ├── entry │ │ │ ├── CacheEntry.java │ │ │ ├── CacheEntryFactory.java │ │ │ ├── ClassCacheEntryFactory.java │ │ │ ├── DeclaredMethodCacheEntry.java │ │ │ ├── DeclaredMethodCacheEntryFactory.java │ │ │ ├── FieldCacheEntryFactory.java │ │ │ ├── GenericMethodParameterTypeCacheEntry.java │ │ │ ├── GenericMethodParameterTypeFactory.java │ │ │ ├── MethodAccessCacheEntryFactory.java │ │ │ ├── MethodAccessEntryValue.java │ │ │ ├── MethodCacheEntry.java │ │ │ ├── MethodCacheEntryFactory.java │ │ │ ├── MethodPermCacheEntryFactory.java │ │ │ ├── ParametrizedCacheEntryFactory.java │ │ │ ├── PermissionCacheEntry.java │ │ │ ├── PermissionCacheEntryFactory.java │ │ │ └── PropertyDescriptorCacheEntryFactory.java │ │ └── package-info.java │ │ └── package-info.java ├── javacc │ └── ognl.jj └── jjtree │ └── ognl.jjt ├── media └── logo.xcf ├── site ├── resources │ ├── download_ognl.cgi │ └── images │ │ └── logo.png ├── site.xml └── xdoc │ ├── developer-guide.xml │ ├── download_ognl.xml │ ├── index.xml │ └── language-guide.xml └── test └── java └── org └── apache └── commons └── ognl ├── InExpressionTest.java ├── TestOgnlException.java ├── TestOgnlRuntime.java ├── internal ├── ConcurrentHashMapCacheTest.java ├── ConstructorCacheTest.java ├── DeclaredMethodCacheTest.java ├── FieldCacheTest.java ├── GenericMethodParameterTypeCacheTest.java ├── MethodAccessCacheTest.java ├── MethodPermCacheTest.java ├── PermissionCacheTest.java └── PropertyDescriptorCacheTest.java └── test ├── ASTChainTest.java ├── ASTMethodTest.java ├── ASTPropertyTest.java ├── ArithmeticAndLogicalOperatorsTest.java ├── ArrayCreationTest.java ├── ArrayElementsTest.java ├── ClassMethodTest.java ├── CollectionDirectPropertyTest.java ├── CompilingPropertyAccessor.java ├── ConstantTest.java ├── ConstantTreeTest.java ├── ContextVariableTest.java ├── CorrectedObjectNullHandler.java ├── GenericsTest.java ├── IndexAccessTest.java ├── IndexedPropertyTest.java ├── InheritedMethodsTest.java ├── InterfaceInheritanceTest.java ├── LambdaExpressionTest.java ├── MapCreationTest.java ├── MemberAccessTest.java ├── MethodTest.java ├── MethodWithConversionTest.java ├── NestedMethodTest.java ├── NullHandlerTest.java ├── NullStringCatenationTest.java ├── NumberFormatExceptionTest.java ├── NumericConversionTest.java ├── ObjectIndexedPropertyTest.java ├── ObjectIndexedTest.java ├── OgnlTestCase.java ├── OperatorTest.java ├── Performance.java ├── PrimitiveArrayTest.java ├── PrimitiveNullHandlingTest.java ├── PrivateAccessorTest.java ├── PrivateMemberTest.java ├── ProjectionSelectionTest.java ├── PropertyArithmeticAndLogicalOperatorsTest.java ├── PropertyNotFoundTest.java ├── PropertySetterTest.java ├── PropertyTest.java ├── ProtectedInnerClassTest.java ├── QuotingTest.java ├── SetterTest.java ├── SetterWithConversionTest.java ├── ShortCircuitingExpressionTest.java ├── SimpleNavigationChainTreeTest.java ├── SimplePropertyTreeTest.java ├── StaticsAndConstructorsTest.java ├── accessors └── ListPropertyAccessorTest.java ├── enhance └── TestExpressionCompiler.java ├── objects ├── BaseBean.java ├── BaseGeneric.java ├── BaseIndexed.java ├── BaseObjectIndexed.java ├── BaseSyntheticObject.java ├── Bean1.java ├── Bean2.java ├── Bean3.java ├── BeanProvider.java ├── BeanProviderAccessor.java ├── BeanProviderImpl.java ├── Component.java ├── ComponentImpl.java ├── ComponentSubclass.java ├── Copy.java ├── CorrectedObject.java ├── Cracker.java ├── Entry.java ├── EvenOdd.java ├── FirstBean.java ├── FormComponentImpl.java ├── FormImpl.java ├── GameGeneric.java ├── GameGenericObject.java ├── GenericCracker.java ├── GenericObject.java ├── GenericRoot.java ├── GenericService.java ├── GenericServiceImpl.java ├── GetterMethods.java ├── IComponent.java ├── IContentProvider.java ├── IForm.java ├── IFormComponent.java ├── ITreeContentProvider.java ├── Indexed.java ├── IndexedMapObject.java ├── IndexedSetObject.java ├── Inherited.java ├── ListSource.java ├── ListSourceImpl.java ├── MenuItem.java ├── Messages.java ├── Model.java ├── MyMap.java ├── MyMapImpl.java ├── ObjectIndexed.java ├── OtherObjectIndexed.java ├── PersonGenericObject.java ├── PropertyHolder.java ├── Root.java ├── SearchCriteria.java ├── SearchTab.java ├── SecondBean.java ├── SetterReturns.java ├── Simple.java ├── SimpleEnum.java ├── SimpleNumeric.java ├── SubclassSyntheticObject.java ├── TestClass.java ├── TestImpl.java ├── TestInherited1.java ├── TestInherited2.java ├── TestModel.java ├── TreeContentProvider.java └── Two.java └── util ├── ContextClassLoader.java ├── EnhancedClassLoader.java └── NameFactory.java /.asf.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | github: 17 | description: "Apache Commons OGNL (Dormant)" 18 | homepage: https://commons.apache.org/ognl/ 19 | 20 | notifications: 21 | commits: commits@commons.apache.org 22 | issues: issues@commons.apache.org 23 | pullrequests: issues@commons.apache.org 24 | jira_options: link label 25 | jobs: notifications@commons.apache.org 26 | issues_bot_dependabot: notifications@commons.apache.org 27 | pullrequests_bot_dependabot: notifications@commons.apache.org 28 | issues_bot_codecov-commenter: notifications@commons.apache.org 29 | pullrequests_bot_codecov-commenter: notifications@commons.apache.org 30 | -------------------------------------------------------------------------------- /.github/workflows/maven.yml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | name: Java CI 17 | 18 | # on: [push, pull_request] 19 | on: 20 | workflow_dispatch: 21 | 22 | jobs: 23 | build: 24 | runs-on: ubuntu-latest 25 | strategy: 26 | matrix: 27 | java: [ 8, 11, 17 ] 28 | steps: 29 | - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 30 | with: 31 | persist-credentials: false 32 | - name: Set up JDK ${{ matrix.java }} 33 | uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0 34 | with: 35 | distribution: 'temurin' 36 | java-version: ${{ matrix.java }} 37 | cache: 'maven' 38 | - name: Build with Maven on Java ${{ matrix.java }} 39 | run: mvn -V -Ddoclint=all --file pom.xml --no-transfer-progress 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .java-version 2 | target/ 3 | .idea/ 4 | *.iml 5 | /.classpath 6 | /.project 7 | /.settings/ 8 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | 17 | The Apache code of conduct page is [https://www.apache.org/foundation/policies/conduct.html](https://www.apache.org/foundation/policies/conduct.html). 18 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | Apache Commons OGNL 2 | Copyright 2001-2024 The Apache Software Foundation 3 | 4 | This product includes software developed at 5 | The Apache Software Foundation (https://www.apache.org/). 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 17 | # Apache Commons OGNL 18 | 19 | Warning: The Apache Commons OGNL component is now DORMANT, meaning 20 | this component is not being developed. 21 | 22 | For queries, please contact the 23 | Commons Developer list 24 | -------------------------------------------------------------------------------- /RELEASE-NOTES.txt: -------------------------------------------------------------------------------- 1 | 2 | Commons OGNL Package 3 | Version 4.0 4 | Release Notes 5 | 6 | 7 | INTRODUCTION 8 | ============ 9 | 10 | The Apache Commons OGNL library is a Java development framework for Object-Graph Navigation Language, 11 | plus other extras such as list projection and selection and lambda expressions. 12 | 13 | This is the first release under Apache Incubator. 14 | New projects are encouraged to use this release of OGNL. 15 | 16 | IMPORTANT NOTES 17 | =============== 18 | 19 | Dependencies 20 | ============= 21 | Commons OGNL depends on Javassist. It is built against version 3.11.0.GA. 22 | 23 | BUGS FROM PREVIOUS RELEASE 24 | ========================= 25 | 26 | JIRA Issues Addressed 27 | --------------------- 28 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 17 | The Apache Commons security page is [https://commons.apache.org/security.html](https://commons.apache.org/security.html). 18 | -------------------------------------------------------------------------------- /findbugs-exclude-filter.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 24 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/benchmarks/java/org/apache/commons/ognl/performance/PerformanceCommonsOgnlTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | */ 20 | 21 | package org.apache.commons.ognl.performance; 22 | 23 | import com.carrotsearch.junitbenchmarks.annotation.BenchmarkMethodChart; 24 | import org.junit.AfterClass; 25 | import org.junit.BeforeClass; 26 | 27 | /** 28 | * User: Maurizio Cucchiara 29 | * Date: 10/22/11 30 | * Time: 12:49 AM 31 | */ 32 | 33 | @BenchmarkMethodChart( filePrefix = "benchmark" ) 34 | public class PerformanceCommonsOgnlTest 35 | extends BasePerformanceTest 36 | { 37 | @BeforeClass 38 | public static void before() 39 | { 40 | runtimeWrapper = COMMONS_RUNTIME_WRAPPER; 41 | } 42 | 43 | @AfterClass 44 | public static void after() 45 | { 46 | runtimeWrapper.clearCache(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/benchmarks/java/org/apache/commons/ognl/performance/PerformanceOldOgnlTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | */ 20 | 21 | package org.apache.commons.ognl.performance; 22 | 23 | import com.carrotsearch.junitbenchmarks.annotation.BenchmarkMethodChart; 24 | import org.junit.AfterClass; 25 | import org.junit.BeforeClass; 26 | 27 | /** 28 | * User: Maurizio Cucchiara 29 | * Date: 10/22/11 30 | * Time: 12:49 AM 31 | */ 32 | 33 | @BenchmarkMethodChart( filePrefix = "benchmark-legacy" ) 34 | public class PerformanceOldOgnlTest 35 | extends BasePerformanceTest 36 | { 37 | @BeforeClass 38 | public static void before() 39 | { 40 | runtimeWrapper = OLD_RUNTIME_WRAPPER; 41 | } 42 | 43 | @AfterClass 44 | public static void after() 45 | { 46 | runtimeWrapper.clearCache(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/benchmarks/java/org/apache/commons/ognl/performance/invocation/CompilerInvocation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | */ 20 | package org.apache.commons.ognl.performance.invocation; 21 | 22 | import org.apache.commons.ognl.performance.runtime.RuntimeWrapper; 23 | 24 | /** 25 | * User: mcucchiara 26 | * Date: 28/10/11 27 | * Time: 18.42 28 | */ 29 | public class CompilerInvocation 30 | extends RepeatableInvocation 31 | { 32 | public CompilerInvocation( RuntimeWrapper runtimeWrapper, int times ) 33 | throws Exception 34 | { 35 | super( runtimeWrapper, times ); 36 | 37 | } 38 | 39 | @Override 40 | protected void invoke( Class c ) 41 | throws Exception 42 | { 43 | getRuntime().getCompiler(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/benchmarks/java/org/apache/commons/ognl/performance/invocation/FieldInvocation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | */ 20 | 21 | package org.apache.commons.ognl.performance.invocation; 22 | 23 | import org.apache.commons.ognl.performance.runtime.RuntimeWrapper; 24 | 25 | /** 26 | * User: mcucchiara 27 | * Date: 18/10/11 28 | * Time: 16.28 29 | */ 30 | public class FieldInvocation 31 | extends RepeatableInvocation 32 | { 33 | public FieldInvocation( RuntimeWrapper runtimeWrapper ) 34 | throws Exception 35 | { 36 | super( runtimeWrapper ); 37 | } 38 | 39 | public FieldInvocation( RuntimeWrapper runtimeWrapper, int times ) 40 | throws Exception 41 | { 42 | super( runtimeWrapper, times ); 43 | } 44 | 45 | @Override 46 | protected void invoke( Class c ) 47 | throws Exception 48 | { 49 | getRuntime().getFields( c ); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/benchmarks/java/org/apache/commons/ognl/performance/invocation/FindParameterTypesInvocation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | */ 20 | 21 | package org.apache.commons.ognl.performance.invocation; 22 | 23 | import org.apache.commons.ognl.performance.runtime.RuntimeWrapper; 24 | 25 | import java.lang.reflect.Method; 26 | 27 | /** 28 | * User: mcucchiara 29 | * Date: 18/10/11 30 | * Time: 16.37 31 | */ 32 | public class FindParameterTypesInvocation 33 | extends RepeatableInvocation 34 | { 35 | 36 | public FindParameterTypesInvocation( RuntimeWrapper runtimeWrapper, int times ) 37 | throws Exception 38 | { 39 | super( runtimeWrapper, times ); 40 | } 41 | 42 | public FindParameterTypesInvocation( RuntimeWrapper runtimeWrapper ) 43 | throws Exception 44 | { 45 | super( runtimeWrapper ); 46 | } 47 | 48 | @Override 49 | protected void invoke( Class c ) 50 | throws Exception 51 | { 52 | for ( Method method : c.getMethods() ) 53 | { 54 | getRuntime().findParameterTypes( String.class, method ); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/benchmarks/java/org/apache/commons/ognl/performance/invocation/GetConstructorsInvocation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | */ 20 | 21 | package org.apache.commons.ognl.performance.invocation; 22 | 23 | import org.apache.commons.ognl.performance.runtime.RuntimeWrapper; 24 | 25 | /** 26 | * User: mcucchiara 27 | * Date: 18/10/11 28 | * Time: 16.21 29 | */ 30 | public class GetConstructorsInvocation 31 | extends RepeatableInvocation 32 | { 33 | public GetConstructorsInvocation( RuntimeWrapper runtimeWrapper ) 34 | throws Exception 35 | { 36 | super( runtimeWrapper ); 37 | } 38 | 39 | public GetConstructorsInvocation( RuntimeWrapper runtimeWrapper, int times ) 40 | throws Exception 41 | { 42 | super( runtimeWrapper, times ); 43 | } 44 | 45 | @Override 46 | protected void invoke( Class c ) 47 | throws Exception 48 | { 49 | getRuntime().getConstructors( c ); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/benchmarks/java/org/apache/commons/ognl/performance/invocation/GetDeclaredMethodsInvocation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | */ 20 | 21 | package org.apache.commons.ognl.performance.invocation; 22 | 23 | import org.apache.commons.ognl.performance.runtime.RuntimeWrapper; 24 | 25 | /** 26 | * User: mcucchiara 27 | * Date: 18/10/11 28 | * Time: 15.57 29 | */ 30 | public class GetDeclaredMethodsInvocation 31 | extends RepeatableInvocation 32 | { 33 | 34 | public GetDeclaredMethodsInvocation( RuntimeWrapper runtimeWrapper ) 35 | throws Exception 36 | { 37 | super( runtimeWrapper ); 38 | } 39 | 40 | public GetDeclaredMethodsInvocation( RuntimeWrapper runtimeWrapper, int times ) 41 | throws Exception 42 | { 43 | super( runtimeWrapper, times ); 44 | } 45 | 46 | @Override 47 | protected void invoke( Class c ) 48 | throws Exception 49 | { 50 | getRuntime().getDeclaredMethods( c, "class", false ); 51 | getRuntime().getDeclaredMethods( c, "class", true ); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/benchmarks/java/org/apache/commons/ognl/performance/invocation/GetMethodsInvocation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | */ 20 | 21 | package org.apache.commons.ognl.performance.invocation; 22 | 23 | import org.apache.commons.ognl.performance.runtime.RuntimeWrapper; 24 | 25 | /** 26 | * User: mcucchiara 27 | * Date: 18/10/11 28 | * Time: 15.57 29 | */ 30 | public class GetMethodsInvocation 31 | extends RepeatableInvocation 32 | { 33 | 34 | public GetMethodsInvocation( RuntimeWrapper runtimeWrapper ) 35 | throws Exception 36 | { 37 | super( runtimeWrapper ); 38 | } 39 | 40 | public GetMethodsInvocation( RuntimeWrapper runtimeWrapper, int times ) 41 | throws Exception 42 | { 43 | super( runtimeWrapper, times ); 44 | } 45 | 46 | @Override 47 | protected void invoke( Class c ) 48 | throws Exception 49 | { 50 | getRuntime().getMethods( c, false ); 51 | getRuntime().getMethods( c, true ); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/benchmarks/java/org/apache/commons/ognl/performance/invocation/InvokeMethodInvocation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | */ 20 | 21 | package org.apache.commons.ognl.performance.invocation; 22 | 23 | import org.apache.commons.ognl.performance.runtime.RuntimeWrapper; 24 | 25 | import java.lang.reflect.Method; 26 | 27 | /** 28 | * User: mcucchiara 29 | * Date: 18/10/11 30 | * Time: 16.45 31 | */ 32 | public class InvokeMethodInvocation 33 | extends RepeatableInvocation 34 | { 35 | public InvokeMethodInvocation( RuntimeWrapper runtimeWrapper ) 36 | throws Exception 37 | { 38 | super( runtimeWrapper ); 39 | } 40 | 41 | public InvokeMethodInvocation( RuntimeWrapper runtimeWrapper, int times ) 42 | throws Exception 43 | { 44 | super( runtimeWrapper, times ); 45 | } 46 | 47 | @Override 48 | protected void invoke( Class c ) 49 | throws Exception 50 | { 51 | Object o; 52 | o = c.newInstance(); 53 | 54 | Method toString = c.getMethod( "toString" ); 55 | getRuntime().invokeMethod( o, toString, new Object[0] ); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/benchmarks/java/org/apache/commons/ognl/performance/invocation/PermissionInvocation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | */ 20 | 21 | package org.apache.commons.ognl.performance.invocation; 22 | 23 | import org.apache.commons.ognl.performance.runtime.RuntimeWrapper; 24 | 25 | import java.lang.reflect.Method; 26 | 27 | /** 28 | * User: mcucchiara 29 | * Date: 18/10/11 30 | * Time: 16.25 31 | */ 32 | public class PermissionInvocation 33 | extends RepeatableInvocation 34 | { 35 | 36 | public PermissionInvocation( RuntimeWrapper runtimeWrapper ) 37 | throws Exception 38 | { 39 | super( runtimeWrapper ); 40 | } 41 | 42 | public PermissionInvocation( RuntimeWrapper runtimeWrapper, int times ) 43 | throws Exception 44 | { 45 | super( runtimeWrapper, times ); 46 | } 47 | 48 | @Override 49 | protected void invoke( Class c ) 50 | throws Exception 51 | { 52 | Method[] methods = c.getMethods(); 53 | for ( Method method : methods ) 54 | { 55 | getRuntime().getPermission( method ); 56 | } 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/benchmarks/java/org/apache/commons/ognl/performance/invocation/PrimitiveDefaultInvocation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | */ 20 | 21 | package org.apache.commons.ognl.performance.invocation; 22 | 23 | import org.apache.commons.ognl.performance.runtime.RuntimeWrapper; 24 | 25 | /** 26 | * User: Maurizio Cucchiara 27 | * Date: 10/22/11 28 | * Time: 1:02 AM 29 | */ 30 | public class PrimitiveDefaultInvocation 31 | extends RepeatableInvocation 32 | { 33 | public PrimitiveDefaultInvocation( RuntimeWrapper runtimeWrapper ) 34 | throws Exception 35 | { 36 | super( runtimeWrapper ); 37 | } 38 | 39 | public PrimitiveDefaultInvocation( RuntimeWrapper runtimeWrapper, int times ) 40 | throws Exception 41 | { 42 | super( runtimeWrapper, times ); 43 | } 44 | 45 | @Override 46 | protected void invoke( Class c ) 47 | throws Exception 48 | { 49 | getRuntime().getPrimitiveDefaultValue( c ); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/benchmarks/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/main/assembly/src.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 21 | src 22 | 23 | tar.gz 24 | zip 25 | 26 | ${project.build.finalName}-src 27 | 28 | 29 | ${basedir} 30 | 31 | **/.classpath 32 | **/.project 33 | **/.settings/ 34 | **/doap_*.rdf 35 | **/bin/ 36 | **/.externalToolBuilders/ 37 | **/${project.build.directory}/ 38 | **/download*.cgi 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/ASTDivide.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | */ 24 | class ASTDivide 25 | extends NumericExpression 26 | { 27 | public ASTDivide( int id ) 28 | { 29 | super( id ); 30 | } 31 | 32 | public ASTDivide( OgnlParser p, int id ) 33 | { 34 | super( p, id ); 35 | } 36 | 37 | protected Object getValueBody( OgnlContext context, Object source ) 38 | throws OgnlException 39 | { 40 | Object v1 = children[0].getValue( context, source ); 41 | Object v2 = children[1].getValue( context, source ); 42 | return OgnlOps.divide( v1, v2 ); 43 | } 44 | 45 | public String getExpressionOperator( int index ) 46 | { 47 | return "/"; 48 | } 49 | 50 | public R accept( NodeVisitor visitor, P data ) 51 | throws OgnlException 52 | { 53 | return visitor.visit( this, data ); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/ASTKeyValue.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | */ 24 | class ASTKeyValue 25 | extends SimpleNode 26 | { 27 | public ASTKeyValue( int id ) 28 | { 29 | super( id ); 30 | } 31 | 32 | public ASTKeyValue( OgnlParser p, int id ) 33 | { 34 | super( p, id ); 35 | } 36 | 37 | protected Node getKey() 38 | { 39 | return children[0]; 40 | } 41 | 42 | protected Node getValue() 43 | { 44 | return ( jjtGetNumChildren() > 1 ) ? children[1] : null; 45 | } 46 | 47 | /** 48 | * Returns null because this is a parser construct and does not evaluate 49 | */ 50 | protected Object getValueBody( OgnlContext context, Object source ) 51 | throws OgnlException 52 | { 53 | return null; 54 | } 55 | 56 | public R accept( NodeVisitor visitor, P data ) 57 | throws OgnlException 58 | { 59 | return visitor.visit( this, data ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/ASTNegate.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | */ 24 | class ASTNegate 25 | extends NumericExpression 26 | { 27 | public ASTNegate( int id ) 28 | { 29 | super( id ); 30 | } 31 | 32 | public ASTNegate( OgnlParser p, int id ) 33 | { 34 | super( p, id ); 35 | } 36 | 37 | protected Object getValueBody( OgnlContext context, Object source ) 38 | throws OgnlException 39 | { 40 | return OgnlOps.negate( children[0].getValue( context, source ) ); 41 | } 42 | 43 | public String toGetSourceString( OgnlContext context, Object target ) 44 | { 45 | String source = children[0].toGetSourceString( context, target ); 46 | 47 | if ( !(children[0] instanceof ASTNegate)) 48 | { 49 | return "-" + source; 50 | } 51 | return "-(" + source + ")"; 52 | } 53 | 54 | public R accept( NodeVisitor visitor, P data ) 55 | throws OgnlException 56 | { 57 | return visitor.visit( this, data ); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/ASTRemainder.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | */ 24 | class ASTRemainder 25 | extends NumericExpression 26 | { 27 | public ASTRemainder( int id ) 28 | { 29 | super( id ); 30 | } 31 | 32 | public ASTRemainder( OgnlParser p, int id ) 33 | { 34 | super( p, id ); 35 | } 36 | 37 | protected Object getValueBody( OgnlContext context, Object source ) 38 | throws OgnlException 39 | { 40 | Object v1 = children[0].getValue( context, source ); 41 | Object v2 = children[1].getValue( context, source ); 42 | return OgnlOps.remainder( v1, v2 ); 43 | } 44 | 45 | public String getExpressionOperator( int index ) 46 | { 47 | return "%"; 48 | } 49 | 50 | public R accept( NodeVisitor visitor, P data ) 51 | throws OgnlException 52 | { 53 | return visitor.visit( this, data ); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/ASTShiftLeft.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | */ 24 | class ASTShiftLeft 25 | extends NumericExpression 26 | { 27 | public ASTShiftLeft( int id ) 28 | { 29 | super( id ); 30 | } 31 | 32 | public ASTShiftLeft( OgnlParser p, int id ) 33 | { 34 | super( p, id ); 35 | } 36 | 37 | protected Object getValueBody( OgnlContext context, Object source ) 38 | throws OgnlException 39 | { 40 | Object v1 = children[0].getValue( context, source ); 41 | Object v2 = children[1].getValue( context, source ); 42 | return OgnlOps.shiftLeft( v1, v2 ); 43 | } 44 | 45 | public String getExpressionOperator( int index ) 46 | { 47 | return "<<"; 48 | } 49 | 50 | public R accept( NodeVisitor visitor, P data ) 51 | throws OgnlException 52 | { 53 | return visitor.visit( this, data ); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/ASTShiftRight.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | */ 24 | class ASTShiftRight 25 | extends NumericExpression 26 | { 27 | public ASTShiftRight( int id ) 28 | { 29 | super( id ); 30 | } 31 | 32 | public ASTShiftRight( OgnlParser p, int id ) 33 | { 34 | super( p, id ); 35 | } 36 | 37 | protected Object getValueBody( OgnlContext context, Object source ) 38 | throws OgnlException 39 | { 40 | Object v1 = children[0].getValue( context, source ); 41 | Object v2 = children[1].getValue( context, source ); 42 | return OgnlOps.shiftRight( v1, v2 ); 43 | } 44 | 45 | public String getExpressionOperator( int index ) 46 | { 47 | return ">>"; 48 | } 49 | 50 | public R accept( NodeVisitor visitor, P data ) 51 | throws OgnlException 52 | { 53 | return visitor.visit( this, data ); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/ASTSubtract.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | */ 24 | class ASTSubtract 25 | extends NumericExpression 26 | { 27 | public ASTSubtract( int id ) 28 | { 29 | super( id ); 30 | } 31 | 32 | public ASTSubtract( OgnlParser p, int id ) 33 | { 34 | super( p, id ); 35 | } 36 | 37 | protected Object getValueBody( OgnlContext context, Object source ) 38 | throws OgnlException 39 | { 40 | Object v1 = children[0].getValue( context, source ); 41 | Object v2 = children[1].getValue( context, source ); 42 | return OgnlOps.subtract( v1, v2 ); 43 | } 44 | 45 | public String getExpressionOperator( int index ) 46 | { 47 | return "-"; 48 | } 49 | 50 | public R accept( NodeVisitor visitor, P data ) 51 | throws OgnlException 52 | { 53 | return visitor.visit( this, data ); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/ArrayElementsAccessor.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import java.lang.reflect.Array; 23 | import java.util.Enumeration; 24 | 25 | /** 26 | * Implementation of ElementsAccessor that returns an iterator over a Java array. 27 | */ 28 | public class ArrayElementsAccessor 29 | implements ElementsAccessor 30 | { 31 | /** 32 | * {@inheritDoc} 33 | */ 34 | public Enumeration getElements( final Object target ) 35 | { 36 | return new Enumeration() 37 | { 38 | private final int count = Array.getLength( target ); 39 | 40 | private int index; 41 | 42 | public boolean hasMoreElements() 43 | { 44 | return index < count; 45 | } 46 | 47 | public Object nextElement() 48 | { 49 | return Array.get( target, index++ ); 50 | } 51 | }; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/ClassCacheInspector.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | * Optional interface that may be registered with {@link OgnlRuntime#setClassCacheInspector(ClassCacheInspector)} as a 24 | * means to disallow caching of specific class types. 25 | */ 26 | public interface ClassCacheInspector 27 | { 28 | 29 | /** 30 | * Invoked just before storing a class type within a cache instance. 31 | * 32 | * @param type The class that is to be stored. 33 | * @return True if the class can be cached, false otherwise. 34 | */ 35 | boolean shouldCache( Class type ); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/ClassResolver.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import java.util.Map; 23 | 24 | /** 25 | * This interface defines an object that will resolve a class from a string and an ognl context table. 26 | */ 27 | public interface ClassResolver 28 | { 29 | Class classForName( String className, Map context ) 30 | throws ClassNotFoundException; 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/CollectionElementsAccessor.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import static org.apache.commons.ognl.IteratorEnumeration.newEnumeration; 23 | 24 | import java.util.Collection; 25 | import java.util.Enumeration; 26 | 27 | /** 28 | * Implementation of ElementsAccessor that returns a collection's iterator. 29 | */ 30 | public class CollectionElementsAccessor 31 | implements ElementsAccessor 32 | { 33 | /** 34 | * {@inheritDoc} 35 | */ 36 | public Enumeration getElements( Object target ) 37 | { 38 | return newEnumeration( ( (Collection) target ).iterator() ); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/DefaultTypeConverter.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import java.lang.reflect.Member; 23 | import java.util.Map; 24 | 25 | /** 26 | * Default type conversion. Converts among numeric types and also strings. 27 | */ 28 | public class DefaultTypeConverter 29 | implements TypeConverter 30 | { 31 | 32 | public T convertValue( Map context, Object value, Class toType ) 33 | { 34 | @SuppressWarnings( "unchecked" ) // type checking performed in OgnlOps.convertValue( value, toType ) 35 | T ret = (T) OgnlOps.convertValue( value, toType ); 36 | return ret; 37 | } 38 | 39 | /** 40 | * {@inheritDoc} 41 | */ 42 | public T convertValue( Map context, Object target, Member member, String propertyName, 43 | Object value, Class toType ) 44 | { 45 | return convertValue( context, value, toType ); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/EnumerationElementsAccessor.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import java.util.Enumeration; 23 | 24 | /** 25 | * Implementation of the ElementsAccessor interface for Enumerations, which returns an iterator that passes its calls 26 | * through to the target Enumeration. 27 | */ 28 | public class EnumerationElementsAccessor 29 | implements ElementsAccessor 30 | { 31 | /** 32 | * {@inheritDoc} 33 | */ 34 | public Enumeration getElements( Object target ) 35 | { 36 | return (Enumeration) target; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/EnumerationIterator.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import java.util.Enumeration; 23 | import java.util.Iterator; 24 | 25 | /** 26 | * Object that implements Iterator from an Enumeration 27 | */ 28 | public class EnumerationIterator 29 | implements Iterator 30 | { 31 | 32 | public static Iterator newIterator( Enumeration e ) 33 | { 34 | return new EnumerationIterator( e ); 35 | } 36 | 37 | private final Enumeration e; 38 | 39 | public EnumerationIterator( Enumeration e ) 40 | { 41 | this.e = e; 42 | } 43 | 44 | public boolean hasNext() 45 | { 46 | return e.hasMoreElements(); 47 | } 48 | 49 | public E next() 50 | { 51 | return e.nextElement(); 52 | } 53 | 54 | public void remove() 55 | { 56 | throw new UnsupportedOperationException( "remove() not supported by Enumeration" ); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/ExpressionSyntaxException.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | * Exception thrown if a malformed OGNL expression is encountered. 24 | */ 25 | public class ExpressionSyntaxException 26 | extends OgnlException 27 | { 28 | 29 | private static final long serialVersionUID = 3828005676770762146L; 30 | 31 | public ExpressionSyntaxException( String expression, Throwable reason ) 32 | { 33 | super( "Malformed OGNL expression: " + expression, reason ); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/InappropriateExpressionException.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | * Exception thrown if an OGNL expression is evaluated in the wrong context; the usual case is when an expression that 24 | * does not end in a property reference is passed to setValue. 25 | */ 26 | public class InappropriateExpressionException 27 | extends OgnlException 28 | { 29 | 30 | private static final long serialVersionUID = -101395753764475977L; 31 | 32 | public InappropriateExpressionException( Node tree ) 33 | { 34 | super( "Inappropriate OGNL expression: " + tree ); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/IteratorElementsAccessor.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import static org.apache.commons.ognl.IteratorEnumeration.newEnumeration; 23 | 24 | import java.util.Enumeration; 25 | import java.util.Iterator; 26 | 27 | /** 28 | * Implementation of the ElementsAccessor interface for Iterators, which simply returns the target iterator itself. 29 | */ 30 | public class IteratorElementsAccessor 31 | implements ElementsAccessor 32 | { 33 | /** 34 | * {@inheritDoc} 35 | */ 36 | public Enumeration getElements( Object target ) 37 | { 38 | return newEnumeration( (Iterator) target ); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/IteratorEnumeration.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import java.util.Enumeration; 23 | import java.util.Iterator; 24 | 25 | /** 26 | * Maps an Iterator to an Enumeration 27 | */ 28 | public class IteratorEnumeration 29 | implements Enumeration 30 | { 31 | 32 | public static Enumeration newEnumeration( Iterator iterator ) 33 | { 34 | return new IteratorEnumeration( iterator ); 35 | } 36 | 37 | private final Iterator it; 38 | 39 | private IteratorEnumeration( Iterator it ) 40 | { 41 | this.it = it; 42 | } 43 | 44 | /** 45 | * {@inheritDoc} 46 | */ 47 | public boolean hasMoreElements() 48 | { 49 | return it.hasNext(); 50 | } 51 | 52 | /** 53 | * {@inheritDoc} 54 | */ 55 | public T nextElement() 56 | { 57 | return it.next(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/MapElementsAccessor.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import static org.apache.commons.ognl.IteratorEnumeration.newEnumeration; 23 | 24 | import java.util.Enumeration; 25 | import java.util.Map; 26 | 27 | /** 28 | * Implementation of ElementsAccessor that returns an iterator over the map's values. 29 | */ 30 | public class MapElementsAccessor 31 | implements ElementsAccessor 32 | { 33 | /** 34 | * {@inheritDoc} 35 | */ 36 | public Enumeration getElements( Object target ) 37 | { 38 | return newEnumeration( ( (Map) target ).values().iterator() ); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/MemberAccess.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import java.lang.reflect.Member; 23 | import java.util.Map; 24 | 25 | /** 26 | * This interface provides a hook for preparing for accessing members of objects. The Java2 version of this method can 27 | * allow access to otherwise inaccessible members, such as private fields. 28 | */ 29 | public interface MemberAccess 30 | { 31 | /** 32 | * Sets the member up for accessibility 33 | */ 34 | Object setup( Map context, Object target, Member member, String propertyName ); 35 | 36 | /** 37 | * Restores the member from the previous setup call. 38 | */ 39 | void restore( Map context, Object target, Member member, String propertyName, Object state ); 40 | 41 | /** 42 | * Returns true if the given member is accessible or can be made accessible by this object. 43 | */ 44 | boolean isAccessible( Map context, Object target, Member member, String propertyName ); 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/MethodFailedException.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import static java.lang.String.format; 23 | 24 | /** 25 | * Exception thrown if a method or constructor call fails. 26 | */ 27 | public class MethodFailedException 28 | extends OgnlException 29 | { 30 | private static final long serialVersionUID = -8537354635249153386L; 31 | 32 | public MethodFailedException( Object source, String name ) 33 | { 34 | super( format( "Method \"%s\" failed for object %s", name, source ) ); 35 | } 36 | 37 | public MethodFailedException( Object source, String name, Throwable reason ) 38 | { 39 | super( format( "Method \"%s\" failed for object %s", name, source ), reason ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/NodeType.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | * Used by some of the {@link ognl.enhance.OgnlExpressionCompiler} logic to determine the object type of {@link Node}s 24 | * during expression evaluation. 25 | */ 26 | public interface NodeType 27 | { 28 | /** 29 | * The type returned from the expression - if any. 30 | * 31 | * @return The type. 32 | */ 33 | Class getGetterClass(); 34 | 35 | /** 36 | * The type used to set the value - if any. 37 | * 38 | * @return The type. 39 | */ 40 | Class getSetterClass(); 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/NullHandler.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import java.util.Map; 23 | 24 | /** 25 | * Interface for handling null results from Chains. Object has the opportunity to substitute an object for the null and 26 | * continue. 27 | */ 28 | public interface NullHandler 29 | { 30 | /** 31 | * Method called on target returned null. 32 | */ 33 | Object nullMethodResult( Map context, Object target, String methodName, Object[] args ); 34 | 35 | /** 36 | * Property in target evaluated to null. Property can be a constant String property name or a DynamicSubscript. 37 | */ 38 | Object nullPropertyValue( Map context, Object target, Object property ); 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/NumericCasts.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import java.math.BigDecimal; 23 | import java.math.BigInteger; 24 | import java.util.HashMap; 25 | import java.util.Map; 26 | 27 | /** 28 | * Constant strings for casting different primitive types. 29 | */ 30 | class NumericCasts { 31 | 32 | private final Map, String> map = new HashMap, String>(); 33 | 34 | NumericCasts() { 35 | map.put( Double.class, "(double)" ); 36 | map.put( Float.class, "(float)" ); 37 | map.put( Integer.class, "(int)" ); 38 | map.put( Long.class, "(long)" ); 39 | map.put( BigDecimal.class, "(double)" ); 40 | map.put( BigInteger.class, "" ); 41 | } 42 | 43 | String get( Class cls ) { 44 | return map.get( cls ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/NumericDefaults.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import java.math.BigDecimal; 23 | import java.math.BigInteger; 24 | import java.util.HashMap; 25 | import java.util.Map; 26 | 27 | /** 28 | */ 29 | class NumericDefaults { 30 | 31 | private final Map, Object> NUMERIC_DEFAULTS = new HashMap, Object>(); 32 | 33 | NumericDefaults() { 34 | NUMERIC_DEFAULTS.put( Boolean.class, Boolean.FALSE ); 35 | NUMERIC_DEFAULTS.put( Byte.class, (byte) 0 ); 36 | NUMERIC_DEFAULTS.put( Short.class, (short) 0 ); 37 | NUMERIC_DEFAULTS.put( Character.class, (char) 0 ); 38 | NUMERIC_DEFAULTS.put( Integer.class, 0 ); 39 | NUMERIC_DEFAULTS.put( Long.class, 0L ); 40 | NUMERIC_DEFAULTS.put( Float.class, 0.0f ); 41 | NUMERIC_DEFAULTS.put( Double.class, 0.0 ); 42 | 43 | NUMERIC_DEFAULTS.put( BigInteger.class, BigInteger.ZERO ); 44 | NUMERIC_DEFAULTS.put( BigDecimal.class, BigDecimal.ZERO ); 45 | } 46 | 47 | Object get( Class cls ) { 48 | return NUMERIC_DEFAULTS.get( cls ); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/NumericLiterals.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import java.math.BigDecimal; 23 | import java.math.BigInteger; 24 | import java.util.HashMap; 25 | import java.util.Map; 26 | 27 | /** 28 | * Numeric primitive literal string expressions. 29 | */ 30 | class NumericLiterals { 31 | 32 | private final Map, String> map = new HashMap, String>(); 33 | 34 | NumericLiterals() { 35 | map.put( Integer.class, "" ); 36 | map.put( Integer.TYPE, "" ); 37 | map.put( Long.class, "l" ); 38 | map.put( Long.TYPE, "l" ); 39 | map.put( BigInteger.class, "d" ); 40 | map.put( Float.class, "f" ); 41 | map.put( Float.TYPE, "f" ); 42 | map.put( Double.class, "d" ); 43 | map.put( Double.TYPE, "d" ); 44 | map.put( BigInteger.class, "d" ); 45 | map.put( BigDecimal.class, "d" ); 46 | } 47 | 48 | String get( Class clazz ) { 49 | return map.get( clazz ); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/NumericValues.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import java.math.BigDecimal; 23 | import java.math.BigInteger; 24 | import java.util.HashMap; 25 | import java.util.Map; 26 | 27 | /** 28 | * Constant strings for getting the primitive value of different native types on the generic {@link Number} object 29 | * interface. (or the less generic BigDecimal/BigInteger types) 30 | */ 31 | class NumericValues { 32 | 33 | private final Map, String> map = new HashMap, String>(); 34 | 35 | NumericValues() { 36 | map.put( Double.class, "doubleValue()" ); 37 | map.put( Float.class, "floatValue()" ); 38 | map.put( Integer.class, "intValue()" ); 39 | map.put( Long.class, "longValue()" ); 40 | map.put( Short.class, "shortValue()" ); 41 | map.put( Byte.class, "byteValue()" ); 42 | map.put( BigDecimal.class, "doubleValue()" ); 43 | map.put( BigInteger.class, "doubleValue()" ); 44 | map.put( Boolean.class, "booleanValue()" ); 45 | } 46 | 47 | String get( Class cls ) { 48 | return map.get( cls ); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/ObjectElementsAccessor.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import java.util.Enumeration; 23 | 24 | /** 25 | * Implementation of ElementsAccessor that returns a single-element iterator, containing the original target object. 26 | */ 27 | public class ObjectElementsAccessor 28 | implements ElementsAccessor 29 | { 30 | /** 31 | * {@inheritDoc} 32 | */ 33 | public Enumeration getElements( Object target ) 34 | { 35 | final Object object = target; 36 | 37 | return new Enumeration() 38 | { 39 | private boolean seen; 40 | 41 | public boolean hasMoreElements() 42 | { 43 | return !seen; 44 | } 45 | 46 | public Object nextElement() 47 | { 48 | Object result = null; 49 | 50 | if ( !seen ) 51 | { 52 | result = object; 53 | seen = true; 54 | } 55 | return result; 56 | } 57 | }; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/ObjectNullHandler.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import java.util.Map; 23 | 24 | /** 25 | * Implementation of NullHandler that returns null in all cases, so that NullPointerException will be thrown by the 26 | * caller. 27 | */ 28 | public class ObjectNullHandler 29 | implements NullHandler 30 | { 31 | /* NullHandler interface */ 32 | public Object nullMethodResult( Map context, Object target, String methodName, Object[] args ) 33 | { 34 | return null; 35 | } 36 | 37 | public Object nullPropertyValue( Map context, Object target, Object property ) 38 | { 39 | return null; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/OgnlInvokePermission.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import java.security.BasicPermission; 23 | 24 | /** 25 | * BasicPermission subclass that defines a permission token for invoking methods within OGNL. This does not override any 26 | * methods (except constructors) and does not implement actions. It is similar in spirit to the 27 | * {@link java.lang.reflect.ReflectPermission} class in that it guards access to methods. 28 | */ 29 | public class OgnlInvokePermission 30 | extends BasicPermission 31 | { 32 | 33 | private static final long serialVersionUID = 1L; 34 | 35 | public OgnlInvokePermission( String name ) 36 | { 37 | super( name ); 38 | } 39 | 40 | public OgnlInvokePermission( String name, String actions ) 41 | { 42 | super( name, actions ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/PrimitiveDefaults.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import java.math.BigDecimal; 23 | import java.math.BigInteger; 24 | import java.util.HashMap; 25 | import java.util.Map; 26 | 27 | /** 28 | */ 29 | class PrimitiveDefaults { 30 | 31 | private final Map, Object> map = new HashMap, Object>( 20 ); 32 | 33 | PrimitiveDefaults() { 34 | map.put( Boolean.TYPE, Boolean.FALSE ); 35 | map.put( Boolean.class, Boolean.FALSE ); 36 | map.put( Byte.TYPE, (byte) 0 ); 37 | map.put( Byte.class, (byte) 0 ); 38 | map.put( Short.TYPE, (short) 0 ); 39 | map.put( Short.class, (short) 0 ); 40 | map.put( Character.TYPE, (char) 0 ); 41 | map.put( Integer.TYPE, 0 ); 42 | map.put( Long.TYPE, 0L ); 43 | map.put( Float.TYPE, 0.0f ); 44 | map.put( Double.TYPE, 0.0 ); 45 | 46 | map.put( BigInteger.class, BigInteger.ZERO ); 47 | map.put( BigDecimal.class, BigDecimal.ZERO ); 48 | } 49 | 50 | Object get( Class cls ) { 51 | return map.get( cls ); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/PrimitiveTypes.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import java.util.HashMap; 23 | import java.util.Map; 24 | 25 | /** 26 | */ 27 | class PrimitiveTypes { 28 | 29 | private final Map> map = new HashMap>( 101 ); 30 | 31 | PrimitiveTypes() { 32 | map.put( "boolean", Boolean.TYPE ); 33 | map.put( "byte", Byte.TYPE ); 34 | map.put( "short", Short.TYPE ); 35 | map.put( "char", Character.TYPE ); 36 | map.put( "int", Integer.TYPE ); 37 | map.put( "long", Long.TYPE ); 38 | map.put( "float", Float.TYPE ); 39 | map.put( "double", Double.TYPE ); 40 | } 41 | 42 | Class get(String className) { 43 | return map.get(className); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/enhance/EnhancedClassLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.commons.ognl.enhance; 21 | 22 | public class EnhancedClassLoader 23 | extends ClassLoader 24 | { 25 | /* 26 | * =================================================================== Constructors 27 | * =================================================================== 28 | */ 29 | public EnhancedClassLoader( ClassLoader parentClassLoader ) 30 | { 31 | super( parentClassLoader ); 32 | } 33 | 34 | /* 35 | * =================================================================== Overridden methods 36 | * =================================================================== 37 | */ 38 | public Class defineClass( String enhancedClassName, byte[] byteCode ) 39 | { 40 | return defineClass( enhancedClassName, byteCode, 0, byteCode.length ); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/enhance/LocalReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.commons.ognl.enhance; 21 | 22 | /** 23 | * Container class for {@link OgnlExpressionCompiler} generated local method block references. 24 | */ 25 | public interface LocalReference 26 | { 27 | 28 | /** 29 | * The name of the assigned variable reference. 30 | * 31 | * @return The name of the reference as it will be when compiled. 32 | */ 33 | String getName(); 34 | 35 | /** 36 | * The expression that sets the value, ie the part after refName = . 37 | * 38 | * @return The setting expression. 39 | */ 40 | String getExpression(); 41 | 42 | /** 43 | * The type of reference. 44 | * 45 | * @return The type. 46 | */ 47 | Class getType(); 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/enhance/OrderedReturn.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.commons.ognl.enhance; 21 | 22 | /** 23 | * Marks an ognl expression {@link org.apache.commons.ognl.Node} as needing to have the return portion of a getter 24 | * method happen in a specific 25 | * part of the generated expression vs just having the whole expression returned in one chunk. 26 | */ 27 | public interface OrderedReturn 28 | { 29 | 30 | /** 31 | * Gets the core expression to execute first before any return foo logic is started. 32 | * 33 | * @return The core standalone expression that shouldn't be pre-pended with a return keyword. 34 | */ 35 | String getCoreExpression(); 36 | 37 | /** 38 | * Gets the last expression to be pre-pended with a return <expression> block. 39 | * 40 | * @return The expression representing the return portion of a statement; 41 | */ 42 | String getLastExpression(); 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/enhance/UnsupportedCompilationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.commons.ognl.enhance; 21 | 22 | /** 23 | * Thrown during bytecode enhancement conversions of ognl expressions to indicate that a certain expression isn't 24 | * currently supported as a pure Java bytecode enhanced version. 25 | *

26 | * If this exception is thrown it is expected that ognl will fall back to default ognl evaluation of the expression. 27 | *

28 | */ 29 | public class UnsupportedCompilationException 30 | extends RuntimeException 31 | { 32 | 33 | /** 34 | */ 35 | private static final long serialVersionUID = 4961625077128174947L; 36 | 37 | public UnsupportedCompilationException( String message ) 38 | { 39 | super( message ); 40 | } 41 | 42 | public UnsupportedCompilationException( String message, Throwable cause ) 43 | { 44 | super( message, cause ); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/enhance/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.commons.ognl.enhance; 21 | 22 | /* 23 | * Enhanced basic Java components. 24 | */ 25 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/internal/Cache.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl.internal; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | */ 24 | public interface Cache 25 | { 26 | void clear(); 27 | 28 | int getSize(); 29 | 30 | V get( K key ) 31 | throws CacheException; 32 | 33 | V put( K key, V value ); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/internal/CacheException.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl.internal; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /* 23 | */ 24 | public class CacheException 25 | extends RuntimeException 26 | { 27 | public CacheException( Throwable e ) 28 | { 29 | super( e.getMessage(), e ); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/internal/CacheFactory.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl.internal; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import org.apache.commons.ognl.internal.entry.CacheEntryFactory; 23 | import org.apache.commons.ognl.internal.entry.ClassCacheEntryFactory; 24 | 25 | /** 26 | * User: Maurizio Cucchiara 27 | * Date: 10/22/11 28 | * Time: 1:35 AM 29 | */ 30 | public interface CacheFactory 31 | { 32 | Cache createCache( CacheEntryFactory entryFactory ); 33 | 34 | ClassCache createClassCache(); 35 | 36 | ClassCache createClassCache( ClassCacheEntryFactory entryFactory ); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/internal/ClassCache.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl.internal; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /* 23 | */ 24 | import org.apache.commons.ognl.ClassCacheInspector; 25 | 26 | /** 27 | * This is a highly specialized map for storing values keyed by Class objects. 28 | */ 29 | public interface ClassCache 30 | extends Cache, V> 31 | { 32 | void setClassInspector( ClassCacheInspector inspector ); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/internal/ConcurrentHashMapCacheFactory.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl.internal; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /* 23 | */ 24 | 25 | import org.apache.commons.ognl.internal.entry.CacheEntryFactory; 26 | import org.apache.commons.ognl.internal.entry.ClassCacheEntryFactory; 27 | 28 | public class ConcurrentHashMapCacheFactory 29 | implements CacheFactory 30 | { 31 | 32 | public Cache createCache( CacheEntryFactory entryFactory ) 33 | { 34 | return new ConcurrentHashMapCache( entryFactory ); 35 | } 36 | 37 | public ClassCache createClassCache() 38 | { 39 | return createClassCache( null ); 40 | } 41 | 42 | public ClassCache createClassCache( ClassCacheEntryFactory entryFactory ) 43 | { 44 | return new ConcurrentHashMapClassCache( entryFactory ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/internal/ConcurrentHashMapClassCache.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl.internal; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import org.apache.commons.ognl.ClassCacheInspector; 23 | import org.apache.commons.ognl.internal.entry.CacheEntryFactory; 24 | 25 | /* 26 | */ 27 | 28 | public class ConcurrentHashMapClassCache 29 | extends ConcurrentHashMapCache, T> 30 | implements ClassCache 31 | { 32 | private ClassCacheInspector inspector; 33 | 34 | public ConcurrentHashMapClassCache( CacheEntryFactory, T> entryFactory ) 35 | { 36 | super( entryFactory ); 37 | } 38 | 39 | public void setClassInspector( ClassCacheInspector inspector ) 40 | { 41 | this.inspector = inspector; 42 | } 43 | 44 | @Override 45 | public T put( Class key, T value ) 46 | { 47 | if ( inspector != null && !inspector.shouldCache( key ) ) 48 | { 49 | return value; 50 | } 51 | return super.put( key, value ); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/internal/HashMapCacheFactory.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl.internal; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /* 23 | */ 24 | 25 | import org.apache.commons.ognl.internal.entry.CacheEntryFactory; 26 | import org.apache.commons.ognl.internal.entry.ClassCacheEntryFactory; 27 | 28 | public class HashMapCacheFactory 29 | implements CacheFactory 30 | { 31 | public Cache createCache( CacheEntryFactory entryFactory ) 32 | { 33 | return new HashMapCache( entryFactory ); 34 | } 35 | 36 | public ClassCache createClassCache() 37 | { 38 | return createClassCache( null ); 39 | } 40 | 41 | public ClassCache createClassCache( ClassCacheEntryFactory entryFactory ) 42 | { 43 | return new HashMapClassCache( entryFactory ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/internal/HashMapClassCache.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl.internal; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /* 23 | */ 24 | 25 | import org.apache.commons.ognl.ClassCacheInspector; 26 | import org.apache.commons.ognl.internal.entry.CacheEntryFactory; 27 | 28 | public class HashMapClassCache 29 | extends HashMapCache,T> 30 | implements ClassCache 31 | { 32 | private ClassCacheInspector inspector; 33 | 34 | public HashMapClassCache( CacheEntryFactory, T> entryFactory ) 35 | { 36 | super( entryFactory ); 37 | } 38 | 39 | public void setClassInspector( ClassCacheInspector inspector ) 40 | { 41 | this.inspector = inspector; 42 | } 43 | 44 | public T put( Class key, T value ) 45 | { 46 | if ( inspector != null && !inspector.shouldCache( key ) ) 47 | { 48 | return value; 49 | } 50 | return super.put( key, value ); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/internal/ReentrantReadWriteLockCacheFactory.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl.internal; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /* 23 | */ 24 | 25 | import org.apache.commons.ognl.internal.entry.CacheEntryFactory; 26 | import org.apache.commons.ognl.internal.entry.ClassCacheEntryFactory; 27 | 28 | public class ReentrantReadWriteLockCacheFactory 29 | implements CacheFactory 30 | { 31 | public Cache createCache( CacheEntryFactory entryFactory ) 32 | { 33 | return new ReentrantReadWriteLockCache( entryFactory ); 34 | } 35 | 36 | public ClassCache createClassCache() 37 | { 38 | return createClassCache( null ); 39 | } 40 | 41 | public ClassCache createClassCache( ClassCacheEntryFactory entryFactory ) 42 | { 43 | return new ReentrantReadWriteLockClassCache( entryFactory ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/internal/ReentrantReadWriteLockClassCache.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl.internal; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /* 23 | */ 24 | 25 | import org.apache.commons.ognl.ClassCacheInspector; 26 | import org.apache.commons.ognl.internal.entry.CacheEntryFactory; 27 | 28 | public class ReentrantReadWriteLockClassCache 29 | extends HashMapCache, T> 30 | implements ClassCache 31 | { 32 | private ClassCacheInspector inspector; 33 | 34 | public ReentrantReadWriteLockClassCache( CacheEntryFactory, T> entryFactory ) 35 | { 36 | super( entryFactory ); 37 | } 38 | 39 | public void setClassInspector( ClassCacheInspector inspector ) 40 | { 41 | this.inspector = inspector; 42 | } 43 | 44 | public T put( Class key, T value ) 45 | { 46 | if ( inspector != null && !inspector.shouldCache( key ) ) 47 | { 48 | return value; 49 | } 50 | return super.put( key, value ); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/internal/entry/CacheEntry.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl.internal.entry; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /* 23 | */ 24 | 25 | public interface CacheEntry 26 | { 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/internal/entry/CacheEntryFactory.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl.internal.entry; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /* 23 | */ 24 | 25 | import org.apache.commons.ognl.internal.CacheException; 26 | 27 | public interface CacheEntryFactory 28 | { 29 | V create( K key ) 30 | throws CacheException; 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/internal/entry/ClassCacheEntryFactory.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl.internal.entry; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /* 23 | */ 24 | 25 | public interface ClassCacheEntryFactory 26 | extends CacheEntryFactory, T> 27 | { 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/internal/entry/DeclaredMethodCacheEntryFactory.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl.internal.entry; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /* 23 | */ 24 | 25 | import java.lang.reflect.Method; 26 | import java.lang.reflect.Modifier; 27 | 28 | /** 29 | * User: mcucchiara 30 | * Date: 13/10/11 31 | * Time: 13.00 32 | */ 33 | public class DeclaredMethodCacheEntryFactory 34 | extends MethodCacheEntryFactory 35 | { 36 | @Override 37 | protected boolean shouldCache( DeclaredMethodCacheEntry key, Method method ) 38 | { 39 | if ( key.type == null ) 40 | { 41 | return true; 42 | } 43 | boolean isStatic = Modifier.isStatic( method.getModifiers() ); 44 | if ( key.type == DeclaredMethodCacheEntry.MethodType.STATIC ) 45 | { 46 | return isStatic; 47 | } 48 | return !isStatic; 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/internal/entry/FieldCacheEntryFactory.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl.internal.entry; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /* 23 | * $Id: FiedlCacheEntryFactory.java 1194954 2011-10-29 18:00:27Z mcucchiara $ 24 | */ 25 | 26 | import org.apache.commons.ognl.internal.CacheException; 27 | 28 | import java.lang.reflect.Field; 29 | import java.util.HashMap; 30 | import java.util.Map; 31 | 32 | public class FieldCacheEntryFactory 33 | implements ClassCacheEntryFactory> 34 | { 35 | public Map create( Class key ) 36 | throws CacheException 37 | { 38 | Field[] declaredFields = key.getDeclaredFields(); 39 | Map result = new HashMap( declaredFields.length ); 40 | for ( Field field : declaredFields ) 41 | { 42 | result.put( field.getName(), field ); 43 | } 44 | return result; 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/internal/entry/MethodAccessEntryValue.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl.internal.entry; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /* 23 | */ 24 | 25 | public class MethodAccessEntryValue 26 | { 27 | private final boolean isAccessible; 28 | 29 | private boolean notPublic; 30 | 31 | public MethodAccessEntryValue( boolean accessible ) 32 | { 33 | this.isAccessible = accessible; 34 | } 35 | 36 | public MethodAccessEntryValue( boolean accessible, boolean notPublic ) 37 | { 38 | isAccessible = accessible; 39 | this.notPublic = notPublic; 40 | } 41 | 42 | public boolean isAccessible() 43 | { 44 | return isAccessible; 45 | } 46 | 47 | public boolean isNotPublic() 48 | { 49 | return notPublic; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/internal/entry/MethodCacheEntry.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl.internal.entry; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /* 23 | */ 24 | 25 | public class MethodCacheEntry 26 | implements CacheEntry 27 | { 28 | public final Class targetClass; 29 | 30 | public MethodCacheEntry( Class targetClass ) 31 | { 32 | this.targetClass = targetClass; 33 | } 34 | 35 | @Override 36 | public boolean equals( Object o ) 37 | { 38 | if ( this == o ) 39 | { 40 | return true; 41 | } 42 | if ( !( o instanceof MethodCacheEntry ) ) 43 | { 44 | return false; 45 | } 46 | 47 | MethodCacheEntry that = (MethodCacheEntry) o; 48 | 49 | return targetClass.equals( that.targetClass ); 50 | 51 | } 52 | 53 | @Override 54 | public int hashCode() 55 | { 56 | return targetClass.hashCode(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/internal/entry/ParametrizedCacheEntryFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | */ 20 | 21 | package org.apache.commons.ognl.internal.entry; 22 | 23 | import java.util.Map; 24 | 25 | public interface ParametrizedCacheEntryFactory 26 | { 27 | void setParameterValues( Map parameters ); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/internal/entry/PermissionCacheEntry.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl.internal.entry; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /* 23 | */ 24 | 25 | import java.lang.reflect.Method; 26 | 27 | public class PermissionCacheEntry 28 | implements CacheEntry 29 | { 30 | public final Method method; 31 | 32 | public PermissionCacheEntry( Method method ) 33 | { 34 | this.method = method; 35 | } 36 | 37 | @Override 38 | public boolean equals( Object o ) 39 | { 40 | if ( this == o ) 41 | { 42 | return true; 43 | } 44 | if ( !( o instanceof PermissionCacheEntry ) ) 45 | { 46 | return false; 47 | } 48 | 49 | PermissionCacheEntry that = (PermissionCacheEntry) o; 50 | 51 | return !( method != null ? !method.equals( that.method ) : that.method != null ); 52 | 53 | } 54 | 55 | @Override 56 | public int hashCode() 57 | { 58 | return method != null ? method.hashCode() : 0; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/internal/entry/PermissionCacheEntryFactory.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl.internal.entry; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /* 23 | */ 24 | 25 | import org.apache.commons.ognl.OgnlInvokePermission; 26 | import org.apache.commons.ognl.internal.CacheException; 27 | 28 | import java.security.Permission; 29 | 30 | public class PermissionCacheEntryFactory 31 | implements CacheEntryFactory 32 | { 33 | 34 | public Permission create( PermissionCacheEntry key ) 35 | throws CacheException 36 | { 37 | return new OgnlInvokePermission( 38 | "invoke." + key.method.getDeclaringClass().getName() + "." + key.method.getName() ); 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/internal/package-info.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl.internal; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | * Internal stuff only, users don't need to take this package in consideration. 24 | */ 25 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/ognl/package-info.java: -------------------------------------------------------------------------------- 1 | package org.apache.commons.ognl; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | * OGNL stands for Object-Graph Navigation Language; it is an expression language 24 | * for getting and setting properties of Java objects. You use the same expression 25 | * for both getting and setting the value of a property. 26 | * 27 | * OGNL started out as a way to set up associations between UI 28 | * components and controllers using property names. As the desire for 29 | * more complicated associations grew, Drew Davidson created what he 30 | * called KVCL, for Key-Value Coding Language, egged on by Luke 31 | * Blanshard. Luke then reimplemented the language using ANTLR, came up 32 | * with the new name, and, egged on by Drew, filled it out to its current 33 | * state. 34 | * 35 | * We pronounce OGNL as a word, like the last syllables of a drunken 36 | * pronunciation of "orthogonal" or like "ogg-null". 37 | */ 38 | 39 | -------------------------------------------------------------------------------- /src/media/logo.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/commons-ognl/bf1cf2a93b03ff037ea1a02c29534060301b2ef2/src/media/logo.xcf -------------------------------------------------------------------------------- /src/site/resources/download_ognl.cgi: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Licensed to the Apache Software Foundation (ASF) under one or more 4 | # contributor license agreements. See the NOTICE file distributed with 5 | # this work for additional information regarding copyright ownership. 6 | # The ASF licenses this file to You under the Apache License, Version 2.0 7 | # (the "License"); you may not use this file except in compliance with 8 | # the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # Just call the standard mirrors.cgi script. It will use download.html 19 | # as the input template. 20 | exec /www/www.apache.org/dyn/mirrors/mirrors.cgi $* -------------------------------------------------------------------------------- /src/site/resources/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/commons-ognl/bf1cf2a93b03ff037ea1a02c29534060301b2ef2/src/site/resources/images/logo.png -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/InExpressionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl; 20 | 21 | import static junit.framework.Assert.assertEquals; 22 | 23 | import org.junit.Test; 24 | 25 | /** 26 | * Test for OGNL-118. 27 | */ 28 | public class InExpressionTest 29 | { 30 | 31 | @Test 32 | public void test_String_In() 33 | throws Exception 34 | { 35 | OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null ); 36 | Object node = Ognl.parseExpression( "#name in {\"Greenland\", \"Austin\", \"Africa\", \"Rome\"}" ); 37 | Object root = null; 38 | 39 | context.put( "name", "Austin" ); 40 | assertEquals( Boolean.TRUE, Ognl.getValue( node, context, root ) ); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/TestOgnlException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl; 20 | 21 | import org.junit.Test; 22 | 23 | import static junit.framework.Assert.assertTrue; 24 | 25 | /** 26 | * Tests {@link OgnlException}. 27 | */ 28 | public class TestOgnlException 29 | { 30 | 31 | @Test 32 | public void test_Throwable_Reason() 33 | { 34 | try 35 | { 36 | throwException(); 37 | } 38 | catch ( OgnlException e ) 39 | { 40 | assertTrue( NumberFormatException.class.isInstance( e.getReason() ) ); 41 | } 42 | } 43 | 44 | void throwException() 45 | throws OgnlException 46 | { 47 | try 48 | { 49 | Integer.parseInt( "45ac" ); 50 | } 51 | catch ( NumberFormatException et ) 52 | { 53 | throw new OgnlException( "Unable to parse input string.", et ); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/ASTChainTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test; 20 | 21 | import junit.framework.TestCase; 22 | import org.apache.commons.ognl.Ognl; 23 | import org.apache.commons.ognl.OgnlContext; 24 | import org.apache.commons.ognl.test.objects.IndexedSetObject; 25 | 26 | /** 27 | * Tests for {@link org.apache.commons.ognl.ASTChain}. 28 | */ 29 | public class ASTChainTest extends TestCase { 30 | 31 | public void test_Get_Indexed_Value() throws Exception { 32 | OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); 33 | IndexedSetObject root = new IndexedSetObject(); 34 | 35 | String expr = "thing[\"x\"].val"; 36 | 37 | assertEquals(1, (int) Ognl.getValue(expr, context, root)); 38 | 39 | Ognl.setValue(expr, context, root, 2); 40 | 41 | assertEquals(2, (int) Ognl.getValue(expr, context, root)); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/BaseBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | /** 20 | */ 21 | package org.apache.commons.ognl.test.objects; 22 | 23 | /** 24 | * Base class used to test inheritance class casting. 25 | */ 26 | public abstract class BaseBean 27 | { 28 | 29 | public abstract String getName(); 30 | 31 | public boolean getActive() 32 | { 33 | return true; 34 | } 35 | 36 | public boolean isActive2() 37 | { 38 | return true; 39 | } 40 | 41 | public Two getTwo() 42 | { 43 | return new Two(); 44 | } 45 | 46 | public String getMessage( String mes ) 47 | { 48 | return "[" + mes + "]"; 49 | } 50 | 51 | public boolean hasChildren( String name ) 52 | { 53 | return name.length() > 2; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/BaseGeneric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | import java.io.Serializable; 22 | 23 | /** 24 | * Used to test ognl handling of Java generics. 25 | */ 26 | public class BaseGeneric 27 | { 28 | 29 | E _value; 30 | 31 | GenericService _service; 32 | 33 | protected I[] ids; 34 | 35 | public BaseGeneric() 36 | { 37 | _service = new GenericServiceImpl(); 38 | } 39 | 40 | public void setIds( I[] ids ) 41 | { 42 | this.ids = ids; 43 | } 44 | 45 | public I[] getIds() 46 | { 47 | return this.ids; 48 | } 49 | 50 | public String getMessage() 51 | { 52 | return "Message"; 53 | } 54 | 55 | public E getValue() 56 | { 57 | return _value; 58 | } 59 | 60 | public GenericService getService() 61 | { 62 | return _service; 63 | } 64 | 65 | public String format( Object value ) 66 | { 67 | return value.toString(); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/BaseIndexed.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | * Class used to test inheritance. 23 | */ 24 | public class BaseIndexed 25 | { 26 | 27 | public Object getLine( int index ) 28 | { 29 | return "line:" + index; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/BaseSyntheticObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | import java.util.ArrayList; 22 | import java.util.List; 23 | 24 | /** 25 | * Used to test OGNL-136 use of synthetic methods. 26 | */ 27 | public abstract class BaseSyntheticObject 28 | { 29 | 30 | protected List getList() 31 | { 32 | return new ArrayList(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/Bean1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | public class Bean1 22 | { 23 | private final Bean2 bean2 = new Bean2(); 24 | 25 | public Bean2 getBean2() 26 | { 27 | return bean2; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/BeanProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | /** 20 | */ 21 | package org.apache.commons.ognl.test.objects; 22 | 23 | /** 24 | * Test interface to be used with a custom propery accessor. 25 | */ 26 | public interface BeanProvider 27 | { 28 | 29 | /** 30 | * Gets a bean by name. 31 | * 32 | * @param name 33 | * @return the related bean by name 34 | */ 35 | Object getBean( String name ); 36 | 37 | /** 38 | * Sets a new bean mapping. 39 | * 40 | * @param name 41 | * @param bean 42 | */ 43 | void setBean( String name, Object bean ); 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/BeanProviderImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | /** 20 | */ 21 | package org.apache.commons.ognl.test.objects; 22 | 23 | import java.io.Serializable; 24 | import java.util.HashMap; 25 | import java.util.Map; 26 | 27 | /** 28 | * Implementation of {@link BeanProvider}. 29 | */ 30 | public class BeanProviderImpl 31 | implements Serializable, BeanProvider 32 | { 33 | private final Map _map = new HashMap(); 34 | 35 | public BeanProviderImpl() 36 | { 37 | } 38 | 39 | public Object getBean( String name ) 40 | { 41 | return _map.get( name ); 42 | } 43 | 44 | public void setBean( String name, Object bean ) 45 | { 46 | _map.put( name, bean ); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/ComponentImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public class ComponentImpl 24 | implements IComponent 25 | { 26 | 27 | String _clientId; 28 | 29 | int _count = 0; 30 | 31 | public String getClientId() 32 | { 33 | return _clientId; 34 | } 35 | 36 | public void setClientId( String id ) 37 | { 38 | _clientId = id; 39 | } 40 | 41 | public int getCount( String index ) 42 | { 43 | return _count; 44 | } 45 | 46 | public void setCount( String index, int count ) 47 | { 48 | _count = count; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/ComponentSubclass.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public class ComponentSubclass 24 | extends ComponentImpl 25 | { 26 | 27 | int _count = 0; 28 | 29 | public int getCount() 30 | { 31 | return _count; 32 | } 33 | 34 | public void setCount( int count ) 35 | { 36 | _count = count; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/Copy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public class Copy 24 | { 25 | 26 | public int size() 27 | { 28 | return 1; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/CorrectedObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | public class CorrectedObject 22 | { 23 | public CorrectedObject() 24 | { 25 | } 26 | 27 | public void setStringValue( String value ) 28 | { 29 | } 30 | 31 | public String getStringValue() 32 | { 33 | return null; 34 | } 35 | 36 | public String getIndexedStringValue( String key ) 37 | { 38 | return null; 39 | } 40 | 41 | public void setIndexedStringValue( String key, String value ) 42 | { 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/Cracker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | import java.io.Serializable; 22 | 23 | /** 24 | * Generic test object. 25 | */ 26 | public interface Cracker 27 | { 28 | 29 | T getParam(); 30 | 31 | void setParam( T param ); 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/Entry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public class Entry 24 | { 25 | 26 | private final int _size = 1; 27 | 28 | public int size() 29 | { 30 | return _size; 31 | } 32 | 33 | public Copy getCopy() 34 | { 35 | return new Copy(); 36 | } 37 | 38 | public boolean equals( Object o ) 39 | { 40 | if ( this == o ) 41 | return true; 42 | if ( o == null || getClass() != o.getClass() ) 43 | return false; 44 | 45 | Entry entry = (Entry) o; 46 | return _size == entry._size; 47 | } 48 | 49 | public int hashCode() 50 | { 51 | return _size; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/EvenOdd.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public class EvenOdd 24 | { 25 | 26 | private boolean even = true; 27 | 28 | /** 29 | * Returns "even" or "odd". Whatever it returns on one invocation, it will return the opposite on the next. By 30 | * default, the first value returned is "even". 31 | */ 32 | public String getNext() 33 | { 34 | String result = even ? "even" : "odd"; 35 | 36 | even = !even; 37 | 38 | return result; 39 | } 40 | 41 | public boolean isEven() 42 | { 43 | return even; 44 | } 45 | 46 | /** 47 | * Overrides the even flag. 48 | */ 49 | 50 | public void setEven( boolean value ) 51 | { 52 | even = value; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/FirstBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | /** 20 | */ 21 | package org.apache.commons.ognl.test.objects; 22 | 23 | /** 24 | */ 25 | public class FirstBean 26 | extends BaseBean 27 | { 28 | 29 | public String getName() 30 | { 31 | return "FirstBean"; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/FormComponentImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public class FormComponentImpl 24 | extends ComponentImpl 25 | implements IFormComponent 26 | { 27 | 28 | IForm _form; 29 | 30 | public IForm getForm() 31 | { 32 | return _form; 33 | } 34 | 35 | public void setForm( IForm form ) 36 | { 37 | _form = form; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/FormImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public class FormImpl 24 | extends ComponentImpl 25 | implements IForm 26 | { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/GameGeneric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public class GameGeneric 24 | extends BaseGeneric 25 | { 26 | 27 | public GameGeneric() 28 | { 29 | _value = new GameGenericObject(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/GameGenericObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public class GameGenericObject 24 | implements GenericObject 25 | { 26 | 27 | public GameGenericObject() 28 | { 29 | } 30 | 31 | public int getId() 32 | { 33 | return 20; 34 | } 35 | 36 | public String getDisplayName() 37 | { 38 | return "Halo 3"; 39 | } 40 | 41 | public String getHappy() 42 | { 43 | return "happy"; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/GenericCracker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public class GenericCracker 24 | implements Cracker 25 | { 26 | 27 | Integer _param; 28 | 29 | public Integer getParam() 30 | { 31 | return _param; 32 | } 33 | 34 | public void setParam( Integer param ) 35 | { 36 | _param = param; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/GenericObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | * Used by {@link BaseGeneric} to reference a class type. 23 | */ 24 | public interface GenericObject 25 | { 26 | 27 | int getId(); 28 | 29 | String getDisplayName(); 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/GenericRoot.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public class GenericRoot 24 | { 25 | 26 | Root _root = new Root(); 27 | 28 | GenericCracker _cracker = new GenericCracker(); 29 | 30 | public Root getRoot() 31 | { 32 | return _root; 33 | } 34 | 35 | public void setRoot( Root root ) 36 | { 37 | _root = root; 38 | } 39 | 40 | public GenericCracker getCracker() 41 | { 42 | return _cracker; 43 | } 44 | 45 | public void setCracker( GenericCracker cracker ) 46 | { 47 | _cracker = cracker; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/GenericService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public interface GenericService 24 | { 25 | 26 | String getFullMessageFor( PersonGenericObject person, Object... arguments ); 27 | 28 | String getFullMessageFor( GameGenericObject game, Object... arguments ); 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/GenericServiceImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public class GenericServiceImpl 24 | implements GenericService 25 | { 26 | 27 | public String getFullMessageFor( GameGenericObject game, Object... arguments ) 28 | { 29 | game.getHappy(); 30 | 31 | return game.getDisplayName(); 32 | } 33 | 34 | public String getFullMessageFor( PersonGenericObject person, Object... arguments ) 35 | { 36 | return person.getDisplayName(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/GetterMethods.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public class GetterMethods 24 | { 25 | 26 | private int theInt = 1; 27 | 28 | public boolean isAllowDisplay( Object something ) 29 | { 30 | return true; 31 | } 32 | 33 | public int getAllowDisplay() 34 | { 35 | return theInt; 36 | } 37 | 38 | public void setAllowDisplay( int val ) 39 | { 40 | theInt = val; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/IComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public interface IComponent 24 | { 25 | 26 | String getClientId(); 27 | 28 | void setClientId( String id ); 29 | 30 | int getCount( String index ); 31 | 32 | void setCount( String index, int count ); 33 | } 34 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/IContentProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | import java.util.List; 22 | 23 | /** 24 | */ 25 | public interface IContentProvider 26 | { 27 | 28 | List getElements(); 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/IForm.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public interface IForm 24 | extends IComponent 25 | { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/IFormComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public interface IFormComponent 24 | extends IComponent 25 | { 26 | 27 | String getClientId(); 28 | 29 | IForm getForm(); 30 | 31 | void setForm( IForm form ); 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/ITreeContentProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | import java.util.Collection; 22 | 23 | /** 24 | */ 25 | public interface ITreeContentProvider 26 | extends IContentProvider 27 | { 28 | 29 | Collection getChildren( Object parentElement ); 30 | 31 | boolean hasChildren( Object parentElement ); 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/IndexedMapObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | * Simple object used to test indexed map references using "#this" references. 23 | */ 24 | public class IndexedMapObject 25 | { 26 | 27 | String property; 28 | 29 | public IndexedMapObject( String property ) 30 | { 31 | this.property = property; 32 | } 33 | 34 | public String getProperty() 35 | { 36 | return property; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/IndexedSetObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | import java.util.HashMap; 22 | 23 | /** 24 | * Test for OGNL-119. 25 | */ 26 | public class IndexedSetObject 27 | { 28 | 29 | private final HashMap things = new HashMap(); 30 | 31 | public IndexedSetObject() 32 | { 33 | things.put( "x", new Container( 1 ) ); 34 | } 35 | 36 | public Object getThing( String index ) 37 | { 38 | return things.get( index ); 39 | } 40 | 41 | public void setThing( String index, Object value ) 42 | { 43 | things.put( index, value ); 44 | } 45 | 46 | public static class Container 47 | { 48 | private int val; 49 | 50 | public Container( int val ) 51 | { 52 | this.val = val; 53 | } 54 | 55 | public int getVal() 56 | { 57 | return val; 58 | } 59 | 60 | public void setVal( int val ) 61 | { 62 | this.val = val; 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/Inherited.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public interface Inherited 24 | { 25 | 26 | String getMyString(); 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/ListSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public interface ListSource 24 | { 25 | 26 | int getTotal(); 27 | 28 | Object addValue( Object value ); 29 | 30 | Object getName(); 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/ListSourceImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | import java.util.ArrayList; 22 | 23 | /** 24 | */ 25 | public class ListSourceImpl 26 | extends ArrayList 27 | implements ListSource 28 | { 29 | 30 | public ListSourceImpl() 31 | { 32 | } 33 | 34 | public int getTotal() 35 | { 36 | return super.size(); 37 | } 38 | 39 | public Object addValue( Object value ) 40 | { 41 | return super.add( value ); 42 | } 43 | 44 | public Object getName() 45 | { 46 | return null; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/Messages.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | import java.util.Map; 22 | 23 | /** 24 | */ 25 | public class Messages 26 | { 27 | 28 | Map _source; 29 | 30 | public Messages( Map source ) 31 | { 32 | _source = source; 33 | } 34 | 35 | public String getMessage( String key ) 36 | { 37 | return (String) _source.get( key ); 38 | } 39 | 40 | public String format( String key, Object[] params ) 41 | { 42 | return "foo"; 43 | } 44 | 45 | public String format( String key, Object param1, Object param2, Object param3 ) 46 | { 47 | return "blah"; 48 | } 49 | 50 | public String format( String key, Object param1 ) 51 | { 52 | return "first"; 53 | } 54 | 55 | public String format( String key, Object param1, Object param2 ) 56 | { 57 | return "haha"; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/Model.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public class Model 24 | { 25 | 26 | public int getOptionCount() 27 | { 28 | return 1; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/MyMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | import java.util.*; 22 | 23 | /** 24 | * This tests the interface inheritence test. This is a subinterface of Map and therefore should inherit the Map 25 | * property accessor. 26 | */ 27 | public interface MyMap 28 | extends Map 29 | { 30 | String getDescription(); 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/ObjectIndexed.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | public class ObjectIndexed 22 | extends BaseObjectIndexed 23 | { 24 | public ObjectIndexed() 25 | { 26 | setAttribute( "foo", "bar" ); 27 | setAttribute( "bar", "baz" ); 28 | setAttribute( "other", new OtherObjectIndexed() ); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/OtherObjectIndexed.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | public class OtherObjectIndexed 22 | extends BaseObjectIndexed 23 | { 24 | public OtherObjectIndexed() 25 | { 26 | setAttribute( "foo", "bar" ); 27 | setAttribute( "bar", "baz" ); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/PersonGenericObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public class PersonGenericObject 24 | implements GenericObject 25 | { 26 | 27 | public int getId() 28 | { 29 | return 1; 30 | } 31 | 32 | public String getDisplayName() 33 | { 34 | return "Henry Collins"; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/PropertyHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | * Simple class used to test various kind of property resolutions. 23 | */ 24 | public class PropertyHolder 25 | { 26 | 27 | String _value = ""; 28 | 29 | String _search = "foo"; 30 | 31 | public String getValue() 32 | { 33 | return _value; 34 | } 35 | 36 | public void setValue( String value ) 37 | { 38 | _value = value; 39 | } 40 | 41 | public boolean hasValue() 42 | { 43 | return _value != null && !_value.isEmpty(); 44 | } 45 | 46 | public void setSearch( String value ) 47 | { 48 | _search = value; 49 | } 50 | 51 | public String getSearch() 52 | { 53 | return _search; 54 | } 55 | 56 | public void search() 57 | { 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/SearchCriteria.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | * Test for OGNL-131. 23 | */ 24 | public class SearchCriteria 25 | { 26 | 27 | String _displayName; 28 | 29 | public SearchCriteria( String name ) 30 | { 31 | _displayName = name; 32 | } 33 | 34 | public String getDisplayName() 35 | { 36 | return _displayName; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/SecondBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | /** 20 | */ 21 | package org.apache.commons.ognl.test.objects; 22 | 23 | /** 24 | */ 25 | public class SecondBean 26 | extends BaseBean 27 | { 28 | public String getName() 29 | { 30 | return "SecondBean"; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/SetterReturns.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public class SetterReturns 24 | { 25 | 26 | private String _value = ""; 27 | 28 | public String getValue() 29 | { 30 | return _value; 31 | } 32 | 33 | public SetterReturns setValue( String value ) 34 | { 35 | _value += value; 36 | return this; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/SimpleEnum.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public enum SimpleEnum 24 | { 25 | 26 | ONE( 1 ); 27 | 28 | private final int _value; 29 | 30 | SimpleEnum( int value ) 31 | { 32 | _value = value; 33 | } 34 | 35 | public int getValue() 36 | { 37 | return _value; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/SimpleNumeric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | * Used for {@link org.apache.commons.ognl.test.PropertyArithmeticAndLogicalOperatorsTest}. 23 | */ 24 | public class SimpleNumeric 25 | { 26 | 27 | public double getBudget() 28 | { 29 | return 140; 30 | } 31 | 32 | public double getTimeBilled() 33 | { 34 | return 24.12; 35 | } 36 | 37 | public String getTableSize() 38 | { 39 | return "10"; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/SubclassSyntheticObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | import java.util.ArrayList; 22 | 23 | /** 24 | * Simple subclass. 25 | */ 26 | public class SubclassSyntheticObject 27 | extends BaseSyntheticObject 28 | { 29 | 30 | public ArrayList getList() 31 | { 32 | return new ArrayList(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/TestClass.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public abstract class TestClass 24 | { 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/TestImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | import java.util.HashMap; 22 | import java.util.Map; 23 | 24 | /** 25 | */ 26 | public class TestImpl 27 | extends TestClass 28 | { 29 | 30 | public Map getTheMap() 31 | { 32 | Map map = new HashMap(); 33 | map.put( "key", "value" ); 34 | return map; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/TestInherited1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public class TestInherited1 24 | implements Inherited 25 | { 26 | 27 | public String getMyString() 28 | { 29 | return "inherited1"; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/TestInherited2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public class TestInherited2 24 | implements Inherited 25 | { 26 | 27 | public String getMyString() 28 | { 29 | return "inherited2"; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/TestModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public class TestModel 24 | { 25 | 26 | public Copy getCopy() 27 | { 28 | return new Copy(); 29 | } 30 | 31 | public Model getUnassignedCopyModel() 32 | { 33 | return new Model(); 34 | } 35 | 36 | public boolean isCanApproveCopy() 37 | { 38 | return true; 39 | } 40 | 41 | public Entry getEntry() 42 | { 43 | return new Entry(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/TreeContentProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | import java.util.Collection; 22 | import java.util.Collections; 23 | import java.util.List; 24 | 25 | /** 26 | */ 27 | public class TreeContentProvider 28 | implements ITreeContentProvider 29 | { 30 | 31 | public Collection getChildren( Object parentElement ) 32 | { 33 | return Collections.EMPTY_LIST; 34 | } 35 | 36 | public boolean hasChildren( Object parentElement ) 37 | { 38 | return true; 39 | } 40 | 41 | public List getElements() 42 | { 43 | return Collections.EMPTY_LIST; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/objects/Two.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.objects; 20 | 21 | /** 22 | */ 23 | public class Two 24 | { 25 | 26 | public String getMessage( String mes ) 27 | { 28 | return "[" + mes + "]"; 29 | } 30 | 31 | public boolean hasChildren( String name ) 32 | { 33 | return name.length() > 2; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/ognl/test/util/EnhancedClassLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.commons.ognl.test.util; 20 | 21 | public class EnhancedClassLoader 22 | extends ClassLoader 23 | { 24 | /* 25 | * =================================================================== Constructors 26 | * =================================================================== 27 | */ 28 | public EnhancedClassLoader( ClassLoader parentClassLoader ) 29 | { 30 | super( parentClassLoader ); 31 | } 32 | 33 | /* 34 | * =================================================================== Overridden methods 35 | * =================================================================== 36 | */ 37 | public Class defineClass( String enhancedClassName, byte[] byteCode ) 38 | { 39 | return defineClass( enhancedClassName, byteCode, 0, byteCode.length ); 40 | } 41 | } 42 | --------------------------------------------------------------------------------