Index: C:/Naidu/Projects/eclipse/policy_workspace/apache/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/IdentPrimaryTuple.java =================================================================== --- C:/Naidu/Projects/eclipse/policy_workspace/apache/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/IdentPrimaryTuple.java (revision 662669) +++ C:/Naidu/Projects/eclipse/policy_workspace/apache/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/IdentPrimaryTuple.java (working copy) @@ -80,23 +80,33 @@ 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; - } + public Object evaluate(Object parentObject) throws SPLException { Object returnValue = null; @@ -113,23 +123,30 @@ parentObject, symbolsofInstance); - Symbol sym = _symbolTable.getSymbol(_classType + "." + _identifier); + // Symbol sym = _symbolTable.getSymbol(_classType + "." + _identifier); //_symbolTable.setAnchors(mapOfAnchorClassToInstance); if(_isMethod) { - returnValue = AnchorMethodInvokeAction.invokeClassMethod(_symbolTable, _classType, qualifier, _identifier, _paramList, parentObject); } 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 +157,20 @@ // ensure symbol table is populated _populateSymbolTable(_classType); - Symbol sym = _symbolTable.getSymbol(classTypeOrVariableName + "." + _identifier); + // Symbol sym = _symbolTable.getSymbol(classTypeOrVariableName + "." + _identifier); + + // added this to access private variables in policy using accessor methods + Symbol sym = null; + try + { + sym = _symbolTable.getSymbol(classTypeOrVariableName + "." + _identifier); + } + catch(SPLException splex) + { + sym = _symbolTable.getSymbol(classTypeOrVariableName + "." + getAccessorMethodName(_identifier)); + } + if(_isMethod) { if(sym instanceof MethodSymbol) @@ -184,6 +213,16 @@ } + 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 {