├── .classpath
├── .gitignore
├── .project
├── ASM-LICENSE.txt
├── LICENSE.txt
├── build.properties
├── lib
├── asm.jar
├── commons-el-1.0.jar
├── js.jar
├── jsp-api-2.1.jar
├── junit-3.8.2.jar
├── ognl-2.6.7.jar
├── script-api.jar
├── script-js.jar
├── servlet-api-2.5.jar
├── xpp3_min-1.1.4c.jar
└── xstream-1.3.1.jar
├── pom.xml
├── samples
└── scripts
│ ├── fquicksort.mvel
│ ├── functions1.mvel
│ ├── multibyte.mvel
│ ├── multilinestring.mvel
│ ├── quicksort.mvel
│ ├── quicksort2.mvel
│ ├── quicksort3.mvel
│ └── randomguess.mvel
└── src
├── main
└── java
│ └── org
│ └── mvel2
│ ├── CompileException.java
│ ├── ConversionException.java
│ ├── ConversionHandler.java
│ ├── DataConversion.java
│ ├── DataTypes.java
│ ├── ErrorDetail.java
│ ├── ImmutableElementException.java
│ ├── MVEL.java
│ ├── MVELInterpretedRuntime.java
│ ├── MVELRuntime.java
│ ├── Macro.java
│ ├── MacroProcessor.java
│ ├── Operator.java
│ ├── OptimizationFailure.java
│ ├── ParserConfiguration.java
│ ├── ParserContext.java
│ ├── PreProcessor.java
│ ├── PropertyAccessException.java
│ ├── PropertyAccessor.java
│ ├── ScriptRuntimeException.java
│ ├── Unit.java
│ ├── UnresolveablePropertyException.java
│ ├── asm
│ ├── AnnotationVisitor.java
│ ├── AnnotationWriter.java
│ ├── Attribute.java
│ ├── ByteVector.java
│ ├── ClassAdapter.java
│ ├── ClassReader.java
│ ├── ClassVisitor.java
│ ├── ClassWriter.java
│ ├── Edge.java
│ ├── FieldVisitor.java
│ ├── FieldWriter.java
│ ├── Frame.java
│ ├── Handler.java
│ ├── Item.java
│ ├── Label.java
│ ├── MethodAdapter.java
│ ├── MethodVisitor.java
│ ├── MethodWriter.java
│ ├── Opcodes.java
│ ├── Type.java
│ ├── package.html
│ ├── signature
│ │ ├── SignatureReader.java
│ │ ├── SignatureVisitor.java
│ │ ├── SignatureWriter.java
│ │ └── package.html
│ └── util
│ │ ├── AbstractVisitor.java
│ │ ├── TraceAbstractVisitor.java
│ │ ├── TraceAnnotationVisitor.java
│ │ ├── TraceClassVisitor.java
│ │ ├── TraceFieldVisitor.java
│ │ ├── TraceMethodVisitor.java
│ │ ├── TraceSignatureVisitor.java
│ │ └── Traceable.java
│ ├── ast
│ ├── ASTNode.java
│ ├── And.java
│ ├── ArraySize.java
│ ├── AssertNode.java
│ ├── Assignment.java
│ ├── AssignmentNode.java
│ ├── BinaryOperation.java
│ ├── BlockNode.java
│ ├── BooleanNode.java
│ ├── Contains.java
│ ├── Convertable.java
│ ├── DeclProtoVarNode.java
│ ├── DeclTypedVarNode.java
│ ├── DeepAssignmentNode.java
│ ├── DoNode.java
│ ├── DoUntilNode.java
│ ├── EndOfStatement.java
│ ├── Fold.java
│ ├── ForEachNode.java
│ ├── ForNode.java
│ ├── Function.java
│ ├── IfNode.java
│ ├── ImportNode.java
│ ├── IndexedAssignmentNode.java
│ ├── IndexedDeclTypedVarNode.java
│ ├── IndexedOperativeAssign.java
│ ├── IndexedPostFixDecNode.java
│ ├── IndexedPostFixIncNode.java
│ ├── IndexedPreFixDecNode.java
│ ├── IndexedPreFixIncNode.java
│ ├── InlineCollectionNode.java
│ ├── Instance.java
│ ├── IntAdd.java
│ ├── IntDiv.java
│ ├── IntMult.java
│ ├── IntOptimized.java
│ ├── IntSub.java
│ ├── InterceptorWrapper.java
│ ├── Invert.java
│ ├── IsDef.java
│ ├── LineLabel.java
│ ├── LiteralDeepPropertyNode.java
│ ├── LiteralNode.java
│ ├── Negation.java
│ ├── NestedStatement.java
│ ├── NewObjectNode.java
│ ├── NewPrototypeNode.java
│ ├── OperativeAssign.java
│ ├── OperatorNode.java
│ ├── Or.java
│ ├── PostFixDecNode.java
│ ├── PostFixIncNode.java
│ ├── PreFixDecNode.java
│ ├── PreFixIncNode.java
│ ├── Proto.java
│ ├── ProtoVarNode.java
│ ├── ReduceableCodeException.java
│ ├── RedundantCodeException.java
│ ├── RegExMatch.java
│ ├── RegExMatchNode.java
│ ├── ReturnNode.java
│ ├── Safe.java
│ ├── Sign.java
│ ├── Soundslike.java
│ ├── StaticImportNode.java
│ ├── Strsim.java
│ ├── Substatement.java
│ ├── ThisWithNode.java
│ ├── TypeCast.java
│ ├── TypeDescriptor.java
│ ├── TypedVarNode.java
│ ├── Union.java
│ ├── UntilNode.java
│ ├── WhileNode.java
│ └── WithNode.java
│ ├── compiler
│ ├── AbstractParser.java
│ ├── Accessor.java
│ ├── AccessorNode.java
│ ├── BlankLiteral.java
│ ├── CompiledAccExpression.java
│ ├── CompiledExpression.java
│ ├── EndWithValue.java
│ ├── ExecutableAccessor.java
│ ├── ExecutableAccessorSafe.java
│ ├── ExecutableLiteral.java
│ ├── ExecutableStatement.java
│ ├── ExpressionCompiler.java
│ ├── Parser.java
│ └── PropertyVerifier.java
│ ├── conversion
│ ├── ArrayCH.java
│ ├── ArrayHandler.java
│ ├── BigDecimalCH.java
│ ├── BigIntegerCH.java
│ ├── BooleanCH.java
│ ├── ByteCH.java
│ ├── CharArrayCH.java
│ ├── CharCH.java
│ ├── Converter.java
│ ├── DoubleCH.java
│ ├── FloatCH.java
│ ├── IntArrayCH.java
│ ├── IntegerCH.java
│ ├── ListCH.java
│ ├── LongCH.java
│ ├── ObjectCH.java
│ ├── PrimIntArrayCH.java
│ ├── SetCH.java
│ ├── ShortCH.java
│ ├── StringArrayCH.java
│ ├── StringCH.java
│ └── UnitConversion.java
│ ├── debug
│ ├── DebugTools.java
│ ├── Debugger.java
│ ├── DebuggerContext.java
│ └── Frame.java
│ ├── integration
│ ├── GlobalListenerFactory.java
│ ├── Interceptor.java
│ ├── Listener.java
│ ├── PropertyHandler.java
│ ├── PropertyHandlerFactory.java
│ ├── ResolverTools.java
│ ├── VariableResolver.java
│ ├── VariableResolverFactory.java
│ └── impl
│ │ ├── BaseVariableResolverFactory.java
│ │ ├── CachedMapVariableResolverFactory.java
│ │ ├── CachingMapVariableResolverFactory.java
│ │ ├── ClassImportResolver.java
│ │ ├── ClassImportResolverFactory.java
│ │ ├── DefaultLocalVariableResolverFactory.java
│ │ ├── FunctionVariableResolverFactory.java
│ │ ├── ImmutableDefaultFactory.java
│ │ ├── IndexVariableResolver.java
│ │ ├── IndexedVariableResolverFactory.java
│ │ ├── ItemResolverFactory.java
│ │ ├── LocalVariableResolverFactory.java
│ │ ├── MapVariableResolver.java
│ │ ├── MapVariableResolverFactory.java
│ │ ├── PrecachedMapVariableResolver.java
│ │ ├── SimpleSTValueResolver.java
│ │ ├── SimpleValueResolver.java
│ │ ├── SimpleVariableResolverFactory.java
│ │ ├── StaticMethodImportResolver.java
│ │ ├── StaticMethodImportResolverFactory.java
│ │ ├── TypeInjectionResolverFactory.java
│ │ └── TypeInjectionResolverFactoryImpl.java
│ ├── math
│ └── MathProcessor.java
│ ├── optimizers
│ ├── AbstractOptimizer.java
│ ├── AccessorOptimizer.java
│ ├── OptimizationNotSupported.java
│ ├── OptimizerFactory.java
│ ├── OptimizerHook.java
│ ├── dynamic
│ │ ├── DynamicAccessor.java
│ │ ├── DynamicClassLoader.java
│ │ ├── DynamicCollectionAccessor.java
│ │ ├── DynamicGetAccessor.java
│ │ ├── DynamicOptimizer.java
│ │ └── DynamicSetAccessor.java
│ └── impl
│ │ ├── asm
│ │ ├── ASMAccessorOptimizer.java
│ │ └── ProducesBytecode.java
│ │ └── refl
│ │ ├── ReflectiveAccessorOptimizer.java
│ │ ├── collection
│ │ ├── ArrayCreator.java
│ │ ├── ExprValueAccessor.java
│ │ ├── ListCreator.java
│ │ ├── MDArrayCreator.java
│ │ └── MapCreator.java
│ │ └── nodes
│ │ ├── ArrayAccessor.java
│ │ ├── ArrayAccessorNest.java
│ │ ├── ArrayLength.java
│ │ ├── BaseAccessor.java
│ │ ├── ConstructorAccessor.java
│ │ ├── DynamicFieldAccessor.java
│ │ ├── DynamicFunctionAccessor.java
│ │ ├── DynamicSetterAccessor.java
│ │ ├── FieldAccessor.java
│ │ ├── FieldAccessorNH.java
│ │ ├── FunctionAccessor.java
│ │ ├── GetterAccessor.java
│ │ ├── GetterAccessorNH.java
│ │ ├── IndexedCharSeqAccessor.java
│ │ ├── IndexedCharSeqAccessorNest.java
│ │ ├── IndexedVariableAccessor.java
│ │ ├── ListAccessor.java
│ │ ├── ListAccessorNest.java
│ │ ├── MapAccessor.java
│ │ ├── MapAccessorNest.java
│ │ ├── MethodAccessor.java
│ │ ├── MethodAccessorNH.java
│ │ ├── Notify.java
│ │ ├── NullSafe.java
│ │ ├── PropertyHandlerAccessor.java
│ │ ├── SetterAccessor.java
│ │ ├── StaticReferenceAccessor.java
│ │ ├── StaticVarAccessor.java
│ │ ├── StaticVarAccessorNH.java
│ │ ├── ThisValueAccessor.java
│ │ ├── Union.java
│ │ ├── VariableAccessor.java
│ │ └── WithAccessor.java
│ ├── sh
│ ├── Command.java
│ ├── CommandException.java
│ ├── CommandSet.java
│ ├── DefaultEnvironment.java
│ ├── Main.java
│ ├── ShellSession.java
│ ├── command
│ │ ├── basic
│ │ │ ├── BasicCommandSet.java
│ │ │ ├── Exit.java
│ │ │ ├── Help.java
│ │ │ ├── ObjectInspector.java
│ │ │ ├── PushContext.java
│ │ │ ├── Set.java
│ │ │ └── ShowVars.java
│ │ └── file
│ │ │ ├── ChangeWorkingDir.java
│ │ │ ├── DirList.java
│ │ │ ├── FileCommandSet.java
│ │ │ └── PrintWorkingDirectory.java
│ └── text
│ │ └── TextUtil.java
│ ├── templates
│ ├── CompiledTemplate.java
│ ├── SimpleTemplateRegistry.java
│ ├── TemplateCompiler.java
│ ├── TemplateDebug.java
│ ├── TemplateError.java
│ ├── TemplateRegistry.java
│ ├── TemplateRuntime.java
│ ├── TemplateRuntimeError.java
│ ├── TemplateSyntaxError.java
│ ├── res
│ │ ├── CodeNode.java
│ │ ├── CommentNode.java
│ │ ├── CompiledCodeNode.java
│ │ ├── CompiledDeclareNode.java
│ │ ├── CompiledEvalNode.java
│ │ ├── CompiledExpressionNode.java
│ │ ├── CompiledForEachNode.java
│ │ ├── CompiledIfNode.java
│ │ ├── CompiledIncludeNode.java
│ │ ├── CompiledNamedIncludeNode.java
│ │ ├── CompiledTerminalExpressionNode.java
│ │ ├── DeclareNode.java
│ │ ├── EndNode.java
│ │ ├── EvalNode.java
│ │ ├── ExpressionNode.java
│ │ ├── ForEachNode.java
│ │ ├── IfNode.java
│ │ ├── IncludeNode.java
│ │ ├── NamedIncludeNode.java
│ │ ├── Node.java
│ │ ├── Opcodes.java
│ │ ├── TerminalExpressionNode.java
│ │ ├── TerminalNode.java
│ │ └── TextNode.java
│ └── util
│ │ ├── ArrayIterator.java
│ │ ├── CountIterator.java
│ │ ├── TemplateOutputStream.java
│ │ ├── TemplateTools.java
│ │ └── io
│ │ ├── StandardOutputStream.java
│ │ ├── StringAppenderStream.java
│ │ └── StringBuilderStream.java
│ └── util
│ ├── ASTIterator.java
│ ├── ASTLinkedList.java
│ ├── ArrayTools.java
│ ├── CallableProxy.java
│ ├── CollectionParser.java
│ ├── CompilerTools.java
│ ├── ErrorUtil.java
│ ├── ExecutionStack.java
│ ├── FastList.java
│ ├── FunctionParser.java
│ ├── InternalNumber.java
│ ├── JITClassLoader.java
│ ├── LineMapper.java
│ ├── MVELClassLoader.java
│ ├── Make.java
│ ├── MethodStub.java
│ ├── NullType.java
│ ├── ParseTools.java
│ ├── PropertyTools.java
│ ├── ProtoParser.java
│ ├── ReflectionUtil.java
│ ├── SharedVariableSpaceModel.java
│ ├── SimpleIndexHashMapWrapper.java
│ ├── SimpleVariableSpaceModel.java
│ ├── Soundex.java
│ ├── Stack.java
│ ├── StackElement.java
│ ├── StringAppender.java
│ ├── ThisLiteral.java
│ ├── VariableSpaceCompiler.java
│ └── VariableSpaceModel.java
└── test
├── java
└── org
│ └── mvel2
│ ├── compiler
│ └── GenericsTypeInferenceTest.java
│ ├── marshalling
│ └── MarshallingTest.java
│ ├── tests
│ ├── AccessorBMModel.java
│ ├── MVEL238.mvel
│ ├── core
│ │ ├── AbstractTest.java
│ │ ├── ArithmeticTests.java
│ │ ├── ArraysTests.java
│ │ ├── CommentParsingTests.java
│ │ ├── ComparisonTests.java
│ │ ├── ControlFlowTests.java
│ │ ├── CoreConfidenceTests.java
│ │ ├── DebuggerTests.java
│ │ ├── FailureTests.java
│ │ ├── FunctionsTest.java
│ │ ├── IndexedVariablesTests.java
│ │ ├── InlineCollectionsTests.java
│ │ ├── IntegrationTests.java
│ │ ├── LiteralParsingTests.java
│ │ ├── MVELTest.java
│ │ ├── MVELThreadTest.java
│ │ ├── MacroProcessorTest.java
│ │ ├── MutationsTests.java
│ │ ├── ProjectionsTests.java
│ │ ├── PropertyAccessTests.java
│ │ ├── PropertyAccessUnitTest.java
│ │ ├── PropertyHandlerTests.java
│ │ ├── ProtoTests.java
│ │ ├── RegularExpressionTests.java
│ │ ├── SamplesTests.java
│ │ ├── ScopeTests.java
│ │ ├── TypesAndInferenceTests.java
│ │ ├── UnsupportedFeaturesTests.java
│ │ ├── UtilsTests.java
│ │ ├── WithTests.java
│ │ └── res
│ │ │ ├── AStatic.java
│ │ │ ├── Bar.java
│ │ │ ├── Base.java
│ │ │ ├── Cake.java
│ │ │ ├── Cheese.java
│ │ │ ├── Cheesery.java
│ │ │ ├── Column.java
│ │ │ ├── DefaultKnowledgeHelper.java
│ │ │ ├── DerivedClass.java
│ │ │ ├── FactHandle.java
│ │ │ ├── Foo.java
│ │ │ ├── Grid.java
│ │ │ ├── KnowledgeHelper.java
│ │ │ ├── KnowledgeHelperFixer.java
│ │ │ ├── MapObject.java
│ │ │ ├── Model.java
│ │ │ ├── MyClass.java
│ │ │ ├── MyEnum.java
│ │ │ ├── MyInterface.java
│ │ │ ├── MyInterface2.java
│ │ │ ├── MyInterface3.java
│ │ │ ├── MySuperInterface.java
│ │ │ ├── PDFFieldUtil.java
│ │ │ ├── PojoStatic.java
│ │ │ ├── PresentationElements.java
│ │ │ ├── RuleBase.java
│ │ │ ├── RuleBaseImpl.java
│ │ │ ├── SampleBean.java
│ │ │ ├── SampleBeanAccessor.java
│ │ │ ├── Ship.java
│ │ │ ├── Status.java
│ │ │ ├── Task.java
│ │ │ ├── TestClass.java
│ │ │ ├── TestInterface.java
│ │ │ ├── TestMVEL197.java
│ │ │ ├── Thing.java
│ │ │ ├── User.java
│ │ │ ├── Users.java
│ │ │ ├── WorkingMemory.java
│ │ │ ├── WorkingMemoryImpl.java
│ │ │ └── res2
│ │ │ ├── ClassProvider.java
│ │ │ ├── Outer.java
│ │ │ ├── PrivateClass.java
│ │ │ └── PublicClass.java
│ ├── fuzz
│ │ ├── Fuzzer.java
│ │ └── IdentifierFuzzer.java
│ ├── perftests
│ │ ├── CompiledPerformanceTests.java
│ │ ├── InlineCollectionsPerformance.java
│ │ ├── NullOutputStream.java
│ │ └── SimpleTests.java
│ └── templates
│ │ ├── TemplateTests.java
│ │ ├── perfTest1.mv
│ │ ├── templateDeclareTest.mv
│ │ ├── templateError.mv
│ │ ├── templateError2.mv
│ │ ├── templateIfTest.mv
│ │ ├── templateTest.mv
│ │ └── tests
│ │ └── res
│ │ └── TestPluginNode.java
│ └── util
│ ├── FastListTest.java
│ └── QuickSort.java
└── resources
└── eventing-example.jar
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignored files deleted by mvn clean
2 | /target
3 | # Ignored files not deleted by mvn clean
4 | /local
5 |
6 | # Netbeans and IntelliJ files
7 | /.idea
8 | !.gitignore
9 | /nbproject
10 | /*.ipr
11 | /*.iws
12 | /*.iml
13 |
14 | # The META-INF directory is generated by the maven-felix-plugin
15 | /META-INF
16 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | mvel
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.maven.ide.eclipse.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.maven.ide.eclipse.maven2Nature
21 | org.eclipse.jdt.core.javanature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/build.properties:
--------------------------------------------------------------------------------
1 | src.includes = .,\
2 | build.properties,\
3 | META-INF/,\
4 | src/,\
5 | pom.xml
6 | bin.includes = .,\
7 | META-INF/,\
8 | build.properties,\
9 | source.. = src/main/java/,\
10 | src/main/resources/
11 | output.. = target/classes/
12 | jars.compile.order = .
13 |
--------------------------------------------------------------------------------
/lib/asm.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikebrock/mvel/c8ded0833626cdc6fbe2755234904fce06a9c0fa/lib/asm.jar
--------------------------------------------------------------------------------
/lib/commons-el-1.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikebrock/mvel/c8ded0833626cdc6fbe2755234904fce06a9c0fa/lib/commons-el-1.0.jar
--------------------------------------------------------------------------------
/lib/js.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikebrock/mvel/c8ded0833626cdc6fbe2755234904fce06a9c0fa/lib/js.jar
--------------------------------------------------------------------------------
/lib/jsp-api-2.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikebrock/mvel/c8ded0833626cdc6fbe2755234904fce06a9c0fa/lib/jsp-api-2.1.jar
--------------------------------------------------------------------------------
/lib/junit-3.8.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikebrock/mvel/c8ded0833626cdc6fbe2755234904fce06a9c0fa/lib/junit-3.8.2.jar
--------------------------------------------------------------------------------
/lib/ognl-2.6.7.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikebrock/mvel/c8ded0833626cdc6fbe2755234904fce06a9c0fa/lib/ognl-2.6.7.jar
--------------------------------------------------------------------------------
/lib/script-api.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikebrock/mvel/c8ded0833626cdc6fbe2755234904fce06a9c0fa/lib/script-api.jar
--------------------------------------------------------------------------------
/lib/script-js.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikebrock/mvel/c8ded0833626cdc6fbe2755234904fce06a9c0fa/lib/script-js.jar
--------------------------------------------------------------------------------
/lib/servlet-api-2.5.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikebrock/mvel/c8ded0833626cdc6fbe2755234904fce06a9c0fa/lib/servlet-api-2.5.jar
--------------------------------------------------------------------------------
/lib/xpp3_min-1.1.4c.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikebrock/mvel/c8ded0833626cdc6fbe2755234904fce06a9c0fa/lib/xpp3_min-1.1.4c.jar
--------------------------------------------------------------------------------
/lib/xstream-1.3.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikebrock/mvel/c8ded0833626cdc6fbe2755234904fce06a9c0fa/lib/xstream-1.3.1.jar
--------------------------------------------------------------------------------
/samples/scripts/fquicksort.mvel:
--------------------------------------------------------------------------------
1 | /**
2 | * Sample MVEL 2.1 Script
3 | * "Functional QuickSort"
4 | * by: Mike Brock, Inspired by: Dhanji Prasanna
5 | */
6 |
7 | def quicksort(list) {
8 | list.size() <= 1 ? list :
9 | (pivot = list[0]; (quicksort(($ in list if $ < pivot)) + pivot)
10 | + quicksort(($ in list if $ > pivot)))
11 | }
12 |
13 | // create a list to sort
14 | list = [5,2,4,1,18,10,15,1,0];
15 |
16 | // sort it!
17 | quicksort(list);
--------------------------------------------------------------------------------
/samples/scripts/functions1.mvel:
--------------------------------------------------------------------------------
1 | /**
2 | * Sample MVEL 2.0 Script
3 | * "Functions Demonstration"
4 | * by: Christopher Michael Brock
5 | */
6 |
7 | def isGood(obj) {
8 | return !(obj.toLowerCase() contains "evil");
9 | }
10 |
11 | def describe(obj) {
12 | System.out.println(obj + " is " + (isGood(obj) ? "Good" : "Evil"));
13 | }
14 |
15 | $test1 = "Mr. Good";
16 | $test2 = "Mr. Evil";
17 |
18 | describe($test1);
19 | describe($test2);
--------------------------------------------------------------------------------
/samples/scripts/multibyte.mvel:
--------------------------------------------------------------------------------
1 | a = "?????";
--------------------------------------------------------------------------------
/samples/scripts/multilinestring.mvel:
--------------------------------------------------------------------------------
1 |
2 | System.out.println(
3 | "Hello, are you there?
4 | Is it wonderful?
5 | Did you try to escape the population?"
6 | );
7 |
8 |
--------------------------------------------------------------------------------
/samples/scripts/quicksort.mvel:
--------------------------------------------------------------------------------
1 | /**
2 | * Sample MVEL 2.0 Script
3 | * "QuickSort"
4 | * by: Christopher Michael Brock
5 | */
6 |
7 |
8 | array = null;
9 |
10 | def swap(i, j) {
11 | temp = array[i];
12 | array[i] = array[j];
13 | array[j] = temp;
14 | }
15 |
16 | def partition(low, high) {
17 | pivotPoint = array[low];
18 |
19 | i = low - 1;
20 | j = high + 1;
21 |
22 | while (i < j) {
23 | i++; while (array[i] < pivotPoint) ++i;
24 | j--; while (array[j] > pivotPoint) --j;
25 | if (i < j) swap(i, j);
26 | }
27 |
28 | j; //return j
29 | }
30 |
31 | def sort(low, high) {
32 | if (low < high) {
33 | var p;
34 | sort(low, p = partition(low, high));
35 | sort(p + 1, high);
36 | }
37 | }
38 |
39 | def quicksort() {
40 | sort(0, array.length - 1);
41 | }
42 |
43 | array = {99,20,21,209,10,77,8,9,55,73,41,50};
44 |
45 | quicksort();
46 |
47 | array; // return array
--------------------------------------------------------------------------------
/samples/scripts/quicksort2.mvel:
--------------------------------------------------------------------------------
1 | /**
2 | * Sample MVEL 2.0 Script
3 | * "QuickSort"
4 | * by: Christopher Michael Brock
5 | */
6 |
7 | array = null;
8 |
9 | def swap(i, j) {
10 | temp = array[i];
11 | array[i] = array[j];
12 | array[j] = temp;
13 | }
14 |
15 | def partition(low, high) {
16 | pivotPoint = array[low];
17 |
18 | i = low - 1;
19 | j = high + 1;
20 |
21 | while (i < j) {
22 | i += 1; while (array[i] < pivotPoint) i += 1;
23 | j -= 1; while (array[j] > pivotPoint) j -= 1;
24 | if (i < j) swap(i, j);
25 | }
26 |
27 | j; //return j
28 | }
29 |
30 | def sort(low, high) {
31 | if (low < high) {
32 | var p;
33 | sort(low, p = partition(low, high));
34 | sort(p + 1, high);
35 | }
36 | }
37 |
38 | def quicksort() {
39 | sort(0, array.length - 1);
40 | }
41 |
42 | array = {50,20,21,209,10,77,8,9,55,73,41,99};
43 |
44 | quicksort();
45 |
46 | array; // return array
--------------------------------------------------------------------------------
/samples/scripts/quicksort3.mvel:
--------------------------------------------------------------------------------
1 | /**
2 | * Sample MVEL 2.0 Script
3 | * "QuickSort"
4 | * by: Christopher Michael Brock
5 | */
6 |
7 | array = null;
8 |
9 |
10 | def swap(i, j) {
11 | temp = array[i];
12 | array[i] = array[j];
13 | array[j] = temp;
14 | }
15 |
16 | def partition(low, high) {
17 | int pivotPoint = array[low], i = low - 1, j = high + 1;
18 |
19 | while (i < j) {
20 | i += 1; while (array[i] < pivotPoint) i += 1;
21 | j -= 1; while (array[j] > pivotPoint) j -= 1;
22 | if (i < j) swap(i, j);
23 | }
24 |
25 | j; //return j
26 | }
27 |
28 | def sort(low, high) {
29 | if (low < high) {
30 | var p;
31 | sort(low, p = partition(low, high));
32 | sort(p + 1, high);
33 | }
34 | }
35 |
36 | def quicksort() {
37 | sort(0, array.length - 1);
38 | }
39 |
40 | array = {50,20,21,209,10,77,8,9,55,73,41,99};
41 |
42 | quicksort();
43 |
44 | array; // return array
--------------------------------------------------------------------------------
/samples/scripts/randomguess.mvel:
--------------------------------------------------------------------------------
1 | /**
2 | * Sample MVEL 2.0 Script
3 | * "Random Guess"
4 | * by: Christopher Michael Brock
5 | */
6 |
7 | import java.io.*;
8 |
9 | //
10 | // Seed the random number
11 | //
12 |
13 | $num = (int) Math.random() * 100;
14 | $guesses = 0;
15 | $in = -1;
16 |
17 | //
18 | // Setup the STDIN line reader.
19 | //
20 |
21 | $linereader = new BufferedReader(new InputStreamReader(System.in));
22 |
23 | System.out.print("I'm Thinking of a Number Between 1 and 100... Can you guess what it is? ");
24 |
25 | //
26 | // Main program loop
27 | //
28 |
29 | while ($in != $num) {
30 | if ($in != -1) {
31 | System.out.print("Nope. The number is: " + ($num < $in ? "Lower" : "Higher") + ". What's your next guess? ");
32 | }
33 | if (($in = $linereader.readLine().trim()) == empty) $in = -2;
34 | $guesses++;
35 | }
36 |
37 | System.out.println("You got it! It took you " + $guesses + " tries");
38 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ConversionException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2;
20 |
21 | public class ConversionException extends RuntimeException {
22 |
23 |
24 | public ConversionException(String message) {
25 | super(message); //To change body of overridden methods use File | Settings | File Templates.
26 | }
27 |
28 | public ConversionException(String message, Throwable cause) {
29 | super(message, cause); //To change body of overridden methods use File | Settings | File Templates.
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ConversionHandler.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 MVFLEX/Valhalla Project and the Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2;
20 |
21 | /**
22 | * The conversion handler interface defines the basic interface for implementing conversion handlers in MVEL.
23 | *
24 | * @see org.mvel2.DataConversion
25 | */
26 | public interface ConversionHandler {
27 | /**
28 | * Converts the passed argument to the type represented by the handler.
29 | *
30 | * @param in - the input type
31 | * @return - the converted type
32 | */
33 | public Object convertFrom(Object in);
34 |
35 | /**
36 | * This method is used to indicate to the runtime whehter or not the handler knows how to convert
37 | * from the specified type.
38 | *
39 | * @param cls - the source type
40 | * @return - true if the converter supports converting from the specified type.
41 | */
42 | public boolean canConvertFrom(Class cls);
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ImmutableElementException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 |
20 | package org.mvel2;
21 |
22 | /**
23 | * Exception thrown by internal immutable structures if any modifications are attempted.
24 | */
25 | public class ImmutableElementException extends RuntimeException {
26 |
27 | public ImmutableElementException() {
28 | super();
29 | }
30 |
31 | public ImmutableElementException(String s) {
32 | super(s);
33 | }
34 |
35 | public ImmutableElementException(String s, Throwable throwable) {
36 | super(s, throwable);
37 | }
38 |
39 | public ImmutableElementException(Throwable throwable) {
40 | super(throwable);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/Macro.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2;
20 |
21 | /**
22 | * @author Christopher Brock
23 | */
24 | public interface Macro {
25 | public String doMacro();
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/OptimizationFailure.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 | package org.mvel2;
19 |
20 | public class OptimizationFailure extends RuntimeException {
21 |
22 | public OptimizationFailure() {
23 | super();
24 | }
25 |
26 | public OptimizationFailure(String message) {
27 | super(message);
28 | }
29 |
30 | public OptimizationFailure(String message, Throwable cause) {
31 | super(message, cause);
32 | }
33 |
34 | public OptimizationFailure(Throwable cause) {
35 | super(cause);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/PreProcessor.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2;
20 |
21 | /**
22 | * A preprocessor used for pre-processing any expressions before being parsed/compiled.
23 | */
24 | public interface PreProcessor {
25 | public char[] parse(char[] input);
26 |
27 | public String parse(String input);
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/PropertyAccessException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 | package org.mvel2;
19 |
20 | public class PropertyAccessException extends CompileException {
21 |
22 | // public PropertyAccessException() {
23 | // super();
24 | // }
25 | //
26 | // public PropertyAccessException(String message) {
27 | // super( message);
28 | // }
29 | //
30 | // public PropertyAccessException(String message, Throwable cause) {
31 | // super( message, cause);
32 | // }
33 | //
34 | // public PropertyAccessException(Throwable cause) {
35 | // super(cause);
36 | // }
37 |
38 | public PropertyAccessException(String message, char[] expr, int cursor, Throwable e) {
39 | super(message, expr, cursor, e);
40 | }
41 |
42 | public PropertyAccessException(String message, char[] expr, int cursor) {
43 | super(message, expr, cursor);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ScriptRuntimeException.java:
--------------------------------------------------------------------------------
1 | package org.mvel2;
2 |
3 | /**
4 | * @author Mike Brock .
5 | */
6 | public class ScriptRuntimeException extends RuntimeException {
7 | public ScriptRuntimeException() {
8 | }
9 |
10 | public ScriptRuntimeException(String message) {
11 | super(message);
12 | }
13 |
14 | public ScriptRuntimeException(String message, Throwable cause) {
15 | super(message, cause);
16 | }
17 |
18 | public ScriptRuntimeException(Throwable cause) {
19 | super(cause);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/Unit.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2;
20 |
21 | public interface Unit extends ConversionHandler {
22 | public double getValue();
23 |
24 | public void setValue(double value);
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/UnresolveablePropertyException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2;
20 |
21 | import org.mvel2.ast.ASTNode;
22 |
23 | /**
24 | * @author Christopher Brock
25 | */
26 | public class UnresolveablePropertyException extends RuntimeException {
27 |
28 | private String name;
29 |
30 | public UnresolveablePropertyException(ASTNode astNode, Throwable throwable) {
31 | super("unable to resolve token: " + astNode.getName(), throwable);
32 | this.name = astNode.getName();
33 | }
34 |
35 | public UnresolveablePropertyException(ASTNode astNode) {
36 | super("unable to resolve token: " + astNode.getName());
37 | this.name = astNode.getName();
38 | }
39 |
40 | public UnresolveablePropertyException(String name) {
41 | super("unable to resolve token: " + name);
42 | this.name = name;
43 | }
44 |
45 | public String getName() {
46 | return name;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/asm/signature/package.html:
--------------------------------------------------------------------------------
1 |
2 |
31 |
32 | Provides support for type signatures.
33 |
34 | @since ASM 2.0
35 |
36 |
37 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/ArraySize.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.ast;
20 |
21 | import java.io.Serializable;
22 |
23 | public class ArraySize implements Serializable {
24 | public ArraySize(char[] value) {
25 | this.value = value;
26 | }
27 |
28 | public char[] value;
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/Assignment.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.ast;
20 |
21 | import org.mvel2.compiler.ExecutableStatement;
22 |
23 | public interface Assignment {
24 | public String getAssignmentVar();
25 |
26 | public char[] getExpression();
27 |
28 | public boolean isNewDeclaration();
29 |
30 | public void setValueStatement(ExecutableStatement stmt);
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/BlockNode.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.ast;
20 |
21 | import org.mvel2.compiler.ExecutableStatement;
22 |
23 | /**
24 | * @author Christopher Brock
25 | */
26 | public class BlockNode extends ASTNode {
27 | protected int blockStart;
28 | protected int blockOffset;
29 |
30 | protected ExecutableStatement compiledBlock;
31 |
32 | public BlockNode() {
33 | }
34 |
35 | public ExecutableStatement getCompiledBlock() {
36 | return compiledBlock;
37 | }
38 |
39 | public int getBlockStart() {
40 | return blockStart;
41 | }
42 |
43 | public int getBlockOffset() {
44 | return blockOffset;
45 | }
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/BooleanNode.java:
--------------------------------------------------------------------------------
1 | package org.mvel2.ast;
2 |
3 | public abstract class BooleanNode extends ASTNode {
4 | protected ASTNode left;
5 | protected ASTNode right;
6 |
7 | public ASTNode getLeft() {
8 | return this.left;
9 | }
10 |
11 | public ASTNode getRight() {
12 | return this.right;
13 | }
14 |
15 | public void setLeft(ASTNode node) {
16 | this.left = node;
17 | }
18 |
19 | public void setRight(ASTNode node) {
20 | this.right = node;
21 | }
22 |
23 | public abstract void setRightMost(ASTNode right);
24 |
25 | public abstract ASTNode getRightMost();
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/Contains.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.ast;
20 |
21 | import org.mvel2.integration.VariableResolverFactory;
22 |
23 | import static org.mvel2.util.ParseTools.containsCheck;
24 |
25 | public class Contains extends ASTNode {
26 | private ASTNode stmt;
27 | private ASTNode stmt2;
28 |
29 | public Contains(ASTNode stmt, ASTNode stmt2) {
30 | this.stmt = stmt;
31 | this.stmt2 = stmt2;
32 | }
33 |
34 | public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
35 | return containsCheck(stmt.getReducedValueAccelerated(ctx, thisValue, factory), stmt2.getReducedValueAccelerated(ctx, thisValue, factory));
36 | }
37 |
38 | public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
39 | throw new RuntimeException("operation not supported");
40 | }
41 |
42 | public Class getEgressType() {
43 | return Boolean.class;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/Convertable.java:
--------------------------------------------------------------------------------
1 | package org.mvel2.ast;
2 |
3 | import org.mvel2.DataConversion;
4 | import org.mvel2.integration.VariableResolverFactory;
5 | import org.mvel2.util.CompilerTools;
6 |
7 | public class Convertable extends ASTNode {
8 | private ASTNode stmt;
9 | private ASTNode clsStmt;
10 |
11 | public Convertable(ASTNode stmt, ASTNode clsStmt) {
12 | this.stmt = stmt;
13 | this.clsStmt = clsStmt;
14 | CompilerTools.expectType(clsStmt, Class.class, true);
15 | }
16 |
17 | public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
18 | Object o = stmt.getReducedValueAccelerated(ctx, thisValue, factory);
19 | return o != null && DataConversion.canConvert(
20 | (Class) clsStmt.getReducedValueAccelerated(ctx, thisValue, factory), o.getClass());
21 |
22 | }
23 |
24 | public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
25 | try {
26 |
27 | Object o = stmt.getReducedValue(ctx, thisValue, factory);
28 | if (o == null) return false;
29 |
30 | Class i = (Class) clsStmt.getReducedValue(ctx, thisValue, factory);
31 | if (i == null) throw new ClassCastException();
32 |
33 |
34 | return DataConversion.canConvert(i, o.getClass());
35 | }
36 | catch (ClassCastException e) {
37 | throw new RuntimeException("not a class reference: " + clsStmt.getName());
38 | }
39 |
40 | }
41 |
42 | public Class getEgressType() {
43 | return Boolean.class;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/EndOfStatement.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.ast;
20 |
21 | import org.mvel2.Operator;
22 | import org.mvel2.integration.VariableResolverFactory;
23 |
24 | /**
25 | * @author Christopher Brock
26 | */
27 | public class EndOfStatement extends ASTNode {
28 | public EndOfStatement() {
29 | this.literal = getOperator();
30 | }
31 |
32 | public boolean isOperator() {
33 | return true;
34 | }
35 |
36 | public boolean isOperator(Integer operator) {
37 | return operator == Operator.END_OF_STMT;
38 | }
39 |
40 | public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
41 | return null;
42 | }
43 |
44 | public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
45 | return null;
46 | }
47 |
48 | public Integer getOperator() {
49 | return Operator.END_OF_STMT;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/IndexedPostFixIncNode.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.ast;
20 |
21 | import org.mvel2.DataTypes;
22 | import org.mvel2.Operator;
23 | import org.mvel2.ParserContext;
24 | import org.mvel2.integration.VariableResolver;
25 | import org.mvel2.integration.VariableResolverFactory;
26 | import org.mvel2.math.MathProcessor;
27 |
28 | /**
29 | * @author Christopher Brock
30 | */
31 | public class IndexedPostFixIncNode extends ASTNode {
32 | private int register;
33 |
34 | public IndexedPostFixIncNode(int register, ParserContext pCtx) {
35 | this.register = register;
36 | this.egressType = pCtx.getVarOrInputType(pCtx.getIndexedVarNames()[register]);
37 | }
38 |
39 | public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
40 | VariableResolver vResolver = factory.getIndexedVariableResolver(register);
41 | vResolver.setValue(MathProcessor.doOperations(ctx = vResolver.getValue(), Operator.ADD, DataTypes.INTEGER, 1));
42 | return ctx;
43 | }
44 |
45 | public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
46 | return getReducedValueAccelerated(ctx, thisValue, factory);
47 | }
48 | }
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/IndexedPreFixDecNode.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 | package org.mvel2.ast;
19 |
20 | import org.mvel2.DataTypes;
21 | import org.mvel2.Operator;
22 | import org.mvel2.ParserContext;
23 | import org.mvel2.integration.VariableResolver;
24 | import org.mvel2.integration.VariableResolverFactory;
25 | import org.mvel2.math.MathProcessor;
26 |
27 | /**
28 | * @author Christopher Brock
29 | */
30 | public class IndexedPreFixDecNode extends ASTNode {
31 | private int register;
32 |
33 | public IndexedPreFixDecNode(int register, ParserContext pCtx) {
34 | this.register = register;
35 | this.egressType = pCtx.getVarOrInputType(pCtx.getIndexedVarNames()[register]);
36 | }
37 |
38 | public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
39 | VariableResolver vResolver = factory.getIndexedVariableResolver(register);
40 | vResolver.setValue(ctx = MathProcessor.doOperations(vResolver.getValue(), Operator.SUB, DataTypes.INTEGER, 1));
41 | return ctx;
42 | }
43 |
44 | public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
45 | return getReducedValueAccelerated(ctx, thisValue, factory);
46 | }
47 | }
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/IndexedPreFixIncNode.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.ast;
20 |
21 | import org.mvel2.DataTypes;
22 | import org.mvel2.Operator;
23 | import org.mvel2.ParserContext;
24 | import org.mvel2.integration.VariableResolver;
25 | import org.mvel2.integration.VariableResolverFactory;
26 | import org.mvel2.math.MathProcessor;
27 |
28 | /**
29 | * @author Christopher Brock
30 | */
31 | public class IndexedPreFixIncNode extends ASTNode {
32 | private int register;
33 |
34 | public IndexedPreFixIncNode(int register, ParserContext pCtx) {
35 | this.register = register;
36 | this.egressType = pCtx.getVarOrInputType(pCtx.getIndexedVarNames()[register]);
37 | }
38 |
39 | public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
40 | VariableResolver vResolver = factory.getIndexedVariableResolver(register);
41 | vResolver.setValue(ctx = MathProcessor.doOperations(vResolver.getValue(), Operator.ADD, DataTypes.INTEGER, 1));
42 | return ctx;
43 | }
44 |
45 | public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
46 | return getReducedValueAccelerated(ctx, thisValue, factory);
47 | }
48 | }
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/Instance.java:
--------------------------------------------------------------------------------
1 | package org.mvel2.ast;
2 |
3 | import org.mvel2.integration.VariableResolverFactory;
4 | import org.mvel2.util.CompilerTools;
5 |
6 |
7 | public class Instance extends ASTNode {
8 | private ASTNode stmt;
9 | private ASTNode clsStmt;
10 |
11 | public Instance(ASTNode stmt, ASTNode clsStmt) {
12 | this.stmt = stmt;
13 | this.clsStmt = clsStmt;
14 | CompilerTools.expectType(clsStmt, Class.class, true);
15 | }
16 |
17 | public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
18 | return ((Class) clsStmt.getReducedValueAccelerated(ctx, thisValue, factory)).isInstance(stmt.getReducedValueAccelerated(ctx, thisValue, factory));
19 | }
20 |
21 | public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
22 | try {
23 | Class i = (Class) clsStmt.getReducedValue(ctx, thisValue, factory);
24 | if (i == null) throw new ClassCastException();
25 |
26 | return i.isInstance(stmt.getReducedValue(ctx, thisValue, factory));
27 | }
28 | catch (ClassCastException e) {
29 | throw new RuntimeException("not a class reference: " + clsStmt.getName());
30 | }
31 |
32 | }
33 |
34 | public Class getEgressType() {
35 | return Boolean.class;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/IntAdd.java:
--------------------------------------------------------------------------------
1 | package org.mvel2.ast;
2 |
3 | import org.mvel2.Operator;
4 | import org.mvel2.integration.VariableResolverFactory;
5 |
6 | public class IntAdd extends BinaryOperation implements IntOptimized {
7 | public IntAdd(ASTNode left, ASTNode right) {
8 | super(Operator.ADD);
9 | this.left = left;
10 | this.right = right;
11 | }
12 |
13 | @Override
14 | public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
15 | return ((Integer) left.getReducedValueAccelerated(ctx, thisValue, factory))
16 | + ((Integer) right.getReducedValueAccelerated(ctx, thisValue, factory));
17 | }
18 |
19 | @Override
20 | public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
21 | return ((Integer) left.getReducedValue(ctx, thisValue, factory))
22 | + ((Integer) right.getReducedValue(ctx, thisValue, factory));
23 | }
24 |
25 | @Override
26 | public Class getEgressType() {
27 | return Integer.class;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/IntDiv.java:
--------------------------------------------------------------------------------
1 | package org.mvel2.ast;
2 |
3 | import org.mvel2.Operator;
4 | import org.mvel2.integration.VariableResolverFactory;
5 |
6 |
7 | public class IntDiv extends BinaryOperation implements IntOptimized {
8 | public IntDiv(ASTNode left, ASTNode right) {
9 | super(Operator.MULT);
10 | this.left = left;
11 | this.right = right;
12 | }
13 |
14 | @Override
15 | public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
16 | return ((Integer) left.getReducedValueAccelerated(ctx, thisValue, factory))
17 | / ((Integer) right.getReducedValueAccelerated(ctx, thisValue, factory));
18 | }
19 |
20 | @Override
21 | public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
22 | return ((Integer) left.getReducedValue(ctx, thisValue, factory))
23 | / ((Integer) right.getReducedValue(ctx, thisValue, factory));
24 | }
25 |
26 | @Override
27 | public void setRight(ASTNode node) {
28 | super.setRight(node);
29 | }
30 |
31 | @Override
32 | public Class getEgressType() {
33 | return Integer.class;
34 | }
35 | }
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/IntMult.java:
--------------------------------------------------------------------------------
1 | package org.mvel2.ast;
2 |
3 | import org.mvel2.Operator;
4 | import org.mvel2.integration.VariableResolverFactory;
5 |
6 |
7 | public class IntMult extends BinaryOperation implements IntOptimized {
8 | public IntMult(ASTNode left, ASTNode right) {
9 | super(Operator.MULT);
10 | this.left = left;
11 | this.right = right;
12 | }
13 |
14 | @Override
15 | public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
16 | return ((Integer) left.getReducedValueAccelerated(ctx, thisValue, factory))
17 | * ((Integer) right.getReducedValueAccelerated(ctx, thisValue, factory));
18 | }
19 |
20 | @Override
21 | public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
22 | return ((Integer) left.getReducedValue(ctx, thisValue, factory))
23 | * ((Integer) right.getReducedValue(ctx, thisValue, factory));
24 | }
25 |
26 | @Override
27 | public Class getEgressType() {
28 | return Integer.class;
29 | }
30 | }
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/IntOptimized.java:
--------------------------------------------------------------------------------
1 | package org.mvel2.ast;
2 |
3 | public interface IntOptimized {
4 | }
5 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/IntSub.java:
--------------------------------------------------------------------------------
1 | package org.mvel2.ast;
2 |
3 | import org.mvel2.Operator;
4 | import org.mvel2.integration.VariableResolverFactory;
5 |
6 |
7 | public class IntSub extends BinaryOperation implements IntOptimized {
8 | public IntSub(ASTNode left, ASTNode right) {
9 | super(Operator.SUB);
10 | this.left = left;
11 | this.right = right;
12 | }
13 |
14 | @Override
15 | public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
16 | return ((Integer) left.getReducedValueAccelerated(ctx, thisValue, factory))
17 | - ((Integer) right.getReducedValueAccelerated(ctx, thisValue, factory));
18 | }
19 |
20 | @Override
21 | public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
22 | return ((Integer) left.getReducedValue(ctx, thisValue, factory))
23 | - ((Integer) right.getReducedValue(ctx, thisValue, factory));
24 | }
25 |
26 |
27 | @Override
28 | public Class getEgressType() {
29 | return Integer.class;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/InterceptorWrapper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.ast;
20 |
21 | import org.mvel2.integration.Interceptor;
22 | import org.mvel2.integration.VariableResolverFactory;
23 |
24 | /**
25 | * @author Christopher Brock
26 | */
27 | public class InterceptorWrapper extends ASTNode {
28 | private Interceptor interceptor;
29 | private ASTNode node;
30 |
31 | public InterceptorWrapper(Interceptor interceptor, ASTNode node) {
32 | this.interceptor = interceptor;
33 | this.node = node;
34 | }
35 |
36 | public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
37 | interceptor.doBefore(node, factory);
38 | interceptor.doAfter(ctx = node.getReducedValueAccelerated(ctx, thisValue, factory), node, factory);
39 | return ctx;
40 | }
41 |
42 | public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
43 | interceptor.doBefore(node, factory);
44 | interceptor.doAfter(ctx = node.getReducedValue(ctx, thisValue, factory), node, factory);
45 | return ctx;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/IsDef.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.ast;
20 |
21 | import org.mvel2.integration.VariableResolverFactory;
22 |
23 | import static org.mvel2.util.PropertyTools.getFieldOrAccessor;
24 |
25 | public class IsDef extends ASTNode {
26 | public IsDef(char[] expr, int start, int offset) {
27 | this.nameCache = new String(this.expr = expr, this.start = start, this.offset = offset);
28 | }
29 |
30 | public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
31 | return factory.isResolveable(nameCache) || (thisValue != null && getFieldOrAccessor(thisValue.getClass(), nameCache) != null);
32 | }
33 |
34 | public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
35 | return factory.isResolveable(nameCache) || (thisValue != null && getFieldOrAccessor(thisValue.getClass(), nameCache) != null);
36 |
37 | }
38 |
39 | public Class getEgressType() {
40 | return Boolean.class;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/NestedStatement.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 | package org.mvel2.ast;
19 |
20 | import org.mvel2.compiler.ExecutableStatement;
21 |
22 | /**
23 | * @author Christopher Brock
24 | */
25 | public interface NestedStatement {
26 | public ExecutableStatement getNestedStatement();
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/NewPrototypeNode.java:
--------------------------------------------------------------------------------
1 | package org.mvel2.ast;
2 |
3 | import org.mvel2.integration.VariableResolverFactory;
4 |
5 | public class NewPrototypeNode extends ASTNode {
6 | private String protoName;
7 |
8 | public NewPrototypeNode(TypeDescriptor t) {
9 | this.protoName = t.getClassName();
10 | }
11 |
12 | @Override
13 | public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
14 | return ((Proto) factory.getVariableResolver(protoName).getValue())
15 | .newInstance(ctx, thisValue, factory);
16 | }
17 |
18 | @Override
19 | public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
20 | return ((Proto) factory.getVariableResolver(protoName).getValue())
21 | .newInstance(ctx, thisValue, factory);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/OperatorNode.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.ast;
20 |
21 | import org.mvel2.CompileException;
22 | import org.mvel2.integration.VariableResolverFactory;
23 |
24 | import static org.mvel2.debug.DebugTools.getOperatorSymbol;
25 |
26 | public class OperatorNode extends ASTNode {
27 | private Integer operator;
28 |
29 | public OperatorNode(Integer operator, char[] expr, int start) {
30 | assert operator != null;
31 | this.expr = expr;
32 | this.literal = this.operator = operator;
33 | this.start = start;
34 | }
35 |
36 | public boolean isOperator() {
37 | return true;
38 | }
39 |
40 | public boolean isOperator(Integer operator) {
41 | return operator.equals(this.operator);
42 | }
43 |
44 | public Integer getOperator() {
45 | return operator;
46 | }
47 |
48 | public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
49 | throw new CompileException("illegal use of operator: " + getOperatorSymbol(operator), expr, start);
50 | }
51 |
52 | public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
53 | throw new CompileException("illegal use of operator: " + getOperatorSymbol(operator), expr, start);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/PostFixDecNode.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 | package org.mvel2.ast;
19 |
20 | import org.mvel2.DataTypes;
21 | import org.mvel2.Operator;
22 | import org.mvel2.ParserContext;
23 | import org.mvel2.integration.VariableResolver;
24 | import org.mvel2.integration.VariableResolverFactory;
25 | import org.mvel2.math.MathProcessor;
26 |
27 | /**
28 | * @author Christopher Brock
29 | */
30 | public class PostFixDecNode extends ASTNode {
31 | private String name;
32 |
33 | public PostFixDecNode(String name, ParserContext pCtx) {
34 | this.name = name;
35 | if (pCtx != null) {
36 | this.egressType = pCtx.getVarOrInputType(name);
37 | }
38 | }
39 |
40 | public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
41 | VariableResolver vResolver = factory.getVariableResolver(name);
42 | vResolver.setValue(MathProcessor.doOperations(ctx = vResolver.getValue(), Operator.SUB, DataTypes.INTEGER, 1));
43 | return ctx;
44 | }
45 |
46 | public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
47 | return getReducedValueAccelerated(ctx, thisValue, factory);
48 | }
49 |
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/PostFixIncNode.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 | package org.mvel2.ast;
19 |
20 | import org.mvel2.DataTypes;
21 | import org.mvel2.Operator;
22 | import org.mvel2.ParserContext;
23 | import org.mvel2.integration.VariableResolver;
24 | import org.mvel2.integration.VariableResolverFactory;
25 | import org.mvel2.math.MathProcessor;
26 |
27 | /**
28 | * @author Christopher Brock
29 | */
30 | public class PostFixIncNode extends ASTNode {
31 | private String name;
32 |
33 | public PostFixIncNode(String name, ParserContext pCtx) {
34 | this.name = name;
35 | if (pCtx != null) {
36 | this.egressType = pCtx.getVarOrInputType(name);
37 | }
38 | }
39 |
40 | public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
41 | VariableResolver vResolver = factory.getVariableResolver(name);
42 | vResolver.setValue(MathProcessor.doOperations(ctx = vResolver.getValue(), Operator.ADD, DataTypes.INTEGER, 1));
43 | return ctx;
44 | }
45 |
46 | public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
47 | return getReducedValueAccelerated(ctx, thisValue, factory);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/PreFixDecNode.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 | package org.mvel2.ast;
19 |
20 | import org.mvel2.DataTypes;
21 | import org.mvel2.Operator;
22 | import org.mvel2.ParserContext;
23 | import org.mvel2.integration.VariableResolver;
24 | import org.mvel2.integration.VariableResolverFactory;
25 | import org.mvel2.math.MathProcessor;
26 |
27 | /**
28 | * @author Christopher Brock
29 | */
30 | public class PreFixDecNode extends ASTNode {
31 | private String name;
32 |
33 | public PreFixDecNode(String name, ParserContext pCtx) {
34 | this.name = name;
35 | if (pCtx != null) {
36 | this.egressType = pCtx.getVarOrInputType(name);
37 | }
38 | }
39 |
40 | public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
41 | VariableResolver vResolver = factory.getVariableResolver(name);
42 | vResolver.setValue(ctx = MathProcessor.doOperations(vResolver.getValue(), Operator.SUB, DataTypes.INTEGER, 1));
43 | return ctx;
44 | }
45 |
46 | public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
47 | return getReducedValueAccelerated(ctx, thisValue, factory);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/PreFixIncNode.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 | package org.mvel2.ast;
19 |
20 | import org.mvel2.DataTypes;
21 | import org.mvel2.Operator;
22 | import org.mvel2.ParserContext;
23 | import org.mvel2.integration.VariableResolver;
24 | import org.mvel2.integration.VariableResolverFactory;
25 | import org.mvel2.math.MathProcessor;
26 |
27 |
28 | /**
29 | * @author Christopher Brock
30 | */
31 | public class PreFixIncNode extends ASTNode {
32 | private String name;
33 |
34 | public PreFixIncNode(String name, ParserContext pCtx) {
35 | this.name = name;
36 | if (pCtx != null) {
37 | this.egressType = pCtx.getVarOrInputType(name);
38 | }
39 | }
40 |
41 | public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
42 | VariableResolver vResolver = factory.getVariableResolver(name);
43 | vResolver.setValue(ctx = MathProcessor.doOperations(vResolver.getValue(), Operator.ADD, DataTypes.INTEGER, 1));
44 | return ctx;
45 | }
46 |
47 | public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
48 | return getReducedValueAccelerated(ctx, thisValue, factory);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/ReduceableCodeException.java:
--------------------------------------------------------------------------------
1 | package org.mvel2.ast;
2 |
3 | public class ReduceableCodeException extends RuntimeException {
4 | private Object literal;
5 |
6 | public Object getLiteral() {
7 | return literal;
8 | }
9 |
10 | public ReduceableCodeException(Object literal) {
11 | this.literal = literal;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/RedundantCodeException.java:
--------------------------------------------------------------------------------
1 | package org.mvel2.ast;
2 |
3 | public class RedundantCodeException extends RuntimeException {
4 | }
5 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/RegExMatchNode.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.ast;
20 |
21 | import org.mvel2.integration.VariableResolverFactory;
22 |
23 | import static java.lang.String.valueOf;
24 | import static java.util.regex.Pattern.compile;
25 | import static org.mvel2.MVEL.eval;
26 |
27 | public class RegExMatchNode extends ASTNode {
28 | private ASTNode node;
29 | private ASTNode patternNode;
30 |
31 | public RegExMatchNode(ASTNode matchNode, ASTNode patternNode) {
32 | this.node = matchNode;
33 | this.patternNode = patternNode;
34 | }
35 |
36 | public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
37 | return compile(valueOf(patternNode.getReducedValueAccelerated(ctx, thisValue, factory))).matcher(valueOf(node.getReducedValueAccelerated(ctx, thisValue, factory))).matches();
38 | }
39 |
40 | public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
41 | return compile(valueOf(eval(expr, patternNode.start, patternNode.offset, ctx, factory)))
42 | .matcher(valueOf(eval(expr, node.start, node.offset, ctx, factory))).matches();
43 | }
44 |
45 | public Class getEgressType() {
46 | return Boolean.class;
47 | }
48 | }
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/Safe.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 | package org.mvel2.ast;
19 |
20 | /**
21 | * Marker interface to tell MVEL it can safely hard-reference.
22 | */
23 | public interface Safe {
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/Soundslike.java:
--------------------------------------------------------------------------------
1 | package org.mvel2.ast;
2 |
3 | import org.mvel2.CompileException;
4 | import org.mvel2.integration.VariableResolverFactory;
5 | import org.mvel2.util.CompilerTools;
6 |
7 | import static org.mvel2.util.Soundex.soundex;
8 |
9 | public class Soundslike extends ASTNode {
10 | private ASTNode stmt;
11 | private ASTNode soundslike;
12 |
13 | public Soundslike(ASTNode stmt, ASTNode clsStmt) {
14 | this.stmt = stmt;
15 | this.soundslike = clsStmt;
16 | CompilerTools.expectType(clsStmt, String.class, true);
17 | }
18 |
19 | public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
20 | return soundex(String.valueOf(soundslike.getReducedValueAccelerated(ctx, thisValue, factory)))
21 | .equals(soundex((String) stmt.getReducedValueAccelerated(ctx, thisValue, factory)));
22 | }
23 |
24 | public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
25 | try {
26 | String i = String.valueOf(soundslike.getReducedValue(ctx, thisValue, factory));
27 | if (i == null) throw new ClassCastException();
28 |
29 | String x = (String) stmt.getReducedValue(ctx, thisValue, factory);
30 | if (x == null) throw new CompileException("not a string: " + stmt.getName(), stmt.getExpr(), stmt.getStart());
31 |
32 | return soundex(i).equals(soundex(x));
33 | }
34 | catch (ClassCastException e) {
35 | throw new CompileException("not a string: " + soundslike.getName(), soundslike.getExpr(), soundslike.getStart());
36 | }
37 |
38 | }
39 |
40 | public Class getEgressType() {
41 | return Boolean.class;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/ast/Strsim.java:
--------------------------------------------------------------------------------
1 | package org.mvel2.ast;
2 |
3 | import org.mvel2.CompileException;
4 | import org.mvel2.integration.VariableResolverFactory;
5 | import org.mvel2.util.CompilerTools;
6 |
7 | import static org.mvel2.util.ParseTools.similarity;
8 |
9 | public class Strsim extends ASTNode {
10 | private ASTNode stmt;
11 | private ASTNode soundslike;
12 |
13 | public Strsim(ASTNode stmt, ASTNode clsStmt) {
14 | this.stmt = stmt;
15 | this.soundslike = clsStmt;
16 | CompilerTools.expectType(clsStmt, String.class, true);
17 | }
18 |
19 | public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
20 | return similarity(String.valueOf(soundslike.getReducedValueAccelerated(ctx, thisValue, factory)),
21 | ((String) stmt.getReducedValueAccelerated(ctx, thisValue, factory)));
22 | }
23 |
24 | public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
25 | try {
26 | String i = String.valueOf(soundslike.getReducedValue(ctx, thisValue, factory));
27 | if (i == null) throw new ClassCastException();
28 |
29 | String x = (String) stmt.getReducedValue(ctx, thisValue, factory);
30 | if (x == null) throw new CompileException("not a string: " + stmt.getName(), stmt.getExpr(), getStart());
31 |
32 | return similarity(i, x);
33 | }
34 | catch (ClassCastException e) {
35 | throw new CompileException("not a string: " + soundslike.getName(), soundslike.getExpr(), soundslike.getStart());
36 | }
37 |
38 | }
39 |
40 | public Class getEgressType() {
41 | return Boolean.class;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/compiler/Accessor.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.compiler;
20 |
21 | import org.mvel2.integration.VariableResolverFactory;
22 |
23 | public interface Accessor {
24 | public Object getValue(Object ctx, Object elCtx, VariableResolverFactory variableFactory);
25 |
26 | public Object setValue(Object ctx, Object elCtx, VariableResolverFactory variableFactory, Object value);
27 |
28 | public Class getKnownEgressType();
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/compiler/AccessorNode.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.compiler;
20 |
21 | import java.io.Serializable;
22 |
23 | public interface AccessorNode extends Accessor, Serializable {
24 | public AccessorNode getNextNode();
25 |
26 | public AccessorNode setNextNode(AccessorNode accessorNode);
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/compiler/BlankLiteral.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.compiler;
20 |
21 | import java.io.Serializable;
22 | import java.util.Collection;
23 |
24 | import static java.lang.String.valueOf;
25 | import static java.lang.reflect.Array.getLength;
26 | import static org.mvel2.util.ParseTools.isNumeric;
27 |
28 | public class BlankLiteral implements Serializable {
29 | public static final BlankLiteral INSTANCE = new BlankLiteral();
30 |
31 | public BlankLiteral() {
32 | }
33 |
34 | public boolean equals(Object obj) {
35 | if (obj == null || "".equals(valueOf(obj))) {
36 | return true;
37 | }
38 | else if (isNumeric(obj)) {
39 | return "0".equals(valueOf(obj));
40 | }
41 | else if (obj instanceof Collection) {
42 | return ((Collection) obj).size() == 0;
43 | }
44 | else if (obj.getClass().isArray()) {
45 | return getLength(obj) == 0;
46 | }
47 | return false;
48 | }
49 |
50 | public String toString() {
51 | return "";
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/compiler/EndWithValue.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.compiler;
20 |
21 | /**
22 | * @author Christopher Brock
23 | */
24 | public class EndWithValue extends RuntimeException {
25 | private Object value;
26 |
27 |
28 | public EndWithValue(Object value) {
29 | this.value = value;
30 | }
31 |
32 | public Object getValue() {
33 | return value;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/compiler/ExecutableStatement.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.compiler;
20 |
21 | import org.mvel2.integration.VariableResolverFactory;
22 |
23 | import java.io.Serializable;
24 |
25 | public interface ExecutableStatement extends Accessor, Serializable, Cloneable {
26 | public Object getValue(Object staticContext, VariableResolverFactory factory);
27 |
28 | public void setKnownIngressType(Class type);
29 |
30 | public void setKnownEgressType(Class type);
31 |
32 | public Class getKnownIngressType();
33 |
34 | public Class getKnownEgressType();
35 |
36 | public boolean isExplicitCast();
37 |
38 | public boolean isConvertableIngressEgress();
39 |
40 | public void computeTypeConversionRule();
41 |
42 | public boolean intOptimized();
43 |
44 | public boolean isLiteralOnly();
45 |
46 | public boolean isEmptyStatement();
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/compiler/Parser.java:
--------------------------------------------------------------------------------
1 | package org.mvel2.compiler;
2 |
3 | /**
4 | * @author Mike Brock .
5 | */
6 | public interface Parser {
7 | public int getCursor();
8 |
9 | public char[] getExpression();
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/conversion/CharArrayCH.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.conversion;
20 |
21 | import org.mvel2.ConversionException;
22 | import org.mvel2.ConversionHandler;
23 |
24 | import java.util.HashMap;
25 | import java.util.Map;
26 |
27 | public class CharArrayCH implements ConversionHandler {
28 | private static final Map CNV =
29 | new HashMap();
30 |
31 |
32 | public Object convertFrom(Object in) {
33 | if (!CNV.containsKey(in.getClass())) throw new ConversionException("cannot convert type: "
34 | + in.getClass().getName() + " to: " + Boolean.class.getName());
35 | return CNV.get(in.getClass()).convert(in);
36 | }
37 |
38 |
39 | public boolean canConvertFrom(Class cls) {
40 | return CNV.containsKey(cls);
41 | }
42 |
43 | static {
44 | CNV.put(String.class,
45 | new Converter() {
46 | public Object convert(Object o) {
47 | return ((String) o).toCharArray();
48 | }
49 | }
50 | );
51 |
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/conversion/Converter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 |
20 | package org.mvel2.conversion;
21 |
22 | public interface Converter {
23 | public Object convert(Object o);
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/conversion/ListCH.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 |
20 | package org.mvel2.conversion;
21 |
22 | import org.mvel2.ConversionHandler;
23 |
24 | import java.util.ArrayList;
25 | import java.util.Arrays;
26 | import java.util.Collection;
27 | import java.util.List;
28 |
29 | public class ListCH implements ConversionHandler {
30 | public Object convertFrom(Object in) {
31 | Class type = in.getClass();
32 | List newList = new ArrayList();
33 | if (type.isArray()) {
34 | newList.addAll(Arrays.asList(((Object[]) in)));
35 | }
36 | else if (Collection.class.isAssignableFrom(type)) {
37 | newList.addAll((Collection) in);
38 | }
39 | else if (Iterable.class.isAssignableFrom(type)) {
40 | for (Object o : (Iterable) in) {
41 | newList.add(o);
42 | }
43 | }
44 |
45 | return newList;
46 | }
47 |
48 | public boolean canConvertFrom(Class cls) {
49 | return cls.isArray() || Collection.class.isAssignableFrom(cls) || Iterable.class.isAssignableFrom(cls);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/conversion/ObjectCH.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.conversion;
20 |
21 | import org.mvel2.ConversionHandler;
22 |
23 | public class ObjectCH implements ConversionHandler {
24 | public Object convertFrom(Object in) {
25 | return in;
26 | }
27 |
28 |
29 | public boolean canConvertFrom(Class cls) {
30 | return true;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/conversion/SetCH.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.conversion;
20 |
21 | import org.mvel2.ConversionHandler;
22 |
23 | import java.util.Arrays;
24 | import java.util.Collection;
25 | import java.util.LinkedHashSet;
26 | import java.util.Set;
27 |
28 | public class SetCH implements ConversionHandler {
29 | public Object convertFrom(Object in) {
30 | Class type = in.getClass();
31 | Set newSet = new LinkedHashSet();
32 | if (type.isArray()) {
33 | newSet.addAll(Arrays.asList(((Object[]) in)));
34 | }
35 | else if (Collection.class.isAssignableFrom(type)) {
36 | newSet.addAll((Collection) in);
37 | }
38 | else if (Iterable.class.isAssignableFrom(type)) {
39 | for (Object o : (Iterable) in) {
40 | newSet.add(o);
41 | }
42 | }
43 |
44 | return newSet;
45 | }
46 |
47 | public boolean canConvertFrom(Class cls) {
48 | return cls.isArray() || Collection.class.isAssignableFrom(cls) || Iterable.class.isAssignableFrom(cls);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/conversion/StringCH.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.conversion;
20 |
21 | import org.mvel2.ConversionHandler;
22 | import org.mvel2.compiler.BlankLiteral;
23 |
24 | import static java.lang.String.valueOf;
25 |
26 | public class StringCH implements ConversionHandler {
27 | public Object convertFrom(Object in) {
28 | return valueOf(in);
29 | }
30 |
31 |
32 | public boolean canConvertFrom(Class cls) {
33 | return cls != BlankLiteral.class;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/conversion/UnitConversion.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.conversion;
20 |
21 | import org.mvel2.ConversionHandler;
22 | import org.mvel2.Unit;
23 |
24 |
25 | public class UnitConversion implements ConversionHandler {
26 | public Object convertFrom(Object in) {
27 | try {
28 | return Unit.class.newInstance().convertFrom(in);
29 | }
30 | catch (InstantiationException e) {
31 | e.printStackTrace();
32 | }
33 | catch (IllegalAccessException e) {
34 | e.printStackTrace();
35 | }
36 | return null;
37 | }
38 |
39 | public boolean canConvertFrom(Class cls) {
40 | if (Unit.class.isAssignableFrom(cls) || Number.class.isAssignableFrom(cls)) {
41 | try {
42 | return Unit.class.newInstance().canConvertFrom(cls);
43 | }
44 | catch (InstantiationException e) {
45 | e.printStackTrace();
46 | }
47 | catch (IllegalAccessException e) {
48 | e.printStackTrace();
49 | }
50 | }
51 | return false;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/debug/Debugger.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.debug;
20 |
21 | public interface Debugger {
22 | public static int CONTINUE = 0;
23 | public static int STEP = 1;
24 | public static int STEP_OVER = STEP;
25 |
26 |
27 | /**
28 | * When a breakpoint is recached,
29 | *
30 | * @param frame
31 | * @return continuation command
32 | */
33 | public int onBreak(Frame frame);
34 | }
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/debug/Frame.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.debug;
20 |
21 | import org.mvel2.ParserContext;
22 | import org.mvel2.ast.LineLabel;
23 | import org.mvel2.integration.VariableResolverFactory;
24 |
25 | public class Frame {
26 | private LineLabel label;
27 | private VariableResolverFactory factory;
28 | private ParserContext parserContext;
29 |
30 | public Frame(LineLabel label, VariableResolverFactory factory, ParserContext pCtx) {
31 | this.label = label;
32 | this.factory = factory;
33 | this.parserContext = pCtx;
34 | }
35 |
36 | public String getSourceName() {
37 | return label.getSourceFile();
38 | }
39 |
40 | public int getLineNumber() {
41 | return label.getLineNumber();
42 | }
43 |
44 | public VariableResolverFactory getFactory() {
45 | return factory;
46 | }
47 |
48 | public void setFactory(VariableResolverFactory factory) {
49 | this.factory = factory;
50 | }
51 |
52 | public ParserContext getParserContext() {
53 | return parserContext;
54 | }
55 |
56 | public void setParserContext(ParserContext parserContext) {
57 | this.parserContext = parserContext;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/integration/GlobalListenerFactory.java:
--------------------------------------------------------------------------------
1 | package org.mvel2.integration;
2 |
3 | import java.util.LinkedList;
4 | import java.util.List;
5 |
6 | public class GlobalListenerFactory {
7 | private static List propertyGetListeners;
8 | private static List propertySetListeners;
9 |
10 | public static boolean hasGetListeners() {
11 | return propertyGetListeners != null && !propertyGetListeners.isEmpty();
12 | }
13 |
14 | public static boolean hasSetListeners() {
15 | return propertySetListeners != null && !propertySetListeners.isEmpty();
16 | }
17 |
18 | public static boolean registerGetListener(Listener getListener) {
19 | if (propertyGetListeners == null) propertyGetListeners = new LinkedList();
20 | return propertyGetListeners.add(getListener);
21 | }
22 |
23 | public static boolean registerSetListener(Listener getListener) {
24 | if (propertySetListeners == null) propertySetListeners = new LinkedList();
25 | return propertySetListeners.add(getListener);
26 | }
27 |
28 |
29 | public static void notifyGetListeners(Object target, String name, VariableResolverFactory variableFactory) {
30 | if (propertyGetListeners != null) {
31 | for (Listener l : propertyGetListeners) {
32 | l.onEvent(target, name, variableFactory, null);
33 | }
34 | }
35 | }
36 |
37 | public static void notifySetListeners(Object target, String name, VariableResolverFactory variableFactory, Object value) {
38 | if (propertySetListeners != null) {
39 | for (Listener l : propertySetListeners) {
40 | l.onEvent(target, name, variableFactory, value);
41 | }
42 | }
43 | }
44 |
45 | public static void disposeAll() {
46 | propertyGetListeners = null;
47 | propertySetListeners = null;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/integration/Listener.java:
--------------------------------------------------------------------------------
1 | package org.mvel2.integration;
2 |
3 | public interface Listener {
4 | public void onEvent(Object context, String contextName, VariableResolverFactory variableFactory, Object value);
5 | }
6 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/integration/impl/ClassImportResolver.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.integration.impl;
20 |
21 | import org.mvel2.integration.VariableResolver;
22 |
23 | public class ClassImportResolver implements VariableResolver {
24 | private String name;
25 | private Class type;
26 |
27 | public ClassImportResolver(String fqcn, String name) {
28 | this.name = name;
29 | try {
30 | this.type = Class.forName(fqcn, true, Thread.currentThread().getContextClassLoader());
31 | }
32 | catch (Exception e) {
33 | throw new RuntimeException("failed import", e);
34 | }
35 | }
36 |
37 | public ClassImportResolver(String name, Class type) {
38 | this.name = name;
39 | this.type = type;
40 | }
41 |
42 | public void setName(String name) {
43 | this.name = name;
44 | }
45 |
46 | public void setStaticType(Class knownType) {
47 | this.type = knownType;
48 | }
49 |
50 | public String getName() {
51 | return name;
52 | }
53 |
54 | public Class getType() {
55 | return Class.class;
56 | }
57 |
58 | public Object getValue() {
59 | return type;
60 | }
61 |
62 | public int getFlags() {
63 | return 0;
64 | }
65 |
66 | public void setValue(Object value) {
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/integration/impl/IndexVariableResolver.java:
--------------------------------------------------------------------------------
1 | package org.mvel2.integration.impl;
2 |
3 | import org.mvel2.integration.VariableResolver;
4 |
5 | public class IndexVariableResolver implements VariableResolver {
6 | private int indexPos;
7 | private Object[] vars;
8 |
9 | public IndexVariableResolver(int indexPos, Object[] vars) {
10 | this.indexPos = indexPos;
11 | this.vars = vars;
12 | }
13 |
14 | public String getName() {
15 | return null;
16 | }
17 |
18 | public Class getType() {
19 | return null;
20 | }
21 |
22 | public void setStaticType(Class type) {
23 | }
24 |
25 | public int getFlags() {
26 | return 0;
27 | }
28 |
29 | public Object getValue() {
30 | return vars[indexPos];
31 | }
32 |
33 | public void setValue(Object value) {
34 | vars[indexPos] = value;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/integration/impl/LocalVariableResolverFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.integration.impl;
20 |
21 | public interface LocalVariableResolverFactory {
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/integration/impl/PrecachedMapVariableResolver.java:
--------------------------------------------------------------------------------
1 | package org.mvel2.integration.impl;
2 |
3 | import org.mvel2.integration.VariableResolver;
4 |
5 | import java.util.Map;
6 |
7 | import static org.mvel2.DataConversion.canConvert;
8 | import static org.mvel2.DataConversion.convert;
9 |
10 | public class PrecachedMapVariableResolver implements VariableResolver {
11 | private String name;
12 | private Class> knownType;
13 | private Map.Entry entry;
14 |
15 | public PrecachedMapVariableResolver(Map.Entry entry, String name) {
16 | this.entry = entry;
17 | this.name = name;
18 | }
19 |
20 | public PrecachedMapVariableResolver(Map.Entry entry, String name, Class knownType) {
21 | this.name = name;
22 | this.knownType = knownType;
23 | this.entry = entry;
24 | }
25 |
26 | public void setName(String name) {
27 | this.name = name;
28 | }
29 |
30 | public void setStaticType(Class knownType) {
31 | this.knownType = knownType;
32 | }
33 |
34 |
35 | public String getName() {
36 | return name;
37 | }
38 |
39 | public Class getType() {
40 | return knownType;
41 | }
42 |
43 | public void setValue(Object value) {
44 | if (knownType != null && value != null && value.getClass() != knownType) {
45 | Class t = value.getClass();
46 | if (!canConvert(knownType, t)) {
47 | throw new RuntimeException("cannot assign " + value.getClass().getName() + " to type: "
48 | + knownType.getName());
49 | }
50 | try {
51 | value = convert(value, knownType);
52 | }
53 | catch (Exception e) {
54 | throw new RuntimeException("cannot convert value of " + value.getClass().getName()
55 | + " to: " + knownType.getName());
56 | }
57 | }
58 |
59 | //noinspection unchecked
60 | entry.setValue(value);
61 | }
62 |
63 | public Object getValue() {
64 | return entry.getValue();
65 | }
66 |
67 | public int getFlags() {
68 | return 0;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/integration/impl/SimpleValueResolver.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.integration.impl;
20 |
21 | import org.mvel2.integration.VariableResolver;
22 |
23 | public class SimpleValueResolver implements VariableResolver {
24 | private Object value;
25 |
26 | public SimpleValueResolver(Object value) {
27 | this.value = value;
28 | }
29 |
30 | public String getName() {
31 | return null;
32 | }
33 |
34 | public Class getType() {
35 | return Object.class;
36 | }
37 |
38 | public void setStaticType(Class type) {
39 | }
40 |
41 | public int getFlags() {
42 | return 0;
43 | }
44 |
45 | public Object getValue() {
46 | return value;
47 | }
48 |
49 | public void setValue(Object value) {
50 | this.value = value;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/integration/impl/StaticMethodImportResolver.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.integration.impl;
20 |
21 | import org.mvel2.integration.VariableResolver;
22 | import org.mvel2.util.MethodStub;
23 |
24 | /**
25 | * @author Christopher Brock
26 | */
27 | public class StaticMethodImportResolver implements VariableResolver {
28 | private String name;
29 | private MethodStub method;
30 |
31 | public StaticMethodImportResolver(String name, MethodStub method) {
32 | this.name = name;
33 | this.method = method;
34 | }
35 |
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public Class getType() {
41 | return null;
42 | }
43 |
44 | public void setStaticType(Class type) {
45 | }
46 |
47 | public int getFlags() {
48 | return 0;
49 | }
50 |
51 | public MethodStub getValue() {
52 | return method;
53 | }
54 |
55 | public void setValue(Object value) {
56 | this.method = (MethodStub) value;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/integration/impl/TypeInjectionResolverFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.integration.impl;
20 |
21 | /**
22 | * This is a marker interface
23 | */
24 | public interface TypeInjectionResolverFactory {
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/optimizers/OptimizationNotSupported.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 | package org.mvel2.optimizers;
19 |
20 | public class OptimizationNotSupported extends RuntimeException {
21 |
22 | public OptimizationNotSupported() {
23 | super();
24 | }
25 |
26 | public OptimizationNotSupported(String message) {
27 | super(message);
28 | }
29 |
30 | public OptimizationNotSupported(String message, Throwable cause) {
31 | super(message, cause);
32 | }
33 |
34 | public OptimizationNotSupported(Throwable cause) {
35 | super(cause);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/optimizers/OptimizerHook.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.optimizers;
20 |
21 | import org.mvel2.compiler.Accessor;
22 |
23 | /**
24 | * @author Christopher Brock
25 | */
26 | public interface OptimizerHook {
27 | /**
28 | * Should answer back whether or not this hook understands how to work with the current
29 | * optimizer.
30 | *
31 | * @param optimizer - class type of the current optimizer being used
32 | * @return boolean
33 | */
34 | public boolean isOptimizerSupported(Class extends AccessorOptimizer> optimizer);
35 |
36 |
37 | /**
38 | * The optimizer should delegate back to the hook through this method, passing an instance of itself
39 | * in the current state.
40 | *
41 | * @param optimizer - instance of optimizer
42 | * @return boolean
43 | */
44 | public Accessor generateAccessor(AccessorOptimizer optimizer);
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/optimizers/dynamic/DynamicAccessor.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL 2.0
3 | * Copyright (C) 2007 The Codehaus
4 | * Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 |
19 | package org.mvel2.optimizers.dynamic;
20 |
21 | import org.mvel2.compiler.Accessor;
22 |
23 | public interface DynamicAccessor extends Accessor {
24 | public void deoptimize();
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/mvel2/optimizers/impl/refl/collection/ListCreator.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MVEL (The MVFLEX Expression Language)
3 | *
4 | * Copyright (C) 2007 Christopher Brock, MVFLEX/Valhalla Project and the Codehaus
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * 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 | */
19 | package org.mvel2.optimizers.impl.refl.collection;
20 |
21 | import org.mvel2.compiler.Accessor;
22 | import org.mvel2.integration.VariableResolverFactory;
23 |
24 | import java.util.ArrayList;
25 | import java.util.Arrays;
26 | import java.util.List;
27 |
28 | /**
29 | * @author Christopher Brock
30 | */
31 | public class ListCreator implements Accessor {
32 | public Accessor[] values;
33 |
34 | public Object getValue(Object ctx, Object elCtx, VariableResolverFactory variableFactory) {
35 | Object[] template = new Object[values.length];
36 | for (int i = 0; i < values.length; i++) {
37 | template[i] = values[i].getValue(ctx, elCtx, variableFactory);
38 | }
39 | return new ArrayList