incubator-imperius-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jnee...@apache.org
Subject svn commit: r678422 - in /incubator/imperius/trunk: imperius-splcore/src/main/antlr/org/apache/imperius/spl/parser/compiler/ imperius-splcore/src/main/java/org/apache/imperius/spl/parser/factory/ imperius-splcore/src/main/java/org/apache/imperius/spl/p...
Date Mon, 21 Jul 2008 14:03:47 GMT
Author: jneeraj
Date: Mon Jul 21 07:03:47 2008
New Revision: 678422

URL: http://svn.apache.org/viewvc?rev=678422&view=rev
Log:
Commited changes for IMPERIUS-10 - Nested method invocation changes by Naidu J

Modified:
    incubator/imperius/trunk/imperius-splcore/src/main/antlr/org/apache/imperius/spl/parser/compiler/cimspl.g
    incubator/imperius/trunk/imperius-splcore/src/main/antlr/org/apache/imperius/spl/parser/compiler/cimspl.tree.g
    incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/factory/ActionFactory.java
    incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/actions/impl/AnchorMethodInvokeAction.java
    incubator/imperius/trunk/javaspl-samples/resources/samples/simple/policies/AccessPrivateVariablesSample.spl

Modified: incubator/imperius/trunk/imperius-splcore/src/main/antlr/org/apache/imperius/spl/parser/compiler/cimspl.g
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/antlr/org/apache/imperius/spl/parser/compiler/cimspl.g?rev=678422&r1=678421&r2=678422&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/antlr/org/apache/imperius/spl/parser/compiler/cimspl.g
(original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/antlr/org/apache/imperius/spl/parser/compiler/cimspl.g
Mon Jul 21 07:03:47 2008
@@ -272,9 +272,17 @@
                             
                         
 basicActionBlock :
-                (IDENT | "Set" | "InvokePolicy" ) (DOT! IDENT)? (methodCall) ((EQUAL | NOT_EQUAL
| GE | GT | LT | LE) constant)?
+                // (IDENT | "Set" | "InvokePolicy" ) (DOT! IDENT)? (methodCall) ((EQUAL |
NOT_EQUAL | GE | GT | LT | LE) constant)?
+                (
+                	// ( IDENT (DOT! IDENT (methodCall))* )
+                	IDENT^ ( (DOT! IDENT (indexOp | methodCall)?)* | methodCall)
+                	|
+                	( ("Set" | "InvokePolicy") (DOT! IDENT)? (methodCall) )
+                )
+                (
+                	(EQUAL | NOT_EQUAL | GE | GT | LT | LE) constant
+                )?
                 {#basicActionBlock = #(#[ACTIONBLOCK,"ACTIONBLK"],basicActionBlock );}
-
 ;  
 
 policyGroup :

Modified: incubator/imperius/trunk/imperius-splcore/src/main/antlr/org/apache/imperius/spl/parser/compiler/cimspl.tree.g
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/antlr/org/apache/imperius/spl/parser/compiler/cimspl.tree.g?rev=678422&r1=678421&r2=678422&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/antlr/org/apache/imperius/spl/parser/compiler/cimspl.tree.g
(original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/antlr/org/apache/imperius/spl/parser/compiler/cimspl.tree.g
Mon Jul 21 07:03:47 2008
@@ -1298,110 +1298,94 @@
                         
 basicActionBlock[SPLSymbolTable symTab] returns [ActionBlock ab=null] :
 {
-        ArrayList paramList = new ArrayList();
-        String ident1 = null;
-        String ident2 = "";
-        String st = "";
-        String op = ""; 
-        MethodSymbol x=null;
-        SPLSymbolTable table=symTab;
-        Expression c = null;
-       
+    	String st = "";
+    	String op = "";
+    	SPLSymbolTable table = symTab;
+    	ArrayList paramList = new ArrayList();
+    	Expression c = null;
+    	String ident1 = null;
+    	String secondId = "";
+    	boolean isMethod = false;
+   	 	boolean isBuiltInMethod = false;
+    	List identTupleList = new ArrayList();
+    	IdentPrimaryTuple tp = null;
+    	Expression arrexp = null;
 }
-   #( ACTIONBLOCK
-   				( 
-   					id1:IDENT {ident1 = id1.getText(); } 
-            	|     
-            		s:"Set" {st = s.getText();} 
-            	|
-            		i:"InvokePolicy" {st = i.getText();} 
-            	) 
-            	
-            	( 
-            		id2:IDENT 
-            			{
-            				ident2 = id2.getText();
-            				try
-            				{
-            					//System.out.println(" trying to get method  : "+ ident1+"."+ident2	);
-            					x = (MethodSymbol)symTab.getSymbol(ident1+"."+ident2);
-            				}
-            				catch (SPLException ex)
-            				{
-            					//System.out.println(" symTab get method Symbol failed : "+ ex.getMessage()
);
-            				}		
-            				if(x!=null)
-            				{
-            					//System.out.println(" x != null");
-            					SPLSymbolTable methodTable=x.getMethodSymbolTable(); 
-            					if(methodTable!=null)
-            					{
-            						//System.out.println("table is not null therefore table.setParentSymbolTable(symTab)");
-            						table=methodTable;
-            						table.setParentSymbolTable(symTab); 
-            					}
-            					else
-            					{
-            						//System.out.println("table is null therefore table=symTab");
-            						table=symTab;
-            					}
-            				}
-            				else
-            				{
-            					//System.out.println("x is null therefore table=symTab");
-            					table=symTab;
-            				}
-            			} 
-            	)?  
-            	
-    			#(METHOD_CALL 
-    						(
-    							paramList = exprList[table]
-    						)
-      			 ) 
-      			 
-            	(
-            		(
-            			e:EQUAL {op = e.getText();}
-            		| 
-            			ne:NOT_EQUAL {op = ne.getText();} 
-            		|
-            			ge:GE {op = ge.getText();}
-            		| 
-            			gt:GT {op = gt.getText();}
-            		| 
-            			lt:LT {op = lt.getText();}
-            		| 
-            			le:LE {op = le.getText();} 
-            		) 
-            	
-            		c=constant
-           		)?
-     )  
-{
-       //System.out.println("ident1, ident2 "+ident1+" "+ ident2);
+	#( ACTIONBLOCK
+		(	
+			(
+				#(i1:IDENT { ident1 = i1.getText(); }
+					(
+						#(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;
+								table = new SPLSymbolTable();
+								tp = new IdentPrimaryTuple(arrexp, paramList, secondId, isMethod, table);
+								identTupleList.add(tp);
+							}
+						)*
+					)
+				 )
+			)
+			
+			|		
+			
+			(		
+				(	s:"Set" {st = s.getText();}
+				  |	i:"InvokePolicy" {st = i.getText();}	 	
+				)
+				( id3:IDENT {ident1 = id3.getText(); } )?
+	
+				#( METHOD_CALL ( paramList = exprList[symTab] ) ) 
+			)
+		)	
+
+
+		(
+			(
+					e:EQUAL {op = e.getText();}
+				| 
+					ne:NOT_EQUAL {op = ne.getText();} 
+				|
+					ge:GE {op = ge.getText();}
+				| 
+					gt:GT {op = gt.getText();}
+				| 
+					lt:LT {op = lt.getText();}
+				| 
+					le:LE {op = le.getText();} 
+			) 
+			c = constant
+		)?	
+	
+	)	
+	
+	{
        try
        {
-       	//System.out.println("creating action : "+ident1+" "+ident2+" "+st+" "+op);
-        ab = ActionFactory.createAction(ident1, ident2, paramList, st, op, c,symTab);
-        if(logger.isLoggable(Level.FINE))
-  			logger.fine(Thread.currentThread().getName()+" CIMSPLTreeParser:: basicActionBlock created
");
+			// System.out.println("creating action : "+ident1+" "+ident2+" "+st+" "+op);
+			ab = ActionFactory.createAction(ident1, paramList, identTupleList, isBuiltInMethod, st,
op, c, symTab);
+			if(logger.isLoggable(Level.FINE))
+				logger.fine(Thread.currentThread().getName()+" CIMSPLTreeParser:: basicActionBlock created
");
        }
        catch (SPLException ex)
        {
-       	   ASTWithLineNumber q = (ASTWithLineNumber)id1;
+			ASTWithLineNumber q = (ASTWithLineNumber)i1;
 			logger.severe(ex.getMessage());
 			logger.severe(Thread.currentThread().getName()+" "+"TreeParser::Exception creating Expression
at line "+q.getLine());
-		//System.out.println(ex.getMessage());
-		//System.out.println("TreeParser::Exception inserting action at line "+q.getLine());
-        	System.err.println("$SPLTreeParser$ Error at line no#"+q.getLine()+":"+ex.getMessage());
+			System.err.println("$SPLTreeParser$ Error at line no#"+q.getLine()+":"+ex.getMessage());
 			throw new RecognitionException(ex.getMessage());
-       	
        }		 	
-   
-        
-}                 
-             
+	}                 
 ;    
 
 policyGroup[SPLSymbolTable symTab] returns [PolicyGroup pg = null]:

Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/factory/ActionFactory.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/factory/ActionFactory.java?rev=678422&r1=678421&r2=678422&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/factory/ActionFactory.java
(original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/factory/ActionFactory.java
Mon Jul 21 07:03:47 2008
@@ -85,17 +85,16 @@
      * 
      */
 
-    public static ActionBlock createAction(String className1,
-            String classNameOrMethodName, List paramList, String set,
-            String op, Expression c, SPLSymbolTable symTab) throws SPLException
+    public static ActionBlock createAction(String className1, List paramList,
+            List identTupleList, boolean isBuiltInMethod, String set,
+            String op, Expression c, SPLSymbolTable symTab) throws SPLException 
     {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "createAction");
-
-        
+        logger.entering(sourceClass, Thread.currentThread().getName() + " " + "createAction");
         ActionBlock returnBlock = null;
+        
         if (set.equalsIgnoreCase("Set"))
         {
-           List anchorClasses=symTab.getAnchorData().getAnchorClassList();
+           List anchorClasses = symTab.getAnchorData().getAnchorClassList();
            
            returnBlock = new SetActionBlock((String)anchorClasses.get(0), paramList, symTab);
         }
@@ -112,14 +111,10 @@
         else
         {
             returnBlock = new AnchorMethodInvokeAction(className1,
-                    classNameOrMethodName, paramList, op, c, symTab);
+                    identTupleList, op, c, symTab);
         }
         logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "createAction");
         
         return returnBlock;
-        
     }
