incubator-imperius-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jnee...@apache.org
Subject svn commit: r669905 - in /incubator/imperius/trunk: imperius-javaspl/src/main/java/org/apache/imperius/javaspl/ imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/ imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statem...
Date Fri, 20 Jun 2008 14:11:40 GMT
Author: jneeraj
Date: Fri Jun 20 07:11:40 2008
New Revision: 669905

URL: http://svn.apache.org/viewvc?rev=669905&view=rev
Log:
Commited changes for IMPERIUS-8 - Cascaded policy invocation changes by Naidu J

Added:
    incubator/imperius/trunk/javaspl-samples/resources/samples/simple/policies/AccessPrivateVariablesSample.spl
Modified:
    incubator/imperius/trunk/imperius-javaspl/src/main/java/org/apache/imperius/javaspl/JavaActuatorImpl.java
    incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/IdentPrimaryTuple.java
    incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/actions/impl/AnchorMethodInvokeAction.java
    incubator/imperius/trunk/javaspl-samples/src/main/java/org/apache/imperius/javaspl/samples/simplepolicies/RunSamples.java
    incubator/imperius/trunk/javaspl-samples/src/main/java/org/apache/imperius/javaspl/samples/simplepolicies/TestElement.java

Modified: incubator/imperius/trunk/imperius-javaspl/src/main/java/org/apache/imperius/javaspl/JavaActuatorImpl.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-javaspl/src/main/java/org/apache/imperius/javaspl/JavaActuatorImpl.java?rev=669905&r1=669904&r2=669905&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-javaspl/src/main/java/org/apache/imperius/javaspl/JavaActuatorImpl.java (original)
+++ incubator/imperius/trunk/imperius-javaspl/src/main/java/org/apache/imperius/javaspl/JavaActuatorImpl.java Fri Jun 20 07:11:40 2008
@@ -46,167 +46,200 @@
 
 public class JavaActuatorImpl implements Actuator {
 
-	//private static final String sourceClass="JavaActuatorImpl";
-	//private static Logger logger = SPLLogger.getCIMSPLLogger().getLogger();
+    //private static final String sourceClass="JavaActuatorImpl";
+    //private static Logger logger = SPLLogger.getCIMSPLLogger().getLogger();
 
-	private URL[] fUrls = null;
-	
-	public JavaActuatorImpl() {
-		
-	}
-	
-	public JavaActuatorImpl(URL[] urls) {
-		fUrls = urls;
-	}
-	
-	
-	/**
-	 * Invokes the given method on the given instance 
-	 */
-	public Object invokeMethod(String className, String qualifier,
-			Object instance, String methodName, List arguments)	throws SPLException {
-		Class c;
-		Object result = null;
-		try {
-			// Load class
-			
-			//c = Class.forName(instance.getClass().getName());
-			
-			// modified by naidu to enable URL class loading
-			if(fUrls == null) {
-				c = Class.forName(instance.getClass().getName());
-			} else {
-				URLClassLoader uc = new URLClassLoader(fUrls);
-				c = uc.loadClass(instance.getClass().getName());
-			}
-			
-
-			// Get an array of formal parameter class types
-			Class[] arrayOfParameterTypes = _getParameterTypeArray(arguments);
-
-			// Load the method using reflection
-			Method method = c.getMethod(methodName, arrayOfParameterTypes);
-
-			// If No. of formal params > 0
-			if (arguments.size() != 0) {
-				List paramValues = new ArrayList();
-				Iterator it = arguments.iterator();
-				// Iterate over the passed parameters
-				while (it.hasNext()) {
-					Argument arg = (Argument) it.next();
-					//Add the values of the passed parameters to a list
-					paramValues.add(arg.getValue());
-				}
-
-				// Convert list to an array
-				Object[] arrayOfParameters = paramValues.toArray();
-
-				// Invoke the method on the passed object
-				result = method.invoke(instance, arrayOfParameters);
-			} else {
-				Object[] arrayOfParameters = new Object[0];
-				result = method.invoke(instance, arrayOfParameters);
-			}
-		} catch (ClassNotFoundException e) {
-			throw new SPLException(e.getMessage());
-		} catch (SecurityException e) {
-			throw new SPLException(e.getMessage());
-		} catch (NoSuchMethodException e) {
-			throw new SPLException(e.getMessage());
-		} catch (IllegalArgumentException e) {
-			throw new SPLException(e.getMessage());
-		} catch (IllegalAccessException e) {
-			throw new SPLException(e.getMessage());
-		} catch (InvocationTargetException e) {
-			throw new SPLException(e.getMessage());
-		}
-		return result;
-	}
-
-	/**
-	 * @param className : fully qualified name of the class whoose instance is to be modified
-	 * @param instance : instance to be modified
-	 * @param memberMap: A map of the form (String member Name ->  Object value to be set to)
-	 * 
-	 */
-
-	public void modifyInstance(String className, String qualifier,
-			Object instance, Map memberMap) throws SPLException {
-		Class c;
-		try {
-			// Load class
-			//c = Class.forName(className);
-			
-			// modified by naidu to enable URL class loading
-			if(fUrls == null) {
-				c = Class.forName(className);
-			} else {
-				URLClassLoader uc = new URLClassLoader(fUrls);
-				c = uc.loadClass(className);
-			}
-
-			// Iterate over the property map for the instance
-			Iterator keyIt = memberMap.keySet().iterator();
-			while (keyIt.hasNext()) {
-				String propName = (String) keyIt.next();
-				// Retrieve value of the property
-				Object value = memberMap.get(propName);
-
-				// Load field
-				Field member = c.getField(propName);
-
-				// Set the value of the field
-				member.set(instance, value);
-
-			}
-		} catch (ClassNotFoundException e) {
-			throw new SPLException(e.getMessage());
-
-		} catch (SecurityException e) {
-			throw new SPLException(e.getMessage());
-		} catch (NoSuchFieldException e) {
-			throw new SPLException(e.getMessage());
-		} catch (IllegalArgumentException e) {
-			throw new SPLException(e.getMessage());
-		} catch (IllegalAccessException e) {
-			throw new SPLException(e.getMessage());
-		}
-
-	}
-
-	/**
-	 * Iterate over the list of Argument objects to retrieve an
-	 * array of the class types
-	 * @param inParameterList
-	 * @return
-	 * @throws SPLException 
-	 */
-
-	private Class[] _getParameterTypeArray(List inParameterList)
-			throws SPLException {
-		int listSize = inParameterList.size();
-		int i = 0;
-		Class[] paramTypeArray = new Class[listSize];
-		try {
-			Iterator it = inParameterList.iterator();
-			// Iterate over the arguments
-			while (it.hasNext()) {
-				Argument arg = (Argument) it.next();
-				TypeInfo tp = arg.getType();
-				boolean isArray = arg.getIsArray();
-				String referenceName = arg.getReferenceTypeName();
-
-				// convert internal type to java type
-				Class c = JavaSPLTypeConstants.convertInternalTypeToJavaType(tp.getType(), isArray, referenceName);
-
-				// Add to array
-				paramTypeArray[i++] = c;
-			}
-		} catch (ClassNotFoundException e) {
-			e.printStackTrace();
-			throw new SPLException(e.getMessage());
-		}
-		return paramTypeArray;
-	}
+    private URL[] fUrls = null;
+    
+    public JavaActuatorImpl() {
+        
+    }
+    
+    public JavaActuatorImpl(URL[] urls) {
+        fUrls = urls;
+    }
+    
+    
+    /**
+     * Invokes the given method on the given instance 
+     */
+    public Object invokeMethod(String className, String qualifier,
+            Object instance, String methodName, List arguments) throws SPLException {
+        Class c;
+        Object result = null;
+        try {
+            // Load class
+            
+            //c = Class.forName(instance.getClass().getName());
+            
+            // modified by naidu to enable URL class loading
+            if(fUrls == null) {
+                c = Class.forName(instance.getClass().getName());
+            } else {
+                URLClassLoader uc = new URLClassLoader(fUrls);
+                c = uc.loadClass(instance.getClass().getName());
+            }
+            
+
+            // Get an array of formal parameter class types
+            Class[] arrayOfParameterTypes = _getParameterTypeArray(arguments);
+
+            // Load the method using reflection
+            Method method = c.getMethod(methodName, arrayOfParameterTypes);
+
+            // If No. of formal params > 0
+            if (arguments.size() != 0) {
+                List paramValues = new ArrayList();
+                Iterator it = arguments.iterator();
+                // Iterate over the passed parameters
+                while (it.hasNext()) {
+                    Argument arg = (Argument) it.next();
+                    //Add the values of the passed parameters to a list
+                    paramValues.add(arg.getValue());
+                }
+
+                // Convert list to an array
+                Object[] arrayOfParameters = paramValues.toArray();
+
+                // Invoke the method on the passed object
+                result = method.invoke(instance, arrayOfParameters);
+            } else {
+                Object[] arrayOfParameters = new Object[0];
+                result = method.invoke(instance, arrayOfParameters);
+            }
+        } catch (ClassNotFoundException e) {
+            throw new SPLException(e.getMessage());
+        } catch (SecurityException e) {
+            throw new SPLException(e.getMessage());
+        } catch (NoSuchMethodException e) {
+            throw new SPLException(e.getMessage());
+        } catch (IllegalArgumentException e) {
+            throw new SPLException(e.getMessage());
+        } catch (IllegalAccessException e) {
+            throw new SPLException(e.getMessage());
+        } catch (InvocationTargetException e) {
+            throw new SPLException(e.getMessage());
+        }
+        return result;
+    }
+
+    /**
+     * @param className : fully qualified name of the class whoose instance is to be modified
+     * @param instance : instance to be modified
+     * @param memberMap: A map of the form (String member Name ->  Object value to be set to)
+     * 
+     */
+
+    public void modifyInstance(String className, String qualifier,
+            Object instance, Map memberMap) throws SPLException {
+        Class c;
+        try {
+            // Load class
+            //c = Class.forName(className);
+            
+            // modified by naidu to enable URL class loading
+            if(fUrls == null) {
+                c = Class.forName(className);
+            } else {
+                URLClassLoader uc = new URLClassLoader(fUrls);
+                c = uc.loadClass(className);
+            }
+
+            // Iterate over the property map for the instance
+            Iterator keyIt = memberMap.keySet().iterator();
+            while (keyIt.hasNext()) {
+                String propName = (String) keyIt.next();
+                // Retrieve value of the property
+                Object value = memberMap.get(propName);
+
+                try
+                {
+                    // Load field
+                    Field member = c.getField(propName);
+                    
+                    // Set the value of the field
+                    member.set(instance, value);
+                }
+                catch (NoSuchFieldException e) 
+                {
+                    boolean isMethodExists = false;
+                    Method[] classMethods = c.getMethods();
+                    if (classMethods != null) {
+                        for (int i = 0; i < classMethods.length; i++) 
+                        {
+                            if (classMethods[i].getName().equals(
+                                    getAccessorMethodName(propName))) 
+                            {
+                                isMethodExists = true;
+                                classMethods[i].invoke(instance,
+                                        new Object[] { value });
+                                break;
+                            }
+                        }
+                        if (!isMethodExists)
+                            throw new NoSuchMethodException();
+                    }
+                }
+            }
+        } catch (ClassNotFoundException e) {
+            throw new SPLException(e.getMessage());
+        } catch (SecurityException e) {
+            throw new SPLException(e.getMessage());
+        } catch(NoSuchMethodException e) {
+            throw new SPLException(e.getMessage());
+        } catch(InvocationTargetException e) {
+            throw new SPLException(e.getMessage());
+        } catch (IllegalArgumentException e) {
+            throw new SPLException(e.getMessage());
+        } catch (IllegalAccessException e) {
+            throw new SPLException(e.getMessage());
+        }
+
+    }
+
+    /**
+     * Iterate over the list of Argument objects to retrieve an
+     * array of the class types
+     * @param inParameterList
+     * @return
+     * @throws SPLException 
+     */
+
+    private Class[] _getParameterTypeArray(List inParameterList)
+            throws SPLException {
+        int listSize = inParameterList.size();
+        int i = 0;
+        Class[] paramTypeArray = new Class[listSize];
+        try {
+            Iterator it = inParameterList.iterator();
+            // Iterate over the arguments
+            while (it.hasNext()) {
+                Argument arg = (Argument) it.next();
+                TypeInfo tp = arg.getType();
+                boolean isArray = arg.getIsArray();
+                String referenceName = arg.getReferenceTypeName();
+
+                // convert internal type to java type
+                Class c = JavaSPLTypeConstants.convertInternalTypeToJavaType(tp.getType(), isArray, referenceName);
+
+                // Add to array
+                paramTypeArray[i++] = c;
+            }
+        } catch (ClassNotFoundException e) {
+            e.printStackTrace();
+            throw new SPLException(e.getMessage());
+        }
+        return paramTypeArray;
+    }
+    
+    private String getAccessorMethodName(String identifier)
+    {
+        if(Character.isLetter(identifier.charAt(0)))
+        {
+            identifier = Character.toUpperCase(identifier.charAt(0)) + identifier.substring(1);
+        }
+        identifier = "set"+identifier;
+        return identifier;
+    }
 
 }

Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/IdentPrimaryTuple.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/IdentPrimaryTuple.java?rev=669905&r1=669904&r2=669905&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/IdentPrimaryTuple.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/IdentPrimaryTuple.java Fri Jun 20 07:11:40 2008
@@ -47,49 +47,49 @@
 
 public class IdentPrimaryTuple 
 {
-	private Expression _arrExp = null;
+    private Expression _arrExp = null;
     private List _paramList ;
     private String _identifier = "";
     private boolean _isMethod = false;
-	private SPLSymbolTable _symbolTable;
-	private String _classType = null;
+    private SPLSymbolTable _symbolTable;
+    private String _classType = null;
     
     public IdentPrimaryTuple(Expression arrExp, 
-    		List paramList, String id, boolean isMethod,
-    		SPLSymbolTable sTab)
+            List paramList, String id, boolean isMethod,
+            SPLSymbolTable sTab)
     {
-    	_arrExp = arrExp;
-    	_paramList = paramList;
-    	_identifier = id;
-    	_isMethod = isMethod;
-    	_symbolTable = sTab;
-    	
+        _arrExp = arrExp;
+        _paramList = paramList;
+        _identifier = id;
+        _isMethod = isMethod;
+        _symbolTable = sTab;
+        
     }
     
     public String getPropertyName()
     {
-    	return _identifier;
+        return _identifier;
     }
     
     public void setSymbolTable(SPLSymbolTable spt)
     {
-    	_symbolTable = spt;
+        _symbolTable = spt;
     }
     // no input object means that the symbol table already has anchor object
     // populated
     public Object evaluate() throws SPLException
     {
-    	Object returnValue = null;
-    	Object instance = _symbolTable.getInstance(_classType);
+        Object returnValue = null;
+        Object instance = _symbolTable.getInstance(_classType);
         String qualifier = _symbolTable.getQualifierForClass(_classType);
-    	if(_isMethod)
-    	{
-    		returnValue = AnchorMethodInvokeAction.invokeClassMethod(_symbolTable, 
-    		_classType, qualifier, _identifier, _paramList,instance);
-    	}
-    	else
-    	{
-    	    Symbol sym = null;
+        if(_isMethod)
+        {
+            returnValue = AnchorMethodInvokeAction.invokeClassMethod(_symbolTable, 
+            _classType, qualifier, _identifier, _paramList,instance);
+        }
+        else
+        {
+            Symbol sym = null;
             try
             {
                 sym =  _symbolTable.getSymbol(_classType + "." + _identifier);
@@ -97,45 +97,65 @@
             } 
             catch(SPLException splex) 
             {
-                String accessorMethodName = getAccessorMethodName(_identifier);
-                sym =  _symbolTable.getSymbol(_classType + "." + accessorMethodName);
-                returnValue = AnchorMethodInvokeAction.invokeClassMethod(_symbolTable, 
-                        _classType, qualifier, accessorMethodName, _paramList,instance);
-            }    	}
-    	
-    	
-    	return returnValue;
-    	
+                String accessorMethodName = getAccessorMethodName(_identifier, "get");
+                try
+                {
+                    sym =  _symbolTable.getSymbol(_classType + "." + accessorMethodName);
+                }
+                catch(SPLException splex1)
+                {
+                    accessorMethodName = getAccessorMethodName(_identifier, "is");
+                    try
+                    {
+                        sym =  _symbolTable.getSymbol(_classType + "." + accessorMethodName);
+                    }
+                    catch(SPLException splex2)
+                    {
+                        throw new SPLException("Symbol does not exist "
+                                + _classType + "." + _identifier
+                                + "Or it can be a private variable without"
+                                + "getter and setter methods");
+                    }
+                }
+                returnValue = AnchorMethodInvokeAction.invokeClassMethod(
+                        _symbolTable, _classType, qualifier,
+                        accessorMethodName, _paramList, instance);
+            }       
+        }
+        
+        
+        return returnValue;
+        
     }
     public Object evaluate(Object parentObject) throws SPLException
     {
-    	Object returnValue = null;
-    	
-    	DataCollector dc = DataCollectorFactory.getDataCollector();
-    	String qualifier = _symbolTable.getQualifierForClass(_classType);
-		Map symbolsofInstance = dc.getSymbolsForInstance(_classType,
-				qualifier,
-				parentObject);
-		Map instanceMap = new HashMap();
-		instanceMap.put(_classType, parentObject);
-		_symbolTable.populateInstanceValuesForInstance(_classType, 
-				_classType, 
-				parentObject, 
-				symbolsofInstance);
-    	
-		// Symbol sym = _symbolTable.getSymbol(_classType + "." + _identifier);
-		
-    	//_symbolTable.setAnchors(mapOfAnchorClassToInstance);
-    	if(_isMethod)
-    	{
-    	
-    		returnValue = AnchorMethodInvokeAction.invokeClassMethod(_symbolTable, 
-    		_classType, qualifier, _identifier, _paramList, parentObject);
-    	}
-    	else
-    	{
-    		
-    	    Symbol sym = null;
+        Object returnValue = null;
+        
+        DataCollector dc = DataCollectorFactory.getDataCollector();
+        String qualifier = _symbolTable.getQualifierForClass(_classType);
+        Map symbolsofInstance = dc.getSymbolsForInstance(_classType,
+                qualifier,
+                parentObject);
+        Map instanceMap = new HashMap();
+        instanceMap.put(_classType, parentObject);
+        _symbolTable.populateInstanceValuesForInstance(_classType, 
+                _classType, 
+                parentObject, 
+                symbolsofInstance);
+        
+        // Symbol sym = _symbolTable.getSymbol(_classType + "." + _identifier);
+        
+        //_symbolTable.setAnchors(mapOfAnchorClassToInstance);
+        if(_isMethod)
+        {
+        
+            returnValue = AnchorMethodInvokeAction.invokeClassMethod(_symbolTable, 
+            _classType, qualifier, _identifier, _paramList, parentObject);
+        }
+        else
+        {
+            
+            Symbol sym = null;
             try
             {
                 sym =  _symbolTable.getSymbol(_classType + "." + _identifier);
@@ -143,127 +163,170 @@
             } 
             catch(SPLException splex) 
             {
-                String accessorMethodName = getAccessorMethodName(_identifier);
-                sym =  _symbolTable.getSymbol(_classType + "." + accessorMethodName);
-                returnValue = AnchorMethodInvokeAction.invokeClassMethod(_symbolTable, 
-                        _classType, qualifier, accessorMethodName, _paramList,parentObject);
-            }    		
-    	}
-    	
-    	return returnValue;
-    }
-    
-	public TypeInfo validate(String classTypeOrVariableName) throws SPLException
-	{
-		TypeInfo typeInfo = new TypeInfo();
-		_classType = classTypeOrVariableName;
-		// ensure symbol table is populated
-		_populateSymbolTable(_classType);
-		
-		// Symbol sym = _symbolTable.getSymbol(classTypeOrVariableName + "." + _identifier);
-		
-		Symbol sym = null;
+                String accessorMethodName = getAccessorMethodName(_identifier, "get");
+                try
+                {
+                    sym = _symbolTable.getSymbol(_classType + "."
+                            + accessorMethodName);
+                }
+                catch(SPLException splex1)
+                {
+                    accessorMethodName = getAccessorMethodName(_identifier, "is");
+                    try
+                    {
+                        sym = _symbolTable.getSymbol(_classType + "."
+                                + accessorMethodName);
+                    }
+                    catch(SPLException splex2)
+                    {
+                        throw new SPLException("Symbol does not exist "
+                                + _classType + "." + _identifier
+                                + "Or it can be a private variable without"
+                                + "getter and setter methods");
+                    }
+                }
+                returnValue = AnchorMethodInvokeAction.invokeClassMethod(
+                        _symbolTable, _classType, qualifier,
+                        accessorMethodName, _paramList, parentObject);
+            }           
+        }
+        
+        return returnValue;
+    }
+    
+    public TypeInfo validate(String classTypeOrVariableName) throws SPLException
+    {
+        TypeInfo typeInfo = new TypeInfo();
+        _classType = classTypeOrVariableName;
+        // ensure symbol table is populated
+        _populateSymbolTable(_classType);
+        
+        // Symbol sym = _symbolTable.getSymbol(classTypeOrVariableName + "." + _identifier);
+        
+        Symbol sym = null;
         try
         {
             sym = _symbolTable.getSymbol(classTypeOrVariableName + "." + _identifier);
         } 
         catch(SPLException splex) 
         {
-            sym = _symbolTable.getSymbol(classTypeOrVariableName + "." + getAccessorMethodName(_identifier));
+            try
+            {
+                sym = _symbolTable.getSymbol(classTypeOrVariableName + "."
+                        + getAccessorMethodName(_identifier, "get"));
+            } 
+            catch(SPLException splex1)
+            {
+                try
+                {
+                    sym = _symbolTable.getSymbol(classTypeOrVariableName + "."
+                            + getAccessorMethodName(_identifier, "is"));
+                }
+                catch(SPLException splex2)
+                {
+                    throw new SPLException(
+                            "Symbol does not exist "
+                                    + classTypeOrVariableName
+                                    + "."
+                                    + _identifier
+                                    + "Or it can be a private variable without"
+                                    + "getter and setter methods");
+                }
+            }
+        }
+        
+        if(_isMethod)
+        {
+            if(sym instanceof MethodSymbol)
+            {
+                typeInfo = _validateActualParameters(sym,classTypeOrVariableName);
+                
+            }
+            else
+            {
+                throw new SPLException("Symbol " + _identifier + "is not a method");
+            }
+        }
+        else
+        {
+            TypeInfo tp = sym.getType();
+            boolean isArray = sym.isArray();
+            if(_arrExp != null) // expression is like A.b[2] which means
+            { // the result is not an array
+                isArray = false;
+            }
+            String resultClass = null;
+            if(TypeResolver.isReference(tp))
+            {
+                resultClass = sym.getReferenceTypeName();
+                typeInfo.setReferenceTypeName(resultClass);
+                typeInfo.setType(tp.getType());
+                typeInfo.setIsArray(isArray);
+            }
+            else
+            {
+                typeInfo.setType(tp.getType());
+                typeInfo.setIsArray(isArray);
+            }
+            
         }
         
-		if(_isMethod)
-		{
-			if(sym instanceof MethodSymbol)
-			{
-				typeInfo = _validateActualParameters(sym,classTypeOrVariableName);
-				
-			}
-			else
-			{
-				throw new SPLException("Symbol " + _identifier + "is not a method");
-			}
-		}
-		else
-		{
-			TypeInfo tp = sym.getType();
-			boolean isArray = sym.isArray();
-			if(_arrExp != null) // expression is like A.b[2] which means
-			{ // the result is not an array
-				isArray = false;
-			}
-			String resultClass = null;
-			if(TypeResolver.isReference(tp))
-			{
-				resultClass = sym.getReferenceTypeName();
-				typeInfo.setReferenceTypeName(resultClass);
-				typeInfo.setType(tp.getType());
-				typeInfo.setIsArray(isArray);
-			}
-			else
-			{
-				typeInfo.setType(tp.getType());
-				typeInfo.setIsArray(isArray);
-			}
-			
-		}
-		
-		
-		
-		return typeInfo;
-		
-	}
-	
-	private String getAccessorMethodName(String identifier)
+        
+        
+        return typeInfo;
+        
+    }
+    
+    private String getAccessorMethodName(String identifier, String setOrGetOrIs)
     {
         if(Character.isLetter(identifier.charAt(0)))
         {
             identifier = Character.toUpperCase(identifier.charAt(0)) + identifier.substring(1);
         }
-        identifier = "get"+identifier;
+        identifier = setOrGetOrIs+identifier;
         return identifier;
     }
 
