package com.poco;


/**
 * Created by caoyan on 12/4/14.
 */
public class AlternationExecution extends SequentialExecution
{
	private Boolean isQueried = false;
    private Boolean resultBool = false;
	private SRE resultSRE = null;
	
    public AlternationExecution(String modifier) throws PoCoException {
        super(modifier);
    }
 	
    @Override
    public SRE query(Event event) {
    	if (children.size() == 0){
			return null;
		}

		if (!isQueried) {
			isQueried = true;
			if (children.get(0).accepts(event))  {
				resultBool = true;
				resultSRE = children.get(0).query(event);
			} else  {
				resultBool = children.get(1).accepts(event);
				resultSRE = children.get(1).query(event);
			}
			return resultSRE;
		}
		else {
			return resultSRE;
		}
    }

    @Override
    public boolean accepts(Event event) {
    	if (children.size() == 0) {
			return false;
		}
		// The first child of a sequential execution must accept for its parent
		// to accept
		this.query(event);
		return resultBool;
    }
}

@@ -122,44 +122,8 @@
 n%0A%7B%0A
-%09private Boolean isQueried = false;%0A
     
@@ -399,17 +399,16 @@
 ll;%0A%09%09%7D%0A
-%0A
 %09%09if (!i
@@ -423,29 +423,8 @@
 ) %7B%0A
-%09%09%09isQueried = true;%0A
 %09%09%09i
@@ -642,13 +642,34 @@
 t);%0A
-
 %09%09%09%7D%0A
+%09%09%09isQueried = true;%0A
 %09%09%09r

delete unneeded field