-    
-   
-    
 }

Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/actions/impl/AnchorMethodInvokeAction.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/actions/impl/AnchorMethodInvokeAction.java?rev=678422&r1=678421&r2=678422&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/actions/impl/AnchorMethodInvokeAction.java
(original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/actions/impl/AnchorMethodInvokeAction.java
Mon Jul 21 07:03:47 2008
@@ -32,6 +32,8 @@
 import org.apache.imperius.spl.external.Actuator;
 import org.apache.imperius.spl.external.Argument;
 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.MethodSymbol;
 import org.apache.imperius.spl.parser.compiler.symboltable.SPLSymbolTable;
 import org.apache.imperius.spl.parser.exceptions.SPLException;
@@ -40,148 +42,271 @@
 import org.apache.imperius.spl.parser.statements.BasicActionBlock;
 import org.apache.imperius.spl.parser.statements.impl.ArgumentImpl;
 import org.apache.imperius.spl.parser.util.ActuatorFactory;
-import org.apache.imperius.spl.parser.util.DataCollectorFactory;
 import org.apache.imperius.spl.parser.util.ExpressionUtility;
+import org.apache.imperius.spl.parser.util.TypeInfo;
 import org.apache.imperius.spl.parser.util.TypeResolver;
 import org.apache.imperius.util.SPLLogger;
 
-//import com.ibm.ac.cimspl.CIMSPLTypeConstants;
-
-
-public class AnchorMethodInvokeAction implements BasicActionBlock
+public class AnchorMethodInvokeAction implements BasicActionBlock 
 {
-    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
-
-    private static final String sourceClass="MethodInvokeAction";
-
-    private String _optClassName;
 
-    private String _methodName;
-
-    private SPLSymbolTable _symTab;
-
-    private List _pList;
-
-    private String _operatorType;
+    private String _className = null;
+    private SPLSymbolTable _symTable = null;
+    private List _identTupleList = null;
+    private String _operatorType = null;
+    private Expression _constantExpression = null;
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass = "MethodInvokeAction";
 
-    private Expression _constantExpression;
+    public AnchorMethodInvokeAction(String className, List identTupleList,
+            String operatorType, Expression constExpr, SPLSymbolTable symTable) 
+    {
+        logger.entering(sourceClass, Thread.currentThread().getName() + " "
+                + "MethodInvokeAction");
 
+        _className = className;
+        _identTupleList = identTupleList;
+        _operatorType = operatorType;
+        _constantExpression = constExpr;
+        _symTable = symTable;
+        _validate();
 
+        logger.exiting(sourceClass, Thread.currentThread().getName() + " "
+                + "MethodInvokeAction");
+    }
 
-    // cexp--->integer, compare action result with that, paramlist format--->
-    public AnchorMethodInvokeAction(String optClassName, String methodName,
-            List paramList, String op, Expression cExp, SPLSymbolTable symTab) throws SPLException
+    private void _validate() 
+    {
+        try 
+        {
+            boolean isArray = false;
+            if (!_identTupleList.isEmpty()) 
             {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "MethodInvokeAction");
+                TypeInfo returnType = new TypeInfo(TypeConstants.referenceType,
+                        _className, isArray);
 
-
-        //System.out.println("creating MethodInvokeAction block " + optClassName+ " " + methodName);
-        _optClassName = optClassName;
-        _methodName = methodName;
-        _pList = paramList;
-        _symTab = symTab;
-        if ((op != null) && (op != ""))
+                Iterator identTupleIt = _identTupleList.iterator();
+                int i = 0;
+                while (identTupleIt.hasNext()) 
+                {
+                    if (returnType.getType() == TypeConstants.referenceType) 
+                    {
+                        String referenceTypeName = returnType
+                                .getReferenceTypeName();
+                        IdentPrimaryTuple ipt = (IdentPrimaryTuple) identTupleIt
+                                .next();
+                        if (i++ == 0) 
+                        {
+                            ipt.setSymbolTable(_symTable);
+                        }
+                        returnType = ipt.validate(referenceTypeName);
+                    }
+                }
+            }
+        } 
+        catch (SPLException splex) 
         {
-            _operatorType = op;
-        }
-        _constantExpression = cExp;
-        _validate();
-
-
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "MethodInvokeAction");
 
-
-            }
+        }
+    }
 
     public static void validateActualParameters(SPLSymbolTable symTab,
-            String classNameOrVariableName, 
-            String methodName, 
-            List pList) throws SPLException
-            {
+            String classNameOrVariableName, String methodName, List pList)
+            throws SPLException 
+    {
 
-        MethodSymbol methodSym = 
-            (MethodSymbol)symTab.getSymbol(classNameOrVariableName + "." + methodName);
+        MethodSymbol methodSym = (MethodSymbol) symTab
+                .getSymbol(classNameOrVariableName + "." + methodName);
         List argTypeList = methodSym.getArgumentList();
         Iterator formalParamTypeIt = argTypeList.iterator();
         Iterator actualParamIt = pList.iterator();
-        if(argTypeList.size() == pList.size())
-        {   
-            while(formalParamTypeIt.hasNext() && actualParamIt.hasNext())
+        if (argTypeList.size() == pList.size()) 
+        {
+            while (formalParamTypeIt.hasNext() && actualParamIt.hasNext()) 
             {
-                Argument formalArg = (Argument)formalParamTypeIt.next();
-                Expression actualParam = (Expression)actualParamIt.next();
-                if(!TypeResolver.isTypeAssignableForEquality(formalArg.getType(),actualParam.getType())

-                        || formalArg.getIsArray() != actualParam.isArray())
+                Argument formalArg = (Argument) formalParamTypeIt.next();
+                Expression actualParam = (Expression) actualParamIt.next();
+                if (!TypeResolver.isTypeAssignableForEquality(formalArg
+                        .getType(), actualParam.getType())
+                        || formalArg.getIsArray() != actualParam.isArray()) 
                 {
-                    throw new SPLException("Formal and passed parameter types don't match
for method "
-                            + methodName);
-                }   
+                    throw new SPLException(
+                            "Formal and passed parameter types don't match for method "
+                                    + methodName);
+                }
 
-            }   
-        }
-        else
+            }
+        } 
+        else 
         {
-            System.err.println("Number of Formal and passed parameters don't match for method
"
-                    + methodName);
-//          throw new SPLException("Number of Formal and passed parameters don't match for
method "
-//          + methodName);
-        }   
+            System.err
+                    .println("Number of Formal and passed parameters don't match for method
"
+                            + methodName);
+            //          throw new SPLException("Number of Formal and passed parameters don't
match for method "
+            //          + methodName);
+        }
 
