Example usage for com.badlogic.gdx.beans Statement Statement

List of usage examples for com.badlogic.gdx.beans Statement Statement

Introduction

In this page you can find the example usage for com.badlogic.gdx.beans Statement Statement.

Prototype

public Statement(Object target, String methodName, Object[] arguments) 

Source Link

Usage

From source file:org.apache.harmony.beans.Command.java

License:Apache License

private int doAfterRun(Map<String, Command> references) throws Exception {
    if (status == Command.COMMAND_EXECUTED) {
        // System.out.println("doAfterRun(): command " + getResultType() + "
        // processed...");
        Vector<Command> toBeRemoved = new Vector<Command>();
        try {//from   www  .  j a va2 s . c  om
            Statement[] statements = null;

            for (int i = 0; i < operations.size(); ++i) {
                Command cmd = operations.elementAt(i);

                if (cmd.isArrayElement()) {

                    if (cmd.isResolved()) {
                        if (statements == null) {
                            statements = new Statement[operations.size()];
                        }
                        statements[i] = new Statement(getResultValue(), "set", //$NON-NLS-1$
                                new Object[] { Integer.valueOf(i), cmd.getResultValue() });
                        if ((i + 1) == operations.size()) {
                            for (int j = 0; j < operations.size(); ++j) {
                                statements[j].execute();
                            }
                            toBeRemoved.addAll(operations);
                        }
                    } else {
                        break;
                    }

                } else {
                    // since the call is Array.set()
                    if (!isArray()) {
                        cmd.setTarget(getResultValue());
                    }
                    cmd.exec(references);

                    if (cmd.isResolved()) {
                        // System.out.println("doAfterRun(): cmd = " +
                        // cmd.methodName + " is resolved");
                        toBeRemoved.add(cmd);
                    } else {
                        // System.out.println("doAfterRun(): cmd = " +
                        // cmd.methodName + " is unresolved");
                        break;
                    }

                }

            }
        } catch (Exception e) {
            throw new Exception(e);
        } finally {
            operations.removeAll(toBeRemoved);
        }

        // if (operations.size() == 0) {
        // System.out.println("doAfterRun(): command " + getResultType()
        // + " completely processed.");
        // } else {
        // System.out.println("doAfterRun(): command " + getResultType()
        // + " contains incomplete " +
        // operations.size() + " commands.");
        // }
        return (operations.size() == 0) ? Command.CHILDREN_PROCESSED : status;
    }
    return status;
}