Revision: 48
Author:
mohit...@vedantatree.com
Date: Sat Jun 14 20:36:31 2014 UTC
Log: Checkin for release 3.2. Added Utilities code. Fix few issues.
Improvement in code.
http://code.google.com/p/expressionoasis/source/detail?r=48
Added:
/trunk/ReleaseNotes1.txt
/trunk/src/main/java/org/vedantatree/expressionoasis/exceptions/ErrorCodes.java
/trunk/src/main/java/org/vedantatree/expressionoasis/types
/trunk/src/main/java/org/vedantatree/expressionoasis/types/MethodKey.java
/trunk/src/main/java/org/vedantatree/expressionoasis/types/Type.java
/trunk/src/main/java/org/vedantatree/expressionoasis/types/ValueObject.java
/trunk/src/main/java/org/vedantatree/expressionoasis/utils
/trunk/src/main/java/org/vedantatree/expressionoasis/utils/BeanUtils.java
/trunk/src/main/java/org/vedantatree/expressionoasis/utils/JavaUtils.java
/trunk/src/main/java/org/vedantatree/expressionoasis/utils/StringUtils.java
/trunk/src/main/java/org/vedantatree/expressionoasis/utils/Utilities.java
/trunk/src/main/java/org/vedantatree/expressionoasis/utils/XMLErrorHandler.java
/trunk/src/main/java/org/vedantatree/expressionoasis/utils/XMLUtils.java
/trunk/src/main/java/org/vedantatree/expressionoasis/utils/XPathUtils.java
Deleted:
/trunk/ReleaseNotes.txt
/trunk/lib/Utilities-1.1.jar
Modified:
/trunk/build.gradle
/trunk/docs/TODO.txt
/trunk/pom.xml
/trunk/readme.txt
/trunk/src/main/java/org/vedantatree/expressionoasis/Compiler.java
/trunk/src/main/java/org/vedantatree/expressionoasis/EOErrorCodes.java
/trunk/src/main/java/org/vedantatree/expressionoasis/ExpressionContext.java
/trunk/src/main/java/org/vedantatree/expressionoasis/ExpressionEngine.java
/trunk/src/main/java/org/vedantatree/expressionoasis/ExpressionEngineConstants.java
/trunk/src/main/java/org/vedantatree/expressionoasis/Parser.java
/trunk/src/main/java/org/vedantatree/expressionoasis/config/ConfigFactory.java
/trunk/src/main/java/org/vedantatree/expressionoasis/config/ConstructorArgument.java
/trunk/src/main/java/org/vedantatree/expressionoasis/config/ExpressionConfig.java
/trunk/src/main/java/org/vedantatree/expressionoasis/config/ExpressionOasisConfig.java
/trunk/src/main/java/org/vedantatree/expressionoasis/config/FunctionProviderConfig.java
/trunk/src/main/java/org/vedantatree/expressionoasis/exceptions/ExpressionEngineException.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/BinaryOperatorExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/BooleanExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/DecimalExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/Expression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/ExpressionFactory.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/ExpressionTypeFinder.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/ExpressionVisitor.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/IdentifierExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/NullExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/NumericExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/StringExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/UnaryOperatorExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/arithmatic/AddExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/arithmatic/ArrayIndexExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/arithmatic/DivideExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/arithmatic/MinusExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/arithmatic/MultiplyExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/arithmatic/ParanthesisExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/arithmatic/PlusExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/arithmatic/RemainderExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/arithmatic/SubtractExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/bitwise/BWAndExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/bitwise/BWComplementExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/bitwise/BWOrExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/bitwise/BWSignedLeftShiftExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/bitwise/BWSignedRightShiftExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/bitwise/BWUnsignedRightShiftExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/bitwise/BWXorExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/booleanexp/AndExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/booleanexp/ConditionTernaryExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/booleanexp/NotExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/booleanexp/OrExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/booleanexp/ResultTernaryExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/property/ArgumentExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/property/FunctionExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/property/PropertyExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/property/UnaryPropertyExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/relational/EQExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/relational/GTEExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/relational/GTExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/relational/LTEExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/relational/LTExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/relational/NEExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/string/ContainsExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/string/EndsWithExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/string/StartsWithExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/xml/NodeValueExpression.java
/trunk/src/main/java/org/vedantatree/expressionoasis/extensions/DefaultFunctionProvider.java
/trunk/src/main/java/org/vedantatree/expressionoasis/extensions/DefaultVariableProvider.java
/trunk/src/main/java/org/vedantatree/expressionoasis/extensions/FunctionProvider.java
/trunk/src/main/java/org/vedantatree/expressionoasis/extensions/MathFunctions.java
/trunk/src/main/java/org/vedantatree/expressionoasis/extensions/StringFunctions.java
/trunk/src/main/java/org/vedantatree/expressionoasis/extensions/VariableProvider.java
/trunk/src/main/java/org/vedantatree/expressionoasis/extensions/XMLFunctionProvider.java
/trunk/src/main/java/org/vedantatree/expressionoasis/extensions/customfunctions/CustomFunctionProvider.java
/trunk/src/main/java/org/vedantatree/expressionoasis/extensions/customfunctions/CustomFunctionSourceProvider.java
/trunk/src/main/java/org/vedantatree/expressionoasis/extensions/customfunctions/CustomFunctionsClassFactory.java
/trunk/src/main/java/org/vedantatree/expressionoasis/extensions/customfunctions/xml/XMLCustomFunctionSourceProvider.java
/trunk/src/main/java/org/vedantatree/expressionoasis/extensions/customfunctions/xml/XMLCustomFunctionsPlaceholder.java
/trunk/src/main/java/org/vedantatree/expressionoasis/grammar/DefaultXMLGrammar.java
/trunk/src/main/java/org/vedantatree/expressionoasis/grammar/ExpressionToken.java
/trunk/src/main/java/org/vedantatree/expressionoasis/grammar/Grammar.java
/trunk/src/main/java/org/vedantatree/expressionoasis/grammar/rules/IProductionRule.java
/trunk/src/main/java/org/vedantatree/expressionoasis/grammar/rules/ProductionRule.java
/trunk/src/main/java/org/vedantatree/expressionoasis/ui/ErrorPane.java
/trunk/src/main/java/org/vedantatree/expressionoasis/ui/ExpressionEngineUI.java
/trunk/src/main/java/org/vedantatree/expressionoasis/ui/ExpressionEvaluator.java
/trunk/src/main/java/org/vedantatree/expressionoasis/ui/ExpressionEvaluatorUI.java
/trunk/src/main/java/org/vedantatree/expressionoasis/ui/IExpressionEvaluator.java
/trunk/src/main/java/org/vedantatree/expressionoasis/ui/KeyPad.java
/trunk/src/main/java/org/vedantatree/expressionoasis/ui/ResultPane.java
/trunk/src/test/java/org/vedantatree/expressionoasis/TestCustomFunctionProvider.java
/trunk/src/test/java/org/vedantatree/expressionoasis/TestEvaluator.java
/trunk/src/test/java/org/vedantatree/expressionoasis/TestParser.java
=======================================
--- /dev/null
+++ /trunk/ReleaseNotes1.txt Sat Jun 14 20:36:31 2014 UTC
@@ -0,0 +1,67 @@
+Release 3.2
+
+Updated the build system from Maven to Gradle. Gradle is more flexible
system.
+Added source code of Utilities.jar to ExpressionOasis project itself
+Improved code for Type system and fixed few issues
+
+---------------------------------------------------------------------------------------------
+
+Release 3.1
+
+- Grammar class is loaded from configuration flexibly. Now, developers can
implement custom Grammar class and can specify this in configuration.
ExpressionOasis will pick this at runtime.
+- Made config.xml path configurable from System Property (Contribution by
Girish Kumar)
+- Made grammar.xml path configurable by exporting it to config.xml
+- Improved code for ExpressionFactory to improve the performance
+- Defined new way to add function definition using new API in Grammar
interface
+- Exposed Grammar through ExpressionEngine Class, so that user can get the
metadata if required and also can add specific metadata like custom
function identification etc
+- Added three new String operation expressions > startsWith, endsWith,
contains (Contribution by Girish Kumar)
+- Improved documentation
+
+---------------------------------------------------------------------------------------------
+
+Release 3.0.1
+
+- A micro-release with few but important bugs fixes. The new 3.0.1 version
should be used to have bug free solution.
+ Fixed issues are: GoogleCode: #1, #4
+
+---------------------------------------------------------------------------------------------
+
+Release 3.0
+
+- License changed from GPL to LGPLv3, so that more people can be benefited
by using this free software
+- Major change in root packages name. Package name is changed from
org.ganges.expressionengine to org.vedantatree.expressionoasis
+- Introduced Maven build system, earlier it was based on Ant
(Contributions by Kris Marwood)
+- Dynamic function support. Now custom functions can be defined in xml
file, i.e. customfunctions.xml. System will pick these functions at runtime
and make these available (Contributions by Kris Marwood)
+- Merged configurations in single config.xml file
+- In memory cache for Compiled Expressions - In memory cache may be useful
for performance reasons. It can be turned on/off from config by setting
value of 'cacheCompiledExpressions' element
+- Issue #2, #3 are fixed listed at Google Code
+- Many New test cases have been added
+
+---------------------------------------------------------------------------------------------
+
+Release 2.3
+
+- Support for ternary operator
+- Support for XML expressions, using Xalan XPath
+ - XML Expressions will return only String type value.
+ - We can change it to other specific types also, like Number, String etc
in future depending upon data or we may provide some type casting function
+Added more test cases
+
+More at
http://www.vedantatree.com/
+
+---------------------------------------------------------------------------------------------
+
+Release 2.2
+
+- Support for more math functions
+- Support for Bitwise operators
+- Change precedence of operators -
http://en.wikipedia.org/wiki/Order_of_operations
+- Change '=' operator with '=='
+
+---------------------------------------------------------------------------------------------
+
+Release 2.1
+
+- Documentation Update
+- Support for unary operators. Now expressions with unary operators are
supported. For example, (!false), (!false && true), (-3 + 2/-4) etc
+- Please refer to
http://expressionoasis.vedantatree.com/ and
http://www.vedantatree.com/ for further details
=======================================
--- /dev/null
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/exceptions/ErrorCodes.java
Sat Jun 14 20:36:31 2014 UTC
@@ -0,0 +1,56 @@
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
+ *
+ * This file is part of ExpressionOasis.
+ *
+ * ExpressionOasis is free software. You can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * ExpressionOasis is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
License
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
+ */
+package org.vedantatree.expressionoasis.exceptions;
+
+/**
+ * @author Mohit Gupta
+ */
+public interface ErrorCodes
+{
+
+ static final int UNKNOWN_PROBLEM = 1;
+
+ static final int SERVER_PROBLEM = 2;
+
+ static final int USER_PROBLEM = 3;
+
+ static final int PERSISTENCE_SYSTEM_PROBLEM = 4;
+
+ static final int IO_PROBLEM = 5;
+
+ static final int RESOURCE_NOT_FOUND = 6;
+
+ static final int PARSING_PROBLEM = 7;
+
+ static final int EXPRESSION_EVALUATION_PROBLEM = 7;
+
+ static final String[] ERROR_DESCRIPTION =
+ { "Unknow Problem", "Server Internal Problem",
+ "User Created Probelm", "Persistence System Problem", "IO
Problem", "Resources not found",
+ "Parsing Problem" };
+
+}
=======================================
--- /dev/null
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/types/MethodKey.java
Sat Jun 14 20:36:31 2014 UTC
@@ -0,0 +1,107 @@
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
+ *
+ * This file is part of ExpressionOasis.
+ *
+ * ExpressionOasis is free software. You can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * ExpressionOasis is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
License
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
+ */
+package org.vedantatree.expressionoasis.types;
+
+public class MethodKey
+{
+
+ public MethodKey( String methodName, Type parameterTypes[] )
+ {
+ this.methodName = methodName;
+ this.parameterTypes = parameterTypes;
+ key = generateKey( methodName, parameterTypes );
+ }
+
+ public static String generateKey( String methodName, Type
parameterTypes[] )
+ {
+ if( methodName == null )
+ throw new IllegalArgumentException( "Passed methodName can't be null."
);
+ StringBuffer buffer = new StringBuffer( methodName );
+ buffer.append( '(' );
+ int length = parameterTypes != null ? parameterTypes.length : 0;
+ for( int i = 0; i < length; i++ )
+ {
+ Type type = parameterTypes[i];
+ buffer.append( type.getTypeName() );
+ if( i < length - 1 )
+ buffer.append( ',' );
+ }
+
+ buffer.append( ')' );
+ return buffer.toString();
+ }
+
+ public boolean isAssignaleFrom( MethodKey key )
+ {
+ boolean result = false;
+ if( key != null && key.methodName.equals( methodName ) )
+ {
+ Type thatParameterTypes[] = key.parameterTypes;
+ int thatLength = thatParameterTypes != null ?
thatParameterTypes.length : 0;
+ int length = parameterTypes != null ? parameterTypes.length : 0;
+ if( thatLength == length )
+ {
+ boolean assignableFrom = true;
+ for( int i = 0; i < length; i++ )
+ {
+ if( parameterTypes[i].isAssignableFrom( thatParameterTypes[i] ) )
+ continue;
+ assignableFrom = false;
+ break;
+ }
+
+ result = assignableFrom;
+ }
+ }
+ return result;
+ }
+
+ public boolean equals( Object obj )
+ {
+ boolean result = false;
+ if( obj instanceof MethodKey )
+ {
+ MethodKey thatKey = (MethodKey) obj;
+ result = thatKey.key.equals( key );
+ }
+ return result;
+ }
+
+ public int hashCode()
+ {
+ return key.hashCode();
+ }
+
+ public String toString()
+ {
+ return key.toString();
+ }
+
+ private String methodName;
+ private Type parameterTypes[];
+ private String key;
+}
=======================================
--- /dev/null
+++ /trunk/src/main/java/org/vedantatree/expressionoasis/types/Type.java
Sat Jun 14 20:36:31 2014 UTC
@@ -0,0 +1,476 @@
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
+ *
+ * This file is part of ExpressionOasis.
+ *
+ * ExpressionOasis is free software. You can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * ExpressionOasis is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
License
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
+ */
+package org.vedantatree.expressionoasis.types;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.vedantatree.expressionoasis.utils.JavaUtils;
+import org.vedantatree.expressionoasis.utils.StringUtils;
+import org.vedantatree.expressionoasis.utils.Utilities;
+
+
+/**
+ * This class represents the type for value object. Its default
implementation is for java classes.
+ *
+ * @author Mohit Gupta
+ * @author Parmod Kamboj
+ * @version 1.0
+ *
+ * Fixed isAssignableFrom method. Wasn't working as thisClass and
thatClass were around the wrong way.
+ * Changed to use nullable types and removed primitive checking.
+ * Made createType thread safe by implementing double checked
locking.
+ * Cache the type class for performance.
+ *
+ * @author Kris Marwood
+ * @version 1.1
+ *
+ * Added documentation
+ * Fix the bug in constructor while creating the type. Wrappers
types were not getting created with
+ * initialization.
+ * Restructured the code for primitive and wrapper types
+ * Added more assertions
+ *
+ * @author Mohit Gupta
+ * @version 1.2
+ * @since June 2014
+ */
+public class Type
+{
+
+ /**
+ * An in memory cache for storing the generated types.
+ */
+ private static final Map<String, Type> TYPE_CACHE = new HashMap<>();
+
+ /**
+ * This is the byte type.
+ */
+ public static final Type BYTE = new Type( (byte) 1, Byte.class );
+
+ /**
+ * This is the short type.
+ */
+ public static final Type SHORT = new Type( (byte) 2, Short.class );
+
+ /**
+ * This is the integer type
+ */
+ public static final Type INTEGER = new Type( (byte) 3, Integer.class
);
+
+ /**
+ * This is the long type.
+ */
+ public static final Type LONG = new Type( (byte) 4, Long.class );
+
+ /**
+ * This is the double type.
+ */
+ public static final Type DOUBLE = new Type( (byte) 5, Double.class );
+
+ /**
+ * This is the float type.
+ */
+ public static final Type FLOAT = new Type( (byte) 6, Float.class );
+
+ /**
+ * This is the boolean type.
+ */
+ public static final Type BOOLEAN = new Type( (byte) 7, Boolean.class
);
+
+ /**
+ * This is the character type.
+ */
+ public static final Type CHARACTER = new Type( (byte) 8,
Character.class );
+
+ /**
+ * This is the string type.
+ */
+ public static final Type STRING = new Type( (byte) 9, String.class );
+
+ /**
+ * This is the XML type.
+ */
+ public static final Type XML = new Type( (byte) 10, null, "Type.XML"
);
+
+ /**
+ * This is the objec type (for nulls)
+ */
+ public static final Type OBJECT = new Type( (byte) 11, Object.class );
+
+ /**
+ * This is the type for custome types.
+ */
+ public static final Type ANY_TYPE = new Type( (byte) Byte.MAX_VALUE,
null, "Type.ANY" );
+
+ /**
+ * This is the type for custom types.
+ */
+ private static final byte CUSTOM_TYPE = Byte.MIN_VALUE;
+
+ /**
+ * Name of the type. This is the main attribute based on which type is
created
+ * and is being stored in cache.
+ */
+ private String typeName;
+
+ /**
+ * Class represented by this Type. It can be null as some of the types
may not
+ * have any class, for example like XML
+ */
+ private Class typeClass;
+
+ /**
+ * Code for the type. These are predefined code to identify the default
or custom types
+ */
+ private byte typeCode;
+
+ /**
+ * Component type for this Type. Applicable only if this Type represents
an Array
+ */
+ private Type componentType;
+
+ static
+ {
+ populatePrimitiveTypes();
+ }
+
+ private static void populatePrimitiveTypes()
+ {
+ // these types will automatically be added to Type Cache from constructor
+ // keeping same code as of Wrapper types, to support equality of
primitiveType.equals(wrapperType) in
+ // Type.equals operation
+
+ new Type( (byte) 1, Byte.TYPE );
+ new Type( (byte) 2, Short.TYPE );
+ new Type( (byte) 3, Integer.TYPE );
+ new Type( (byte) 4, Long.TYPE );
+ new Type( (byte) 5, Double.TYPE );
+ new Type( (byte) 6, Float.TYPE );
+ new Type( (byte) 7, Boolean.TYPE );
+ new Type( (byte) 8, Character.TYPE );
+ // Void.Type
+ }
+
+ private Type( byte typeCode, Class typeClass )
+ {
+ this( typeCode, typeClass, null );
+ }
+
+ /**
+ * Constructs the Type
+ *
+ * @param pTypeCode type code should always be set. No validation because
it is being called from Create Type method
+ * only
+ * @param pTypeClass Class can null, like for XML types, there is no class
+ * @param pTypeName Type name is must. It can be null only if class name
is not null. In that case, we shall use
+ * class name as type name
+ */
+ private Type( byte pTypeCode, Class pTypeClass, String pTypeName )
+ {
+ // initialize the type name if given type name is null and class name is
not null
+ if( pTypeClass != null && pTypeName == null )
+ {
+ pTypeName = pTypeClass.getName();
+ }
+
+ if( !StringUtils.isQualifiedString( pTypeName ) )
+ {
+ throw new IllegalArgumentException( "Type name is not valid. typeCode["
+ pTypeCode + "] typeName["
+ + pTypeName + "] typeClass[" + pTypeClass + "]" );
+ }
+
+ // Check for default type. Default types can't be overriden.
+ // Also it ensures that no duplicate type can be created.
+ // createType method must have already be invoked to check in TypeCache
before requesting to create new type
+ if( TYPE_CACHE.containsKey( pTypeName ) )
+ {
+ throw new IllegalArgumentException( "A type is already created for
given type code. given-code["
+ + pTypeCode + "] given-typeName[" + pTypeName + "] existing-type[" +
TYPE_CACHE.get( pTypeName )
+ + "]" );
+ }
+
+ this.typeCode = pTypeCode;
+ this.typeName = pTypeName;
+
+ // try to initialize the class
+ if( pTypeClass == null )
+ {
+ try
+ {
+ pTypeClass = Class.forName( pTypeName );
+ }
+ catch( ClassNotFoundException e )
+ {
+ // do nothing. Some type names are not class names (e.g. Type.XML).
+ }
+ }
+ this.typeClass = pTypeClass;
+
+ // not synchronizing as access is already synchronized in
caller 'createType'
+ TYPE_CACHE.put( pTypeName, this );
+ }
+
+ /**
+ * Creates the type for given class
+ *
+ * @param typeClass Class of the Object or Primitive for which type is
being created
+ * @return the Type for given class
+ */
+ public static final Type createType( Class<?> typeClass )
+ {
+ Utilities.assertNotNullArgument( typeClass, "Type-Class" );
+ return createTypeInternal( typeClass, typeClass.getName() );
+ }
+
+ /**
+ * Creates the type for given type name
+ *
+ * @param typeName Name of the type. It can be class name or even any
other string also. In case if given name does
+ * not match with any primitive or respective wrapper classes, it
will be marked as Custom Type
+ * @return the type.
+ */
+ public static final Type createType( String typeName )
+ {
+ return createTypeInternal( null, typeName );
+ }
+
+ private static Type createTypeInternal( Class typeClass, String typeName )
+ {
+ StringUtils.assertQualifiedArgument( typeName, "typeName" );
+
+ // Search from cache.
+ Type type = (Type) TYPE_CACHE.get( typeName );
+ if( type == null )
+ {
+ synchronized( TYPE_CACHE )
+ {
+ type = (Type) TYPE_CACHE.get( typeName );
+ if( type == null )
+ {
+ type = new Type( CUSTOM_TYPE, typeClass, typeName );
+ TYPE_CACHE.put( typeName, type );
+ }
+ }
+ }
+ return type;
+ }
+
+ /**
+ * Checks whether the type represents an array or not.
+ *
+ * @return <code>true</code> if the type represents an array,
<code>false</code> otherwise
+ */
+ public final boolean isArray()
+ {
+ return getComponentType() != null;
+ }
+
+ /**
+ * Gets the component type for this type.
+ *
+ * @return the component type of this type, valid for
+ * array type only.
+ */
+ public final Type getComponentType()
+ {
+ // return component type if already initialize, or null if type class is
null
+ if( componentType != null || typeClass == null )
+ {
+ return componentType;
+ }
+ Class<?> clazz = typeClass.getComponentType();
+ componentType = clazz != null ? createType( clazz ) : null;
+ return componentType;
+ }
+
+ /**
+ * @param type Type to check for assignment
+ * @return true if this Type is assignable from specified Type
+ */
+ public final boolean isAssignableFrom( Type type )
+ {
+ boolean result = false;
+ if( type != null && type.getTypeClass() != null && typeClass != null )
+ {
+ Class<?> thisClass = typeClass;
+ Class<?> thatClass = type.getTypeClass();
+ result = thatClass.isAssignableFrom( thisClass );
+ }
+ return result;
+ }
+
+ /**
+ * Gets the typeClass
+ *
+ * @return Returns the typeClass. It can be null for types which does not
represents a specific class, like XML type
+ */
+ public final Class<?> getTypeClass()
+ {
+ return typeClass;
+ }
+
+ /**
+ * Gets the typeName
+ *
+ * @return Returns the typeName. It can never be null
+ */
+ public final String getTypeName()
+ {
+ return typeName;
+ }
+
+ /**
+ * Performs the type equality.
+ */
+ public boolean equals( Object arg )
+ {
+ boolean result = false;
+ if( arg instanceof Type )
+ {
+ Type type = (Type) arg;
+ result = type.typeCode == this.typeCode;
+ if( result )
+ {
+ result = type.typeName.equals( typeName );
+ if( !result )
+ {
+ if( getTypeClass() != null && getTypeClass().isPrimitive() )
+ {
+ String newTypeClass = JavaUtils.convertToWrapper( getTypeClass()
).getName();
+ result = type.typeName.equals( newTypeClass );
+ }
+ else if( type.getTypeClass() != null &&
type.getTypeClass().isPrimitive() )
+ {
+ String newTypeClass = JavaUtils.convertToWrapper(
type.getTypeClass() ).getName();
+ result = typeName.equals( newTypeClass );
+ }
+ }
+
+ }
+
+ }
+ return result;
+ }
+
+ /**
+ * @see java.lang.Object#toString()
+ */
+ public String toString()
+ {
+ return getTypeName();
+ }
+
+ public String toDebugString()
+ {
+ return "Type: type[" + typeCode + "] typeName[" + typeName + "]
typeClass[" + typeClass + "]";
+ }
+
+ public static void main( String[] args ) throws Exception
+ {
+ System.out.println( Type.INTEGER );
+ System.out.println( Type.BYTE );
+ System.out.println( Type.DOUBLE );
+ System.out.println( Type.LONG );
+ System.out.println( Type.CHARACTER );
+ System.out.println( Type.OBJECT );
+ System.out.println( Type.ANY_TYPE );
+ System.out.println( Type.STRING );
+ System.out.println( boolean.class );
+ System.out.println( boolean.class.getName() );
+ // System.out.println(Class.forName( boolean.class.getName() ));
+
+ Type booleanArrayType = Type.createType( new Boolean[]
+ { null, null }.getClass() );
+ System.out.println( "boolean array type[" +
booleanArrayType.toDebugString() + "]" );
+ Type componentType = booleanArrayType.getComponentType();
+ System.out.println( "boolean array type's component type[" +
componentType.toDebugString() + "]" );
+ }
+}
+
+// ------------------------------------------- Commented Code - to be
removed soon -----------------------------
+
+// /**
+// * Gets the type name for default type.
+// *
+// * @return the default type name
+// */
+// private static final String getDefaultName( byte type )
+// {
+// String typeName = null;
+// switch( type )
+// {
+// case 1:
+// /*
+// * @author: Mohit
+// *
+// * @date: 29-09-2013
+// * all type names are replaced with constant strings
+// * Because names will be exposed outside to specify the types in
configuration etc
+// * Using numbers for specifying types is not readable, hence these
constant names will help
+// * Code will not be broken, because this method is not used anywhere
+// * TODO: Define constants
+// */
+// typeName = int.class.getName(); // "int"; //
+// break;
+// case 2:
+// typeName = short.class.getName(); // "short"; //
+// break;
+// case 3:
+// typeName = long.class.getName(); // "long"; //
+// break;
+// case 4:
+// typeName = double.class.getName(); // "double"; //
+// break;
+// case 5:
+// typeName = float.class.getName(); // "float"; //
+// break;
+// case 6:
+// typeName = char.class.getName(); // "char"; //
+// break;
+// case 7:
+// typeName = boolean.class.getName(); // "boolean"; //
+// break;
+// case 8:
+// typeName = byte.class.getName(); // "byte"; //
+// break;
+// case 9:
+// typeName = String.class.getName(); // "string"; //
+// break;
+// case 10:
+// typeName = "Type.XML"; // "xml"; //
+// break;
+// case 11:
+// typeName = Object.class.getName(); // "object"; //
+// break;
+// case Byte.MAX_VALUE:
+// typeName = "Type.ANY"; // "any"; //
+// break;
+// }
+// return typeName;
+// }
+//
=======================================
--- /dev/null
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/types/ValueObject.java
Sat Jun 14 20:36:31 2014 UTC
@@ -0,0 +1,90 @@
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
+ *
+ * This file is part of ExpressionOasis.
+ *
+ * ExpressionOasis is free software. You can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * ExpressionOasis is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
License
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
+ */
+package org.vedantatree.expressionoasis.types;
+
+/**
+ * This is the value wrapper for any object.
+ * Also contains the type information for the ibject.
+ *
+ * @author Parmod Kamboj
+ * @version 1.0
+ *
+ */
+public class ValueObject
+{
+
+ /**
+ * This is the actual value object.
+ */
+ private Object value;
+
+ /**
+ * This is the type of the object.
+ */
+ private Type valueType;
+
+ /**
+ * Constructs the ValueObject
+ *
+ * @param value
+ * @param valueType
+ */
+ public ValueObject( Object value, Type valueType )
+ {
+ if( valueType == null )
+ {
+ throw new IllegalArgumentException( "Value type is not valid." );
+ }
+ this.value = value;
+ this.valueType = valueType;
+ }
+
+ /**
+ * Gets the value
+ *
+ * @return the value
+ */
+ public Object getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Gets the value type.
+ *
+ * @return the value type.
+ */
+ public Type getValueType()
+ {
+ return valueType;
+ }
+
+ public String toString()
+ {
+ return "ValueObject@" + hashCode() + ": value[" + value + "] type[" +
valueType + "]";
+ }
+}
=======================================
--- /dev/null
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/utils/BeanUtils.java
Sat Jun 14 20:36:31 2014 UTC
@@ -0,0 +1,161 @@
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
+ *
+ * This file is part of ExpressionOasis.
+ *
+ * ExpressionOasis is free software. You can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * ExpressionOasis is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
License
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
+ */
+package org.vedantatree.expressionoasis.utils;
+
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.InvocationTargetException;
+
+
+/**
+ * This class provides the util methods for bean management.
+ * One can handle bean using these util method like method invocation by
name
+ * property accessing by the name and many more.
+ *
+ * @author Mohit Gupta
+ * @author Parmod Kamboj
+ * @version 1.0
+ */
+public final class BeanUtils
+{
+
+ /**
+ * Constructs the BeanUtils
+ * This is made private to restrict the use to singlton object
+ * of this class.
+ */
+ private BeanUtils()
+ {
+ /**
+ * Nothing to do here.
+ */
+ }
+
+ /**
+ * Checks whether the property is editable or not. Generally it checks
+ * whether the mutator is available for this property or not. A property
is
+ * editable iff the property mutator is available.
+ *
+ * @param beanClass the class of bean whose property is being inspecting.
+ * @param property the name of property to inspect.
+ * @return Returns <code>true</code> if the property is editable else
<code>false</code>
+ * @throws IntrospectionException
+ */
+ public static final boolean isPropertyEditable( Class beanClass, String
property ) throws IntrospectionException
+ {
+ // Gets the property descriptor for given property
+ PropertyDescriptor descriptor = getPropertyDescriptor( beanClass,
property );
+ return descriptor == null ? false : descriptor.getWriteMethod() != null;
+ }
+
+ /**
+ * Gets the return type of property.
+ *
+ * @param beanClass the class of bean whose property is being inspecting.
+ * @param property the name of property
+ * @return the type of property. Returns <code>null</code> if the
property name
+ * if not found in bean class.
+ * @throws IntrospectionException
+ */
+ public static final Class getPropertyType( Class beanClass, String
property ) throws IntrospectionException
+ {
+ // Gets the property descriptor for property name.
+ PropertyDescriptor descriptor = getPropertyDescriptor( beanClass,
property );
+ return descriptor == null ? null : descriptor.getPropertyType();
+ }
+
+ /**
+ * Gets the value of property from the bean object.
+ *
+ * @param bean the object of bean class whose property is to access.
+ * @param property the name of property.
+ * @return the value of property.
+ * @throws IntrospectionException
+ * @throws IllegalArgumentException
+ * @throws IllegalAccessException
+ * @throws InvocationTargetException
+ */
+ public static final Object getPropertyValue( Object bean, String property
) throws IntrospectionException,
+ IllegalArgumentException, IllegalAccessException,
InvocationTargetException
+ {
+ Object propertyValue = null;
+ PropertyDescriptor descriptor = getPropertyDescriptor( bean.getClass(),
property );
+ if( descriptor != null && descriptor.getReadMethod() != null )
+ {
+ propertyValue = descriptor.getReadMethod().invoke( bean, null );
+ }
+ return propertyValue;
+ }
+
+ /**
+ * Sets the value of property to the object of bean
+ *
+ * @param bean the bean object whose proeprty is to set.
+ * @param property the name of property.
+ * @param value the value to set for the property.
+ * @throws IntrospectionException
+ * @throws IllegalArgumentException
+ * @throws IllegalAccessException
+ * @throws InvocationTargetException
+ */
+ public static final void setPropertyValue( Object bean, String property,
Object value )
+ throws IntrospectionException, IllegalArgumentException,
IllegalAccessException, InvocationTargetException
+ {
+ PropertyDescriptor descriptor = getPropertyDescriptor( bean.getClass(),
property );
+ if( descriptor != null && descriptor.getWriteMethod() != null )
+ {
+ descriptor.getWriteMethod().invoke( bean, new Object[]
+ { value } );
+ }
+ }
+
+ /**
+ * Gets the property descriptor for the property name from given class.
+ *
+ * @param beanClass the class of bean
+ * @param property the name of property.
+ * @return the property descriptor if property name found else return
<code>null</code>.
+ * @throws IntrospectionException
+ */
+ public static final PropertyDescriptor getPropertyDescriptor( Class
beanClass, String property )
+ throws IntrospectionException
+ {
+ BeanInfo beanInfo = Introspector.getBeanInfo( beanClass );
+ PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
+ int length = descriptors == null ? 0 : descriptors.length;
+ for( int i = 0; i < length; i++ )
+ {
+ if( descriptors[i].getDisplayName().equals( property ) )
+ {
+ return descriptors[i];
+ }
+ }
+ return null;
+ }
+}
=======================================
--- /dev/null
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/utils/JavaUtils.java
Sat Jun 14 20:36:31 2014 UTC
@@ -0,0 +1,119 @@
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
+ *
+ * This file is part of ExpressionOasis.
+ *
+ * ExpressionOasis is free software. You can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * ExpressionOasis is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
License
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
+ */
+package org.vedantatree.expressionoasis.utils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * This class provides the util methods for java type and
+ * value conversion related.
+ *
+ * @author Parmod Kamboj
+ * @author Mohit Gupta
+ *
+ * @version 1.0
+ *
+ * Improve methods by adding assertions, added new methods for primitives
+ *
+ * @author Mohit Gupta
+ * @version 1.1
+ * @since June 2014
+ */
+public final class JavaUtils
+{
+
+ /**
+ * This is the container for primitive and wrapper mappings.
+ */
+ private static Map<Class, Class> primitiveToWrappers = new HashMap<Class,
Class>();
+ private static Map<Class, Class> wrapperToprimitives = new HashMap<Class,
Class>();
+
+ /**
+ * Filling the primitive and wraper mapping.
+ */
+ static
+ {
+ primitiveToWrappers.put( int.class, Integer.class );
+ primitiveToWrappers.put( long.class, Long.class );
+ primitiveToWrappers.put( short.class, Short.class );
+ primitiveToWrappers.put( byte.class, Byte.class );
+ primitiveToWrappers.put( double.class, Double.class );
+ primitiveToWrappers.put( float.class, Float.class );
+ primitiveToWrappers.put( boolean.class, Boolean.class );
+ primitiveToWrappers.put( char.class, Character.class );
+ primitiveToWrappers.put( void.class, Void.class );
+ wrapperToprimitives.put( java.lang.Integer.class, Integer.TYPE );
+ wrapperToprimitives.put( java.lang.Long.class, Long.TYPE );
+ wrapperToprimitives.put( java.lang.Short.class, Short.TYPE );
+ wrapperToprimitives.put( java.lang.Byte.class, Byte.TYPE );
+ wrapperToprimitives.put( java.lang.Double.class, Double.TYPE );
+ wrapperToprimitives.put( java.lang.Float.class, Float.TYPE );
+ wrapperToprimitives.put( java.lang.Boolean.class, Boolean.TYPE );
+ wrapperToprimitives.put( java.lang.Character.class, Character.TYPE );
+ wrapperToprimitives.put( java.lang.Void.class, Void.TYPE );
+ }
+
+ /**
+ * Constructs the JavaUtils
+ * This constructor is made private to restrict the use
+ * of singleton class.
+ */
+ private JavaUtils()
+ {
+ /**
+ * Nothing to do here.
+ */
+ }
+
+ /**
+ * Converts the primitive class to wrapper class.
+ *
+ * @param type the class to convert
+ * @return the wrapper class corresponding to give primitive class
+ */
+ public final static Class convertToWrapper( Class type )
+ {
+ if( type == null || !type.isPrimitive() )
+ {
+ throw new IllegalArgumentException(
+ "Given class type is wrong. Either it is null or not a primitive.
given-class[" + type + "]" );
+ }
+ return primitiveToWrappers.get( type );
+ }
+
+ public static final Class convertToPrimitive( Class type )
+ {
+ if( type == null || type.isPrimitive() )
+ {
+ throw new IllegalArgumentException(
+ "Given class type is wrong. Either it is null or is a primitive.
given-class[" + type + "]" );
+ }
+ return wrapperToprimitives.get( type );
+ }
+}
=======================================
--- /dev/null
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/utils/StringUtils.java
Sat Jun 14 20:36:31 2014 UTC
@@ -0,0 +1,165 @@
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
+ *
+ * This file is part of ExpressionOasis.
+ *
+ * ExpressionOasis is free software. You can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * ExpressionOasis is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
License
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
+ */
+package org.vedantatree.expressionoasis.utils;
+
+import java.util.StringTokenizer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+/**
+ * This class provides the util methods for string operations.
+ *
+ * @author Mohit Gupta
+ * @author Parmod Kamboj
+ * @version 1.0
+ *
+ */
+public final class StringUtils
+{
+
+ private static Log LOGGER = LogFactory.getLog( StringUtils.class );
+
+ /**
+ * Constructs the StringUtils
+ * This is made private to restrict its use to
+ * singleton class.
+ */
+ private StringUtils()
+ {
+ /**
+ * Nothing to do here.
+ */
+ }
+
+ public static void assertQualifiedArgument( String attribute, String
attributeName )
+ {
+ if( !isQualifiedString( attribute ) )
+ {
+ IllegalArgumentException iae = new IllegalArgumentException(
+ "Null or zero length value found. attribute-name-message[" +
attributeName + "] value[" + attribute
+ + "]" );
+ LOGGER.error( iae );
+ throw iae;
+ }
+ }
+
+ public static void assertQualifiedArgument( String attribute )
+ {
+ if( !isQualifiedString( attribute ) )
+ {
+ IllegalArgumentException iae = new IllegalArgumentException( "Null or
zero length string found. str["
+ + attribute + "]" );
+ LOGGER.error( iae );
+ throw iae;
+ }
+ }
+
+ /**
+ * Checks whether the string is a qualified string or not.
+ * A string is a qualified string if it is not null and contains
+ * at least one charcter other than blank character.
+ *
+ * @param str the string to inspect.
+ * @return Returns <code>true</code> is the string is qualified
<code>false</code> otherwise.
+ */
+ public final static boolean isQualifiedString( String str )
+ {
+ return str != null && !str.trim().equals( "" );
+ }
+
+ /**
+ * Creates an empty string of given length.
+ *
+ * @param length the length of string.
+ * @return the empty string.
+ */
+ public final static String blankString( int length )
+ {
+ StringBuffer buffer = new StringBuffer( length );
+ for( int i = 0; i < length; i++ )
+ {
+ buffer.append( ' ' );
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * Gets the last token for spcefied dlimiter and string.
+ *
+ * @param value the string to parse
+ * @param delimiter the delimiter used for parsing.
+ * @return
+ */
+ public final static String getLastToken( String value, String delimiter )
+ {
+ String result = null;
+ StringTokenizer tokenizer = new StringTokenizer( value, delimiter );
+ while( tokenizer.hasMoreElements() )
+ {
+ result = (String) tokenizer.nextElement();
+ }
+ return result;
+ }
+
+ public final static String objectArrayToString( Object[] objectArray )
+ {
+ StringBuffer arrayString = new StringBuffer( "{" );
+ if( objectArray == null )
+ {
+ arrayString.append( "null" );
+ }
+ else if( objectArray.length == 0 )
+ {
+ arrayString.append( "empty" );
+ }
+ else
+ {
+ boolean first = true;
+ for( int i = 0; i < objectArray.length; i++ )
+ {
+ if( !first )
+ {
+ arrayString.append( ", " );
+ }
+ arrayString.append( objectArray[i] );
+ first = false;
+ }
+ }
+ arrayString.append( "}" );
+
+ return arrayString.toString();
+ }
+
+ public static void main( String[] args )
+ {
+ Object[] array = new Object[]
+ { "1", "2", "Ram" };
+ System.out.println( objectArrayToString( array ) );
+ }
+}
=======================================
--- /dev/null
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/utils/Utilities.java
Sat Jun 14 20:36:31 2014 UTC
@@ -0,0 +1,187 @@
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
+ *
+ * This file is part of ExpressionOasis.
+ *
+ * ExpressionOasis is free software. You can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * ExpressionOasis is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
License
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
+ */
+package org.vedantatree.expressionoasis.utils;
+
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+public class Utilities
+{
+
+ private static Log logger = LogFactory.getLog( Utilities.class );
+
+ public static void assertNotNullArgument( Object attribute, String
attributeName )
+ {
+ if( attribute instanceof String )
+ {
+ StringUtils.assertQualifiedArgument( (String) attribute, attributeName
);
+ }
+ else if( attribute == null )
+ {
+
+ IllegalArgumentException iae = new IllegalArgumentException(
+ "Null Object specified as value of attribute.
attribute-name-message[" + attributeName + "]" );
+ logger.error( iae );
+ throw iae;
+ }
+ }
+
+ public static void assertNotNullArgument( Object attribute )
+ {
+ if( attribute instanceof String )
+ {
+ StringUtils.assertQualifiedArgument( (String) attribute );
+ }
+ else if( attribute == null )
+ {
+ IllegalArgumentException iae = new IllegalArgumentException( "Null
Object specified as attribute" );
+ logger.error( iae );
+ throw iae;
+ }
+ }
+
+ /**
+ * Validates email address.
+ *
+ * @param emailID: email address to be verified
+ * @return boolean: true if varified correctly false if email address is
incorrect
+ */
+ public static boolean validateEmailID( String emailID )
+ {
+
+ if( emailID.indexOf( '@' ) == -1 || emailID.indexOf( '@' ) !=
emailID.lastIndexOf( '@' )
+ || emailID.lastIndexOf( '@' ) == ( emailID.length() - 1 ) ||
emailID.indexOf( '@' ) == 0 )
+ {
+ return false;
+ }
+ else if( emailID.lastIndexOf( '.' ) == -1 || ( emailID.length() -
emailID.lastIndexOf( '.' ) - 1 ) < 2 )
+ {
+ return false;
+ }
+ else if( emailID.indexOf( '@' ) > emailID.lastIndexOf( '.' )
+ || ( emailID.lastIndexOf( '.' ) - emailID.indexOf( '@' ) ) == 1 )
+ {
+ return false;
+ }
+ else if( emailID.indexOf( ' ' ) != -1 )
+ {
+ return false;
+ }
+ else
+ {
+ String spclChars = ";:?<>!~`!#$%^&*()+=|\\/'\"";
+
+ for( int i = 0; i < spclChars.length(); i++ )
+ {
+ if( emailID.indexOf( spclChars.charAt( i ) ) != -1 )
+ {
+ return false;
+ }
+ }
+
+ return true;
+
+ }
+ }
+
+ /**
+ * Converts a camel case string into title case string.
+ *
+ * @param inpString: string to be converted
+ * @return String coverted string
+ */
+ public static String convertCamelToTitleString( String inpString )
+ {
+
+ while( true )
+ {
+ if( inpString.indexOf( "_" ) != -1 )
+ {
+ int k = inpString.indexOf( '_' );
+ inpString = inpString.substring( 0, ( k ) ) + inpString.substring( k +
1 );
+ }
+ else
+ break;
+ }
+
+ for( int i = 0; i < inpString.length(); i++ )
+ {
+ String ch;
+ String rg = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ if( i != 0 )
+ {
+ ch = "" + inpString.charAt( i );
+ if( rg.indexOf( ch ) != -1 )
+ {
+ inpString = inpString.substring( 0, i ) + " " + inpString.substring(
i );
+ i = i + 2;
+ }
+ }
+ }
+
+ return inpString;
+ }
+
+ /**
+ * displays map's keys and its value.
+ *
+ * @param map
+ */
+ public static void printMapEntries( Map map )
+ {
+
+
logger.info( "------------------------------------------" );
+
logger.info( "Printing map >> " );
+
+ int size = map.size();
+ Object[] keys = map.keySet().toArray();
+
+ for( int i = 0; i < size; i++ )
+ {
+
logger.info( "entry[" + keys[i] + "] = " + map.get( keys[i] ) );
+ }
+
+
logger.info( "-------------------------------------------" );
+
+ }
+
+ public static int[] getIndexArray( String combinedString )
+ {
+ System.out.println( "Combined string is [" + combinedString + "]" );
+ String[] idArray = combinedString.split( ":" );
+ int[] idIntArray = new int[idArray.length];
+ for( int i = 0; i < idArray.length; i++ )
+ {
+ idIntArray[i] = Integer.parseInt( idArray[i].trim() );
+ System.out.println( "Long id at index [" + i + "] is [" + idIntArray[i]
+ "]" );
+ }
+ return idIntArray;
+ }
+}
=======================================
--- /dev/null
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/utils/XMLErrorHandler.java
Sat Jun 14 20:36:31 2014 UTC
@@ -0,0 +1,78 @@
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
+ *
+ * This file is part of ExpressionOasis.
+ *
+ * ExpressionOasis is free software. You can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * ExpressionOasis is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
License
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
+ */
+package org.vedantatree.expressionoasis.utils;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+
+/**
+ * It handles the error occurred during validating/parsing the XML document
+ *
+ * @author Mohit Gupta
+ *
+ */
+public class XMLErrorHandler implements ErrorHandler
+{
+
+ /** For logging purpose */
+ private static Log LOGGER = LogFactory.getLog( XMLErrorHandler.class );
+
+ /**
+ * The error is invoked when ever any error occurs during XML validation.
+ *
+ */
+ public void error( SAXParseException exception ) throws SAXException
+ {
+ LOGGER.error( "Error occured during parsing", exception );
+ throw new SAXException( "Error occured during parsing", exception );
+ }
+
+ /**
+ * The fatalError is invoked when ever any fatal error occurs during XML
+ * validation.
+ *
+ */
+ public void fatalError( SAXParseException exception ) throws SAXException
+ {
+ LOGGER.fatal( "Fatal Error occured during parsing", exception );
+ throw new SAXException( "Error occured during parsing", exception );
+ }
+
+ /**
+ * The warning is invoked when ever any warning occurs during XML
+ * validation.
+ */
+ public void warning( SAXParseException exception ) throws SAXException
+ {
+ LOGGER.warn( "Warning call during parsing", exception );
+ }
+
+}
=======================================
--- /dev/null
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/utils/XMLUtils.java
Sat Jun 14 20:36:31 2014 UTC
@@ -0,0 +1,138 @@
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
+ *
+ * This file is part of ExpressionOasis.
+ *
+ * ExpressionOasis is free software. You can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * ExpressionOasis is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
License
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
+ */
+package org.vedantatree.expressionoasis.utils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.xerces.parsers.DOMParser;
+import org.vedantatree.expressionoasis.exceptions.ErrorCodes;
+import
org.vedantatree.expressionoasis.exceptions.ExpressionEngineException;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+
+
+/**
+ * @author Mohit Gupta
+ *
+ * TODO To change the template for this generated type comment go
to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class XMLUtils
+{
+
+ private static Log LOGGER = LogFactory.getLog( XMLUtils.class );
+
+ public static Document parseXML( URL xmlDocumentURL, String xsdPath )
throws ExpressionEngineException
+ {
+ Utilities.assertNotNullArgument( xmlDocumentURL );
+
+ try
+ {
+ return parseXML( xmlDocumentURL.openStream(), xsdPath );
+ }
+ catch( IOException e )
+ {
+ LOGGER.error( "Problem while parsing the XML from URL. url[" +
xmlDocumentURL.getPath() + "]" );
+ throw new ExpressionEngineException( "Problem while parsing the XML
from URL. url["
+ + xmlDocumentURL.getPath() + "]", ErrorCodes.RESOURCE_NOT_FOUND, e );
+ }
+ }
+
+ public static Document parseXML( File xmlFile, String xsdPath ) throws
ExpressionEngineException
+ {
+ Utilities.assertNotNullArgument( xmlFile );
+
+ try
+ {
+ return parseXML( new FileInputStream( xmlFile ), xsdPath );
+ }
+ catch( FileNotFoundException e )
+ {
+ LOGGER.error( "File not found while parsing the xml. file[" +
xmlFile.getAbsolutePath() + "]" );
+ throw new ExpressionEngineException( "File not found while parsing the
xml. file["
+ + xmlFile.getAbsolutePath() + "]", ErrorCodes.RESOURCE_NOT_FOUND, e );
+ }
+ }
+
+ public static Document parseXML( InputStream is, String xsdPath ) throws
ExpressionEngineException
+ {
+ LOGGER.debug( "entering : parseXML" );
+
+ Utilities.assertNotNullArgument( is );
+ DOMParser parser = new DOMParser();
+
+ try
+ {
+ // set XSD path, if not null
+ if( xsdPath != null )
+ {
+ parser.setFeature( "
http://xml.org/sax/features/validation", true );
+
parser.setProperty( "
http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
+ xsdPath );
+ }
+
+ // Set Error Handler
+ parser.setErrorHandler( new XMLErrorHandler() );
+
+ // parse the XML
+ parser.parse( new InputSource( is ) );
+
+ return parser.getDocument();
+ }
+ catch( Exception e )
+ {
+ LOGGER.error( "Problem while parsing XML.", e );
+ throw new ExpressionEngineException( "Problem while parsing XML.",
ErrorCodes.PARSING_PROBLEM, e );
+ }
+ }
+
+ public static void main( String[] args )
+ {
+ }
+}
+
+// --------------------------------------- Commented Code
----------------------------------------
+
+// another way to parse the XML
+
+// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+//
+// try {
+// DocumentBuilder builder = factory.newDocumentBuilder();
+// return builder.parse( file );
+// }
+// catch( Exception e ) {
+// LOGGER.error( "Problem while parsing XML.", e );
+// throw new ApplicationException( IErrorCodes.XML_PARSING_ERROR, "Problem
while parsing XML.", e );
+// }
=======================================
--- /dev/null
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/utils/XPathUtils.java
Sat Jun 14 20:36:31 2014 UTC
@@ -0,0 +1,138 @@
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
+ *
+ * This file is part of ExpressionOasis.
+ *
+ * ExpressionOasis is free software. You can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * ExpressionOasis is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
License
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
+ */
+package org.vedantatree.expressionoasis.utils;
+
+import java.io.File;
+import java.net.URL;
+
+import javax.xml.transform.TransformerException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.xpath.XPathAPI;
+import org.apache.xpath.objects.XNodeSet;
+import org.apache.xpath.objects.XObject;
+import org.vedantatree.expressionoasis.exceptions.ErrorCodes;
+import
org.vedantatree.expressionoasis.exceptions.ExpressionEngineException;
+import org.vedantatree.expressionoasis.types.Type;
+import org.vedantatree.expressionoasis.types.ValueObject;
+import org.w3c.dom.Document;
+
+
+/**
+ * @author Mohit Gupta
+ *
+ * TODO To change the template for this generated type comment go
to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class XPathUtils
+{
+
+ private static Log LOGGER = LogFactory.getLog( XPathUtils.class );
+
+ public static ValueObject evaluateExpressionToValueObject( Document
document, String xPathExpression )
+ throws ExpressionEngineException
+ {
+ XObject xObject = evaluateExpression( document, xPathExpression );
+ try
+ {
+ if( xObject.getType() == XObject.CLASS_BOOLEAN )
+ {
+ return new ValueObject( new Boolean( xObject.bool() ), Type.BOOLEAN );
+ }
+ else if( xObject.getType() == XObject.CLASS_NUMBER )
+ {
+ return new ValueObject( new Double( xObject.num() ), Type.DOUBLE );
+ }
+ else if( xObject.getType() == XObject.CLASS_STRING )
+ {
+ return new ValueObject( xObject.str(), Type.STRING );
+ }
+ else if( xObject.getType() == XObject.CLASS_NODESET )
+ {
+ // passing XNodeSet
+ return new ValueObject( xObject.object(), Type.XML );
+ }
+ else
+ {
+ return new ValueObject( xObject.object(), Type.ANY_TYPE );
+ }
+ }
+ catch( TransformerException e )
+ {
+ ExpressionEngineException eex = new ExpressionEngineException(
+ "Problem while evaluating XPath Expression-[" + xPathExpression + "]",
+ ErrorCodes.EXPRESSION_EVALUATION_PROBLEM, e );
+ LOGGER.error( "Problem while evaluating XPath Expression", eex );
+ throw eex;
+ }
+ }
+
+ public static String getXMLString( Object obj )
+ {
+ Utilities.assertNotNullArgument( obj );
+ if( obj instanceof XNodeSet )
+ {
+ return ( (XNodeSet) obj ).str();
+ }
+ return obj.toString();
+ }
+
+ public static XObject evaluateExpression( Document document, String
xPathExpression )
+ throws ExpressionEngineException
+ {
+ XObject expressionValue = null;
+ try
+ {
+ expressionValue = XPathAPI.eval( document, xPathExpression );
+ }
+ catch( TransformerException e )
+ {
+ ExpressionEngineException eex = new ExpressionEngineException( "Problem
while parsing xPathExpression["
+ + xPathExpression + "]", ErrorCodes.EXPRESSION_EVALUATION_PROBLEM, e
);
+ LOGGER.error( "Problem while parsing XML", eex );
+ throw eex;
+ }
+ return expressionValue;
+ }
+
+ public static void main( String[] args ) throws Exception
+ {
+ URL url = new URL( "file:\\F:\\temp\\test.xml" );
+ System.out.println( url.getFile() );
+ File file = new File( url.getFile() );
+ System.out.println( file.getPath() );
+
+ Document doc = XMLUtils.parseXML( url, null );
+
+ ValueObject value = XPathUtils.evaluateExpressionToValueObject(
doc, "/new1/book/@name" );
+ System.out.println( "value[" + value.getValue() + "]" );
+
+ System.out
+ .println( "valueXObject[" + XPathUtils.evaluateExpression(
doc, "/new1/book/@name" ).toString() + "]" );
+ }
+}
=======================================
--- /trunk/ReleaseNotes.txt Sun Mar 23 10:40:40 2014 UTC
+++ /dev/null
@@ -1,59 +0,0 @@
-Release 3.2
-
-- Grammar class is loaded from configuration flexibly. Now, developers can
implement custom Grammar class and can specify this in configuration.
ExpressionOasis will pick this at runtime.
-- Made config.xml path configurable from System Property (Contribution by
Girish Kumar)
-- Made grammar.xml path configurable by exporting it to config.xml
-- Improved code for ExpressionFactory to improve the performance
-- Defined new way to add function definition using new API in Grammar
interface
-- Exposed Grammar through ExpressionEngine Class, so that user can get the
metadata if required and also can add specific metadata like custom
function identification etc
-- Added three new String operation expressions > startsWith, endsWith,
contains (Contribution by Girish Kumar)
-- Improved documentation
-
----------------------------------------------------------------------------------------------
-
-Release 3.1
-
-- A micro-release with few but important bugs fixes. The new 3.0.1 version
should be used to have bug free solution.
- Fixed issues are: GoogleCode: #1, #4
-
----------------------------------------------------------------------------------------------
-
-Release 3.0
-
-- License changed from GPL to LGPLv3, so that more people can be benefited
by using this free software
-- Major change in root packages name. Package name is changed from
org.ganges.expressionengine to org.vedantatree.expressionoasis
-- Introduced Maven build system, earlier it was based on Ant
(Contributions by Kris Marwood)
-- Dynamic function support. Now custom functions can be defined in xml
file, i.e. customfunctions.xml. System will pick these functions at runtime
and make these available (Contributions by Kris Marwood)
-- Merged configurations in single config.xml file
-- In memory cache for Compiled Expressions - In memory cache may be useful
for performance reasons. It can be turned on/off from config by setting
value of 'cacheCompiledExpressions' element
-- Issue #2, #3 are fixed listed at Google Code
-- Many New test cases have been added
-
----------------------------------------------------------------------------------------------
-
-Release 2.3
-
-- Support for ternary operator
-- Support for XML expressions, using Xalan XPath
- - XML Expressions will return only String type value.
- - We can change it to other specific types also, like Number, String etc
in future depending upon data or we may provide some type casting function
-Added more test cases
-
-More at
http://www.vedantatree.com/
-
----------------------------------------------------------------------------------------------
-
-Release 2.2
-
-- Support for more math functions
-- Support for Bitwise operators
-- Change precedence of operators -
http://en.wikipedia.org/wiki/Order_of_operations
-- Change '=' operator with '=='
-
----------------------------------------------------------------------------------------------
-
-Release 2.1
-
-- Documentation Update
-- Support for unary operators. Now expressions with unary operators are
supported. For example, (!false), (!false && true), (-3 + 2/-4) etc
-- Please refer to
http://expressionoasis.vedantatree.com/ and
http://www.vedantatree.com/ for further details
=======================================
--- /trunk/lib/Utilities-1.1.jar Tue Aug 31 15:49:23 2010 UTC
+++ /dev/null
Binary file, no diff available.
=======================================
--- /trunk/build.gradle Tue Apr 1 14:12:24 2014 UTC
+++ /trunk/build.gradle Sat Jun 14 20:36:31 2014 UTC
@@ -1,10 +1,12 @@
/*
+* Download Gradle and add its bin folder to classpath
+* use 'gradle tasks' to see the available tasks
* use 'gradle eclipse' for generating eclipse project file
-* use 'gradle javadoc' to generate the api docs in 'build/docs/javadoc'
folder
-* use 'gradle test' to run the junit test cases
-* use 'gradle build' to run the complete build
-* use 'gradle checkstyleMain to run checkstyle for code - on going
improvements for config file and code to keep in sync
-* use 'gradle tasks' to see the available tasks
+* use 'gradle javadoc' to generate the api docs in '\build\docs\javadoc'
folder
+* use 'gradle test' to run the junit test cases and to generate the
reports in '\build\reports\tests'
+* use 'gradle build' to run the complete build, jars will be generated
in '\build\libs'
+* use 'gradle distZip' to generate jar in 'build\distributions' folder
+* use 'gradle checkstyleMain to run checkstyle, commented as of now -
config needs improvement
*/
apply plugin: 'java'
@@ -13,9 +15,16 @@
apply plugin: 'eclipse'
// run 'gradle checkstyleMain
-apply plugin: 'checkstyle'
+//apply plugin: 'checkstyle'
+
+// plugin for creating java distribution in 'build\distributions'
+apply plugin: 'java-library-distribution'
+
+// plugin to generate dashboard for all project reports
in 'build\reports\buildDashboard'
+apply plugin: 'build-dashboard'
sourceCompatibility = 1.7
+version = 3.2
repositories {
mavenCentral()
@@ -24,12 +33,16 @@
// Task to create the jar for expressionoasis
jar {
baseName = 'expressionoasis'
- version = '3.2.0'
+ //
http://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#Main_Attributes
+ manifest {
+ attributes("Implementation-Title": "ExpressionOasis",
+ "Implementation-Version": version)
+ }
}
// Define dependencies here
dependencies {
- compile fileTree(dir: 'lib', include: '*.jar')
+ // compile fileTree(dir: 'lib', include: '*.jar')
compile (
[group: 'commons-logging', name: 'commons-logging', version: '1.1.3'],
[group: 'log4j', name: 'log4j', version: '1.2.17'],
@@ -43,22 +56,20 @@
//compile files('lib/local-dependency.jar')
}
-
-//
--------------------------------------------------------------------------------
-
-// plugin for creating distribution
-// apply plugin: 'distribution'
-
-//distributions {
-// main {
-// baseName = 'someName'
-// contents {
-// from { 'src/readme' }
-// }
-// }
-//}
+distributions {
+ main {
+ baseName = 'expressionoasis'
+ contents {
+ from { 'readme.txt' }
+ from { 'ReleaseNotes.txt' }
+ from { 'docs/Project Description.txt' }
+ from { 'build/docs' }
+ }
+ }
+}
// To run the gradle build without installing gradle
-//task wrapper(type: Wrapper) {
-// gradleVersion = '1.11'
-//}
+// task wrapper(type: Wrapper) {
+// gradleVersion = '1.11'
+// }
+
=======================================
--- /trunk/docs/TODO.txt Sun Mar 23 10:41:05 2014 UTC
+++ /trunk/docs/TODO.txt Sat Jun 14 20:36:31 2014 UTC
@@ -1,10 +1,7 @@
-* How to run file, include test cases etc and UI later
-* Updated feature list
-* Swing and Applet for web -
http://smart-math-calculator-linux.runiter-calculators.qarchive.org/
* Compiled Expressions - in XML format And/OR stream
-* Change in Type for 'assignable' check. Also include Any Type handling.
Method for getting best type for two types where both of these can be
assigned
* Change for returning best possible type from ternary operator
* function for type casting
* Event firing with context on property set
* use pmd of jalopy and checkstyle
-* Analalyse if we can utilize type casting to support type pairs, which
are not mentioned in type mappings for an expression
+* can utilize type casting to support type pairs, which are not mentioned
in type mappings for an expression
+* Swing and Applet for web
=======================================
--- /trunk/pom.xml Sat Mar 29 14:16:02 2014 UTC
+++ /trunk/pom.xml Sat Jun 14 20:36:31 2014 UTC
@@ -22,14 +22,14 @@
</resources>
</build>
<dependencies>
- <dependency>
+ <!-- dependency>
<groupId>vedantatree</groupId>
<artifactId>utilities</artifactId>
<version>1.1</version>
<type>jar</type>
<scope>system</scope>
<systemPath>${project.basedir}/lib/Utilities-1.1.jar</systemPath>
- </dependency>
+ </dependency-->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
=======================================
--- /trunk/readme.txt Sun Mar 23 10:41:05 2014 UTC
+++ /trunk/readme.txt Sat Jun 14 20:36:31 2014 UTC
@@ -1,10 +1,10 @@
Application Name: ExpressionOasis
-Author Name: Mohit Gupta <
mohit...@vedantatree.com> & Contributors
email:
mohit...@vedantatree.com
web:
http://www.vedantatree.com/
facebook:
https://www.facebook.com/VedantaTree
+twitter: @VedantaTree
-Description: Refer to docs/Project Descriptor.txt
+Description: Refer to docs/Project Description.txt
Features: Refer to ReleaseNotes.txt
Installation:
=======================================
--- /trunk/src/main/java/org/vedantatree/expressionoasis/Compiler.java Sat
Mar 22 18:13:50 2014 UTC
+++ /trunk/src/main/java/org/vedantatree/expressionoasis/Compiler.java Sat
Jun 14 20:36:31 2014 UTC
@@ -1,20 +1,28 @@
-/**
- * Copyright (c) 2006 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
*
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
*
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis;
@@ -27,11 +35,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.vedantatree.expressionoasis.config.ConfigFactory;
-import org.vedantatree.expressionoasis.config.ExpressionOasisConfig;
import
org.vedantatree.expressionoasis.exceptions.ExpressionEngineException;
import org.vedantatree.expressionoasis.expressions.Expression;
import org.vedantatree.expressionoasis.expressions.ExpressionFactory;
-import org.vedantatree.expressionoasis.grammar.DefaultXMLGrammar;
import org.vedantatree.expressionoasis.grammar.ExpressionToken;
import org.vedantatree.expressionoasis.grammar.Grammar;
@@ -131,8 +137,8 @@
compiledExpressionRPNTokenCache = expressionCachingEnabled ? new
HashMap<String, Stack<ExpressionToken>>()
: null;
}
-
- Grammar getGrammar ()
+
+ Grammar getGrammar()
{
return grammar;
}
=======================================
--- /trunk/src/main/java/org/vedantatree/expressionoasis/EOErrorCodes.java
Tue Aug 31 15:49:23 2010 UTC
+++ /trunk/src/main/java/org/vedantatree/expressionoasis/EOErrorCodes.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,41 +1,50 @@
-/**
- * Copyright (c) 2010 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
- * This file is part of ExpressionOasis.
+ * This file is part of ExpressionOasis.
*
- * ExpressionOasis is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * ExpressionOasis is free software. You can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
- * ExpressionOasis is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * ExpressionOasis is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU Lesser General Public
License
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis;
-import org.vedantatree.exceptions.ErrorCodes;
+import org.vedantatree.expressionoasis.exceptions.ErrorCodes;
/**
* It contains various error codes for the application
*
* TODO
- * Should use Enum
- * Error code description is not set yet
+ * Should use Enum
+ * Error code description is not set yet
*
* @author mohitgupta
*/
-public interface EOErrorCodes extends ErrorCodes {
+public interface EOErrorCodes extends ErrorCodes
+{
/**
- * Error code representing the invalid operand type for any operator in
+ * Error code representing the invalid operand type for any operator in
* an Expression
*/
- byte INVALID_OPERAND_TYPE = 100;
+ byte INVALID_OPERAND_TYPE = 100;
}
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/ExpressionContext.java
Tue Aug 31 15:49:23 2010 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/ExpressionContext.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,20 +1,28 @@
-/**
- * Copyright (c) 2006 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
*
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
*
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis;
@@ -32,60 +40,62 @@
import org.vedantatree.expressionoasis.extensions.DefaultVariableProvider;
import org.vedantatree.expressionoasis.extensions.FunctionProvider;
import org.vedantatree.expressionoasis.extensions.VariableProvider;
-import org.vedantatree.types.Type;
-import org.vedantatree.types.ValueObject;
+import org.vedantatree.expressionoasis.types.Type;
+import org.vedantatree.expressionoasis.types.ValueObject;
/**
- * Object of this class carry the contextual information for expressions
during
- * expression evaluation process. Like it can have information for variable
+ * Object of this class carry the contextual information for expressions
during
+ * expression evaluation process. Like it can have information for variable
* providers, function providers and other properties.
*
- * This is a thread safe object, hence can be used with multiple expression
- * evaluation process at the same time in multiple threads. Care needs to
be
- * taken for the properties if threads are changing them at the same time.
It
+ * This is a thread safe object, hence can be used with multiple expression
+ * evaluation process at the same time in multiple threads. Care needs to
be
+ * taken for the properties if threads are changing them at the same time.
It
* may results in unexpected result.
*
* @author Mohit Gupta
* @author Parmod Kamboj
* @version 1.0
- *
- * Modified constructor to register function providers that are configured
in
- * XML file rather than hardcoded function providers, so that function
providers
- * can be added and removed as required by a given application without
needing
- * to recompile.
- *
+ *
+ * Modified constructor to register function providers that are
configured in
+ * XML file rather than hardcoded function providers, so that
function providers
+ * can be added and removed as required by a given application
without needing
+ * to recompile.
+ *
* @author Kris Marwood
* @version 1.1
*/
-public class ExpressionContext {
+public class ExpressionContext
+{
/**
- * List container for variable providers. Variable providers are used to
+ * List container for variable providers. Variable providers are used to
* provide the value of variables used in expression.
*/
- private Map<String, VariableProvider> variableProviders = new
HashMap<String, VariableProvider>();
+ private Map<String, VariableProvider> variableProviders = new
HashMap<String, VariableProvider>();
/**
- * List container for function providers. Function providers are used to
+ * List container for function providers. Function providers are used to
* call the functions given in expression.
*/
- private List<FunctionProvider> functionProviders = new
ArrayList<FunctionProvider>();
+ private List<FunctionProvider> functionProviders = new
ArrayList<FunctionProvider>();
/**
- * Map container for key <> properties. It contains the value of various
+ * Map container for key <> properties. It contains the value of various
* properties used in expression.
*/
- private Map<Object, Object> properties = new Hashtable<Object,
Object>();
+ private Map<Object, Object> properties = new Hashtable<Object,
Object>();
/**
* Constructor
*/
- public ExpressionContext() throws ExpressionEngineException {
+ public ExpressionContext() throws ExpressionEngineException
+ {
registerFunctionProviders();
DefaultVariableProvider dvp = new DefaultVariableProvider();
- // for supporting the null operand with various operators,
+ // for supporting the null operand with various operators,
// Expression Engine does not understand null as special keyword
// Need to look for more appropriate method
dvp.addVariable( "null", new ValueObject( null, Type.OBJECT ) );
@@ -95,18 +105,21 @@
/**
* Registers the function providers configured in the config XML file.
- *
+ *
* @throws ExpressionEngineException if an error occurs when initializing
function provider
*/
- private void registerFunctionProviders() throws ExpressionEngineException
{
+ private void registerFunctionProviders() throws ExpressionEngineException
+ {
ExpressionOasisConfig config = ConfigFactory.getConfig();
List<FunctionProvider> providers = config.getFunctionProviders();
- for( FunctionProvider provider : providers ) {
+ for( FunctionProvider provider : providers )
+ {
addFunctionProvider( provider );
}
}
- public void addVariableProvider( VariableProvider variableProvider,
String providerName ) {
+ public void addVariableProvider( VariableProvider variableProvider,
String providerName )
+ {
variableProviders.put( providerName, variableProvider );
}
@@ -115,7 +128,8 @@
*
* @param variableProvider the variable provider to add
*/
- public void addVariableProvider( VariableProvider variableProvider ) {
+ public void addVariableProvider( VariableProvider variableProvider )
+ {
variableProviders.put( String.valueOf( variableProvider.hashCode() ),
variableProvider );
}
@@ -124,7 +138,8 @@
*
* @param functionProvider the function provider to add
*/
- public void addFunctionProvider( FunctionProvider functionProvider )
throws ExpressionEngineException {
+ public void addFunctionProvider( FunctionProvider functionProvider )
throws ExpressionEngineException
+ {
functionProviders.add( functionProvider );
functionProvider.initialize( this );
}
@@ -134,7 +149,8 @@
*
* @return Returns the functionProviders.
*/
- public Collection<FunctionProvider> getFunctionProviders() {
+ public Collection<FunctionProvider> getFunctionProviders()
+ {
return Collections.unmodifiableList( functionProviders );
}
@@ -143,11 +159,13 @@
*
* @return Returns the variableProviders
*/
- public Collection<VariableProvider> getVariableProviders() {
+ public Collection<VariableProvider> getVariableProviders()
+ {
return Collections.unmodifiableCollection( variableProviders.values() );
}
- public VariableProvider getVariableProvider( String providerName ) {
+ public VariableProvider getVariableProvider( String providerName )
+ {
return variableProviders.get( providerName );
}
@@ -157,15 +175,19 @@
* @param propertyName the name of property
* @param propertyValue the value of property
*/
- public void setContextProperty( String propertyName, Object propertyValue
) {
- if( propertyName == null ) {
+ public void setContextProperty( String propertyName, Object propertyValue
)
+ {
+ if( propertyName == null )
+ {
throw new IllegalArgumentException( "Property name can't be null." );
}
- if( propertyValue == null ) {
+ if( propertyValue == null )
+ {
properties.remove( propertyName );
}
- else {
+ else
+ {
properties.put( propertyName, propertyValue );
}
}
@@ -177,14 +199,17 @@
* @return the value corresponding to the property. <code>null</code> if
* no property exists in expression context
*/
- public Object getContextProperty( String propertyName ) {
+ public Object getContextProperty( String propertyName )
+ {
return properties.get( propertyName );
}
- /* Resets the variable provider so this expression context can be reused
with
+ /*
+ * Resets the variable provider so this expression context can be reused
with
* a new set of variables.
*/
- public void clearVariableProviders() {
+ public void clearVariableProviders()
+ {
variableProviders.clear();
}
@@ -192,7 +217,8 @@
* Resets the expression context. Cleans all the states of this expression
* context for further reuse.
*/
- public void reset() {
+ public void reset()
+ {
variableProviders.clear();
functionProviders.clear();
properties.clear();
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/ExpressionEngine.java
Sat Mar 22 18:13:50 2014 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/ExpressionEngine.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,20 +1,28 @@
-/**
- * Copyright (c) 2006 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
*
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
*
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis;
@@ -28,7 +36,7 @@
import org.vedantatree.expressionoasis.expressions.ExpressionTypeFinder;
import org.vedantatree.expressionoasis.expressions.IdentifierExpression;
import org.vedantatree.expressionoasis.grammar.Grammar;
-import org.vedantatree.types.ValueObject;
+import org.vedantatree.expressionoasis.types.ValueObject;
/**
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/ExpressionEngineConstants.java
Tue Aug 31 15:49:23 2010 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/ExpressionEngineConstants.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,20 +1,28 @@
-/**
- * Copyright (c) 2010 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
- * This file is part of ExpressionOasis.
+ * This file is part of ExpressionOasis.
*
- * ExpressionOasis is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * ExpressionOasis is free software. You can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
- * ExpressionOasis is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * ExpressionOasis is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU Lesser General Public
License
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis;
@@ -23,9 +31,10 @@
*
* @author Mohit Gupta
*/
-public interface ExpressionEngineConstants {
+public interface ExpressionEngineConstants
+{
- String EXPRESSION_CONTENXT_TOKEN = "TOKEN";
- String EXPRESSION_CONTENXT_XML_PATH_URL = "XML_PATH_URL";
+ String EXPRESSION_CONTENXT_TOKEN = "TOKEN";
+ String EXPRESSION_CONTENXT_XML_PATH_URL = "XML_PATH_URL";
}
=======================================
--- /trunk/src/main/java/org/vedantatree/expressionoasis/Parser.java Sat
Mar 22 16:38:29 2014 UTC
+++ /trunk/src/main/java/org/vedantatree/expressionoasis/Parser.java Sat
Jun 14 20:36:31 2014 UTC
@@ -1,20 +1,28 @@
-/**
- * Copyright (c) 2006 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
*
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
*
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis;
@@ -27,7 +35,7 @@
import org.vedantatree.expressionoasis.grammar.DefaultXMLGrammar;
import org.vedantatree.expressionoasis.grammar.ExpressionToken;
import org.vedantatree.expressionoasis.grammar.Grammar;
-import org.vedantatree.utils.StringUtils;
+import org.vedantatree.expressionoasis.utils.StringUtils;
/**
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/config/ConfigFactory.java
Sat Mar 22 18:13:50 2014 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/config/ConfigFactory.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,20 +1,28 @@
-/**
- * Copyright (c) 2010 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
*
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
*
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.config;
@@ -63,8 +71,19 @@
CONFIG_FILE_PATH = configFilePath;
externalPathSet = true;
}
- System.out.println( "Expression Oasis Configurations Path[" +
CONFIG_FILE_PATH
- + "] externally-set[" + externalPathSet + "]" );
+
+ if( !externalPathSet )
+ {
+ System.out
+ .println( "No custom configuraiton file is set from outside using
System Properties. "
+ + "ExpressionOasis will look for config.xml in class path." );
+ }
+ else
+ {
+ System.out.println( "Configuration file path is specified in system
properties for key["
+ + CONFIG_FILE_PATH_KEY + "]. " + "ExpressionOasis will load the
configuration from: "
+ + CONFIG_FILE_PATH );
+ }
Serializer serializer = new Persister();
try
@@ -75,7 +94,8 @@
}
catch( Exception e )
{
- throw new RuntimeException( "Error loading ExpressionOasis
configuration: " + e.getMessage(), e );
+ throw new RuntimeException( "Error loading ExpressionOasis
configuration. config.xml path["
+ + CONFIG_FILE_PATH + "]", e );
}
}
}
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/config/ConstructorArgument.java
Tue Aug 31 15:49:23 2010 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/config/ConstructorArgument.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,20 +1,28 @@
-/**
- * Copyright (c) 2010 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
*
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
*
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.config;
@@ -25,36 +33,40 @@
/**
* Represents a constructur argument to be passed to a class defined
* in a configuration file
- *
+ *
* @author Kris Marwood
* @version 1.0
*/
@Root(name = "constructorArg")
-public class ConstructorArgument {
+public class ConstructorArgument
+{
@Attribute(name = "className")
- private String className;
+ private String className;
@Attribute(name = "value")
- private String value;
+ private String value;
/**
* @return the className
*/
- public String getClassName() {
+ public String getClassName()
+ {
return className;
}
/**
* @return the value
*/
- public String getValue() {
+ public String getValue()
+ {
return value;
}
@Override
- public String toString() {
+ public String toString()
+ {
return className + " = " + value;
}
}
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/config/ExpressionConfig.java
Sat Mar 22 18:13:50 2014 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/config/ExpressionConfig.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,20 +1,28 @@
-/**
- * Copyright (c) 2010 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
-
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ *
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-
+ *
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
-
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
+ *
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.config;
@@ -24,37 +32,42 @@
/**
* Represents the configuration for an Expression
- *
+ *
* @author Kris Marwood
*/
@Element(name = "expression")
-public class ExpressionConfig {
+public class ExpressionConfig
+{
@Attribute(name = "name")
- private String expressionName;
+ private String expressionName;
@Attribute(name = "className")
- private String className;
+ private String className;
@Attribute(name = "type")
- private String expressionType;
+ private String expressionType;
/**
* @return the expressionName
*/
- public String getExpressionName() {
+ public String getExpressionName()
+ {
return expressionName;
}
/**
* @return the className
*/
- public Class getExpressionClass() {
+ public Class getExpressionClass()
+ {
Class expressionClass = null;
- try {
+ try
+ {
expressionClass = Class.forName( className );
}
- catch( ClassNotFoundException e ) {
+ catch( ClassNotFoundException e )
+ {
throw new RuntimeException( "Error loading expression class[" +
className + "]", e );
}
return expressionClass;
@@ -63,7 +76,8 @@
/**
* @return the expressionType
*/
- public String getExpressionType() {
+ public String getExpressionType()
+ {
return expressionType;
}
}
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/config/ExpressionOasisConfig.java
Sat Mar 22 18:13:50 2014 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/config/ExpressionOasisConfig.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,20 +1,28 @@
-/**
- * Copyright (c) 2010 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
-
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ *
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-
+ *
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
-
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
+ *
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.config;
@@ -22,7 +30,6 @@
import java.util.Collections;
import java.util.List;
-import org.junit.Assert;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root;
@@ -115,8 +122,8 @@
+ grammarClass + "]", e );
}
}
-
- public String getGrammarPath ()
+
+ public String getGrammarPath()
{
return grammarPath;
}
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/config/FunctionProviderConfig.java
Tue Aug 31 15:49:23 2010 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/config/FunctionProviderConfig.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,20 +1,28 @@
-/**
- * Copyright (c) 2010 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
-
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ *
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-
+ *
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
-
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
+ *
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.config;
@@ -32,13 +40,14 @@
/**
* Represents the configuration of a function provider, and builds the
function provider
* that it represents.
- *
+ *
* @author Kris Marwood
* @version 1.0
*/
@Root(name = "functionProvider")
-public class FunctionProviderConfig {
+public class FunctionProviderConfig
+{
/* the name of the function provider class represented by this object */
@Attribute(name = "className")
@@ -46,21 +55,22 @@
/* the arguments that must be passed to the function provider's
constructor */
@ElementList(name = "constructorArgs", entry = "constructorArg", required
= false)
- private final List<ConstructorArgument> args;
+ private final List<ConstructorArgument> args;
/* an instance of the function provider defined by this class */
- private FunctionProvider provider = null;
+ private FunctionProvider provider = null;
/**
* Constructor arguments are annotated so that the Simple XML framework
can use
* constructor injection to create an immutable object.
- *
+ *
* @param className the name of the function provider class to instantiate
* @param args the arguments to pass to the constructor during
instantiation
*/
public FunctionProviderConfig(
@Attribute(name = "className") String className,
- @ElementList(name = "constructorArgs", entry = "constructorArg",
required = false) List<ConstructorArgument> args ) {
+ @ElementList(name = "constructorArgs", entry = "constructorArg",
required = false) List<ConstructorArgument> args )
+ {
this.className = className;
this.args = args;
@@ -69,38 +79,48 @@
/**
* Gets an instance of the function provider that is defined in the XML
config
* this object represents.
- *
+ *
* @return an instance of the function provider as defined in the XML
config
- * this object represents.
- *
+ * this object represents.
+ *
* @throws ExpressionEngineException
*/
- public FunctionProvider getFunctionProvider() {
- if( provider == null ) {
- try {
+ public FunctionProvider getFunctionProvider()
+ {
+ if( provider == null )
+ {
+ try
+ {
Class providerClass = Class.forName( className );
Constructor constructor = providerClass.getConstructor(
getConstructorParameterTypes() );
provider = (FunctionProvider) constructor.newInstance(
getConstructorParameterValues() );
}
- catch( InstantiationException e ) {
+ catch( InstantiationException e )
+ {
throw new RuntimeException( e );
}
- catch( IllegalAccessException e ) {
+ catch( IllegalAccessException e )
+ {
throw new RuntimeException( e );
}
- catch( IllegalArgumentException e ) {
+ catch( IllegalArgumentException e )
+ {
throw new RuntimeException( e );
}
- catch( InvocationTargetException e ) {
+ catch( InvocationTargetException e )
+ {
throw new RuntimeException( e );
}
- catch( NoSuchMethodException e ) {
+ catch( NoSuchMethodException e )
+ {
throw new RuntimeException( e );
}
- catch( SecurityException e ) {
+ catch( SecurityException e )
+ {
throw new RuntimeException( e );
}
- catch( ClassNotFoundException e ) {
+ catch( ClassNotFoundException e )
+ {
throw new RuntimeException( e );
}
}
@@ -110,20 +130,24 @@
/**
* Gets the parameters required by the function provider class's
constructor
* (as defined by the args tags in the XML config).
- *
+ *
* @return an array of classes in the function provider constructor's
signature
* @throws ClassNotFoundException
*/
- private Class[] getConstructorParameterTypes() throws
ClassNotFoundException {
+ private Class[] getConstructorParameterTypes() throws
ClassNotFoundException
+ {
Class[] types;
- if( args != null ) {
+ if( args != null )
+ {
types = new Class[args.size()];
- for( int i = 0; i < args.size(); i++ ) {
+ for( int i = 0; i < args.size(); i++ )
+ {
types[i] = Class.forName( args.get( i ).getClassName() );
}
}
- else {
+ else
+ {
types = new Class[0];
}
@@ -133,25 +157,31 @@
/**
* Gets the values to pass to the function provider class's constructor
* (as defined by the args tags in the XML config).
- *
+ *
* @return an array of objects to pass to the function provider class's
constructor
* @throws ClassNotFoundException
*/
- private Object[] getConstructorParameterValues() throws
ClassNotFoundException {
+ private Object[] getConstructorParameterValues() throws
ClassNotFoundException
+ {
Object[] values;
- if( args != null ) {
+ if( args != null )
+ {
values = new Class[args.size()];
- for( int i = 0; i < args.size(); i++ ) {
- if( args.get( i ).getClassName().equals( "java.lang.Class" ) ) {
+ for( int i = 0; i < args.size(); i++ )
+ {
+ if( args.get( i ).getClassName().equals( "java.lang.Class" ) )
+ {
values[i] = Class.forName( args.get( i ).getValue() );
}
- else {
+ else
+ {
values[i] = args.get( i ).getValue();
}
}
}
- else {
+ else
+ {
values = new Class[0];
}
return values;
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/exceptions/ExpressionEngineException.java
Tue Aug 31 15:49:23 2010 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/exceptions/ExpressionEngineException.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,73 +1,130 @@
-/**
- * Copyright (c) 2005 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
-
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ *
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-
+ *
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
-
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
+ *
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.exceptions;
-import org.vedantatree.exceptions.XException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
- * This exception is used by whole Expression Engine Component to share any
+ * This exception is used by whole Expression Engine Component to share any
* Erroneous information with user of the component, like at the time of
parsing
- * or by the compiler while doing syntactical analysis.
+ * or by the compiler while doing syntactical analysis.
*
* @author Mohit Gupta
* @author Parmod Kamboj
* @version 1.0
- *
+ *
*/
-public class ExpressionEngineException extends XException {
+public class ExpressionEngineException extends Exception
+{
+
+ private static Log LOGGER = LogFactory.getLog(
ExpressionEngineException.class );
/**
* This is the serialization version for this class.
*/
- private static final long serialVersionUID = 2006122401L;
+ private static final long serialVersionUID = 2006122401L;
+
+ protected static final String CUSTOMIZED_ERROR_CODE = "Customized Error
Code";
+
+ private int errorCode = Integer.MIN_VALUE;
/**
* Constructs the ExpressionEngineException
*
* @param msg
- * the massege given by parser to tell the error.
+ * the massege given by parser to tell the error.
*/
- public ExpressionEngineException( String msg ) {
- super( msg, -1 );
+ public ExpressionEngineException( String msg )
+ {
+ this( msg, -1, null );
}
/**
* Constructs the ExpressionEngineException
*
* @param msg
- * the massege given by parser to tell the error.
+ * the massege given by parser to tell the error.
* @param e Exception to wrap
*/
- public ExpressionEngineException( String msg, Exception e ) {
- super( msg, -1, e );
+ public ExpressionEngineException( String msg, Throwable e )
+ {
+ this( msg, -1, e );
}
/**
* Constructs the ExpressionEngineException
*
* @param msg
- * the massege given by parser to tell the error
+ * the massege given by parser to tell the error
* @param errorCode code representing the error type
* @param e Exception to wrap
*/
- public ExpressionEngineException( String msg, int errorCode, Exception e
) {
- super( msg, errorCode, e );
+ public ExpressionEngineException( String msg, int errorCode, Throwable e )
+ {
+ this( msg, errorCode, null, false );
}
+
+ public ExpressionEngineException( String message, int errorCode,
Throwable cause, boolean debug )
+ {
+ super( message, null );
+ this.errorCode = errorCode;
+ if( debug )
+ {
+ LOGGER.debug( getMessage(), cause );
+ }
+ else
+ {
+ LOGGER.error( getMessage(), cause );
+ }
+ }
+
+ public final int getErrorCode()
+ {
+ return errorCode;
+ }
+
+ /*
+ * TODO: Need to use Resource Bundle here.
+ * Resource Bundle should be used on the basis of error codes.
+ * Message can be treated as error detail for technical usage.
+ * The string loaded from resource bundler using error code should be
+ * displayed to the user as error description.
+ */
+ public String getMessage()
+ {
+ return super.getMessage() + ": error-code[" + errorCode + "]
code-description[" + getErrorDescription() + "]";
+ }
+
+ protected String getErrorDescription()
+ {
+ return ( errorCode >= ErrorCodes.ERROR_DESCRIPTION.length || errorCode <
0 ) ? CUSTOMIZED_ERROR_CODE
+ : ErrorCodes.ERROR_DESCRIPTION[errorCode];
+ }
+
}
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/BinaryOperatorExpression.java
Sat Mar 22 18:13:50 2014 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/BinaryOperatorExpression.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,20 +1,28 @@
-/**
- * Copyright (c) 2006 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
*
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
*
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.expressions;
@@ -24,9 +32,9 @@
import org.vedantatree.expressionoasis.EOErrorCodes;
import org.vedantatree.expressionoasis.ExpressionContext;
import
org.vedantatree.expressionoasis.exceptions.ExpressionEngineException;
-import org.vedantatree.types.Type;
-import org.vedantatree.types.ValueObject;
-import org.vedantatree.utils.StringUtils;
+import org.vedantatree.expressionoasis.types.Type;
+import org.vedantatree.expressionoasis.types.ValueObject;
+import org.vedantatree.expressionoasis.utils.StringUtils;
/**
@@ -35,35 +43,36 @@
* @author Parmod Kamboj
* @author Mohit Gupta
* @version 1.0
- *
- * Modified to support visitor design pattern. Also replaced usage of
Hashtable
- * with HashMap for performance improvement as synchronization shouldn't be
- * required.
- *
+ *
+ * Modified to support visitor design pattern. Also replaced
usage of Hashtable
+ * with HashMap for performance improvement as synchronization
shouldn't be
+ * required.
+ *
* @author Kris Marwood
* @version 1.1
*/
-public abstract class BinaryOperatorExpression implements Expression {
+public abstract class BinaryOperatorExpression implements Expression
+{
/**
* This is the type pairs cache.
*/
- private static final Map TYPE_PAIR_CACHE = new HashMap();
+ private static final Map TYPE_PAIR_CACHE = new HashMap();
/**
* This is the type pair mapping for all the binary operators.
*/
- private static Map typePairMapping = new HashMap();
+ private static Map typePairMapping = new HashMap();
/**
* Left operand expression for this binary operator expression.
*/
- protected Expression leftOperandExpression;
+ protected Expression leftOperandExpression;
/**
* Right operand expression for this binary operator expression.
*/
- protected Expression rightOperandExpression;
+ protected Expression rightOperandExpression;
/**
* Initializes the child expressions.
@@ -72,24 +81,29 @@
* java.lang.Object)
*/
public void initialize( ExpressionContext expressionContext, Object
parameters, boolean validate )
- throws ExpressionEngineException {
+ throws ExpressionEngineException
+ {
Expression[] arguments = null;
- try {
+ try
+ {
arguments = (Expression[]) parameters;
- if( arguments == null || arguments.length != 2 || arguments[0] == null |
| arguments[1] == null ) {
+ if( arguments == null || arguments.length != 2 || arguments[0] == null |
| arguments[1] == null )
+ {
throw new ExpressionEngineException( "Child expressions information is
not valid." );
}
}
- catch( ClassCastException ex ) {
+ catch( ClassCastException ex )
+ {
throw new ExpressionEngineException( "Child expressions information is
not valid." );
}
leftOperandExpression = arguments[0];
rightOperandExpression = arguments[1];
- if( validate ) {
+ if( validate )
+ {
validate( expressionContext );
}
}
@@ -97,14 +111,17 @@
/**
* @see
org.vedantatree.expressionoasis.expressions.Expression#getReturnType()
*/
- public Type getReturnType() throws ExpressionEngineException {
+ public Type getReturnType() throws ExpressionEngineException
+ {
HashMap typeMapping = (HashMap) typePairMapping.get( getClass() );
Type type = (Type) typeMapping.get( createTypePair(
leftOperandExpression.getReturnType(),
rightOperandExpression.getReturnType() ) );
- if( type == null ) {
+ if( type == null )
+ {
if( getLeftOperandExpression().getReturnType() == Type.ANY_TYPE
- || getRightOperandExpression().getReturnType() == Type.ANY_TYPE ) {
+ || getRightOperandExpression().getReturnType() == Type.ANY_TYPE )
+ {
type = Type.ANY_TYPE;
}
}
@@ -116,7 +133,8 @@
*
* @return Returns the leftOperandExpression.
*/
- public Expression getLeftOperandExpression() {
+ public Expression getLeftOperandExpression()
+ {
return leftOperandExpression;
}
@@ -125,7 +143,8 @@
*
* @return Returns the rightOperandExpression.
*/
- public Expression getRightOperandExpression() {
+ public Expression getRightOperandExpression()
+ {
return rightOperandExpression;
}
@@ -134,7 +153,8 @@
*
* @see
org.vedantatree.expressionoasis.expressions.Expression#uninitialize(org.vedantatree.expressionoasis.ExpressionContext)
*/
- public void uninitialize( ExpressionContext expressionContext ) {
+ public void uninitialize( ExpressionContext expressionContext )
+ {
this.leftOperandExpression = null;
this.rightOperandExpression = null;
}
@@ -146,11 +166,13 @@
* @param rightType
* @return
*/
- protected static final TypePair createTypePair( Type leftType, Type
rightType ) {
+ protected static final TypePair createTypePair( Type leftType, Type
rightType )
+ {
String key = leftType.getTypeName() + rightType.getTypeName();
TypePair typePair = (TypePair) TYPE_PAIR_CACHE.get( key );
- if( typePair == null ) {
+ if( typePair == null )
+ {
typePair = new TypePair( leftType, rightType );
TYPE_PAIR_CACHE.put( key, typePair );
}
@@ -161,9 +183,9 @@
/**
* Adds the type mapping for the given operator.
*
- * User can add as many mapping as required for operator. Like in case of
- * '+' operator, one possible mapping is left type = integer, right type =
- * string, result type = string. Because if we add integer to string, it
+ * User can add as many mapping as required for operator. Like in case of
+ * '+' operator, one possible mapping is left type = integer, right type =
+ * string, result type = string. Because if we add integer to string, it
* will result in a string value.
*
* @param clazz class of the operator like +, - etc
@@ -171,15 +193,18 @@
* @param rightType type of right operand
* @param resultType type of result
*/
- protected static final void addTypePair( Class clazz, Type leftType, Type
rightType, Type resultType ) {
- if( clazz == null || !BinaryOperatorExpression.class.isAssignableFrom(
clazz ) ) {
+ protected static final void addTypePair( Class clazz, Type leftType, Type
rightType, Type resultType )
+ {
+ if( clazz == null || !BinaryOperatorExpression.class.isAssignableFrom(
clazz ) )
+ {
throw new IllegalArgumentException( "\"" + clazz.getName()
+ "\" is not a valid binary operator expression class." );
}
HashMap typeMapping = (HashMap) typePairMapping.get( clazz );
- if( typeMapping == null ) {
+ if( typeMapping == null )
+ {
typeMapping = new HashMap();
typePairMapping.put( clazz, typeMapping );
}
@@ -193,18 +218,22 @@
* @param expressionContext
* @throws ExpressionEngineException
*/
- protected void validate( ExpressionContext expressionContext ) throws
ExpressionEngineException {
- if( leftOperandExpression.getReturnType() == null ) {
+ protected void validate( ExpressionContext expressionContext ) throws
ExpressionEngineException
+ {
+ if( leftOperandExpression.getReturnType() == null )
+ {
throw new ExpressionEngineException( "Return type of left operand
expression: [" + leftOperandExpression
+ "] is null.", EOErrorCodes.INVALID_OPERAND_TYPE, null );
}
- if( rightOperandExpression.getReturnType() == null ) {
+ if( rightOperandExpression.getReturnType() == null )
+ {
throw new ExpressionEngineException( "Return type of right operand
expression: [" + rightOperandExpression
+ "] is null.", EOErrorCodes.INVALID_OPERAND_TYPE, null );
}
- if( getReturnType() == null ) {
+ if( getReturnType() == null )
+ {
String prefix = StringUtils.getLastToken( getClass().getName(), "." );
prefix = prefix.substring( 0, prefix.length() - "Expression".length() );
throw new ExpressionEngineException( "Either no type mapping is defined
or Operands of types: [\""
@@ -217,7 +246,8 @@
* @see java.lang.Object#toString()
*/
@Override
- public String toString() {
+ public String toString()
+ {
String prefix = StringUtils.getLastToken( getClass().getName(), "." );
prefix = prefix.substring( 0, prefix.length() );
@@ -225,10 +255,13 @@
}
/**
- * Allows an expression visitor to visit this expression and it's
sub-expressions (implements Visitor design pattern).
+ * Allows an expression visitor to visit this expression and it's
sub-expressions (implements Visitor design
+ * pattern).
+ *
* @see
org.vedantatree.expressionoasis.expressions.Expression#accept(org.vedantatree.expressionoasis.ExpressionVisitor)
*/
- public void accept( ExpressionVisitor visitor ) {
+ public void accept( ExpressionVisitor visitor )
+ {
visitor.visit( this );
leftOperandExpression.accept( visitor );
rightOperandExpression.accept( visitor );
@@ -237,17 +270,18 @@
/**
* This is the class for making pair of valid types for a binary operator.
*/
- protected static class TypePair {
+ protected static class TypePair
+ {
/**
* This is the left side operand's type.
*/
- private Type leftType;
+ private Type leftType;
/**
* This is the right side operand's type.
*/
- private Type rightType;
+ private Type rightType;
/**
* Constructs the TypePair
@@ -255,20 +289,24 @@
* @param leftType type of left operand
* @param rightType type of right operand
*/
- public TypePair( Type leftType, Type rightType ) {
+ public TypePair( Type leftType, Type rightType )
+ {
this.leftType = leftType;
this.rightType = rightType;
}
/**
* Performs the equlity of type pairs
+ *
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
- public boolean equals( Object arg ) {
+ public boolean equals( Object arg )
+ {
boolean result = false;
- if( arg instanceof TypePair ) {
+ if( arg instanceof TypePair )
+ {
TypePair typePair = (TypePair) arg;
result = typePair.leftType == leftType && typePair.rightType ==
rightType;
}
@@ -278,10 +316,12 @@
/**
* Returns the hashcode of the type pair.
+ *
* @see java.lang.Object#hashCode()
*/
@Override
- public int hashCode() {
+ public int hashCode()
+ {
return ( leftType.getTypeName() + rightType.getTypeName() ).hashCode();
}
}
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/BooleanExpression.java
Tue Aug 31 15:49:23 2010 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/BooleanExpression.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,27 +1,35 @@
-/**
- * Copyright (c) 2006 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
*
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
*
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.expressions;
import org.vedantatree.expressionoasis.ExpressionContext;
import
org.vedantatree.expressionoasis.exceptions.ExpressionEngineException;
-import org.vedantatree.types.Type;
-import org.vedantatree.types.ValueObject;
+import org.vedantatree.expressionoasis.types.Type;
+import org.vedantatree.expressionoasis.types.ValueObject;
/**
@@ -31,25 +39,27 @@
* @author Mohit Gupta
* @author Parmod Kamboj
* @version 1.0
- *
- * Modified to support visitor design pattern.
- *
+ *
+ * Modified to support visitor design pattern.
+ *
* @author Kris Marwood
* @version 1.1
*/
-public class BooleanExpression implements Expression {
+public class BooleanExpression implements Expression
+{
/**
* This is the boolean value for this expression.
*/
- private ValueObject booleanValue;
+ private ValueObject booleanValue;
/**
* Gets the value object for boolean value.
*
* @see org.vedantatree.expressionoasis.expressions.Expression#getValue()
*/
- public ValueObject getValue() throws ExpressionEngineException {
+ public ValueObject getValue() throws ExpressionEngineException
+ {
return booleanValue;
}
@@ -58,7 +68,8 @@
*
* @see
org.vedantatree.expressionoasis.expressions.Expression#getReturnType()
*/
- public Type getReturnType() throws ExpressionEngineException {
+ public Type getReturnType() throws ExpressionEngineException
+ {
return Type.BOOLEAN;
}
@@ -69,7 +80,8 @@
* java.lang.Object)
*/
public void initialize( ExpressionContext expressionContext, Object
objectInfo, boolean validate )
- throws ExpressionEngineException {
+ throws ExpressionEngineException
+ {
booleanValue = new ValueObject( objectInfo.equals( "true" ) ?
Boolean.TRUE : Boolean.FALSE, Type.BOOLEAN );
}
@@ -78,7 +90,8 @@
*
* @see
org.vedantatree.expressionoasis.expressions.Expression#uninitialize(org.vedantatree.expressionoasis.ExpressionContext)
*/
- public void uninitialize( ExpressionContext expressionContext ) {
+ public void uninitialize( ExpressionContext expressionContext )
+ {
booleanValue = null;
}
@@ -86,15 +99,19 @@
* @see java.lang.Object#toString()
*/
@Override
- public String toString() {
+ public String toString()
+ {
return booleanValue == null ? "null-not-initialized" :
booleanValue.getValue() + "";
}
/**
- * Allows an expression visitor to visit this expression and it's
sub-expressions (implements Visitor design pattern).
+ * Allows an expression visitor to visit this expression and it's
sub-expressions (implements Visitor design
+ * pattern).
+ *
* @see
org.vedantatree.expressionoasis.expressions.Expression#accept(org.vedantatree.expressionoasis.ExpressionVisitor)
*/
- public void accept( ExpressionVisitor visitor ) {
+ public void accept( ExpressionVisitor visitor )
+ {
visitor.visit( this );
}
}
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/DecimalExpression.java
Tue Aug 31 15:49:23 2010 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/DecimalExpression.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,27 +1,35 @@
-/**
- * Copyright (c) 2006 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
*
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
*
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.expressions;
import org.vedantatree.expressionoasis.ExpressionContext;
import
org.vedantatree.expressionoasis.exceptions.ExpressionEngineException;
-import org.vedantatree.types.Type;
-import org.vedantatree.types.ValueObject;
+import org.vedantatree.expressionoasis.types.Type;
+import org.vedantatree.expressionoasis.types.ValueObject;
/**
@@ -30,25 +38,27 @@
*
* @author Parmod Kamboj
* @version 1.0
- *
- * Modified to support visitor design pattern.
- *
+ *
+ * Modified to support visitor design pattern.
+ *
* @author Kris Marwood
* @version 1.1
*/
-public class DecimalExpression implements Expression {
+public class DecimalExpression implements Expression
+{
/**
* This is the decimal value for this expression.
*/
- private ValueObject decimalValue;
+ private ValueObject decimalValue;
/**
* Gets the value object for decimal value.
*
* @see org.vedantatree.expressionoasis.expressions.Expression#getValue()
*/
- public ValueObject getValue() throws ExpressionEngineException {
+ public ValueObject getValue() throws ExpressionEngineException
+ {
return decimalValue;
}
@@ -57,7 +67,8 @@
*
* @see
org.vedantatree.expressionoasis.expressions.Expression#getReturnType()
*/
- public Type getReturnType() throws ExpressionEngineException {
+ public Type getReturnType() throws ExpressionEngineException
+ {
return Type.DOUBLE;
}
@@ -68,7 +79,8 @@
* java.lang.Object)
*/
public void initialize( ExpressionContext expressionContext, Object
objectInfo, boolean validate )
- throws ExpressionEngineException {
+ throws ExpressionEngineException
+ {
Double value = new Double( (String) objectInfo );
decimalValue = new ValueObject( value, Type.DOUBLE );
}
@@ -78,7 +90,8 @@
*
* @see
org.vedantatree.expressionoasis.expressions.Expression#uninitialize(org.vedantatree.expressionoasis.ExpressionContext)
*/
- public void uninitialize( ExpressionContext expressionContext ) {
+ public void uninitialize( ExpressionContext expressionContext )
+ {
decimalValue = null;
}
@@ -86,15 +99,19 @@
* @see java.lang.Object#toString()
*/
@Override
- public String toString() {
+ public String toString()
+ {
return decimalValue == null ? "null-not-initialized" :
decimalValue.getValue() + "";
}
/**
- * Allows an expression visitor to visit this expression and it's
sub-expressions (implements Visitor design pattern).
+ * Allows an expression visitor to visit this expression and it's
sub-expressions (implements Visitor design
+ * pattern).
+ *
* @see
org.vedantatree.expressionoasis.expressions.Expression#accept(org.vedantatree.expressionoasis.ExpressionVisitor)
*/
- public void accept( ExpressionVisitor visitor ) {
+ public void accept( ExpressionVisitor visitor )
+ {
visitor.visit( this );
}
}
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/Expression.java
Tue Aug 31 15:49:23 2010 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/Expression.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,61 +1,70 @@
-/**
- * Copyright (c) 2006 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
*
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
*
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.expressions;
import org.vedantatree.expressionoasis.ExpressionContext;
import
org.vedantatree.expressionoasis.exceptions.ExpressionEngineException;
-import org.vedantatree.types.Type;
-import org.vedantatree.types.ValueObject;
+import org.vedantatree.expressionoasis.types.Type;
+import org.vedantatree.expressionoasis.types.ValueObject;
/**
- * This class represents the executable structure of an expression.
+ * This class represents the executable structure of an expression.
*
- * Parser parse the expression and break it into individual expression
tokens.
- * This token list is feed to compiler for creating the executable
structure of
- * expressions using objects of this class. Compiler create relevant
expression
- * object (of this class) for every token and creates a relative expression
- * chain as operands or operators. Final outcome of Compiler is a single
top
+ * Parser parse the expression and break it into individual expression
tokens.
+ * This token list is feed to compiler for creating the executable
structure of
+ * expressions using objects of this class. Compiler create relevant
expression
+ * object (of this class) for every token and creates a relative expression
+ * chain as operands or operators. Final outcome of Compiler is a single
top
* level expression which contains all expression in hierarchy.
*
- * So the final expression can be an atomic Expression class or an
Expression
+ * So the final expression can be an atomic Expression class or an
Expression
* having a large tree of children expressions with it.
*
* TODO
- * improve tostring to represent actual expression
+ * improve tostring to represent actual expression
*
* @author Mohit Gupta
* @author Parmod Kamboj
* @version 1.0
- *
- * Modified to support visitor design pattern.
- *
+ *
+ * Modified to support visitor design pattern.
+ *
* @author Kris Marwood
* @version 1.1
*/
-public interface Expression {
+public interface Expression
+{
/**
- * Executes and returns the value of this expression.
+ * Executes and returns the value of this expression.
*
* If expression is not at node level, it will further evaluate its
related
- * expression which may represents operands or operators and return the
+ * expression which may represents operands or operators and return the
* final outcome.
*
* @throws ExpressionEngineException if there is any problem during
execution
@@ -74,30 +83,30 @@
/**
* This is used to initialize the expression.
*
- * @param expressionContext contextual information, may help in
- * initialization
- * @param parameters for example, sub expressions and identifiers
+ * @param expressionContext contextual information, may help in
+ * initialization
+ * @param parameters for example, sub expressions and identifiers
* @validate whether or not to validate the type of the expression. It
can be
- * useful to not validate expressions when compiling an
expression
- * for using with an ExpressionTypeFinder.
+ * useful to not validate expressions when compiling an
expression
+ * for using with an ExpressionTypeFinder.
* @throws ExpressionEngineException if there is any problem during
execution
*/
void initialize( ExpressionContext expressionContext, Object parameters,
boolean validate )
throws ExpressionEngineException;
/**
- * This is used to un-initialize the expression, so that expression can be
+ * This is used to un-initialize the expression, so that expression can be
* reused.
*
- * @param expressionContext contextual information, may help in
- * un-initialization
+ * @param expressionContext contextual information, may help in
+ * un-initialization
*/
void uninitialize( ExpressionContext expressionContext );
/**
- * Implements visitor pattern.
- *
- * @param visitor a visitor object that this expression must visit when
accept is called.
- */
+ * Implements visitor pattern.
+ *
+ * @param visitor a visitor object that this expression must visit when
accept is called.
+ */
void accept( ExpressionVisitor visitor );
}
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/ExpressionFactory.java
Sat Mar 22 18:13:50 2014 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/ExpressionFactory.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,20 +1,28 @@
-/**
- * Copyright (c) 2006 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
*
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
*
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.expressions;
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/ExpressionTypeFinder.java
Tue Aug 31 15:49:23 2010 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/ExpressionTypeFinder.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,20 +1,28 @@
-/**
- * Copyright (c) 2010 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
*
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
*
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.expressions;
@@ -25,38 +33,43 @@
* Use to find sub-expressions of a particular type within a given
expression.
* For example, the following would extract a set of variables
(IdentifierExpressions)
* from an expression:
- *
+ *
* ExpressionTypeFinder finder = new ExpressionTypeFinder(someExpression,
IdentifierExpression.class);
* Set<Expression> variables = finder.getExpressions();
- *
+ *
* @author Kris Marwood
* @version 1.0
*/
-public class ExpressionTypeFinder implements ExpressionVisitor {
+public class ExpressionTypeFinder implements ExpressionVisitor
+{
/* the expression to search to find sub-expressions */
private final Expression expressionToSearch;
/* the type of sub-expression to search for */
- private final Class expressionTypeToFind;
+ private final Class expressionTypeToFind;
/* the sub-expressions found within the expression */
- private final LinkedHashSet<Expression> foundExpressions;
+ private final LinkedHashSet<Expression> foundExpressions;
/**
* Creates a new ExpressionTypeFinder
- *
+ *
* @param expressionToSearch the expression to search to find
sub-expressions
* @param expressionTypeToFind the type of the sub-expressions to search
*/
- public ExpressionTypeFinder( Expression expressionToSearch, Class
expressionTypeToFind ) {
- if( expressionToSearch == null ) {
+ public ExpressionTypeFinder( Expression expressionToSearch, Class
expressionTypeToFind )
+ {
+ if( expressionToSearch == null )
+ {
throw new IllegalArgumentException( "expressionToSearch must not be
null" );
}
- if( expressionTypeToFind == null ) {
+ if( expressionTypeToFind == null )
+ {
throw new IllegalArgumentException( "expressionTypeToFind must not be
null" );
}
- if( !Expression.class.isAssignableFrom( expressionTypeToFind ) ) {
+ if( !Expression.class.isAssignableFrom( expressionTypeToFind ) )
+ {
throw new java.lang.IllegalArgumentException( "expressionTypeToFind
must be an Expression class" );
}
@@ -69,22 +82,25 @@
/**
* Implementation of the visitor design pattern. An expression will call
this
* with itself as the <code>expression</code> parameter.
- *
+ *
* @param expression
*/
- public void visit( Expression expression ) {
- if( expression.getClass().equals( expressionTypeToFind ) ) {
+ public void visit( Expression expression )
+ {
+ if( expression.getClass().equals( expressionTypeToFind ) )
+ {
foundExpressions.add( expression );
}
}
/**
* Gets a set of subexpressions of a given type
- *
+ *
* @return a set of expressions of type <code>expressionTypeToFind</code>
contained within
- * <code>expressionToSearch</code>
+ * <code>expressionToSearch</code>
*/
- public LinkedHashSet<Expression> getExpressions() {
+ public LinkedHashSet<Expression> getExpressions()
+ {
expressionToSearch.accept( this );
return foundExpressions;
}
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/ExpressionVisitor.java
Tue Aug 31 15:49:23 2010 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/ExpressionVisitor.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,31 +1,40 @@
-/**
- * Copyright (c) 2010 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
*
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
*
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.expressions;
/**
* Part of visitor design pattern implementation. Defines the interface
* for objects that want to visit expressions.
- *
+ *
* @author Kris Marwood
* @version 1.0
*/
-public interface ExpressionVisitor {
+public interface ExpressionVisitor
+{
void visit( Expression expression );
}
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/IdentifierExpression.java
Tue Aug 31 15:49:23 2010 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/IdentifierExpression.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,20 +1,28 @@
-/**
- * Copyright (c) 2006 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
*
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
*
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.expressions;
@@ -23,9 +31,9 @@
import org.vedantatree.expressionoasis.ExpressionContext;
import
org.vedantatree.expressionoasis.exceptions.ExpressionEngineException;
import org.vedantatree.expressionoasis.extensions.VariableProvider;
-import org.vedantatree.types.Type;
-import org.vedantatree.types.ValueObject;
-import org.vedantatree.utils.StringUtils;
+import org.vedantatree.expressionoasis.types.Type;
+import org.vedantatree.expressionoasis.types.ValueObject;
+import org.vedantatree.expressionoasis.utils.StringUtils;
/**
@@ -35,36 +43,40 @@
* @author Mohit Gupta
* @author Parmod Kamboj
* @version 1.0
- *
- * Modified to support visitor design pattern.
+ *
+ * Modified to support visitor design pattern.
*
* @author Kris Marwood
* @version 1.1
*/
-public class IdentifierExpression implements Expression {
+public class IdentifierExpression implements Expression
+{
/**
* This is the name of identifier.
*/
- private String identifierName;
+ private String identifierName;
/**
* This is the variableProvider of identifier.
*/
- private VariableProvider variableProvider;
+ private VariableProvider variableProvider;
/**
* @see
org.vedantatree.expressionoasis.expressions.Expression#getReturnType()
*/
- public Type getReturnType() throws ExpressionEngineException {
+ public Type getReturnType() throws ExpressionEngineException
+ {
return variableProvider == null ? null :
variableProvider.getVariableType( getIdentifierName() );
}
/**
* @see org.vedantatree.expressionoasis.expressions.Expression#getValue()
*/
- public ValueObject getValue() throws ExpressionEngineException {
- if( variableProvider == null ) {
+ public ValueObject getValue() throws ExpressionEngineException
+ {
+ if( variableProvider == null )
+ {
throw new ExpressionEngineException( "Variable Provider does not exist:
[" + getIdentifierName() + "]" );
}
@@ -78,19 +90,23 @@
* java.lang.Object)
*/
public void initialize( ExpressionContext expressionContext, Object
parameters, boolean validate )
- throws ExpressionEngineException {
+ throws ExpressionEngineException
+ {
this.identifierName = (String) parameters;
- if( !StringUtils.isQualifiedString( this.identifierName ) ) {
+ if( !StringUtils.isQualifiedString( this.identifierName ) )
+ {
throw new ExpressionEngineException( "Identifier name is not valid" );
}
// Initializes the variable provider.
for( Iterator variableProviders =
expressionContext.getVariableProviders().iterator(); variableProviders
- .hasNext(); ) {
+ .hasNext(); )
+ {
VariableProvider variableProvider = (VariableProvider)
variableProviders.next();
- if( variableProvider.supportsVariable( getIdentifierName() ) ) {
+ if( variableProvider.supportsVariable( getIdentifierName() ) )
+ {
this.variableProvider = variableProvider;
break;
}
@@ -102,14 +118,16 @@
*
* @return Returns the identifierName.
*/
- public String getIdentifierName() {
+ public String getIdentifierName()
+ {
return identifierName;
}
/**
* @see
org.vedantatree.expressionoasis.expressions.Expression#uninitialize(org.vedantatree.expressionoasis.ExpressionContext)
*/
- public void uninitialize( ExpressionContext expressionContext ) {
+ public void uninitialize( ExpressionContext expressionContext )
+ {
this.identifierName = null;
}
@@ -117,15 +135,19 @@
* @see java.lang.Object#toString()
*/
@Override
- public String toString() {
+ public String toString()
+ {
return "IdentifierExpression:[" + getIdentifierName() + "]";
}
/**
- * Allows an expression visitor to visit this expression and it's
sub-expressions (implements Visitor design pattern).
- * @see
org.vedantatree.expressionoasis.expressions.Expression#accept(org.vedantatree.expressionoasis.ExpressionVisitor)
- */
- public void accept( ExpressionVisitor visitor ) {
+ * Allows an expression visitor to visit this expression and it's
sub-expressions (implements Visitor design
+ * pattern).
+ *
+ * @see
org.vedantatree.expressionoasis.expressions.Expression#accept(org.vedantatree.expressionoasis.ExpressionVisitor)
+ */
+ public void accept( ExpressionVisitor visitor )
+ {
visitor.visit( this );
}
}
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/NullExpression.java
Tue Aug 31 15:49:23 2010 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/NullExpression.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,82 +1,95 @@
-/**
- * Copyright (c) 2006 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
*
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
*
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.expressions;
import org.vedantatree.expressionoasis.ExpressionContext;
import
org.vedantatree.expressionoasis.exceptions.ExpressionEngineException;
-import org.vedantatree.types.Type;
-import org.vedantatree.types.ValueObject;
+import org.vedantatree.expressionoasis.types.Type;
+import org.vedantatree.expressionoasis.types.ValueObject;
/**
* This class expression is used to make the null value expression. It
gives the
* null value. Based on Numeric Expression.
- *
+ *
* TODO: should we create a special null type in Type class rather than
using
* Type.createType("java.lang.Object")? Currently don't have that option as
* the code for Type class is not yet available.
- *
+ *
* @author Kris Marwood
* @version 1.0
*/
-public class NullExpression implements Expression {
+public class NullExpression implements Expression
+{
/**
* This is the long value for this expression.
*/
- private ValueObject nullValue;
+ private ValueObject nullValue;
/**
* Gets the value object for numeric value.
- *
+ *
* @see org.vedantatree.expressionoasis.expressions.Expression#getValue()
*/
- public ValueObject getValue() throws ExpressionEngineException {
+ public ValueObject getValue() throws ExpressionEngineException
+ {
return nullValue;
}
/**
* Returns the long type.
- *
+ *
* @see
org.vedantatree.expressionoasis.expressions.Expression#getReturnType()
*/
- public Type getReturnType() throws ExpressionEngineException {
+ public Type getReturnType() throws ExpressionEngineException
+ {
return Type.OBJECT;
}
/**
* Initializes the numeric value object.
- *
+ *
* @see
org.vedantatree.expressionoasis.expressions.Expression#initialize(org.vedantatree.expressionoasis.ExpressionContext,
* java.lang.Object)
*/
public void initialize( ExpressionContext expressionContext, Object
parameters, boolean validate )
- throws ExpressionEngineException {
+ throws ExpressionEngineException
+ {
nullValue = new ValueObject( null, Type.OBJECT );
}
/**
* Uninitaizes the expression
- *
+ *
* @see
org.vedantatree.expressionoasis.expressions.Expression#uninitialize(org.vedantatree.expressionoasis.ExpressionContext)
*/
- public void uninitialize( ExpressionContext expressionContext ) {
+ public void uninitialize( ExpressionContext expressionContext )
+ {
/* nothing to do here */
}
@@ -84,15 +97,19 @@
* @see java.lang.Object#toString()
*/
@Override
- public String toString() {
+ public String toString()
+ {
return "null";
}
/**
- * Allows an expression visitor to visit this expression and it's
sub-expressions (implements Visitor design pattern).
- * @see
org.vedantatree.expressionoasis.expressions.Expression#accept(org.vedantatree.expressionoasis.ExpressionVisitor)
- */
- public void accept( ExpressionVisitor visitor ) {
+ * Allows an expression visitor to visit this expression and it's
sub-expressions (implements Visitor design
+ * pattern).
+ *
+ * @see
org.vedantatree.expressionoasis.expressions.Expression#accept(org.vedantatree.expressionoasis.ExpressionVisitor)
+ */
+ public void accept( ExpressionVisitor visitor )
+ {
visitor.visit( this );
}
}
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/NumericExpression.java
Tue Aug 31 15:49:23 2010 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/NumericExpression.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,27 +1,35 @@
-/**
- * Copyright (c) 2006 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
*
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
*
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.expressions;
import org.vedantatree.expressionoasis.ExpressionContext;
import
org.vedantatree.expressionoasis.exceptions.ExpressionEngineException;
-import org.vedantatree.types.Type;
-import org.vedantatree.types.ValueObject;
+import org.vedantatree.expressionoasis.types.Type;
+import org.vedantatree.expressionoasis.types.ValueObject;
/**
@@ -30,25 +38,27 @@
*
* @author Parmod Kamboj
* @version 1.0
- *
- * Modified to support visitor design pattern.
- *
+ *
+ * Modified to support visitor design pattern.
+ *
* @author Kris Marwood
* @version 1.1
*/
-public class NumericExpression implements Expression {
+public class NumericExpression implements Expression
+{
/**
* This is the long value for this expression.
*/
- private ValueObject longValue;
+ private ValueObject longValue;
/**
* Gets the value object for numeric value.
*
* @see org.vedantatree.expressionoasis.expressions.Expression#getValue()
*/
- public ValueObject getValue() throws ExpressionEngineException {
+ public ValueObject getValue() throws ExpressionEngineException
+ {
return longValue;
}
@@ -57,7 +67,8 @@
*
* @see
org.vedantatree.expressionoasis.expressions.Expression#getReturnType()
*/
- public Type getReturnType() throws ExpressionEngineException {
+ public Type getReturnType() throws ExpressionEngineException
+ {
return Type.LONG;
}
@@ -68,7 +79,8 @@
* java.lang.Object)
*/
public void initialize( ExpressionContext expressionContext, Object
parameters, boolean validate )
- throws ExpressionEngineException {
+ throws ExpressionEngineException
+ {
Long value = new Long( (String) parameters );
longValue = new ValueObject( value, Type.LONG );
}
@@ -78,7 +90,8 @@
*
* @see
org.vedantatree.expressionoasis.expressions.Expression#uninitialize(org.vedantatree.expressionoasis.ExpressionContext)
*/
- public void uninitialize( ExpressionContext expressionContext ) {
+ public void uninitialize( ExpressionContext expressionContext )
+ {
longValue = null;
}
@@ -86,15 +99,19 @@
* @see java.lang.Object#toString()
*/
@Override
- public String toString() {
+ public String toString()
+ {
return longValue == null ? "not-initialized-null-value" :
longValue.getValue().toString();
}
/**
- * Allows an expression visitor to visit this expression and it's
sub-expressions (implements Visitor design pattern).
- * @see
org.vedantatree.expressionoasis.expressions.Expression#accept(org.vedantatree.expressionoasis.ExpressionVisitor)
- */
- public void accept( ExpressionVisitor visitor ) {
+ * Allows an expression visitor to visit this expression and it's
sub-expressions (implements Visitor design
+ * pattern).
+ *
+ * @see
org.vedantatree.expressionoasis.expressions.Expression#accept(org.vedantatree.expressionoasis.ExpressionVisitor)
+ */
+ public void accept( ExpressionVisitor visitor )
+ {
visitor.visit( this );
}
}
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/StringExpression.java
Tue Aug 31 15:49:23 2010 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/StringExpression.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,27 +1,35 @@
-/**
- * Copyright (c) 2006 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
*
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
*
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.expressions;
import org.vedantatree.expressionoasis.ExpressionContext;
import
org.vedantatree.expressionoasis.exceptions.ExpressionEngineException;
-import org.vedantatree.types.Type;
-import org.vedantatree.types.ValueObject;
+import org.vedantatree.expressionoasis.types.Type;
+import org.vedantatree.expressionoasis.types.ValueObject;
/**
@@ -30,26 +38,28 @@
*
* @author Parmod Kamboj
* @version 1.0
- *
- * Modified to support visitor design pattern.
- *
+ *
+ * Modified to support visitor design pattern.
+ *
* @author Kris Marwood
* @version 1.1
- *
+ *
*/
-public class StringExpression implements Expression {
+public class StringExpression implements Expression
+{
/**
* This is the string value for this expression.
*/
- private ValueObject stringValue;
+ private ValueObject stringValue;
/**
* Gets the value object for string value.
*
* @see org.vedantatree.expressionoasis.expressions.Expression#getValue()
*/
- public ValueObject getValue() throws ExpressionEngineException {
+ public ValueObject getValue() throws ExpressionEngineException
+ {
return stringValue;
}
@@ -58,7 +68,8 @@
*
* @see
org.vedantatree.expressionoasis.expressions.Expression#getReturnType()
*/
- public Type getReturnType() throws ExpressionEngineException {
+ public Type getReturnType() throws ExpressionEngineException
+ {
return Type.STRING;
}
@@ -69,7 +80,8 @@
* java.lang.Object)
*/
public void initialize( ExpressionContext expressionContext, Object
parameters, boolean validate )
- throws ExpressionEngineException {
+ throws ExpressionEngineException
+ {
String value = (String) parameters;
value = value.substring( 1, value.length() - 1 );
value = value.replaceAll( "[\\\\][']", "'" );
@@ -81,7 +93,8 @@
*
* @see
org.vedantatree.expressionoasis.expressions.Expression#uninitialize(org.vedantatree.expressionoasis.ExpressionContext)
*/
- public void uninitialize( ExpressionContext expressionContext ) {
+ public void uninitialize( ExpressionContext expressionContext )
+ {
stringValue = null;
}
@@ -89,15 +102,19 @@
* @see java.lang.Object#toString()
*/
@Override
- public String toString() {
+ public String toString()
+ {
return stringValue == null ? "String value not set" : (String)
stringValue.getValue();
}
/**
- * Allows an expression visitor to visit this expression and it's
sub-expressions (implements Visitor design pattern).
- * @see
org.vedantatree.expressionoasis.expressions.Expression#accept(org.vedantatree.expressionoasis.ExpressionVisitor)
- */
- public void accept( ExpressionVisitor visitor ) {
+ * Allows an expression visitor to visit this expression and it's
sub-expressions (implements Visitor design
+ * pattern).
+ *
+ * @see
org.vedantatree.expressionoasis.expressions.Expression#accept(org.vedantatree.expressionoasis.ExpressionVisitor)
+ */
+ public void accept( ExpressionVisitor visitor )
+ {
visitor.visit( this );
}
}
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/UnaryOperatorExpression.java
Tue Aug 31 15:49:23 2010 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/UnaryOperatorExpression.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,20 +1,28 @@
-/**
- * Copyright (c) 2006 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
*
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
*
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.expressions;
@@ -24,8 +32,8 @@
import org.vedantatree.expressionoasis.EOErrorCodes;
import org.vedantatree.expressionoasis.ExpressionContext;
import
org.vedantatree.expressionoasis.exceptions.ExpressionEngineException;
-import org.vedantatree.types.Type;
-import org.vedantatree.utils.StringUtils;
+import org.vedantatree.expressionoasis.types.Type;
+import org.vedantatree.expressionoasis.utils.StringUtils;
/**
@@ -35,24 +43,25 @@
* @author Mohit Gupta
*
* @version 1.0
- *
- * Modified to support visitor design pattern.
- *
+ *
+ * Modified to support visitor design pattern.
+ *
* @author Kris Marwood
* @version 1.1
*/
-public abstract class UnaryOperatorExpression implements Expression {
+public abstract class UnaryOperatorExpression implements Expression
+{
/**
* This is the type pair mapping for all the unary operators.
*/
- private static Map typePairMapping = new HashMap();
+ private static Map typePairMapping = new HashMap();
/**
- * This is the operand expression for this unary operator expression.
There
+ * This is the operand expression for this unary operator expression.
There
* will be only one operand with unary operator expression
*/
- private Expression operandExpression;
+ private Expression operandExpression;
/**
* Initializes the operand expression.
@@ -61,7 +70,8 @@
* java.lang.Object)
*/
public void initialize( ExpressionContext expressionContext, Object
parameters, boolean validate )
- throws ExpressionEngineException {
+ throws ExpressionEngineException
+ {
this.operandExpression = (Expression) parameters;
/*
* Earlier operandExpression was asserted to be not-null, but it can be
null
@@ -69,7 +79,8 @@
*
* @see Bug ID: 1691820
*/
- if( validate ) {
+ if( validate )
+ {
validate( expressionContext );
}
}
@@ -79,14 +90,16 @@
*
* @return Returns the operandExpression.
*/
- public Expression getOperandExpression() {
+ public Expression getOperandExpression()
+ {
return operandExpression;
}
/**
* @see
org.vedantatree.expressionoasis.expressions.Expression#getReturnType()
*/
- public Type getReturnType() throws ExpressionEngineException {
+ public Type getReturnType() throws ExpressionEngineException
+ {
HashMap typeMapping = (HashMap) typePairMapping.get( getClass() );
return (Type) typeMapping.get( operandExpression.getReturnType() );
@@ -97,7 +110,8 @@
*
* @see
org.vedantatree.expressionoasis.expressions.Expression#uninitialize(org.vedantatree.expressionoasis.ExpressionContext)
*/
- public void uninitialize( ExpressionContext expressionContext ) {
+ public void uninitialize( ExpressionContext expressionContext )
+ {
this.operandExpression = null;
}
@@ -107,14 +121,17 @@
* @param expressionContext
* @throws ExpressionEngineException
*/
- protected void validate( ExpressionContext expressionContext ) throws
ExpressionEngineException {
+ protected void validate( ExpressionContext expressionContext ) throws
ExpressionEngineException
+ {
HashMap typeMapping = (HashMap) typePairMapping.get( getClass() );
- if( typeMapping == null ) {
+ if( typeMapping == null )
+ {
throw new ExpressionEngineException( "No type mapping specified for
class \"" + getClass().getName() + "\"" );
}
- if( typeMapping.get( operandExpression.getReturnType() ) == null ) {
+ if( typeMapping.get( operandExpression.getReturnType() ) == null )
+ {
String prefix = StringUtils.getLastToken( getClass().getName(), "." );
prefix = prefix.substring( 0, prefix.length() - "Expression".length() );
throw new ExpressionEngineException( "Operand of type: [\"" +
operandExpression.getReturnType()
@@ -130,15 +147,18 @@
* @param operandType type of operand
* @param resultType type of the result
*/
- protected static final void addTypePair( Class clazz, Type operandType,
Type resultType ) {
- if( clazz == null || !UnaryOperatorExpression.class.isAssignableFrom(
clazz ) ) {
+ protected static final void addTypePair( Class clazz, Type operandType,
Type resultType )
+ {
+ if( clazz == null || !UnaryOperatorExpression.class.isAssignableFrom(
clazz ) )
+ {
throw new IllegalArgumentException( "\"" + clazz.getName()
+ "\" is not a valid unary operator expression class." );
}
HashMap typeMapping = (HashMap) typePairMapping.get( clazz );
- if( typeMapping == null ) {
+ if( typeMapping == null )
+ {
typeMapping = new HashMap();
typePairMapping.put( clazz, typeMapping );
}
@@ -150,7 +170,8 @@
* @see java.lang.Object#toString()
*/
@Override
- public String toString() {
+ public String toString()
+ {
String prefix = StringUtils.getLastToken( getClass().getName(), "." );
prefix = prefix.substring( 0, prefix.length() );
@@ -158,10 +179,13 @@
}
/**
- * Allows an expression visitor to visit this expression and it's
sub-expressions (implements Visitor design pattern).
+ * Allows an expression visitor to visit this expression and it's
sub-expressions (implements Visitor design
+ * pattern).
+ *
* @see
org.vedantatree.expressionoasis.expressions.Expression#accept(org.vedantatree.expressionoasis.ExpressionVisitor)
*/
- public void accept( ExpressionVisitor visitor ) {
+ public void accept( ExpressionVisitor visitor )
+ {
visitor.visit( this );
operandExpression.accept( visitor );
}
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/arithmatic/AddExpression.java
Sat Jul 13 07:07:24 2013 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/arithmatic/AddExpression.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,27 +1,35 @@
-/**
- * Copyright (c) 2005 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
-
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ *
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-
+ *
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
-
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
+ *
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.expressions.arithmatic;
import
org.vedantatree.expressionoasis.exceptions.ExpressionEngineException;
import
org.vedantatree.expressionoasis.expressions.BinaryOperatorExpression;
-import org.vedantatree.types.Type;
-import org.vedantatree.types.ValueObject;
+import org.vedantatree.expressionoasis.types.Type;
+import org.vedantatree.expressionoasis.types.ValueObject;
/**
@@ -30,15 +38,17 @@
* @author Parmod Kamboj
* @author Mohit Gupta
* @version 1.0
- *
- * Added support for nulls
- *
+ *
+ * Added support for nulls
+ *
* @author Kris Marwood
* @version 1.1
*/
-public class AddExpression extends BinaryOperatorExpression {
+public class AddExpression extends BinaryOperatorExpression
+{
- static {
+ static
+ {
addTypePair( AddExpression.class, Type.LONG, Type.LONG, Type.LONG );
addTypePair( AddExpression.class, Type.DOUBLE, Type.DOUBLE, Type.DOUBLE
);
addTypePair( AddExpression.class, Type.STRING, Type.STRING, Type.STRING
);
@@ -53,7 +63,7 @@
addTypePair( AddExpression.class, Type.INTEGER, Type.LONG, Type.LONG );
addTypePair( AddExpression.class, Type.BOOLEAN, Type.STRING, Type.STRING
);
addTypePair( AddExpression.class, Type.STRING, Type.BOOLEAN, Type.STRING
);
-
+
// nullable type support
addTypePair( AddExpression.class, Type.OBJECT, Type.OBJECT, Type.OBJECT
);
addTypePair( AddExpression.class, Type.LONG, Type.OBJECT, Type.LONG );
@@ -70,20 +80,25 @@
*
* @see org.vedantatree.expressionoasis.expressions.Expression#getValue()
*/
- public ValueObject getValue() throws ExpressionEngineException {
+ public ValueObject getValue() throws ExpressionEngineException
+ {
Object leftValue = leftOperandExpression.getValue().getValue();
Object rightValue = rightOperandExpression.getValue().getValue();
Object result = null;
Type returnType = getReturnType();
- if( leftValue != null && rightValue != null ) {
- if( returnType == Type.LONG ) {
+ if( leftValue != null && rightValue != null )
+ {
+ if( returnType == Type.LONG )
+ {
result = new Long( ( (Number) leftValue ).longValue() + ( (Number)
rightValue ).longValue() );
}
- else if( returnType == Type.DOUBLE ) {
+ else if( returnType == Type.DOUBLE )
+ {
result = new Double( ( (Number) leftValue ).doubleValue() + ( (Number)
rightValue ).doubleValue() );
}
- else {
+ else
+ {
result = leftValue.toString() + rightValue.toString();
}
}
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/arithmatic/ArrayIndexExpression.java
Tue Aug 31 15:49:23 2010 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/arithmatic/ArrayIndexExpression.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,20 +1,28 @@
-/**
- * Copyright (c) 2005 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
-
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ *
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-
+ *
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
-
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
+ *
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.expressions.arithmatic;
@@ -23,9 +31,9 @@
import org.vedantatree.expressionoasis.ExpressionContext;
import
org.vedantatree.expressionoasis.exceptions.ExpressionEngineException;
import
org.vedantatree.expressionoasis.expressions.BinaryOperatorExpression;
-import org.vedantatree.types.Type;
-import org.vedantatree.types.ValueObject;
-import org.vedantatree.utils.StringUtils;
+import org.vedantatree.expressionoasis.types.Type;
+import org.vedantatree.expressionoasis.types.ValueObject;
+import org.vedantatree.expressionoasis.utils.StringUtils;
/**
@@ -35,14 +43,16 @@
* @author Mohit Gupta
* @version 1.0
*/
-public class ArrayIndexExpression extends BinaryOperatorExpression {
+public class ArrayIndexExpression extends BinaryOperatorExpression
+{
/**
* Gets the value from the array.
*
* @see org.vedantatree.expressionoasis.expressions.Expression#getValue()
*/
- public ValueObject getValue() throws ExpressionEngineException {
+ public ValueObject getValue() throws ExpressionEngineException
+ {
Object value = leftOperandExpression.getValue().getValue();
long index = ( (Number) rightOperandExpression.getValue().getValue()
).longValue();
@@ -53,7 +63,8 @@
* @see
org.vedantatree.expressionoasis.expressions.Expression#getReturnType()
*/
@Override
- public Type getReturnType() throws ExpressionEngineException {
+ public Type getReturnType() throws ExpressionEngineException
+ {
return leftOperandExpression.getReturnType().getComponentType();
}
@@ -61,8 +72,10 @@
* @see
org.vedantatree.expressionoasis.expressions.BinaryOperatorExpression#validate()
*/
@Override
- protected void validate( ExpressionContext expressionContext ) throws
ExpressionEngineException {
- if( !leftOperandExpression.getReturnType().isArray() ||
rightOperandExpression.getReturnType() != Type.LONG ) {
+ protected void validate( ExpressionContext expressionContext ) throws
ExpressionEngineException
+ {
+ if( !leftOperandExpression.getReturnType().isArray() ||
rightOperandExpression.getReturnType() != Type.LONG )
+ {
String prefix = StringUtils.getLastToken( getClass().getName(), "." );
prefix = prefix.substring( 0, prefix.length() - "Expression".length() );
throw new ExpressionEngineException( "Operands of types: [\"" +
leftOperandExpression.getReturnType()
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/arithmatic/DivideExpression.java
Tue Aug 31 15:49:23 2010 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/arithmatic/DivideExpression.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,27 +1,35 @@
-/**
- * Copyright (c) 2005 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
-
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ *
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-
+ *
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
-
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
+ *
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.expressions.arithmatic;
import
org.vedantatree.expressionoasis.exceptions.ExpressionEngineException;
import
org.vedantatree.expressionoasis.expressions.BinaryOperatorExpression;
-import org.vedantatree.types.Type;
-import org.vedantatree.types.ValueObject;
+import org.vedantatree.expressionoasis.types.Type;
+import org.vedantatree.expressionoasis.types.ValueObject;
/**
@@ -31,15 +39,17 @@
* @author Parmod Kamboj
* @version 1.0
*
- * Added support for nulls
- *
+ * Added support for nulls
+ *
* @author Kris Marwood
* @version 1.1
*/
-public class DivideExpression extends BinaryOperatorExpression {
+public class DivideExpression extends BinaryOperatorExpression
+{
- static {
- // changed the return type to double even in case of long & long
operands,
+ static
+ {
+ // changed the return type to double even in case of long & long
operands,
// because division result should always support decimal
addTypePair( DivideExpression.class, Type.LONG, Type.LONG, Type.DOUBLE );
addTypePair( DivideExpression.class, Type.DOUBLE, Type.DOUBLE,
Type.DOUBLE );
@@ -57,7 +67,8 @@
/**
* @see
org.vedantatree.expressionoasis.expressions.Expression#getReturnType()
*/
- public Type getReturnType() throws ExpressionEngineException {
+ public Type getReturnType() throws ExpressionEngineException
+ {
// always returning double because division result should always support
decimals
return Type.DOUBLE;
}
@@ -67,19 +78,22 @@
*
* @see org.vedantatree.expressionoasis.expressions.Expression#getValue()
*/
- public ValueObject getValue() throws ExpressionEngineException {
+ public ValueObject getValue() throws ExpressionEngineException
+ {
Object leftValue = leftOperandExpression.getValue().getValue();
Object rightValue = rightOperandExpression.getValue().getValue();
Object result = null;
Type returnType = getReturnType();
- //commented after changing the return type to double permanently
- // if( returnType == Type.LONG ) {
- // result = new Long( ( (Number) leftValue ).longValue() / ( (Number)
rightValue ).longValue() );
- // }
- // else
- if( leftValue != null && rightValue != null ) {
- if( returnType == Type.DOUBLE ) {
+ // commented after changing the return type to double permanently
+ // if( returnType == Type.LONG ) {
+ // result = new Long( ( (Number) leftValue ).longValue() / ( (Number)
rightValue ).longValue() );
+ // }
+ // else
+ if( leftValue != null && rightValue != null )
+ {
+ if( returnType == Type.DOUBLE )
+ {
result = new Double( ( (Number) leftValue ).doubleValue() / ( (Number)
rightValue ).doubleValue() );
}
}
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/arithmatic/MinusExpression.java
Tue Aug 31 15:49:23 2010 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/arithmatic/MinusExpression.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,27 +1,35 @@
-/**
- * Copyright (c) 2005 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
-
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ *
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-
+ *
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
-
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
+ *
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.expressions.arithmatic;
import
org.vedantatree.expressionoasis.exceptions.ExpressionEngineException;
import org.vedantatree.expressionoasis.expressions.UnaryOperatorExpression;
-import org.vedantatree.types.Type;
-import org.vedantatree.types.ValueObject;
+import org.vedantatree.expressionoasis.types.Type;
+import org.vedantatree.expressionoasis.types.ValueObject;
/**
@@ -29,15 +37,17 @@
*
* @author Parmod Kamboj
* @version 1.0
- *
- * Added support for nulls
- *
+ *
+ * Added support for nulls
+ *
* @author Kris Marwood
* @version 1.1
*/
-public class MinusExpression extends UnaryOperatorExpression {
+public class MinusExpression extends UnaryOperatorExpression
+{
- static {
+ static
+ {
addTypePair( MinusExpression.class, Type.LONG, Type.LONG );
addTypePair( MinusExpression.class, Type.DOUBLE, Type.DOUBLE );
@@ -50,15 +60,19 @@
*
* @see org.vedantatree.expressionoasis.expressions.Expression#getValue()
*/
- public ValueObject getValue() throws ExpressionEngineException {
+ public ValueObject getValue() throws ExpressionEngineException
+ {
Number value = (Number) getOperandExpression().getValue().getValue();
Type resultType = getReturnType();
- if( value != null ) {
- if( resultType == Type.LONG ) {
+ if( value != null )
+ {
+ if( resultType == Type.LONG )
+ {
value = new Long( value.longValue() * -1 );
}
- else {
+ else
+ {
value = new Double( value.doubleValue() * -1 );
}
}
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/arithmatic/MultiplyExpression.java
Tue Aug 31 15:49:23 2010 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/arithmatic/MultiplyExpression.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,27 +1,35 @@
-/**
- * Copyright (c) 2005 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
-
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ *
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-
+ *
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
-
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
+ *
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.expressions.arithmatic;
import
org.vedantatree.expressionoasis.exceptions.ExpressionEngineException;
import
org.vedantatree.expressionoasis.expressions.BinaryOperatorExpression;
-import org.vedantatree.types.Type;
-import org.vedantatree.types.ValueObject;
+import org.vedantatree.expressionoasis.types.Type;
+import org.vedantatree.expressionoasis.types.ValueObject;
/**
@@ -29,15 +37,17 @@
*
* @author Parmod Kamboj
* @version 1.0
- *
- * Added support for nulls
- *
+ *
+ * Added support for nulls
+ *
* @author Kris Marwood
* @version 1.1
*/
-public class MultiplyExpression extends BinaryOperatorExpression {
+public class MultiplyExpression extends BinaryOperatorExpression
+{
- static {
+ static
+ {
addTypePair( MultiplyExpression.class, Type.LONG, Type.LONG, Type.LONG );
addTypePair( MultiplyExpression.class, Type.DOUBLE, Type.DOUBLE,
Type.DOUBLE );
addTypePair( MultiplyExpression.class, Type.LONG, Type.DOUBLE,
Type.DOUBLE );
@@ -56,17 +66,21 @@
*
* @see org.vedantatree.expressionoasis.expressions.Expression#getValue()
*/
- public ValueObject getValue() throws ExpressionEngineException {
+ public ValueObject getValue() throws ExpressionEngineException
+ {
Object leftValue = leftOperandExpression.getValue().getValue();
Object rightValue = rightOperandExpression.getValue().getValue();
Object result = null;
Type returnType = getReturnType();
- if( leftValue != null && rightValue != null ) {
- if( returnType == Type.LONG ) {
+ if( leftValue != null && rightValue != null )
+ {
+ if( returnType == Type.LONG )
+ {
result = new Long( ( (Number) leftValue ).longValue() * ( (Number)
rightValue ).longValue() );
}
- else if( returnType == Type.DOUBLE ) {
+ else if( returnType == Type.DOUBLE )
+ {
result = new Double( ( (Number) leftValue ).doubleValue() * ( (Number)
rightValue ).doubleValue() );
}
}
=======================================
---
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/arithmatic/ParanthesisExpression.java
Tue Aug 31 15:49:23 2010 UTC
+++
/trunk/src/main/java/org/vedantatree/expressionoasis/expressions/arithmatic/ParanthesisExpression.java
Sat Jun 14 20:36:31 2014 UTC
@@ -1,28 +1,36 @@
-/**
- * Copyright (c) 2005 VedantaTree all rights reserved.
+/**
+ * Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
-
- * ExpressionOasis is free software: you can redistribute it and/or modify
+ *
+ * ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-
+ *
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
-
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ * OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public
License
+ * for more details.
+ *
* You should have received a copy of the GNU Lesser General Public
License
- * along with ExpressionOasis. If not, see
<
http://www.gnu.org/licenses/>.
+ * along with ExpressionOasis. If not, see <
http://www.gnu.org/licenses/>.
+ *
+ * Please consider to contribute any enhancements to upstream codebase.
+ * It will help the community in getting improved code and features, and
+ * may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.expressions.arithmatic;
import org.vedantatree.expressionoasis.ExpressionContext;
import
org.vedantatree.expressionoasis.exceptions.ExpressionEngineException;
import org.vedantatree.expressionoasis.expressions.UnaryOperatorExpression;
-import org.vedantatree.types.Type;
-import org.vedantatree.types.ValueObject;
+import org.vedantatree.expressionoasis.types.Type;
+import org.vedantatree.expressionoasis.types.ValueObject;
/**
@@ -32,14 +40,16 @@
* @author Parmod Kamboj
* @version 1.0
*/
-public class ParanthesisExpression extends UnaryOperatorExpression {
+public class ParanthesisExpression extends UnaryOperatorExpression
+{
/**
* Returns value of child expression.
*
* @see org.vedantatree.expressionoasis.expressions.Expression#getValue()
*/
- public ValueObject getValue() throws ExpressionEngineException {
+ public ValueObject getValue() throws ExpressionEngineException
+ {
return getOperandExpression().getValue();
}
@@ -49,7 +59,8 @@
* @see
org.vedantatree.expressionoasis.expressions.Expression#getReturnType()
*/
@Override
- public Type getReturnType() throws ExpressionEngineException {
+ public Type getReturnType() throws ExpressionEngineException
+ {
return getOperandExpression().getReturnType();
}
@@ -57,7 +68,8 @@
* Do nothing.
*/
@Override
- protected void validate( ExpressionContext expressionContext ) {
+ protected void validate( ExpressionContext expressionContext )
+ {
/**
* Nothing to validate
*/
=======================================
***Additional files exist in this changeset.***