incubator-imperius-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jnee...@apache.org
Subject svn commit: r606479 [11/30] - in /incubator/imperius/trunk/trunk: ./ modules/ modules/imperius-javaspl/ modules/imperius-javaspl/resources/ modules/imperius-javaspl/resources/samples/ modules/imperius-javaspl/resources/samples/computersystem/ modules/i...
Date Sat, 22 Dec 2007 19:34:03 GMT
Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expression/primary/CollectOperation.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expression/primary/CollectOperation.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expression/primary/CollectOperation.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expression/primary/CollectOperation.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,882 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+
+
+
+package org.apache.imperius.spl.parser.expression.primary;
+
+import java.security.InvalidParameterException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.DataCollector;
+import org.apache.imperius.spl.external.Expression;
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.compiler.symboltable.SPLSymbolTable;
+import org.apache.imperius.spl.parser.compiler.symboltable.Symbol;
+import org.apache.imperius.spl.parser.exceptions.IllegalExpressionTypeException;
+import org.apache.imperius.spl.parser.exceptions.MissingParameterException;
+import org.apache.imperius.spl.parser.exceptions.NonExistentSymbolException;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.*;
+import org.apache.imperius.spl.parser.util.*;
+import org.apache.imperius.util.SPLLogger;
+//import org.pegasus.jmpi.CIMObjectPath;
+
+//import com.ibm.ac.cimspl.CIMSPLTypeConstants;
+
+public class CollectOperation implements ReferenceExpression {
+
+	private static final int COLLECT_FLAVOUR1 = 0;
+	private static final int COLLECT_FLAVOUR2 = 1;
+	private static final int INVALID_TYPE = 2;
+	private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+	private static final String sourceClass="CollectOperation";
+
+
+	private int collectType;
+	private ArrayList paramList;
+	private SPLSymbolTable symTab;
+	private String returnClassName;
+	private PostCollectExpression postCollectOperation;
+	private TypeInfo _dataType=new TypeInfo();
+//	private boolean isArray;
+	private boolean noPostCollectOperation;
+	private Expression referenceExpression;
+	private String associationName;
+	private String sourceRole;
+	private String targetRole;
+	private String targetClassName;
+	private String targetClassPropertyName;
+	private Expression expressionForTarget;
+
+
+
+//	#(c:COLLECT_OP #(COLLECT_CALL paramList = exprList[collectSymbolTable]) (postExpr = methodPropArrForCollect[symTab,collectSymbolTable])?  )	
+	public CollectOperation(ArrayList pList, Expression postCollect, SPLSymbolTable sTab) throws SPLException
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "CollectOperation");
+		//System.out.println("creating collect expression");
+
+
+
+
+
+		this.paramList = pList;
+		// if no of params is 6 then flavour1 collect(refExp, associationname, srcRole, targetRole, targetClass, targetExp)
+		if(pList.size()  == 6) 
+		{	
+			collectType = COLLECT_FLAVOUR1;
+			//System.out.println("COLLECT_FLAVOUR1");
+
+		}	
+		else if(pList.size()  == 7) 
+		{
+//			if no of params is 7 then flavour2 collect(refExp, associationname, srcRole, targetRole, targetClass, <target class param>, targetExp)
+			collectType = COLLECT_FLAVOUR2;
+			//System.out.println("COLLECT_FLAVOUR2");
+
+		}	
+		else
+		{
+			logger.severe(Thread.currentThread().getName()+" "+"No of parameters for collect has to be 6 or 7");
+			throw new InvalidParameterException("No of parameters for collect has to be 6 or 7");
+		}
+
+		if(postCollect != null) //  expression following collect e.g. collect(....)[1].param
+		{	
+			postCollectOperation = (PostCollectExpression)postCollect;
+			noPostCollectOperation = false;
+			//System.out.println(" PostCollectOperation exists");
+
+		}
+		else // no expression following collect e.g. collect(...) implies return is an array of targetclass instances (flavour 1) or param values (flavour 2) 
+		{
+			_dataType.setIsArray(true);
+			noPostCollectOperation = true;
+			//System.out.println("no PostCollectOperation");
+
+		}
+
+		this.symTab = sTab;
+
+
+		// validate the expression
+		if (!validate())
+		{
+			logger.severe(Thread.currentThread().getName()+" "+"validation error:");
+			throw new SPLException("validation error:");
+		}
+
+
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "CollectOperation");
+
+
+	}
+
+	public boolean validate() throws SPLException 
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+		boolean result = false;
+		if(collectType != INVALID_TYPE)
+		{
+			if(collectType == COLLECT_FLAVOUR1)
+			{
+				//System.out.println(" validateCollectFlavour1");
+
+				result = validateCollectFlavour1();
+			}
+			else
+			{
+				//System.out.println(" validateCollectFlavour2");
+
+				result = validateCollectFlavour2();
+			}
+		}
+		else
+		{
+			logger.severe(Thread.currentThread().getName()+" "+"Missing parameters");
+			throw new MissingParameterException("Missing parameters");
+		}
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+		return result;
+
+
+	}
+	// The first 4 parameters are common to both Collect flavours
+	private boolean validateCommonParameters() throws SPLException
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validateCommonParameters");
+		//System.out.println("validateCommonParameters ");
+
+		String sourceClassValidate = null;
+		if(symTab.getParentSymbolTable() != null) // the symbol table which is the parent of the collect symbol table
+			sourceClassValidate = (String)symTab.getParentSymbolTable().getAnchorData().getAnchorClassList().get(0);
+
+		//System.out.println("sourceClassValidate "+sourceClassValidate);
+		Expression refExp = (Expression)paramList.get(0);
+		if(refExp.getType().getType() != TypeConstants.referenceType) // param 0 is the source class
+		{
+			logger.severe(Thread.currentThread().getName()+" "+"First param to collect needs to be a reference expression");
+			throw new IllegalExpressionTypeException("First param to collect needs to be a reference expression");
+		}
+		if(refExp instanceof ReferenceExpression)
+		{
+			sourceClassValidate = ((ReferenceExpression)refExp).getReferenceTypeName();
+			referenceExpression = refExp;
+			ReferenceExpression ref=(ReferenceExpression)refExp;
+			//System.out.println(" class of refExp is "+ref.getReferenceTypeName());
+
+			//refExp.
+		}
+		else{
+			referenceExpression = refExp;
+		}
+
+		Expression assocExp = (Expression)paramList.get(1); // param 1 is the assoc Name
+		if(assocExp.getType().getType() != TypeConstants.stringType)
+		{
+			logger.severe(Thread.currentThread().getName()+" "+"2nd param to collect needs to be a string expression");
+
+			throw new IllegalExpressionTypeException("2nd param to collect needs to be a string expression");
+		}
+		associationName = (String)assocExp.evaluate();
+
+		Expression roleExp = (Expression)paramList.get(2); // param 2 is role 1
+		if(roleExp.getType().getType() != TypeConstants.stringType)
+		{
+			logger.severe(Thread.currentThread().getName()+" "+"3rd param to collect needs to be a string expression");
+
+			throw new IllegalExpressionTypeException("3rd param to collect needs to be a string expression");
+		}
+
+		sourceRole = (String)roleExp.evaluate();
+
+		roleExp = (Expression)paramList.get(3); // param 3 is role 2
+		if(roleExp.getType().getType() != TypeConstants.stringType)
+		{
+
+			logger.severe(Thread.currentThread().getName()+" "+"4th param to collect needs to be a string expression");
+
+			throw new IllegalExpressionTypeException("4th param to collect needs to be a string expression");
+		}
+		targetRole = (String)roleExp.evaluate();
+
+		Expression targetClassExp = (Expression)paramList.get(4); // param 4 is the target class name
+		if(targetClassExp.getType().getType() != TypeConstants.stringType)
+		{
+
+			logger.severe(Thread.currentThread().getName()+" "+"5th param to collect needs to be a string expression");
+
+			throw new IllegalExpressionTypeException("5th param to collect needs to be a string expression");
+		}
+		targetClassName = (String)targetClassExp.evaluate();
+
+		List instanceInfoList=new ArrayList();
+		String qual=symTab.getDefaultQualifier();
+
+		symTab.addAnchor(this.targetClassName, qual, instanceInfoList);
+
+		if(refExp instanceof ReferenceExpression)
+		{
+			validateAssociation(sourceClassValidate,associationName,sourceRole,targetRole,targetClassName);
+
+		}
+		// validate that such an association actually exists
+
+		// set the anchor for the collect symbol table to the targetclass name. This will populate static symbol info. for the targetclass
+		//symTab.addCollectAnchor(targetClassName, qual, new ArrayList(), true);
+		// NRJ
+
+//		if(symTab.getAnchorClassList().size() !=1)
+//		{
+//		//System.out.println("symTab.getAnchorClassList().size() "+symTab.getAnchorClassList().size());
+//		throw new SPLException(" symTab.getAnchorClassList().size() !=1 ");
+//		}
+//		else
+//		{
+//		symTab.addAnchor(this.targetClassName, qual, instanceInfoList);
+
+//		}
+		// no exceptions were thrown validation success
+
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validateCommonParameters");
+		//System.out.println("validateCommonParameters done "+true);
+
+		return true;
+	}
+
+	//collect(refExp, associationname, srcRole, targetRole, targetClass, <target class property>, targetExp)
+	private boolean validateCollectFlavour2() throws SPLException 
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validateCollectFlavour2");
+		//System.out.println("validateCollectFlavour2()");
+
+		// validate the common params
+		validateCommonParameters();
+
+		Expression propNameExp = (Expression)paramList.get(5); // the 5th parameter is a property of the targetclass
+		if(propNameExp.getType().getType() != TypeConstants.stringType)
+		{
+
+			logger.severe(Thread.currentThread().getName()+" "+"5th param to collect needs to be a string expression");  
+
+			throw new IllegalExpressionTypeException("5th param to collect needs to be a string expression");	
+		}
+		targetClassPropertyName = (String)propNameExp.evaluate();
+
+		boolean recurse = false;
+		if(!symTab.symbolExists(targetClassName + "." + targetClassPropertyName,recurse )) // make sure this is a valid property
+		{
+
+			logger.severe(targetClassName + "." + targetClassPropertyName + " does not exist");
+
+			throw new NonExistentSymbolException(targetClassName + "." + targetClassPropertyName + " does not exist");
+		}
+		else
+		{
+			Symbol propSymbol = symTab.getSymbol(targetClassName + "." + targetClassPropertyName);
+			this._dataType=new TypeInfo(propSymbol.getType());
+			this._dataType.setIsArray(true);
+			expressionForTarget = (Expression)paramList.get(6); // 6th param is an expression involving properties of the targetclass
+			if(expressionForTarget.validate())
+			{
+				if(expressionForTarget.getType().getType() != TypeConstants.booleanType) // this expression is used to filter instances hence needs to be boolean
+				{	
+
+					logger.severe(Thread.currentThread().getName()+" "+"6th param to collect needs to be a boolean expression");
+
+					throw new IllegalExpressionTypeException("6th param to collect needs to be a boolean expression");
+				}
+				if(!noPostCollectOperation) // if an expression exists that follows collect
+				{	
+
+					// REMOVED BY NRJ
+					//System.out.println("Post collect expression exists");		
+					postCollectOperation.validate(this.targetClassName); // validate the expression
+					if(postCollectOperation.Array2Exists() || postCollectOperation.isMethodOrParamExists())	{
+						this._dataType=new TypeInfo(postCollectOperation.getType());
+					}
+					else{
+						this._dataType.setIsArray(false);
+					}
+				}	
+
+
+			}
+		}
+		//System.out.println(" all went well, validation success validateCollectFlavour2");
+
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validateCollectFlavour2");
+		//System.out.println("validateCollectFlavour2 done "+true);
+		//System.out.println(" Type info "+this._dataType.getType()+" "+this._dataType.getIsArray());
+
+		return true;
+
+	}
+	private boolean validateCollectFlavour1() throws SPLException 
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validateCollectFlavour1");
+
+		//System.out.println("validateCollectFlavour1");
+
+		//collect(<refExp>,<assocName>,<role1>,<role2>,<targetClass>,<expression>)[exp].param1[exp]
+		//			       .param1(pList)
+		// validate the common parameters
+		validateCommonParameters();
+
+		// 5th param is an expression used to filter the instances 
+		expressionForTarget = (Expression)paramList.get(5);
+		if(expressionForTarget.validate()) // validate the expression
+		{
+			this._dataType.setReferenceTypeName(this.targetClassName);
+			this._dataType.setType(TypeConstants.referenceType);
+			this._dataType.setIsArray(true);
+			if(expressionForTarget.getType().getType() != TypeConstants.booleanType) // needs to be boolean type
+			{	
+
+				logger.severe(Thread.currentThread().getName()+" "+"6th param to collect needs to be a boolean expression");
+
+				throw new IllegalExpressionTypeException("6th param to collect needs to be a boolean expression");
+			}
+			if(!noPostCollectOperation) // post collect exists e.g. collect(...)[exp].prop
+			{																//		 .prop[exp]		
+
+				// REMOVED BY NRJ
+				//symTab.addCollectAnchor(this.targetClassName, qual, instanceInfoList, true);
+
+				postCollectOperation.validate(this.targetClassName);
+				TypeInfo tpe=null;
+				// validate the expression
+				if(postCollectOperation.isMethodOrParamExists())
+				{
+					tpe = postCollectOperation.getType(); // get the type
+					returnClassName = targetClassName; // return type is same as the targetclass
+
+					this._dataType.setIsArray(tpe.getIsArray());
+					this._dataType.setType(tpe.getType());
+
+				}
+			}
+
+
+
+//			if(tpe != PostCollectExpression.POSTCOLLECT_IS_ARRAY) // implies of the form collect(...)[exp].prop...
+//			{	
+//			dataType = tpe; // return type is same as the type of post collect (either the type of prop or return type of array of type prop
+//			// NEED TO SET isArray IF the Property is an array type with no array subscript expression
+//			isArray = postCollectOperation.isArray();
+//			}	
+//			else
+//			{
+//			dataType = TypeConstants.referenceType; // post collect is simply collect(...)[exp]
+//			returnClassName = targetClassName; // return type is same as the targetclass
+//			isArray = false; // no array
+//			}
+
+
+		}
+
+
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validateCollectFlavour1");
+		//System.out.println("validateCollectFlavour1 done "+true);
+
+		return true;
+	}
+
+	// validate the association
+	private void validateAssociation(String sourceCIMClass, String assocName, String roleName1, String roleName2, String resultclassName) throws SPLException 
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validateAssociation");
+
+		//System.out.println("validateCollectFlavour1");
+
+		boolean result = false;
+		DataCollector dc = DataCollectorFactory.getDataCollector();
+		result = dc.associationExists(sourceCIMClass, symTab.getDefaultQualifier(), resultclassName, assocName, roleName1, roleName2);
+		if(!result)
+		{
+
+			logger.severe(Thread.currentThread().getName()+" "+"Invalid association " + " sourceClass :"+sourceCIMClass+" namespace :"+symTab.getDefaultQualifier()+ " resultclassName :" + resultclassName + " assocName :"+ assocName+ " roleName1 :" + roleName1 + " roleName2 :"+ roleName2);
+
+			throw new SPLException("Invalid association " + " sourceClass :"+sourceCIMClass+" namespace :"+symTab.getDefaultQualifier()+ " resultclassName :" + resultclassName + " assocName :"+ assocName+ " roleName1 :" + roleName1 + " roleName2 :"+ roleName2);
+		}
+
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validateAssociation");
+
+
+	}
+	public Object evaluate() throws SPLException 
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+		Object result = null;
+		if(collectType == COLLECT_FLAVOUR1)
+		{
+			//System.out.println("evaluate COLLECT_FLAVOUR1");
+			result = evaluateFlavour1();
+		}
+		else
+		{
+			//System.out.println("evaluate COLLECT_FLAVOUR2");
+
+			result = evaluateFlavour2();
+		}
+
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+		return result;
+	}
+
+	// evaluating flavour 2 
+	private Object evaluateFlavour2() throws SPLException
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluateFlavour2");
+
+		//System.out.println("evaluate evaluateFlavour2");
+
+		Object result = null;
+		// evaluate the reference expression to obtain the source instance
+		Object refExpressionResult = referenceExpression.evaluate();
+		String referenceStr=refExpressionResult.toString();
+		DataCollector dc = DataCollectorFactory.getDataCollector();
+
+//		String refTypeName=dc.getReferenceTypeName(referenceStr);
+		List targetClassInstanceReferences = null;
+
+
+		// get instances of the targetclass that satisfy the association conditions
+		if(logger.isLoggable(Level.FINE))
+			logger.fine(Thread.currentThread().getName()+" refExpressionResult evaluateFlavour2 "+referenceStr);
+		//System.out.println("targetClassInstanceReferences to dc :"+refExpressionResult+" "+symTab.getDefaultQualifier()+" "+targetClassName+" "+associationName+" "+sourceRole+" "+targetRole);
+		
+		targetClassInstanceReferences = dc.getAssociatedInstanceReferences(refExpressionResult,symTab.getDefaultQualifier(),targetClassName,associationName,sourceRole,targetRole);
+		//System.out.println("targetClassInstanceReferences "+targetClassInstanceReferences.toString());
+		if (logger.isLoggable(Level.FINE))
+			logger.fine(Thread.currentThread().getName()+" got associated references");
+
+//		targetClassInstance = dc.getAssociatedInstanceReferences(refTypeName, symTab.getDefaultQualifier(), targetClassName,associationName,sourceRole,targetRole, refExpressionResult);
+		if (logger.isLoggable(Level.FINE))
+			logger.fine(Thread.currentThread().getName()+" got associated instances");
+
+		// filter the List based on the target filter expression
+		//System.out.println("filteredTargetClassInstanceReferences to dc :"+targetClassInstanceReferences+" "+symTab.getDefaultQualifier()+" "+this.targetClassName);
+		
+		List filteredTargetClassInstanceReferences = filterTargetClassInstanceReferencesWithTargetExpression(targetClassInstanceReferences , this.targetClassName,this.symTab.getDefaultQualifier());
+		//System.out.println("targetClassInstanceReferences "+filteredTargetClassInstanceReferences.toString());
+		
+		if (logger.isLoggable(Level.FINE))
+			logger.fine(Thread.currentThread().getName()+" got filtered references");
+
+		ArrayList filteredTargetClassInstances = new ArrayList();
+
+		Iterator filteredTargetClassInstanceReferencesIt=filteredTargetClassInstanceReferences.iterator();
+		while(filteredTargetClassInstanceReferencesIt.hasNext())
+		{
+			Object ref=filteredTargetClassInstanceReferencesIt.next();
+			Map instanceProperties=dc.getSymbolsForInstance(this.targetClassName,this.symTab.getDefaultQualifier(), ref);
+			filteredTargetClassInstances.add(instanceProperties);
+		}
+
+
+
+
+		// The return type for flavour 2 is either an array of property values or a property value
+		ArrayList listOfValuesForProperty = createListOfValuesForProperty(targetClassPropertyName,filteredTargetClassInstances);
+
+		if(!noPostCollectOperation) // of the form collect(...)[exp]
+		{
+			result = postCollectOperation.evaluate(listOfValuesForProperty); // evaluation will pick one of the values of the listOfValuesForProperty array
+		}
+		else
+		{
+			//Integer index = (Integer)postCollectOperation.evaluate();
+			//result = listOfValuesForProperty.get(index.intValue());
+			result = listOfValuesForProperty; // there is no post collect therefore result is the entire array of property values
+		}
+
+		// return result;
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluateFlavour2");
+
+		return result;
+
+
+
+	}
+
+	//collect(<refExp>,<assocName>,<role1>,<role2>,<targetClass>,<expression>)[exp].param1[exp]
+	//			       .param1(pList)
+	private Object evaluateFlavour1() throws SPLException 
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluateFlavour1");
+		//System.out.println("evaluate evaluateFlavour1");
+
+
+		Object result = null;
+
+		//evaluate the the first parameter to get the source instance
+		Object refExpressionResult = referenceExpression.evaluate();
+		String refExpressionStr=refExpressionResult.toString();
+		//System.out.println("self = "+refExpressionResult);
+		DataCollector dc = DataCollectorFactory.getDataCollector();
+		//NRJ verify this works
+//		String refTypeName = referenceExpression.getReferenceTypeName();
+		//String refTypeName=dc.getReferenceTypeName(refExpressionStr);
+		List targetClassInstanceReferences = null;
+
+		// traverse association to get an array of target class instances. Each instance is a Map of key=values
+		if(logger.isLoggable(Level.FINE))
+			logger.fine(Thread.currentThread().getName()+" refExpressionResult evaluateFlavour1 "+refExpressionStr);
+
+		targetClassInstanceReferences = dc.getAssociatedInstanceReferences((Object)refExpressionResult,symTab.getDefaultQualifier(),targetClassName,associationName,sourceRole,targetRole);
+		//System.out.println("targetClassInstanceReferences size "+targetClassInstanceReferences.size());
+		if (logger.isLoggable(Level.FINE))
+			logger.fine(Thread.currentThread().getName()+" got associated references");
+
+//		targetClassInstance = dc.getAssociatedInstanceReferences(refTypeName, symTab.getDefaultQualifier(), targetClassName,associationName,sourceRole,targetRole, refExpressionResult);
+		if (logger.isLoggable(Level.FINE))
+			logger.fine(Thread.currentThread().getName()+" got associated instances");
+
+		// filter the List based on the target filter expression
+		List filteredTargetClassInstanceReferences = filterTargetClassInstanceReferencesWithTargetExpression(targetClassInstanceReferences , this.targetClassName,this.symTab.getDefaultQualifier());
+		//System.out.println("filteredTargetClassInstanceReferences size "+filteredTargetClassInstanceReferences.size());
+
+		if (logger.isLoggable(Level.FINE))
+			logger.fine(Thread.currentThread().getName()+" got filtered references");
+
+		List filteredTargetClassInstances = new ArrayList();
+
+		Iterator filteredTargetClassInstanceReferencesIt=filteredTargetClassInstanceReferences.iterator();
+		while(filteredTargetClassInstanceReferencesIt.hasNext())
+		{
+			Object ref=filteredTargetClassInstanceReferencesIt.next();
+			//System.out.println("filter passed : "+ref.toString());
+			Map instanceProperties=dc.getSymbolsForInstance(this.targetClassName,this.symTab.getDefaultQualifier(), ref);
+			filteredTargetClassInstances.add(instanceProperties);
+		}
+
+		if (logger.isLoggable(Level.FINE))
+			logger.fine(Thread.currentThread().getName()+" got filtered instances");
+
+		if(!noPostCollectOperation) // post collect exists
+		{
+			if(postCollectOperation.getType().getIsArray()) // of the form collect(...)[exp]
+			{	
+				result = postCollectOperation.evaluate(filteredTargetClassInstances); // will return a map corresponding to the instance to be returned
+				int instanceNumber=postCollectOperation.getInstanceNumer();
+				//symTab.populateInstanceValuesForCollect(this.targetClassName, this.targetClassName, filteredTargetClassInstances.get(instanceNumber), (Map)result); // populate it in the hashtable to obtain the string expression for the instance
+				// NRJ
+				symTab.populateInstanceValuesForInstance(this.targetClassName, this.targetClassName, 
+						filteredTargetClassInstances.get(instanceNumber), (Map)result); 
+				// populate it in the hashtable to obtain the string expression for the instance
+				//result = symTab.getInstance();
+
+			}	
+			else // post collect of the form collect(...)[exp].prop
+			{     
+				// the result will be calculated as follows for 
+				// a) in the case prop is not an array 
+				// 1. Of the array of target class instances passed as the parameter
+				// use the exp to pick one of the instances
+				// for this instance obtain the value of prop and return
+				// b) in the case prop is an array
+				// if of the form collect(...)[exp].prop[exp] and exp == 1then the result will be the props[1]
+				// if of the form collect(...)[exp].prop and prop is an array then the result will be an array of prop
+
+				result = postCollectOperation.evaluate(filteredTargetClassInstances);
+
+			}
+		}
+		else // no post collect result is an array of target instances that satisfy the filter
+		{
+			result = filteredTargetClassInstanceReferences;
+
+		}
+
+
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluateFlavour1");
+
+
+		return result;
+	}
+
+	// for flavour 2 need to extract the values for the property and create an array
+	private ArrayList createListOfValuesForProperty(String propertyName, ArrayList filteredTargetClassInstances) 
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "createListOfValuesForProperty");
+		//System.out.println(" propertyName :"+propertyName);
+		//System.out.println(" filteredTargetClassInstances.size() :"+filteredTargetClassInstances.size());
+		
+		ArrayList propertyList = new ArrayList();
+		for(int i=0; i<filteredTargetClassInstances.size(); i++)
+		{
+			//System.out.println(" inside for");
+			Map currMap = (Map)filteredTargetClassInstances.get(i);
+			//System.out.println("currMap "+currMap.toString());
+			
+			Object s = (Object)currMap.get(propertyName);
+			//System.out.println("adding property "+propertyName);
+			//System.out.println(" object s :"+propertyName+" "+s.toString());
+			propertyList.add(s);
+
+		}
+
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "createListOfValuesForProperty");
+
+		return propertyList;
+	}
+
+	// Given a list of Maps where each map corresponds to an instance of the target class
+	// filter out the instances which satisfy the boolean condition
+	/*   private ArrayList filterTargetClassInstancesWithTargetExpression(List targetClassInstanceReferences) throws SPLException 
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "filterTargetClassInstancesWithTargetExpression");
+
+
+        ArrayList filteredTargetClassInstances = new ArrayList();
+
+        if(targetClassInstanceReferences!=null)
+        {
+            Iterator targetClassInstancesIt = targetClassInstanceReferences.iterator();
+            while(targetClassInstancesIt.hasNext())
+            {
+
+
+                Object instanceRefernce = targetClassInstancesIt.next();
+                DataCollector dc= DataCollectorFactory.getDataCollector();
+                Map instanceProperties=dc.getSymbolsForInstance(this.targetClassName, symTab.getDefaultQualifier(), instanceRefernce);
+                symTab.populateInstanceValuesForInstance(this.targetClassName, this.targetClassName, instanceRefernce, instanceProperties)populateSymbolTableWithInstanceValues(map);
+                Boolean result = (Boolean)expressionForTarget.evaluate();
+                if(result.booleanValue())
+                {
+                    filteredTargetClassInstances.add(map);
+                }
+            }	
+        }
+        else
+        {
+            if (logger.isLoggable(Level.FINE))
+                logger.fine(Thread.currentThread().getName()+" Zero instances passed in hence zero instance references filtered, therefore returning null ");
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "filterTargetClassInstancesWithTargetExpression");
+
+        return filteredTargetClassInstances;
+    }
+	 */
+
+	private ArrayList filterTargetClassInstanceReferencesWithTargetExpression(List targetClassInstanceReferences , String className,String namespc) throws SPLException 
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "filterTargetClassInstanceReferencesWithTargetExpression");
+		DataCollector dc = DataCollectorFactory.getDataCollector();
+		ArrayList filteredTargetClassInstanceReferences = new ArrayList();
+		if(targetClassInstanceReferences!=null)
+		{
+
+
+			Iterator it=targetClassInstanceReferences.iterator();
+			while(it.hasNext())
+			{
+				Object cop=(Object)it.next();
+				//System.out.println("getSymbolsForInstance "+className+" "+ namespc+" "+ cop);
+				Map map = dc.getSymbolsForInstance(className, namespc, cop);
+				//System.out.println("map.size() "+map.size()+" "+map.toString());
+				//symTab.populateInstanceValuesForCollect(className, className, cop, map);
+				//NRJ
+				symTab.populateInstanceValuesForInstance(className, className, cop, map);
+				Boolean result = (Boolean)expressionForTarget.evaluate();
+				//System.out.println("result "+result);
+				if(result.booleanValue())
+				{
+					if (logger.isLoggable(Level.FINE))
+						logger.fine(Thread.currentThread().getName()+" cop passed filter "+cop);
+					//System.out.println("adding cop to list "+cop.toString());
+					
+					filteredTargetClassInstanceReferences.add(cop);
+				}
+				else
+				{
+					if (logger.isLoggable(Level.FINE))
+						logger.fine(Thread.currentThread().getName()+" cop did not pass filter "+cop);
+
+
+				}
+			}
+		}
+		else
+		{
+			if (logger.isLoggable(Level.FINE))
+				logger.fine(Thread.currentThread().getName()+" Zero instances passed in hence zero instance references filtered, therefore returning null ");
+		}
+
+
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "filterTargetClassInstanceReferencesWithTargetExpression");
+
+		return filteredTargetClassInstanceReferences;
+	}
+
+
+
+
+	public TypeInfo getType() throws SPLException {
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "BasicCollectionExpression");
+
+		// if dataType is not set call validate so taht it gets set in the process
+		if(_dataType != null)
+		{
+
+			logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getType");
+			return _dataType;
+
+		}
+
+		else
+		{
+			validate();
+
+			logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getType");
+
+			return _dataType;
+		}
+
+
+	}
+
+
+	public String getReferenceTypeName() {
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getReferenceTypeName");
+
+
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getReferenceTypeName");
+
+		return returnClassName;
+	}
+
+
+
+	public boolean isArray() {
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+
+
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+
+		return this._dataType.getIsArray();
+	}
+
+	public String toString()
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+//		String className=this.getClass().getName();
+
+		String str="Collect(";
+
+		Iterator ExpIt=this.paramList.iterator();
+		while(ExpIt.hasNext()){
+			Expression exp=(Expression)ExpIt.next();
+			if(exp!=null){
+
+				String expstr=exp.toString();
+				str+=expstr + " , ";
+			}
+
+		}
+		str=str.substring(0, str.length()-3) +" ) ";
+//		if(this.expressionForTarget!=null){
+//			str+=" "+this.expressionForTarget.toString()+" ";
+//		}
+		if(this.postCollectOperation!=null){
+			str+="."+this.postCollectOperation.toString()+" ";
+		}
+//		if(this.referenceExpression!=null){
+//			str+=" "+this.referenceExpression.toString()+" ";
+//		}
+
+//		str+=" )";
+
+
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+		return str;
+	}
+
+	public static String getSourceClass()
+	{
+		return sourceClass;
+	}
+
+	public String getAssociationName()
+	{
+		return associationName;
+	}
+
+	public void setAssociationName(String associationName)
+	{
+		this.associationName = associationName;
+	}
+
+	public int getCollectType()
+	{
+		return collectType;
+	}
+
+	public void setCollectType(int collectType)
+	{
+		this.collectType = collectType;
+	}
+
+	public boolean isNoPostCollectOperation()
+	{
+		return noPostCollectOperation;
+	}
+
+	public void setNoPostCollectOperation(boolean noPostCollectOperation)
+	{
+		this.noPostCollectOperation = noPostCollectOperation;
+	}
+
+	public String getReturnClassName()
+	{
+		return returnClassName;
+	}
+
+	public void setReturnClassName(String returnClassName)
+	{
+		this.returnClassName = returnClassName;
+	}
+
+	public String getTargetClassName()
+	{
+		return targetClassName;
+	}
+
+	public void setTargetClassName(String targetClassName)
+	{
+		this.targetClassName = targetClassName;
+	}
+
+
+
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expression/primary/MacroExpression.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expression/primary/MacroExpression.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expression/primary/MacroExpression.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expression/primary/MacroExpression.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,161 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Neeraj Joshi <jneeraj@us.ibm.com>
+ *
+ */
+
+package org.apache.imperius.spl.parser.expression.primary;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.Expression;
+import org.apache.imperius.spl.parser.compiler.symboltable.MacroSymbol;
+import org.apache.imperius.spl.parser.compiler.symboltable.PropertySymbol;
+import org.apache.imperius.spl.parser.compiler.symboltable.SPLSymbolTable;
+import org.apache.imperius.spl.parser.compiler.symboltable.Symbol;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.statements.impl.MacroDefinition;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class MacroExpression implements Expression
+{
+    
+    private TypeInfo _returnType;
+    
+    private MacroDefinition _macroDefn;
+    
+    private List _passedParams;
+    
+      
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="MacroExpression";
+    
+    private boolean _isArray = false;
+    
+    private String _referenceTypeName = "";
+    
+    public boolean isArray()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+        
+        return _isArray;
+    }
+    
+    public MacroExpression(MacroSymbol ms, ArrayList pList,
+            SPLSymbolTable symTab) throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "MacroExpression");
+
+        
+        _returnType = ms.getType();
+        if(TypeResolver.isReference(_returnType))
+        {
+        	_referenceTypeName = ms.getReferenceTypeName();
+        }
+        _macroDefn = ms.getMacroDefn();
+        _passedParams = pList;
+      
+        validate();
+        if(_macroDefn.isArray())
+        {
+           _isArray = true;
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "MacroExpression");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        // TODO Auto-generated method stub
+        SPLSymbolTable macroSymbolTable = _macroDefn.getMacroSymTab();
+        
+        populateMacroSymbolTable(macroSymbolTable, _passedParams);
+        Object result = _macroDefn.evaluate();
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+        
+        return result;
+    }
+    
+    private void populateMacroSymbolTable(SPLSymbolTable macroSymbolTable,
+            List passedParams2) throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "populateMacroSymbolTable");
+
+        Map symbolMap = macroSymbolTable.getSymbolMap();
+        Iterator keySetIt = symbolMap.keySet().iterator();
+        Iterator passedParamIt = passedParams2.iterator();
+        while (keySetIt.hasNext() && passedParamIt.hasNext())
+        {
+            String symbolName = (String) keySetIt.next();
+            Symbol sym = (Symbol) symbolMap.get(symbolName);
+            
+            Expression currentParam = (Expression) passedParamIt.next();
+            Object value = currentParam.evaluate();
+           //System.out.println("symbolName,value : "+symbolName+" "+ value);
+            ((PropertySymbol) sym).setValue(value);
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "populateMacroSymbolTable");
+        
+        
+    }
+    
+    public TypeInfo getType()
+    {
+        
+        return _returnType;
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        List formalParams = _macroDefn.getArgList();
+        TypeResolver.validateActualParameterTypes(formalParams, _passedParams);
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+        
+        return true;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        
+        String str = _macroDefn.getMacroName()+" ( "+_macroDefn.getMacroExpression().toString()+" ) ";
+                
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+
+	public String getReferenceTypeName() throws SPLException 
+	{
+		
+		return _referenceTypeName;
+	}
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expression/primary/PostCollectExpression.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expression/primary/PostCollectExpression.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expression/primary/PostCollectExpression.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expression/primary/PostCollectExpression.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,489 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Neeraj Joshi <jneeraj@us.ibm.com>
+ *
+ */
+
+package org.apache.imperius.spl.parser.expression.primary;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.Expression;
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.compiler.symboltable.MethodSymbol;
+import org.apache.imperius.spl.parser.compiler.symboltable.PropertySymbol;
+import org.apache.imperius.spl.parser.compiler.symboltable.SPLSymbolTable;
+import org.apache.imperius.spl.parser.compiler.symboltable.Symbol;
+import org.apache.imperius.spl.parser.exceptions.IllegalExpressionTypeException;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.util.SPLLogger;
+
+
+
+public class PostCollectExpression implements Expression
+{
+
+	private Expression arrExp1;
+
+	private String methodOrParam;
+	private boolean methodOrParamExists=false;
+	private boolean array2Exists=false;
+	
+	
+	private Expression arrExp2;
+
+	private ArrayList pList;
+
+	private SPLSymbolTable symTab;
+
+	private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+
+	private static final String sourceClass="PostCollectExpression";
+
+	private TypeInfo _dataType=new TypeInfo();
+
+	public boolean isIdentifierMethod;
+
+	public int instanceNumer=-1;
+
+	private String targetName="";
+
+	//public static final int POSTCOLLECT_IS_ARRAY = -1;
+
+//	private boolean isArray;
+
+	public boolean isArray()
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+		return this._dataType.getIsArray();
+
+	}
+
+	public void setArray(boolean isArray)
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setArray");
+		this._dataType.setIsArray(isArray);
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setArray");
+
+
+	}
+
+	public PostCollectExpression(Expression a1, String m, Expression a2,
+			ArrayList pList, SPLSymbolTable sTab) throws SPLException
+			{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "PostCollectExpression");
+
+
+		this.arrExp1 = a1;
+		this.arrExp2 = a2;
+		this.methodOrParam = m;
+		this.pList = pList;
+		this.symTab = sTab;
+		
+		
+
+			}
+
+	// (arrExp1 = arrayIndex[cSymTab] ( id:IDENT ( #(INDEX_OP
+	// arrExp2=expression[cSymTab]) | #(METHOD_CALL (pList = exprList[cSymTab])?
+	// ) )? )? )
+	// [exp].ID1[exp]
+	// [exp].ID1(pList)
+	// [exp].ID1
+	public Object evaluate(List filteredTargetInstances)
+	throws SPLException
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+
+		Object result = null;
+		// evaluate the array expression to get the integer index
+		Integer arrayIndex = (Integer) arrExp1.evaluate();
+		int sizeOfFilteredTargetInstances = filteredTargetInstances.size();
+		this.instanceNumer=arrayIndex.intValue();
+		//System.out.println("arrayIndex" + arrayIndex);
+		//System.out.println("sizeOfFilteredTargetInstances"   + sizeOfFilteredTargetInstances);
+		// use the index to extract the corresponding object from the filtered
+		// instances
+		//System.out.println("doing post collect operation on filtered instances");
+		if ((sizeOfFilteredTargetInstances > arrayIndex.intValue())
+				&& (sizeOfFilteredTargetInstances != 0))
+		{
+			//System.out.println("filteredTargetInstances "+sizeOfFilteredTargetInstances+" "+arrayIndex.intValue() +" list:"+filteredTargetInstances);
+			
+			Object selectedInstance = filteredTargetInstances.get(arrayIndex
+					.intValue());
+			//System.out.println(selectedInstance);
+			if (!methodOrParam.equals("")) // of the form [exp].ID1 OR
+				// [exp].ID1(pList) OR
+				// [exp].ID1[exp]
+			{
+				if (!isIdentifierMethod) // not a method call i.e of type
+					// [exp].ID1 OR [exp].ID1[exp]
+				{
+					// populate the symbol table with the map corresponding to
+					// the current instance
+					//TBD add Map of ClassToInstance
+					symTab.populateInstanceValuesForInstance(this.targetName, this.targetName, selectedInstance, new HashMap());
+
+//					PropertySymbol prop = (PropertySymbol) symTab.getSymbol(this.targetName + "." + methodOrParam); // extract
+					String qualifiedPropertyNm=methodOrParam;                                                                // the symbol
+					if(!targetName.equalsIgnoreCase(""))    
+					{
+
+						qualifiedPropertyNm=targetName+"."+methodOrParam;
+
+					}
+					PropertySymbol prop = (PropertySymbol) symTab.getSymbol( qualifiedPropertyNm); // extract
+					result = prop.getValue(); // get its value
+					if (prop.isArray())
+					{
+						this._dataType.setIsArray(true);
+					}
+					else
+					{
+						this._dataType.setIsArray(false);
+					}
+				} // its a method invoke
+				else
+				{
+					logger.severe(
+							"Cannot invoke methods in the Declaration or Condition sections");
+
+					throw new SPLException(
+					"Cannot invoke methods in the Declaration or Condition sections");
+				}
+			}
+			else
+				// of the type [exp]
+			{
+				// symTab.populateSymbolTableWithInstanceValues((Map)selectedInstance);
+				result = selectedInstance;
+				this._dataType.setIsArray(false);
+			}
+			logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+			return result;
+		}
+		else
+		{
+			logger.severe(Thread.currentThread().getName()+" "+"array index is out of range");
+			throw new SPLException("array index is out of range");
+
+		}
+
+	}
+
+	public TypeInfo getType() throws SPLException
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getType");
+
+
+		if (_dataType != null)
+			return _dataType;
+		else
+		{
+
+			validate();
+			logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getType");
+
+			return _dataType;
+		}
+	}
+
+	public boolean validate(String targetClassName) throws SPLException
+	{
+
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+		//System.out.println("validating post collect expr "+targetClassName);
+
+		if (arrExp1 != null && (arrExp1.getType().getType() == TypeConstants.intType)) // make
+			// sure
+			// [exp]
+			// is
+			// numeric
+		{
+			//System.out.println("arrExp1 != null");
+			targetName=targetClassName;
+//			String targetClassName = (String)this.symTab.getAnchorClassList().get(0);
+			if (!methodOrParam.equals(""))
+			{
+				
+				methodOrParamExists=true;
+				//System.out.println("!methodOrParam.equals() "+methodOrParam);
+
+				String propName = /*targetClassName + "." +*/ methodOrParam;
+				boolean recurse = false; // do not go up the symbol table
+				// hierarchy
+				String qualifiedPropertyName=targetClassName+"."+propName;
+				//System.out.println("!methodOrParam.equals() "+qualifiedPropertyName);
+
+				if (symTab.symbolExists(qualifiedPropertyName, recurse)) // make sure ID1
+					// exists in the
+					// symbol table
+				{
+					//System.out.println("symTab.symbolExists(propName, recurse)");
+
+					Symbol sym = symTab.getSymbol(qualifiedPropertyName);
+					_dataType.copy(sym.getType());
+					
+					if (sym instanceof MethodSymbol)
+					{
+						//System.out.println("sym instanceof MethodSymbol");
+
+						// ArrayList formalParams = (ArrayList)
+						// ((MethodSymbol)sym).getArgTypeList();
+						// TypeResolver.validateActualParameterTypes(formalParams,pList);
+						// dataType = sym.getType();
+						// isIdentifierMethod = true;
+						logger.severe(Thread.currentThread().getName()+" "+"Cannot invoke methods in the Declaration or Condition sections");
+
+						throw new SPLException(
+						"Cannot invoke methods in the Declaration or Condition sections");
+					}
+					else if(sym instanceof PropertySymbol)
+						// sym instanceof PropertySymbol
+					{
+						//System.out.println("sym instanceof PropertySymbol");
+//						//System.out.println("propType "+propType.getType());
+
+						PropertySymbol pSym = (PropertySymbol) sym;
+						if (pSym.isArray())
+						{
+							array2Exists=true;
+							//System.out.println("pSym.isArray()");
+							_dataType.setIsArray(false);
+							
+							if(arrExp2 != null ){
+								if (arrExp2.getType().getType() != TypeConstants.intType)
+								{
+									logger.severe(
+											"arr index should be integer and not "
+											+ arrExp2.getType());
+
+									throw new IllegalExpressionTypeException(
+											"arr index should be integer and not "
+											+ arrExp2.getType());
+								}
+							}
+
+
+						}
+						isIdentifierMethod = false;
+						
+
+					}
+					else{
+						logger.severe(Thread.currentThread().getName()+" "+"unknown symbol type "+qualifiedPropertyName);
+						throw new SPLException("unknown symbol type "+qualifiedPropertyName);
+
+					}
+
+				}
+				else{
+					logger.severe(Thread.currentThread().getName()+" "+"symbol does not exist "+qualifiedPropertyName);
+					throw new SPLException("symbol does not exist "+qualifiedPropertyName);
+
+				}
+			}
+			else
+			{
+				//System.out.println("method or param name is null");
+				// expression of type [exp]
+				_dataType.setType(TypeConstants.referenceType);
+				_dataType.setIsArray(false);
+				isIdentifierMethod = false;
+				// ; // data type is same as the
+				// target class name in the
+				// collect
+			}
+		}
+		else
+		{
+			logger.severe(
+					"arr index should be integer and not " + arrExp1.getType());
+
+			throw new IllegalExpressionTypeException(
+					"arr index should be integer and not " + arrExp1.getType());
+
+		}
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+		//System.out.println("validating post collect expr done is array="+this._dataType.getIsArray());
+
+		return true;
+	}
+
+	public Expression getArrExp1()
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getArrExp1");
+
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getArrExp1");
+
+		return arrExp1;
+	}
+
+	public void setArrExp1(Expression arrExp1)
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setArrExp1");
+		this.arrExp1 = arrExp1;
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setArrExp1");
+
+
+	}
+
+	public Expression getArrExp2()
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getArrExp2");
+
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getArrExp2");
+
+		return arrExp2;
+	}
+
+	public void setArrExp2(Expression arrExp2)
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setArrExp2");
+		this.arrExp2 = arrExp2;
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setArrExp2");
+
+
+	}
+
+	public String getMethodOrParam()
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getMethodOrParam");
+
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getMethodOrParam");
+
+		return methodOrParam;
+	}
+
+	public void setMethodOrParam(String methodOrParam)
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setMethodOrParam");
+		this.methodOrParam = methodOrParam;
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setMethodOrParam");
+
+
+	}
+
+	public ArrayList getPList()
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getPList");
+
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getPList");
+
+		return pList;
+	}
+
+	public void setPList(ArrayList list)
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setPList");
+
+		pList = list;
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setPList");
+
+
+	}
+
+	public SPLSymbolTable getSymTab()
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getSymTab");
+
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getSymTab");
+
+		return symTab;
+	}
+
+	public void setSymTab(SPLSymbolTable symTab)
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setSymTab");
+
+
+		this.symTab = symTab;
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setSymTab");
+
+	}
+
+	public Object evaluate() throws SPLException
+	{
+
+		logger.severe(Thread.currentThread().getName()+" "+"Not supported evaluate without parameters");
+
+		throw new SPLException("Not supported evaluate without parameters");
+
+	}
+
+	public String toString()
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+		String str="";
+		if(this.arrExp1!=null){
+			str+=this.arrExp1.toString();
+		}
+		if(this.methodOrParam!=null){
+			str+=this.methodOrParam.toString();
+		}
+		
+		if(this.arrExp2!=null){
+			str+=" "+this.arrExp1.toString();
+		}
+//		str+=" )";
+
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+		return str;
+	}
+
+	public String getReferenceTypeName() throws SPLException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public int getInstanceNumer() {
+		return instanceNumer;
+	}
+
+	public void setInstanceNumer(int instanceNumer) {
+		this.instanceNumer = instanceNumer;
+	}
+
+	public boolean validate() throws SPLException {
+		// TODO Auto-generated method stub
+		throw new SPLException("validate() not supported for post collect expression");
+	}
+
+	public boolean isMethodOrParamExists() {
+		return methodOrParamExists;
+	}
+
+	
+	public boolean Array2Exists() {
+		return array2Exists;
+	}
+
+	
+
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expression/primary/PrimaryExpression.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expression/primary/PrimaryExpression.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expression/primary/PrimaryExpression.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expression/primary/PrimaryExpression.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,399 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//	
+
+/**
+ * @author Neeraj Joshi <jneeraj@us.ibm.com>
+ *
+ */
+
+package org.apache.imperius.spl.parser.expression.primary;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.Expression;
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.compiler.IdentPrimaryTuple;
+import org.apache.imperius.spl.parser.compiler.symboltable.SPLSymbolTable;
+import org.apache.imperius.spl.parser.compiler.symboltable.Symbol;
+import org.apache.imperius.spl.parser.exceptions.*;
+import org.apache.imperius.spl.parser.util.*;
+import org.apache.imperius.util.SPLLogger;
+
+
+/*
+ * #( i1:IDENT
+         	 (
+	         	#(m2:METHOD_CALL 
+         		 	(paramList = exprList[symTab])?
+         		  )
+         		|  
+         		( 
+         		  i2:IDENT { secondId = i2.getText(); } 
+         	  	   ( 
+         		      arrexp=arrayIndex[symTab]  
+         			   | 
+         			  #( m:METHOD_CALL  
+         				(paramList = exprList[symTab])?  
+         			   ) 
+         			)?  
+         			{ 
+         				if(m != null)
+         					isMethod = true;
+         				tp = new IdentPrimaryTuple(arrexp, paramList, secondId, isMethod);
+         				identTupleList.add(tp);
+         			}
+         		)*
+         	)	
+ * 
+ */
+
+
+public class PrimaryExpression implements Expression
+{
+    
+    private String _classNameOrInstanceVariableName;
+    
+    private List _identTupleList = null;
+    
+    private SPLSymbolTable _symTab;
+    
+    private Object evaluationResult=null;
+      
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+
+    private static final String sourceClass="PrimaryExpression";
+    
+    private TypeInfo _dataType = new TypeInfo();
+    
+    private String _referenceTypeName;
+    
+//    public boolean _isArray = false;
+    
+   
+    public PrimaryExpression(String id1, List identTupleList,
+    		SPLSymbolTable sTab) throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "PrimaryExpression");
+
+        _identTupleList = identTupleList;
+        _classNameOrInstanceVariableName = id1;
+      
+        //System.out.println("_classNameOrInstanceVariableName "+_classNameOrInstanceVariableName);
+        this._symTab = sTab;
+        if(sTab ==null)
+        {
+        	//System.out.println("PrimaryExpression: sTab is null");
+        }
+        if (sTab.getSymbolTableType() != SPLSymbolTable.COLLECT)
+        {
+            validate();
+        }
+        
+        else if (sTab.getSymbolTableType() == SPLSymbolTable.BASICCOLLECT)
+        {
+            
+//            _isArray = true;
+            this._dataType.setIsArray(true);
+            validate();
+        }
+        if (sTab.getSymbolTableType() == SPLSymbolTable.COLLECT)
+        {
+//            _isArray = true;
+        	this._dataType.setIsArray(true);
+            
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "PrimaryExpression");
+        
+        
+    }
+    
+    public String getPropertyName()
+    {
+    	String propName = null;
+    	Iterator idIt = _identTupleList.iterator();
+    	while(idIt.hasNext())
+    	{
+    		IdentPrimaryTuple  idt = (IdentPrimaryTuple)idIt.next();
+    		propName = idt.getPropertyName();
+    		break;
+    	}
+    	//System.out.println("returning property name "+propName);
+    	return propName;
+    }
+    
+    public String getclassNameOrInstanceVariableName()
+    {
+    	
+    	return _classNameOrInstanceVariableName;
+    }
+    
+    public boolean isArray()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+
+        
+        
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+       
+      
+        
+        return this._dataType.getIsArray();
+    }
+    
+   
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+        boolean isArray = false;
+        //System.out.println("PrimaryExpression id1=" + id1 + "  id2=" + id2);
+        // 
+        // case 1: ident1
+        // case 2: ident1.ident2
+        // case 3: ident1[expr]
+        // case 4: ident1.ident2[expr]
+        if(!_identTupleList.isEmpty())
+        {
+        	TypeInfo returnType = new TypeInfo(TypeConstants.referenceType,
+	        		_classNameOrInstanceVariableName,
+	        		isArray);
+	        int i = 0;
+	        Iterator identTupleIt = _identTupleList.iterator();
+	        while(identTupleIt.hasNext())
+	        {
+	        	if(returnType.getType() == TypeConstants.referenceType)
+	        	{
+	        		String referenceTypeName = returnType.getReferenceTypeName();
+	        		IdentPrimaryTuple ipt = (IdentPrimaryTuple)identTupleIt.next();
+	        		if(i++ == 0) // first element in the list has the same symbol table
+	        		{ // as the primary expression
+	        			ipt.setSymbolTable(_symTab);
+	        		}
+	        		returnType = ipt.validate(referenceTypeName);
+	        	}	
+	        	
+	        	
+	        }
+	        _dataType.copy(returnType);
+//	        _isArray = returnType.getIsArray();
+	        _referenceTypeName = returnType.getReferenceTypeName();
+        }
+        else // local constant
+        {
+        	boolean symbolExists = _symTab.symbolExists(_classNameOrInstanceVariableName, true);
+        	Symbol sym = _symTab.getSymbol(_classNameOrInstanceVariableName);
+        	if(!symbolExists)
+        	{
+        		throw new SPLException("Symbol " + _classNameOrInstanceVariableName + " does not exist");
+        	}
+        	_dataType.copy(sym.getType());
+//        	_isArray = sym.isArray();
+        	_referenceTypeName = sym.getReferenceTypeName();
+        	
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+       
+      
+        return true;
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+        int i = 0;
+        Object intermediateObject = null;
+        if(!_identTupleList.isEmpty())
+        {	
+	        Iterator idIter = _identTupleList.iterator();
+	        while(idIter.hasNext())
+	        {
+	        	IdentPrimaryTuple ipt = (IdentPrimaryTuple)idIter.next();
+	        	if(i++ == 0)
+	        	{
+	        		intermediateObject = ipt.evaluate();
+	        	}
+	        	else
+	        	{
+	        		intermediateObject = ipt.evaluate(intermediateObject);
+	        	}
+	        	
+	        }
+        }
+        else
+        {
+        	Symbol sym = _symTab.getSymbol(_classNameOrInstanceVariableName);
+        	intermediateObject = sym.getValue();
+        }
+        
+        
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+        
+        this.evaluationResult=intermediateObject;
+        
+        return intermediateObject;
+    }
+    
+    public TypeInfo getType()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getType");
+
+       
+      
+        if (_dataType != null)
+        {
+            return _dataType;
+        }
+        else
+        {
+            try
+            {
+                validate();
+            }
+            catch (SPLException e)
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"Exception cought");
+                e.printStackTrace();
+            }
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getType");
+            
+            return _dataType;
+        }
+        
+    }
+    
+    
+    
+   
+    
+    public String getClassName()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getClassName");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getClassName");
+       
+      
+        return _classNameOrInstanceVariableName;
+    }
+    
+    public void setClassName(String className)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setClassName");
+        this._classNameOrInstanceVariableName = className;
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setClassName");
+       
+      
+        
+    }
+    
+   
+    
+   
+    
+    public SPLSymbolTable getSymTab()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getSymTab");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getSymTab");
+       
+      
+        return _symTab;
+    }
+    
+    public void setSymTab(SPLSymbolTable symTab)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setSymTab");
+        this._symTab = symTab;
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setSymTab");
+       
+      
+        
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+//        String str=id1;
+//        if(id2!=null && !id2.equalsIgnoreCase("")){
+//            str+="."+id2;
+//        }
+//        
+        
+        
+       /*String retStr=_classNameOrInstanceVariableName;
+       
+       if(this._dataType.getIsArray()){
+    	   retStr+="[ ";
+    	   if(this._dataType.getType()==TypeConstants.referenceType){
+    		   retStr+=this._referenceTypeName;
+        	   
+    	   }
+    	   else{
+    		   List params=this._identTupleList;
+    		   Iterator it=params.iterator();
+    		   while(it.hasNext()){
+    			   Object ob=it.next();
+    			   retStr+=ob.toString();
+    		   }
+    	   }
+    	   retStr+=" ]";
+       }    */ 
+        String retStr=" "+this.getPropertyString() +"( ";
+        
+        if(this.evaluationResult!=null){
+        	retStr+=this.evaluationResult.toString();
+            
+        }
+        
+        retStr+=" )";
+        
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return retStr;
+    }
+
+	public String getReferenceTypeName() throws SPLException 
+	{
+		return _referenceTypeName;
+	}
+    
+	public String getPropertyString()
+    {
+    	String propName = "";
+    	
+    	Iterator idIt = _identTupleList.iterator();
+    	while(idIt.hasNext())
+    	{
+    		IdentPrimaryTuple  idt = (IdentPrimaryTuple)idIt.next();
+    		propName += idt.getPropertyName()+".";
+    		
+    	}
+    	int length=propName.length();
+    	if(length > 0){
+    		propName=propName.substring(0, (length-2));
+        		
+    	}
+    	//System.out.println("returning property name "+propName);
+    	return propName;
+    }
+	
+	
+}
+
+

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expression/primary/SelfExpression.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expression/primary/SelfExpression.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expression/primary/SelfExpression.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expression/primary/SelfExpression.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,164 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Neeraj Joshi <jneeraj@us.ibm.com>
+ *
+ */
+
+package org.apache.imperius.spl.parser.expression.primary;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.Expression;
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.compiler.symboltable.SPLSymbolTable;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.ReferenceExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.util.SPLLogger;
+
+
+
+
+public class SelfExpression implements Expression, ReferenceExpression
+{
+    
+    private SPLSymbolTable sTab;
+    private TypeInfo _dataType = null; 
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+
+    private static final String sourceClass="SelfExpression";
+    
+    
+    public SelfExpression(SPLSymbolTable symTab)throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "SelfExpression");
+       //System.out.println("evaluating Self expression");
+        
+        sTab = symTab;
+        
+        if (!validate())
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"validation error: " + sourceClass
+                    + " has wrong data type passed in.");
+            
+            throw new SPLException("validation error: " + sourceClass
+                    + " has wrong data type passed in.");
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ sourceClass);
+        
+    }
+    
+    public String getReferenceTypeName()
+    {
+    	 logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+         //System.out.println("evaluating Self expression");
+    	 String referenceTypeName = null;
+         
+          SPLSymbolTable symbtab=sTab;
+          while(sTab.getParentSymbolTable() != null && sTab.getParentSymbolTable().getSymbolTableType() == SPLSymbolTable.COLLECT){
+          	symbtab=sTab.getParentSymbolTable();
+          }
+          
+          
+          if (symbtab.getParentSymbolTable() != null && symbtab.getParentSymbolTable().getSymbolTableType() != SPLSymbolTable.COLLECT )
+          {	
+              SPLSymbolTable parentSymTab = symbtab.getParentSymbolTable();
+              List anchorClassList = parentSymTab.getAnchorClassList();
+              Iterator anchorClassListIt = anchorClassList.iterator();
+             
+             	referenceTypeName = (String)anchorClassListIt.next();
+             
+             
+          }
+          else{
+//          	throw new SPLException("non collect Parent SymbolTable not found in Self Expression");
+        	  logger.severe("non collect Parent SymbolTable not found in Self Expression");
+        	  
+          }
+          logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+          return referenceTypeName;
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+       //System.out.println("evaluating Self expression");
+        Object ins = null;
+        SPLSymbolTable symbtab=sTab;
+        while(sTab.getParentSymbolTable() != null && sTab.getParentSymbolTable().getSymbolTableType() == SPLSymbolTable.COLLECT){
+        	symbtab=sTab.getParentSymbolTable();
+        }
+        
+        
+        if (symbtab.getParentSymbolTable() != null && symbtab.getParentSymbolTable().getSymbolTableType() != SPLSymbolTable.COLLECT )
+        {	
+            SPLSymbolTable parentSymTab = symbtab.getParentSymbolTable();
+            String referenceTypeName = null;
+            List anchorClassList = parentSymTab.getAnchorClassList();
+            Iterator anchorClassListIt = anchorClassList.iterator();
+           
+           	referenceTypeName = (String)anchorClassListIt.next();
+           
+            ins = parentSymTab.getInstance(referenceTypeName);
+        }
+        else{
+        	throw new SPLException("non collect Parent SymbolTable not found in Self Expression");
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+        
+        return ins;
+    }
+    
+    public TypeInfo getType()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getType");
+        
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getType");
+        return _dataType;
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+        _dataType = new TypeInfo(TypeConstants.referenceType,null,false);
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+        return true;
+    }
+    
+    public boolean isArray()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+        
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+        // TODO Auto-generated method stub
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        String str=" self ";
+                         
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/BooleanExpression.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/BooleanExpression.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/BooleanExpression.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/BooleanExpression.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,28 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+
+package org.apache.imperius.spl.parser.expressions;
+
+import org.apache.imperius.spl.external.Expression;
+
+public interface BooleanExpression extends Expression
+{
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/CalendarExpression.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/CalendarExpression.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/CalendarExpression.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/CalendarExpression.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,28 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+
+package org.apache.imperius.spl.parser.expressions;
+
+import org.apache.imperius.spl.external.Expression;
+
+public interface CalendarExpression extends Expression
+{
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/ConstantExpression.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/ConstantExpression.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/ConstantExpression.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/ConstantExpression.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,42 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+
+package org.apache.imperius.spl.parser.expressions;
+
+import org.apache.imperius.spl.external.Expression;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+
+
+public abstract class ConstantExpression implements Expression
+{
+    
+    
+    
+    public boolean validate()
+    {
+        return true;
+    }
+    public String getReferenceTypeName() throws SPLException
+    {
+    	//throw new SPLException("Expression is not of type reference");
+    	return null;
+    }
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/DoubleArgumentExpression.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/DoubleArgumentExpression.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/DoubleArgumentExpression.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/DoubleArgumentExpression.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,151 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+
+package org.apache.imperius.spl.parser.expressions;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.Expression;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.util.SPLLogger;
+
+
+
+public abstract class DoubleArgumentExpression implements Expression
+{
+    
+    protected Expression _lhsExp;
+    
+    protected Expression _rhsExp;
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+
+    private final String sourceClass="DoubleArgumentExpression";
+    
+   // protected boolean _isArray = false;
+    
+    protected TypeInfo _dataType = new TypeInfo();
+    
+    public DoubleArgumentExpression(List exprList)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "DoubleArgumentExpression");
+
+    
+        if (exprList != null)
+        {
+            
+            if (exprList.size() == 2)
+            {
+                Expression l = (Expression) exprList.get(0);
+                Expression r = (Expression) exprList.get(1);
+                
+                if (l == null)
+                {
+                    logger.severe(
+                    "left hand side expression passed in is null.");
+                    throw new IllegalArgumentException(
+                            "left hand side expression passed in is null.");
+                }
+                else
+                {
+                    // //System.out.println("DoubleArgumentExpression::LHS
+                    // "+l.getClass()+l.toString());
+                }
+                
+                if (r == null)
+                {
+                    logger.severe(
+                    "right hand side expression passed in is null.");
+                    throw new IllegalArgumentException(
+                            "right hand side expression passed in is null.");
+                }
+                else
+                {
+                    // //System.out.println("DoubleArgumentExpression::RHS
+                    // "+r.getClass()+r.toString());
+                }
+                
+                this._lhsExp = l;
+                this._rhsExp = r;
+                
+            }
+            else
+            {
+                logger.severe(
+                        "No of arguments should be 2, but is "
+                        + exprList.size());
+                
+                throw new IllegalArgumentException(
+                        "No of arguments should be 2, but is "
+                                + exprList.size());
+            }
+        }
+        else
+        {
+            logger.severe(
+            "No of arguments passed required number of arguments is 2");
+            throw new IllegalArgumentException(
+                    "No of arguments passed required number of arguments is 2");
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "DoubleArgumentExpression");
+        
+    }
+    
+    public abstract Object evaluate() throws SPLException;
+    
+    public TypeInfo getType()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getType");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getType");
+       
+        return _dataType;
+    }
+    
+    public boolean isArray()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+       
+        return _dataType.getIsArray();
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        String className=this.getClass().getName();
+        
+        String str=className.substring(className.lastIndexOf(".")+1, className.length())+"( "+this._lhsExp.toString()+" , "+this._rhsExp.toString()+" )";
+        
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+    
+    public abstract boolean validate() throws SPLException;
+    
+    public String getReferenceTypeName() 
+    {
+    	return null;
+    }
+}



Mime
View raw message