-	private TypeInfo _validateActualParameters(Symbol sym, 
-			String classType) throws SPLException
-	{
-		TypeInfo returnTypeInfo = new TypeInfo();
-		String returnClassName = null;
-		AnchorMethodInvokeAction.validateActualParameters(_symbolTable,
-	    		classType, _identifier, _paramList);
-		TypeInfo returnType = sym.getType();
-		boolean isArray = sym.isArray();
-		if(TypeResolver.isReference(returnType))
-		{
-			returnClassName = sym.getReferenceTypeName();
-			returnTypeInfo.setIsArray(isArray);
-			returnTypeInfo.setReferenceTypeName(returnClassName);
-			returnTypeInfo.setType(returnType.getType());
-			
-		}
-		else
-		{
-			returnTypeInfo.setIsArray(isArray);
-			returnTypeInfo.setType(returnType.getType());
-		}
-		return returnTypeInfo;
-		
-			
-		
-	}
+    private TypeInfo _validateActualParameters(Symbol sym, 
+            String classType) throws SPLException
+    {
+        TypeInfo returnTypeInfo = new TypeInfo();
+        String returnClassName = null;
+        AnchorMethodInvokeAction.validateActualParameters(_symbolTable,
+                classType, _identifier, _paramList);
+        TypeInfo returnType = sym.getType();
+        boolean isArray = sym.isArray();
+        if(TypeResolver.isReference(returnType))
+        {
+            returnClassName = sym.getReferenceTypeName();
+            returnTypeInfo.setIsArray(isArray);
+            returnTypeInfo.setReferenceTypeName(returnClassName);
+            returnTypeInfo.setType(returnType.getType());
+            
+        }
+        else
+        {
+            returnTypeInfo.setIsArray(isArray);
+            returnTypeInfo.setType(returnType.getType());
+        }
+        return returnTypeInfo;
+        
+            
+        
+    }
 
