SQLOrExpr.java :  » Workflow-Engines » obe-1.0 » org » obe » sql » Java Open Source

Java Open Source » Workflow Engines » obe 1.0 
obe 1.0 » org » obe » sql » SQLOrExpr.java
package org.obe.sql;

import java.io.IOException;
import java.io.Writer;

/**
 * @author Adrian Price
 */
public class SQLOrExpr extends SimpleNode {
    public SQLOrExpr(int id) {
        super(id);
    }

    public void write(Writer out) throws IOException {
        boolean or = false;
        for (int i = 0; i < children.length; i++) {
            if (or)
                out.write(" OR ");
            children[i].write(out);
            or = true;
        }
    }

    public Object execute(Object context) {
        Boolean result = Boolean.FALSE;
        for (int i = 0; i < children.length; i++) {
            if (((Boolean)children[i].execute(context)).booleanValue()) {
                result = Boolean.TRUE;
                break;
            }
        }
        return result;
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.