+    }
 
+    public boolean execute(Actuator ac) 
+    {
+        boolean postExprResult = false;
+        int i = 0;
+        Object intermediateObject = null;
+        try 
+        {
+            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);
+                    }
+                }
             }
 
-    private void _validate() throws SPLException
-    {
+            if (intermediateObject != null) 
+            {
+                if (_constantExpression == null) 
+                {
+                    postExprResult = true;
+                } 
+                else 
+                {
+                    Expression constexpr = this._constantExpression;
+                    Object constresult;
+                    int compareResult = 0;
+                    try 
+                    {
+                        constresult = constexpr.evaluate();
+                        compareResult = ExpressionUtility.compare(
+                                intermediateObject, constresult);
+                    } 
+                    catch (SPLException e) 
+                    {
+                        e.printStackTrace();
+                        logger.severe(Thread.currentThread().getName() + " "
+                                + e.getMessage());
 
-        validateActualParameters(_symTab,_optClassName,_methodName,_pList);
+                    }
+                    String operation = this._operatorType;
+                    if (operation.equalsIgnoreCase("==")) 
+                    {
+                        if (compareResult != 0)
+                            postExprResult = false;
+                        else
+                            postExprResult = true;
+                    } 
+                    else if (operation.equalsIgnoreCase("!=")) 
+                    {
+                        if (compareResult == 0)
+                            postExprResult = false;
+                        else
+                            postExprResult = true;
+                    } 
+                    else if (operation.equalsIgnoreCase(">=")) 
+                    {
+                        if (compareResult < 0)
+                            postExprResult = false;
+                        else
+                            postExprResult = true;
+                    } 
+                    else if (operation.equalsIgnoreCase(">")) 
+                    {
+                        if (compareResult <= 0)
+                            postExprResult = false;
+                        else
+                            postExprResult = true;
+                    } 
+                    else if (operation.equalsIgnoreCase("<")) 
+                    {
+                        if (compareResult >= 0)
+                            postExprResult = false;
+                        else
+                            postExprResult = true;
+                    } 
+                    else if (operation.equalsIgnoreCase("<=")) 
+                    {
+                        if (compareResult > 0)
+                            postExprResult = false;
+                        else
+                            postExprResult = true;
+                    } 
+                    else 
+                    {
+                        logger
+                                .severe(Thread.currentThread().getName()
+                                        + " "
+                                        + "operation did not match any of the standard expressions
"
+                                        + operation);
 
+                    }
+                }
+                //System.out.println("AnchorMethodInvokeAction returning  "+postExprResult);
+                return postExprResult;
+            }
+        } 
+        catch (SPLException e) 
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        logger.exiting(sourceClass, Thread.currentThread().getName() + " "
+                + "execute");
+        return false;
     }
 