-	private void _populateSymbolTable(String classType) throws SPLException 
-	{
-		String qualifierName = null;
-		if(_symbolTable.getAnchorData() == null)
-		{
-			List instanceInfoList = new ArrayList();
-			instanceInfoList.add(new InstanceInfo(classType, new Object()));
-			_symbolTable.addAnchor(classType,qualifierName,instanceInfoList);
-			
-		}
-		
-	}
+    private void _populateSymbolTable(String classType) throws SPLException 
+    {
+        String qualifierName = null;
+        if(_symbolTable.getAnchorData() == null)
+        {
+            List instanceInfoList = new ArrayList();
+            instanceInfoList.add(new InstanceInfo(classType, new Object()));
+            _symbolTable.addAnchor(classType,qualifierName,instanceInfoList);
+            
+        }
+        
+    }
     
 
 }

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=669905&r1=669904&r2=669905&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 Fri Jun 20 07:11:40 2008
@@ -50,382 +50,383 @@
 
 public class AnchorMethodInvokeAction implements BasicActionBlock
 {
-	private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
 
-	private static final String sourceClass="MethodInvokeAction";
+    private static final String sourceClass="MethodInvokeAction";
 
-	private String _optClassName;
+    private String _optClassName;
 
-	private String _methodName;
+    private String _methodName;
 
-	private SPLSymbolTable _symTab;
-
-	private List _pList;
-
-	private String _operatorType;
-
-	private Expression _constantExpression;
-
-
-
-	// 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
-			{
-		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "MethodInvokeAction");
-
-
-		//System.out.println("creating MethodInvokeAction block " + optClassName+ " " + methodName);
-		_optClassName = optClassName;
-		_methodName = methodName;
-		_pList = paramList;
-		_symTab = symTab;
-		if ((op != null) && (op != ""))
-		{
-			_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
-			{
-
-		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())
-			{
-				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);
-				}	
-
-			}	
-		}
-		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);
-		}	
-
-
-			}
-
-	private void _validate() throws SPLException
-	{
-
-		validateActualParameters(_symTab,_optClassName,_methodName,_pList);
-
-	}
-
-	public static Object invokeClassMethod(SPLSymbolTable symTab, 
-			String className, 
-			String qualifier, 
-			String methodName, 
-			List paramList, 
-			Object targetObject)
-	{
-		List parameterObjects = new ArrayList();     
-
-		try
-		{
-
-			MethodSymbol methodSym = 
-				(MethodSymbol)symTab.getSymbol(className + "." + methodName);
-			List argTypeList = methodSym.getArgumentList();
-
-
-
-			for (int i = 0; i < paramList.size(); i++)
-			{
-				Expression exp = (Expression) paramList.get(i);
-
-				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)
-					{
-						lhsExpression = (Expression) assignmentExpression
-						.getLHSExpression();
-					}
-					if (assignmentExpression.getRHSExpression() instanceof org.apache.imperius.spl.external.Expression)
-					{
-						rhsExpression = (Expression) assignmentExpression
-						.getRHSExpression();
-					}
-					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);
-
-					}
-					//System.out.println("lhsExpression class "+ lhsExpression.getClass());
-					//System.out.println("lhsExpression getPropertyName() "+ ((PrimaryExpression) lhsExpression).getPropertyName());
-					// ((PrimaryExpression)lhsExpression).getPropertyName();
-
-					String keyName = ((PrimaryExpression) lhsExpression)
-					.getclassNameOrInstanceVariableName();
-					//System.out.println("argument name= " + keyName);
-
-					Object keyValue = rhsExpression.evaluate();
-					//System.out.println("argument value= " + keyValue);
-
-					String referenceTypeName=""; 
-
-					if(TypeResolver.isReference(rhsExpression.getType()))
-					{	
-
-						referenceTypeName = rhsExpression.getType().getReferenceTypeName();
-					}
-
-					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());
-						/*
-						 * Expression expression=(Expression)pList.get(i); String
-						 * nameAndValue=(String)expression.evaluate(); Key
-						 */
-						parameterObjects.add(arg);
-					}
-
-				}
-				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);
-					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
-
-
-
-			return result;
-		}
-		catch (SPLException e)
-		{
-			e.printStackTrace();
-			logger.severe(e.getMessage());
-
-			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");
+    private SPLSymbolTable _symTab;
+
+    private List _pList;
+
+    private String _operatorType;
+
+    private Expression _constantExpression;
+
+
+
+    // 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
+            {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "MethodInvokeAction");
+
+
+        //System.out.println("creating MethodInvokeAction block " + optClassName+ " " + methodName);
+        _optClassName = optClassName;
+        _methodName = methodName;
+        _pList = paramList;
+        _symTab = symTab;
+        if ((op != null) && (op != ""))
+        {
+            _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
+            {
+
+        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())
+            {
+                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);
+                }   
+
+            }   
+        }
+        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);
+        }   
+
+
+            }
+
+    private void _validate() throws SPLException
+    {
+
+        validateActualParameters(_symTab,_optClassName,_methodName,_pList);
+
+    }
+
+    public static Object invokeClassMethod(SPLSymbolTable symTab, 
+            String className, 
+            String qualifier, 
+            String methodName, 
+            List paramList, 
+            Object targetObject)
+    {
+        List parameterObjects = new ArrayList();     
+
+        try
+        {
+
+            MethodSymbol methodSym = 
+                (MethodSymbol)symTab.getSymbol(className + "." + methodName);
+            List argTypeList = methodSym.getArgumentList();
+
+
+
+            for (int i = 0; i < paramList.size(); i++)
+            {
+                Expression exp = (Expression) paramList.get(i);
+
+                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)
+                    {
+                        lhsExpression = (Expression) assignmentExpression
+                        .getLHSExpression();
+                    }
+                    if (assignmentExpression.getRHSExpression() instanceof org.apache.imperius.spl.external.Expression)
+                    {
+                        rhsExpression = (Expression) assignmentExpression
+                        .getRHSExpression();
+                    }
+                    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);
+
+                    }
+                    //System.out.println("lhsExpression class "+ lhsExpression.getClass());
+                    //System.out.println("lhsExpression getPropertyName() "+ ((PrimaryExpression) lhsExpression).getPropertyName());
+                    // ((PrimaryExpression)lhsExpression).getPropertyName();
+
+                    String keyName = ((PrimaryExpression) lhsExpression)
+                    .getclassNameOrInstanceVariableName();
+                    //System.out.println("argument name= " + keyName);
+
+                    Object keyValue = rhsExpression.evaluate();
+                    //System.out.println("argument value= " + keyValue);
+
+                    String referenceTypeName=""; 
+
+                    if(TypeResolver.isReference(rhsExpression.getType()))
+                    {   
+
+                        referenceTypeName = rhsExpression.getType().getReferenceTypeName();
+                    }
+
+                    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());
+                        /*
+                         * Expression expression=(Expression)pList.get(i); String
+                         * nameAndValue=(String)expression.evaluate(); Key
+                         */
+                        parameterObjects.add(arg);
+                    }
+
+                }
+                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);
+                    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)
+                result = "";
+
+            return result;
+        }
+        catch (SPLException e)
+        {
+            e.printStackTrace();
+            logger.severe(e.getMessage());
+
+            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;
+        _operatorType = operatorType;
 
-		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setOperatorType");
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setOperatorType");
 
-	}
+    }
 
 
 

