private final void setPlanVariables ( Agent agent , Plan planInstance , Set < Belief > results , int choice ) { if ( agent == null || planInstance == null ) { return ; } Belief belief = getResultAtIndex ( results , choice ) ; if ( belief == null ) { return ; } Object [ ] tuple = belief . getTuple ( ) ; if ( tuple == null ) { return ; } int index = 0 ; HashMap < String , Object > vars = new HashMap < String , Object > ( ) ; for ( Object o : belief . getTuple ( ) ) { try { String fieldname = ABeliefStore . getFieldName ( agent . getId ( ) , belief . getBeliefset ( ) , index ) ; vars . put ( fieldname , o ) ; } catch ( BeliefBaseException e ) { Log . error ( "Agent " + agent . getId ( ) + " could not retrive belief set field: " + e . getMessage ( ) ) ; } index ++ ; } planInstance . setPlanVariables ( vars ) ; }
Sets the plan instance variables using the given results set .