-    public static Object invokeClassMethod(SPLSymbolTable symTab, 
-            String className, 
-            String qualifier, 
-            String methodName, 
-            List paramList, 
-            Object targetObject)
+    public static Object invokeClassMethod(SPLSymbolTable symTab,
+            String className, String qualifier, String methodName,
+            List paramList, Object targetObject) 
     {
-        List parameterObjects = new ArrayList();     
+        List parameterObjects = new ArrayList();
 
-        try
+        try 
         {
 
-            MethodSymbol methodSym = 
-                (MethodSymbol)symTab.getSymbol(className + "." + methodName);
+            MethodSymbol methodSym = (MethodSymbol) symTab.getSymbol(className
+                    + "." + methodName);
             List argTypeList = methodSym.getArgumentList();
 
-
-
-            for (int i = 0; i < paramList.size(); i++)
+            for (int i = 0; i < paramList.size(); i++) 
             {
                 Expression exp = (Expression) paramList.get(i);
 
-                if(exp instanceof AssignmentExpression)
-                {
+                if (exp instanceof AssignmentExpression) {
                     //System.out.println("assignment Expression");
                     Expression lhsExpression = null;
                     Expression rhsExpression = null;
 
-
                     AssignmentExpression assignmentExpression = (AssignmentExpression) exp;
-                    if (assignmentExpression.getLHSExpression() instanceof org.apache.imperius.spl.external.Expression)
+                    if (assignmentExpression.getLHSExpression() instanceof org.apache.imperius.spl.external.Expression)

                     {
                         lhsExpression = (Expression) assignmentExpression
-                        .getLHSExpression();
+                                .getLHSExpression();
                     }
-                    if (assignmentExpression.getRHSExpression() instanceof org.apache.imperius.spl.external.Expression)
-                    {
+                    if (assignmentExpression.getRHSExpression() instanceof org.apache.imperius.spl.external.Expression)
{
                         rhsExpression = (Expression) assignmentExpression
-                        .getRHSExpression();
+                                .getRHSExpression();
                     }
-                    if ((lhsExpression == null) || (rhsExpression == null))
+                    if ((lhsExpression == null) || (rhsExpression == null)) 
                     {
-                        logger.severe("LHS or RHS or argument in method call is null : "+lhsExpression.toString()+"
"+rhsExpression);
-
-                        throw new SPLException("LHS or RHS or argument in method call is
null : "+lhsExpression.toString()+" "+rhsExpression);
+                        logger
+                                .severe("LHS or RHS or argument in method call is null :
"
+                                        + lhsExpression.toString()
+                                        + " "
+                                        + rhsExpression);
+
+                        throw new SPLException(
+                                "LHS or RHS or argument in method call is null : "
+                                        + lhsExpression.toString() + " "
+                                        + rhsExpression);
 
                     }
                     //System.out.println("lhsExpression class "+ lhsExpression.getClass());
@@ -189,22 +314,26 @@
                     // ((PrimaryExpression)lhsExpression).getPropertyName();
 
                     String keyName = ((PrimaryExpression) lhsExpression)
-                    .getclassNameOrInstanceVariableName();
+                            .getclassNameOrInstanceVariableName();
                     //System.out.println("argument name= " + keyName);
 
                     Object keyValue = rhsExpression.evaluate();
                     //System.out.println("argument value= " + keyValue);
 
-                    String referenceTypeName=""; 
+                    String referenceTypeName = "";
 
-                    if(TypeResolver.isReference(rhsExpression.getType()))
-                    {   
+                    if (TypeResolver.isReference(rhsExpression.getType())) 
+                    {
 
-                        referenceTypeName = rhsExpression.getType().getReferenceTypeName();
+                        referenceTypeName = rhsExpression.getType()
+                                .getReferenceTypeName();
                     }
 
-                    if(keyValue!= null){
-                        Argument arg=new ArgumentImpl(rhsExpression.getType().getType(),
keyName, rhsExpression.isArray(), referenceTypeName);
+                    if (keyValue != null) 
+                    {
+                        Argument arg = new ArgumentImpl(rhsExpression.getType()
+                                .getType(), keyName, rhsExpression.isArray(),
+                                referenceTypeName);
                         arg.setValue(keyValue);
                         //System.out.println("created new arg :"+keyName+" "+keyValue.toString());
                         /*
@@ -214,220 +343,46 @@
                         parameterObjects.add(arg);
                     }
 
-                }
-                else
+                } 
+                else 
                 {
                     //System.out.println("argument is not an assignment Expression");
 
                     Object result = exp.evaluate();
-                    Argument arg=new ArgumentImpl(exp.getType().getType(), null, exp.isArray(),
null);
+                    Argument arg = new ArgumentImpl(exp.getType().getType(),
+                            null, exp.isArray(), null);
                     arg.setValue(result);
                     parameterObjects.add(arg);
-                } 
+                }
 
-            }    
+            }
 
             Actuator ac = ActuatorFactory.getActuator();
 
             Object result = ac.invokeMethod(className, qualifier, targetObject,
                     methodName, parameterObjects);
 
-
-
             //System.out.println("method invokation complete : "+className+" "+qualifier+"
"+methodName+" "+targetObject);
             //System.out.println("method invokation result of invokation : "+result);
 
             // TO DO COMPARE RESULT WITH CONSTANT
 
-            if(result == null)
+            if (result == null)
                 result = "";
 
             return result;
-        }
-        catch (SPLException e)
+        } 
+        catch (SPLException e) 
         {
             e.printStackTrace();
             logger.severe(e.getMessage());
 
-            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "execute");
+            logger.exiting(sourceClass, Thread.currentThread().getName() + " "
+                    + "execute");
 
             return null;
         }
 
     }
 
-    public boolean execute(Actuator ac)
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "execute");
-        boolean postExprResult=false;
-        Object instance = _symTab.getInstance(_optClassName);
-        String qualifier = _symTab.getQualifierForClass(_optClassName);
-        Object result = invokeClassMethod(_symTab,_optClassName, qualifier, _methodName,_pList,instance);
-        
-        if(result != null )
-        {
-            if(_constantExpression == null)
-            {   
-                postExprResult = true;
-            }
-            else
-            {   
-                Expression constexpr=this._constantExpression;
-                Object constresult;
-                int compareResult=0;
-                try{
-                    constresult=constexpr.evaluate();
-                    compareResult=ExpressionUtility.compare(result, constresult);
-                }
-                catch(SPLException e){
-                    e.printStackTrace();
-                    logger.severe(Thread.currentThread().getName()+" "+e.getMessage());
-                    
-                }
-                String operation=this._operatorType;
-                if(operation.equalsIgnoreCase("==")){
-                    if(compareResult!=0)
-                        postExprResult=false;
-                    else
-                        postExprResult=true;
-                }
-                else if(operation.equalsIgnoreCase("!=")){
-                    if(compareResult==0)
-                        postExprResult=false;
-                    else
-                        postExprResult=true;
-                }
-                else if(operation.equalsIgnoreCase(">=")){
-                    if(compareResult < 0)
-                        postExprResult=false;
-                    else
-                        postExprResult=true;
-                }
-                else if(operation.equalsIgnoreCase(">")){
-                    if(compareResult <= 0)
-                        postExprResult=false;
-                    else
-                        postExprResult=true;
-                }
-                else if(operation.equalsIgnoreCase("<")){
-                    if(compareResult >= 0)
-                        postExprResult=false;
-                    else
-                        postExprResult=true;
-                }
-                else if(operation.equalsIgnoreCase("<=")){
-                    if(compareResult > 0)
-                        postExprResult=false;
-                    else
-                        postExprResult=true;
-                }
-                else {
-                    logger.severe(Thread.currentThread().getName()+" "+"operation did not
match any of the standard expressions "+operation);
-                    
-                }
-            }   
-            //System.out.println("AnchorMethodInvokeAction returning  "+postExprResult);
-            return postExprResult;
-        }
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "execute");
-        return false;
-
-    }
-
-    public String getMethodName()
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getMethodName");
-
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getMethodName");
-
-        return _methodName;
-    }
-
-    public void setMethodName(String methodName)
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setMethodName");
-
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setMethodName");
-
-        _methodName = methodName;
-    }
-
-    public String getOptClassName()
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getOptClassName");
-
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getOptClassName");
-
-        return _optClassName;
-    }
-
-    public void setOptClassName(String optClassName)
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setOptClassName");
-
-        _optClassName = optClassName;
-
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setOptClassName");
-
-    }
-
-    public List 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 Expression getConstantExpression()
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getConstantExpression");
-
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getConstantExpression");
-
-        return _constantExpression;
-    }
-
-    public void setConstantExpression(Expression constantExpression)
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setConstantExpression");
-
-        _constantExpression = constantExpression;
-
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setConstantExpression");
-
-    }
-
-    public String getOperatorType()
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getOperatorType");
-
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getOperatorType");
-
-        return _operatorType;
-    }
-
-    public void setOperatorType(String operatorType)
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setOperatorType");
-
-        _operatorType = operatorType;
-
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setOperatorType");
-
-    }
-
-
-
-}
+}
\ No newline at end of file

Modified: incubator/imperius/trunk/javaspl-samples/resources/samples/simple/policies/AccessPrivateVariablesSample.spl
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/javaspl-samples/resources/samples/simple/policies/AccessPrivateVariablesSample.spl?rev=678422&r1=678421&r2=678422&view=diff
==============================================================================
--- incubator/imperius/trunk/javaspl-samples/resources/samples/simple/policies/AccessPrivateVariablesSample.spl
(original)
+++ incubator/imperius/trunk/javaspl-samples/resources/samples/simple/policies/AccessPrivateVariablesSample.spl
Mon Jul 21 07:03:47 2008
@@ -37,6 +37,6 @@
 	}
 	Decision 
 	{   
-		te.privateVariable(5)
+		te.scObj.setSampleClassProperty1(7)
 	}
 }:1;



Mime
View raw message