Added: 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=669905&view=auto
==============================================================================
--- incubator/imperius/trunk/javaspl-samples/resources/samples/simple/policies/AccessPrivateVariablesSample.spl (added)
+++ incubator/imperius/trunk/javaspl-samples/resources/samples/simple/policies/AccessPrivateVariablesSample.spl Fri Jun 20 07:11:40 2008
@@ -0,0 +1,42 @@
+Import  Class org.apache.imperius.javaspl.samples.simplepolicies.TestElement:te;
+Strategy Execute_All_Applicable;
+
+Policy 
+{
+	Declaration
+	{
+    	four = 4;
+	}
+	Condition 
+	{	  
+    	te.privateVariable < four
+	}
+	Decision 
+	{   
+		Set(te.privateVariable = four) 
+	}
+}:1;
+
+Policy 
+{
+	Condition 
+	{	  
+    	te.privateBooleanVar == false
+	}
+	Decision 
+	{   
+		Set(te.privateBooleanVar = true) 
+	}
+}:1;
+
+Policy 
+{
+	Condition 
+	{	  
+    	te.scObj.sampleClassProperty1 == 0
+	}
+	Decision 
+	{   
+		te.privateVariable(5)
+	}
+}:1;

Modified: incubator/imperius/trunk/javaspl-samples/src/main/java/org/apache/imperius/javaspl/samples/simplepolicies/RunSamples.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/javaspl-samples/src/main/java/org/apache/imperius/javaspl/samples/simplepolicies/RunSamples.java?rev=669905&r1=669904&r2=669905&view=diff
==============================================================================
--- incubator/imperius/trunk/javaspl-samples/src/main/java/org/apache/imperius/javaspl/samples/simplepolicies/RunSamples.java (original)
+++ incubator/imperius/trunk/javaspl-samples/src/main/java/org/apache/imperius/javaspl/samples/simplepolicies/RunSamples.java Fri Jun 20 07:11:40 2008
@@ -30,7 +30,7 @@
 
 public class RunSamples {
     
-    public static String policyFolder = "policies/";
+    public static String policyFolder = "resources/samples/simple/policies/";
 
     /**
      * @param args
@@ -135,8 +135,8 @@
     public static void test()
     {
         String [] policiesToTest = {"SimplePolicy","ComplexPolicy",
-                "MultiplePolicySample","InvokeMethodSample","DateTime","MacroSample","SimpleInvokePolicy","InvokePolicySample"};
-            
+                "MultiplePolicySample","InvokeMethodSample","DateTime","MacroSample","SimpleInvokePolicy","InvokePolicySample","AccessPrivateVariablesSample"};
+
         for (int i=0 ; i < policiesToTest.length; i++)
         {
             String policy = policiesToTest[i];

Modified: incubator/imperius/trunk/javaspl-samples/src/main/java/org/apache/imperius/javaspl/samples/simplepolicies/TestElement.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/javaspl-samples/src/main/java/org/apache/imperius/javaspl/samples/simplepolicies/TestElement.java?rev=669905&r1=669904&r2=669905&view=diff
==============================================================================
--- incubator/imperius/trunk/javaspl-samples/src/main/java/org/apache/imperius/javaspl/samples/simplepolicies/TestElement.java (original)
+++ incubator/imperius/trunk/javaspl-samples/src/main/java/org/apache/imperius/javaspl/samples/simplepolicies/TestElement.java Fri Jun 20 07:11:40 2008
@@ -36,6 +36,8 @@
     public byte s8;
     public boolean b;
     private int privateVariable;
+    private boolean privateBooleanVar = false;
+    private SampleClass scObj = new SampleClass(2, 3);
     public SampleClass sampleClassInstance = new SampleClass(5, 10);
     
     public void setPrivateVariable(int s)
@@ -74,5 +76,21 @@
         
     }
 
+    public boolean isPrivateBooleanVar() {
+        return privateBooleanVar;
+    }
+
+    public void setPrivateBooleanVar(boolean privateBooleanVar) {
+        this.privateBooleanVar = privateBooleanVar;
+    }
+
+    public SampleClass getScObj() {
+        return scObj;
+    }
+
+    public void setScObj(SampleClass scObj) {
+        this.scObj = scObj;
+    }
+
 
 }



Mime
View raw message