Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package jason.asSemantics;
 
public class GoalListenerForMetaEvents implements GoalListener {
    private TransitionSystem ts;
    
    public GoalListenerForMetaEvents(final TransitionSystem ts) {
        this. = ts;
    }
    public void goalStarted(Event goal) {
    }
    
    public void goalFailed(Trigger goal) {
        generateGoalStateEvent(goal.getLiteral(), goal.getType(), .null);
    }
    public void goalFinished(Trigger goal) {
        generateGoalStateEvent(goal.getLiteral(), goal.getType(), .null);
    }
    public void goalResumed(Trigger goal) {
        generateGoalStateEvent(goal.getLiteral(), goal.getType(), .null);
    }
    public void goalSuspended(Trigger goalString reason) {
        generateGoalStateEvent(goal.getLiteral(), goal.getType(), .reason);
    }
    private void generateGoalStateEvent(final Literal goalfinal TEType typefinal GoalStates statefinal String reason) {
        .runAtBeginOfNextCycle(new Runnable() {
            public void run() {
                Literal newGoal = goal.forceFullLiteralImpl().copy();
                Literal stateAnnot = ASSyntax.createLiteral("state"new Atom(state.toString()));
                if (reason != null)
                    stateAnnot.addAnnot( ASSyntax.createStructure("reason"new StringTermImpl(reason)));
                newGoal.addAnnotstateAnnot );
                Trigger eEnd = new Trigger(.typenewGoal);
                if (.getAg().getPL().hasCandidatePlan(eEnd))
                    .getC().insertMetaEvent(new Event(eEndnull));
            }
        });
    }
New to GrepCode? Check out our FAQ X