incubator-imperius-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jnee...@apache.org
Subject svn commit: r663945 - /incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/IdentPrimaryTuple.java
Date Fri, 06 Jun 2008 14:06:21 GMT
Author: jneeraj
Date: Fri Jun  6 07:06:20 2008
New Revision: 663945

URL: http://svn.apache.org/viewvc?rev=663945&view=rev
Log:
Added fix for accessing private variables in anchor class using getXXX() accessor methods

Modified:
    incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/IdentPrimaryTuple.java

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=663945&r1=663944&r2=663945&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  6 07:06:20 2008
@@ -80,18 +80,28 @@
     public Object evaluate() throws SPLException
     {
     	Object returnValue = null;
+    	Object instance = _symbolTable.getInstance(_classType);
+        String qualifier = _symbolTable.getQualifierForClass(_classType);
     	if(_isMethod)
     	{
-    		Object instance = _symbolTable.getInstance(_classType);
-    		String qualifier = _symbolTable.getQualifierForClass(_classType);
     		returnValue = AnchorMethodInvokeAction.invokeClassMethod(_symbolTable, 
     		_classType, qualifier, _identifier, _paramList,instance);
     	}
     	else
     	{
-    		Symbol sym = _symbolTable.getSymbol(_classType + "." + _identifier);
-    		returnValue = sym.getValue();
-    	}
+    	    Symbol sym = null;
+            try
+            {
+                sym =  _symbolTable.getSymbol(_classType + "." + _identifier);
+                returnValue = sym.getValue();
+            } 
+            catch(SPLException splex) 
+            {
+                String accessorMethodName = getAccessorMethodName(_identifier);
+                sym =  _symbolTable.getSymbol(_classType + "." + accessorMethodName);
+                returnValue = AnchorMethodInvokeAction.invokeClassMethod(_symbolTable, 
+                        _classType, qualifier, accessorMethodName, _paramList,instance);
+            }    	}
     	
     	
     	return returnValue;
@@ -113,7 +123,7 @@
 				parentObject, 
 				symbolsofInstance);
     	
-		Symbol sym = _symbolTable.getSymbol(_classType + "." + _identifier);
+		// Symbol sym = _symbolTable.getSymbol(_classType + "." + _identifier);
 		
     	//_symbolTable.setAnchors(mapOfAnchorClassToInstance);
     	if(_isMethod)
@@ -125,9 +135,19 @@
     	else
     	{
     		
-    		//Symbol sym = _symbolTable.getSymbol(_classType + "." + _identifier);
-    		returnValue = sym.getValue();
-    		
+    	    Symbol sym = null;
+            try
+            {
+                sym =  _symbolTable.getSymbol(_classType + "." + _identifier);
+                returnValue = sym.getValue();
+            } 
+            catch(SPLException splex) 
+            {
+                String accessorMethodName = getAccessorMethodName(_identifier);
+                sym =  _symbolTable.getSymbol(_classType + "." + accessorMethodName);
+                returnValue = AnchorMethodInvokeAction.invokeClassMethod(_symbolTable, 
+                        _classType, qualifier, accessorMethodName, _paramList,parentObject);
+            }    		
     	}
     	
     	return returnValue;
@@ -140,8 +160,18 @@
 		// ensure symbol table is populated
 		_populateSymbolTable(_classType);
 		
-		Symbol sym = _symbolTable.getSymbol(classTypeOrVariableName + "." + _identifier);
+		// Symbol sym = _symbolTable.getSymbol(classTypeOrVariableName + "." + _identifier);
 		
+		Symbol sym = null;
+        try
+        {
+            sym = _symbolTable.getSymbol(classTypeOrVariableName + "." + _identifier);
+        } 
+        catch(SPLException splex) 
+        {
+            sym = _symbolTable.getSymbol(classTypeOrVariableName + "." + getAccessorMethodName(_identifier));
+        }
+        
 		if(_isMethod)
 		{
 			if(sym instanceof MethodSymbol)
@@ -183,6 +213,16 @@
 		return typeInfo;
 		
 	}
+	
+	private String getAccessorMethodName(String identifier)
+    {
+        if(Character.isLetter(identifier.charAt(0)))
+        {
+            identifier = Character.toUpperCase(identifier.charAt(0)) + identifier.substring(1);
+        }
+        identifier = "get"+identifier;
+        return identifier;
+    }
 
 	private TypeInfo _validateActualParameters(Symbol sym, 
 			String classType) throws SPLException



Mime
View raw message