Input:
    private void visitExpression(Node node, int contextFlags)
    {
        int type = node.getType();
        Node child = node.getFirstChild();
        int savedStackDepth = stackDepth;
        switch (type) {
          case Token.FUNCTION:
            {
                int fnIndex = node.getExistingIntProp(Node.FUNCTION_PROP);
                FunctionNode fn = scriptOrFn.getFunctionNode(fnIndex);
                if (fn.getFunctionType() != FunctionNode.FUNCTION_EXPRESSION) {
                    throw Kit.codeBug();
                }
                addIndexOp(Icode_CLOSURE_EXPR, fnIndex);
                stackChange(1);
            }
            break;
          case Token.LOCAL_LOAD:
            {
                int localIndex = getLocalBlockRef(node);
                addIndexOp(Token.LOCAL_LOAD, localIndex);
                stackChange(1);
            }
            break;
          case Token.COMMA:
            {
                Node lastChild = node.getLastChild();
                while (child != lastChild) {
                    visitExpression(child, 0);
                    addIcode(Icode_POP);
                    stackChange(-1);
                    child = child.getNext();
                }
                visitExpression(child, contextFlags & ECF_TAIL);
            }
            break;
          case Token.USE_STACK:
            stackChange(1);
            break;
          case Token.REF_CALL:
          case Token.CALL:
          case Token.NEW:
            {
                if (type == Token.NEW) {
                    visitExpression(child, 0);
                } else {
                    generateCallFunAndThis(child);
                }
                int argCount = 0;
                while ((child = child.getNext()) != null) {
                    visitExpression(child, 0);
                    ++argCount;
                }
                int callType = node.getIntProp(Node.SPECIALCALL_PROP,
                                               Node.NON_SPECIALCALL);
                if (callType != Node.NON_SPECIALCALL) {
                    addIndexOp(Icode_CALLSPECIAL, argCount);
                    addUint8(callType);
                    addUint8(type == Token.NEW ? 1 : 0);
                    addUint16(lineNumber & 0xFFFF);
                } else {
                    if (type == Token.CALL && (contextFlags & ECF_TAIL) != 0 &&
                        !compilerEnv.isGenerateDebugInfo() && !itsInTryFlag)
                    {
                        type = Icode_TAIL_CALL;
                    }
                    addIndexOp(type, argCount);
                }
                if (type == Token.NEW) {
                    stackChange(-argCount);
                } else {
                    stackChange(-1 - argCount);
                }
                if (argCount > itsData.itsMaxCalleeArgs) {
                    itsData.itsMaxCalleeArgs = argCount;
                }
            }
            break;
          case Token.AND:
          case Token.OR:
            {
                visitExpression(child, 0);
                addIcode(Icode_DUP);
                stackChange(1);
                int afterSecondJumpStart = iCodeTop;
                int jump = (type == Token.AND) ? Token.IFNE : Token.IFEQ;
                addGotoOp(jump);
                stackChange(-1);
                addIcode(Icode_POP);
                stackChange(-1);
                child = child.getNext();
                visitExpression(child, contextFlags & ECF_TAIL);
                resolveForwardGoto(afterSecondJumpStart);
            }
            break;
          case Token.HOOK:
            {
                Node ifThen = child.getNext();
                Node ifElse = ifThen.getNext();
                visitExpression(child, 0);
                int elseJumpStart = iCodeTop;
                addGotoOp(Token.IFNE);
                stackChange(-1);
                visitExpression(ifThen, contextFlags & ECF_TAIL);
                int afterElseJumpStart = iCodeTop;
                addGotoOp(Token.GOTO);
                resolveForwardGoto(elseJumpStart);
                stackDepth = savedStackDepth;
                visitExpression(ifElse, contextFlags & ECF_TAIL);
                resolveForwardGoto(afterElseJumpStart);
            }
            break;
          case Token.GETPROP:
          case Token.GETPROPNOWARN:
            visitExpression(child, 0);
            child = child.getNext();
            addStringOp(type, child.getString());
            break;
          case Token.DELPROP:
            boolean isName = child.getType() == Token.BINDNAME;
            visitExpression(child, 0);
            child = child.getNext();
            visitExpression(child, 0);
            if (isName) {
                addIcode(Icode_DELNAME);
            } else {
                addToken(Token.DELPROP);
            }
            stackChange(-1);
            break;
          case Token.GETELEM:
          case Token.BITAND:
          case Token.BITOR:
          case Token.BITXOR:
          case Token.LSH:
          case Token.RSH:
          case Token.URSH:
          case Token.ADD:
          case Token.SUB:
          case Token.MOD:
          case Token.DIV:
          case Token.MUL:
          case Token.EQ:
          case Token.NE:
          case Token.SHEQ:
          case Token.SHNE:
          case Token.IN:
          case Token.INSTANCEOF:
          case Token.LE:
          case Token.LT:
          case Token.GE:
          case Token.GT:
            visitExpression(child, 0);
            child = child.getNext();
            visitExpression(child, 0);
            addToken(type);
            stackChange(-1);
            break;
          case Token.POS:
          case Token.NEG:
          case Token.NOT:
          case Token.BITNOT:
          case Token.TYPEOF:
          case Token.VOID:
            visitExpression(child, 0);
            if (type == Token.VOID) {
                addIcode(Icode_POP);
                addIcode(Icode_UNDEF);
            } else {
                addToken(type);
            }
            break;
          case Token.GET_REF:
          case Token.DEL_REF:
            visitExpression(child, 0);
            addToken(type);
            break;
          case Token.SETPROP:
          case Token.SETPROP_OP:
            {
                visitExpression(child, 0);
                child = child.getNext();
                String property = child.getString();
                child = child.getNext();
                if (type == Token.SETPROP_OP) {
                    addIcode(Icode_DUP);
                    stackChange(1);
                    addStringOp(Token.GETPROP, property);
                    stackChange(-1);
                }
                visitExpression(child, 0);
                addStringOp(Token.SETPROP, property);
                stackChange(-1);
            }
            break;
          case Token.SETELEM:
          case Token.SETELEM_OP:
            visitExpression(child, 0);
            child = child.getNext();
            visitExpression(child, 0);
            child = child.getNext();
            if (type == Token.SETELEM_OP) {
                addIcode(Icode_DUP2);
                stackChange(2);
                addToken(Token.GETELEM);
                stackChange(-1);
                stackChange(-1);
            }
            visitExpression(child, 0);
            addToken(Token.SETELEM);
            stackChange(-2);
            break;
          case Token.SET_REF:
          case Token.SET_REF_OP:
            visitExpression(child, 0);
            child = child.getNext();
            if (type == Token.SET_REF_OP) {
                addIcode(Icode_DUP);
                stackChange(1);
                addToken(Token.GET_REF);
                stackChange(-1);
            }
            visitExpression(child, 0);
            addToken(Token.SET_REF);
            stackChange(-1);
            break;
          case Token.STRICT_SETNAME:
          case Token.SETNAME:
            {
                String name = child.getString();
                visitExpression(child, 0);
                child = child.getNext();
                visitExpression(child, 0);
                addStringOp(type, name);
                stackChange(-1);
            }
            break;
          case Token.SETCONST:
            {
                String name = child.getString();
                visitExpression(child, 0);
                child = child.getNext();
                visitExpression(child, 0);
                addStringOp(Icode_SETCONST, name);
                stackChange(-1);
            }
            break;
          case Token.TYPEOFNAME:
            {
                int index = -1;
                if (itsInFunctionFlag && !itsData.itsNeedsActivation)
                    index = scriptOrFn.getIndexForNameNode(node);
                if (index == -1) {
                    addStringOp(Icode_TYPEOFNAME, node.getString());
                    stackChange(1);
                } else {
                    addVarOp(Token.GETVAR, index);
                    stackChange(1);
                    addToken(Token.TYPEOF);
                }
            }
            break;
          case Token.BINDNAME:
          case Token.NAME:
          case Token.STRING:
            addStringOp(type, node.getString());
            stackChange(1);
            break;
          case Token.INC:
          case Token.DEC:
            visitIncDec(node, child);
            break;
          case Token.NUMBER:
            {
                double num = node.getDouble();
                int inum = (int)num;
                if (inum == num) {
                    if (inum == 0) {
                        addIcode(Icode_ZERO);
                        if (1.0 / num < 0.0) {
                            addToken(Token.NEG);
                        }
                    } else if (inum == 1) {
                        addIcode(Icode_ONE);
                    } else if ((short)inum == inum) {
                        addIcode(Icode_SHORTNUMBER);
                        addUint16(inum & 0xFFFF);
                    } else {
                        addIcode(Icode_INTNUMBER);
                        addInt(inum);
                    }
                } else {
                    int index = getDoubleIndex(num);
                    addIndexOp(Token.NUMBER, index);
                }
                stackChange(1);
            }
            break;
          case Token.GETVAR:
            {
                if (itsData.itsNeedsActivation) Kit.codeBug();
                int index = scriptOrFn.getIndexForNameNode(node);
                addVarOp(Token.GETVAR, index);
                stackChange(1);
            }
            break;
          case Token.SETVAR:
            {
                if (itsData.itsNeedsActivation) Kit.codeBug();
                int index = scriptOrFn.getIndexForNameNode(child);
                child = child.getNext();
                visitExpression(child, 0);
                addVarOp(Token.SETVAR, index);
            }
            break;
          case Token.SETCONSTVAR:
            {
                if (itsData.itsNeedsActivation) Kit.codeBug();
                int index = scriptOrFn.getIndexForNameNode(child);
                child = child.getNext();
                visitExpression(child, 0);
                addVarOp(Token.SETCONSTVAR, index);
            }
            break;
          case Token.NULL:
          case Token.THIS:
          case Token.THISFN:
          case Token.FALSE:
          case Token.TRUE:
            addToken(type);
            stackChange(1);
            break;
          case Token.ENUM_NEXT:
          case Token.ENUM_ID:
            addIndexOp(type, getLocalBlockRef(node));
            stackChange(1);
            break;
          case Token.REGEXP:
            {
                int index = node.getExistingIntProp(Node.REGEXP_PROP);
                addIndexOp(Token.REGEXP, index);
                stackChange(1);
            }
            break;
          case Token.ARRAYLIT:
          case Token.OBJECTLIT:
            visitLiteral(node, child);
            break;
          case Token.ARRAYCOMP:
            visitArrayComprehension(node, child, child.getNext());
            break;
          case Token.REF_SPECIAL:
            visitExpression(child, 0);
            addStringOp(type, (String)node.getProp(Node.NAME_PROP));
            break;
          case Token.REF_MEMBER:
          case Token.REF_NS_MEMBER:
          case Token.REF_NAME:
          case Token.REF_NS_NAME:
            {
                int memberTypeFlags = node.getIntProp(Node.MEMBER_TYPE_PROP, 0);
                int childCount = 0;
                do {
                    visitExpression(child, 0);
                    ++childCount;
                    child = child.getNext();
                } while (child != null);
                addIndexOp(type, memberTypeFlags);
                stackChange(1 - childCount);
            }
            break;
          case Token.DOTQUERY:
            {
                int queryPC;
                updateLineNumber(node);
                visitExpression(child, 0);
                addIcode(Icode_ENTERDQ);
                stackChange(-1);
                queryPC = iCodeTop;
                visitExpression(child.getNext(), 0);
                addBackwardGoto(Icode_LEAVEDQ, queryPC);
            }
            break;
          case Token.DEFAULTNAMESPACE :
          case Token.ESCXMLATTR :
          case Token.ESCXMLTEXT :
            visitExpression(child, 0);
            addToken(type);
            break;
          case Token.YIELD:
            if (child != null) {
                visitExpression(child, 0);
            } else {
                addIcode(Icode_UNDEF);
                stackChange(1);
            }
            addToken(Token.YIELD);
            addUint16(node.getLineno() & 0xFFFF);
            break;
          case Token.WITHEXPR: {
            Node enterWith = node.getFirstChild();
            Node with = enterWith.getNext();
            visitExpression(enterWith.getFirstChild(), 0);
            addToken(Token.ENTERWITH);
            stackChange(-1);
            visitExpression(with.getFirstChild(), 0);
            addToken(Token.LEAVEWITH);
            break;
          }
          default:
            throw badTree(node);
        }
        if (savedStackDepth + 1 != stackDepth) {
            Kit.codeBug();
        }
    }

Output:
    private void visitExpression(Node node, int contextFlags)
    {
        int type = node.getType();
        Node child = node.getFirstChild();
        int savedStackDepth = stackDepth;
        switch (type) {
          case Token.FUNCTION:
            {
                int fnIndex = node.getExistingIntProp(Node.FUNCTION_PROP);
                FunctionNode fn = scriptOrFn.getFunctionNode(fnIndex);
                if (fn.getFunctionType() != FunctionNode.FUNCTION_EXPRESSION) {
                    throw Kit.codeBug();
                }
                addIndexOp(Icode_CLOSURE_EXPR, fnIndex);
                stackChange(1);
            }
            break;
          case Token.LOCAL_LOAD:
            {
                int localIndex = getLocalBlockRef(node);
                addIndexOp(Token.LOCAL_LOAD, localIndex);
                stackChange(1);
            }
            break;
          case Token.COMMA:
            {
                Node lastChild = node.getLastChild();
                while (child != lastChild) {
                    visitExpression(child, 0);
                    addIcode(Icode_POP);
                    stackChange(-1);
                    child = child.getNext();
                }
                visitExpression(child, contextFlags & ECF_TAIL);
            }
            break;
          case Token.USE_STACK:
            stackChange(1);
            break;
          case Token.REF_CALL:
          case Token.CALL:
          case Token.NEW:
            {
                if (type == Token.NEW) {
                    visitExpression(child, 0);
                } else {
                    generateCallFunAndThis(child);
                }
                int argCount = 0;
                while ((child = child.getNext()) != null) {
                    visitExpression(child, 0);
                    ++argCount;
                }
                int callType = node.getIntProp(Node.SPECIALCALL_PROP,
                                               Node.NON_SPECIALCALL);
                if (type != Token.REF_CALL && callType != Node.NON_SPECIALCALL) {
                    addIndexOp(Icode_CALLSPECIAL, argCount);
                    addUint8(callType);
                    addUint8(type == Token.NEW ? 1 : 0);
                    addUint16(lineNumber & 0xFFFF);
                } else {
                    if (type == Token.CALL && (contextFlags & ECF_TAIL) != 0 &&
                        !compilerEnv.isGenerateDebugInfo() && !itsInTryFlag)
                    {
                        type = Icode_TAIL_CALL;
                    }
                    addIndexOp(type, argCount);
                }
                if (type == Token.NEW) {
                    stackChange(-argCount);
                } else {
                    stackChange(-1 - argCount);
                }
                if (argCount > itsData.itsMaxCalleeArgs) {
                    itsData.itsMaxCalleeArgs = argCount;
                }
            }
            break;
          case Token.AND:
          case Token.OR:
            {
                visitExpression(child, 0);
                addIcode(Icode_DUP);
                stackChange(1);
                int afterSecondJumpStart = iCodeTop;
                int jump = (type == Token.AND) ? Token.IFNE : Token.IFEQ;
                addGotoOp(jump);
                stackChange(-1);
                addIcode(Icode_POP);
                stackChange(-1);
                child = child.getNext();
                visitExpression(child, contextFlags & ECF_TAIL);
                resolveForwardGoto(afterSecondJumpStart);
            }
            break;
          case Token.HOOK:
            {
                Node ifThen = child.getNext();
                Node ifElse = ifThen.getNext();
                visitExpression(child, 0);
                int elseJumpStart = iCodeTop;
                addGotoOp(Token.IFNE);
                stackChange(-1);
                visitExpression(ifThen, contextFlags & ECF_TAIL);
                int afterElseJumpStart = iCodeTop;
                addGotoOp(Token.GOTO);
                resolveForwardGoto(elseJumpStart);
                stackDepth = savedStackDepth;
                visitExpression(ifElse, contextFlags & ECF_TAIL);
                resolveForwardGoto(afterElseJumpStart);
            }
            break;
          case Token.GETPROP:
          case Token.GETPROPNOWARN:
            visitExpression(child, 0);
            child = child.getNext();
            addStringOp(type, child.getString());
            break;
          case Token.DELPROP:
            boolean isName = child.getType() == Token.BINDNAME;
            visitExpression(child, 0);
            child = child.getNext();
            visitExpression(child, 0);
            if (isName) {
                addIcode(Icode_DELNAME);
            } else {
                addToken(Token.DELPROP);
            }
            stackChange(-1);
            break;
          case Token.GETELEM:
          case Token.BITAND:
          case Token.BITOR:
          case Token.BITXOR:
          case Token.LSH:
          case Token.RSH:
          case Token.URSH:
          case Token.ADD:
          case Token.SUB:
          case Token.MOD:
          case Token.DIV:
          case Token.MUL:
          case Token.EQ:
          case Token.NE:
          case Token.SHEQ:
          case Token.SHNE:
          case Token.IN:
          case Token.INSTANCEOF:
          case Token.LE:
          case Token.LT:
          case Token.GE:
          case Token.GT:
            visitExpression(child, 0);
            child = child.getNext();
            visitExpression(child, 0);
            addToken(type);
            stackChange(-1);
            break;
          case Token.POS:
          case Token.NEG:
          case Token.NOT:
          case Token.BITNOT:
          case Token.TYPEOF:
          case Token.VOID:
            visitExpression(child, 0);
            if (type == Token.VOID) {
                addIcode(Icode_POP);
                addIcode(Icode_UNDEF);
            } else {
                addToken(type);
            }
            break;
          case Token.GET_REF:
          case Token.DEL_REF:
            visitExpression(child, 0);
            addToken(type);
            break;
          case Token.SETPROP:
          case Token.SETPROP_OP:
            {
                visitExpression(child, 0);
                child = child.getNext();
                String property = child.getString();
                child = child.getNext();
                if (type == Token.SETPROP_OP) {
                    addIcode(Icode_DUP);
                    stackChange(1);
                    addStringOp(Token.GETPROP, property);
                    stackChange(-1);
                }
                visitExpression(child, 0);
                addStringOp(Token.SETPROP, property);
                stackChange(-1);
            }
            break;
          case Token.SETELEM:
          case Token.SETELEM_OP:
            visitExpression(child, 0);
            child = child.getNext();
            visitExpression(child, 0);
            child = child.getNext();
            if (type == Token.SETELEM_OP) {
                addIcode(Icode_DUP2);
                stackChange(2);
                addToken(Token.GETELEM);
                stackChange(-1);
                stackChange(-1);
            }
            visitExpression(child, 0);
            addToken(Token.SETELEM);
            stackChange(-2);
            break;
          case Token.SET_REF:
          case Token.SET_REF_OP:
            visitExpression(child, 0);
            child = child.getNext();
            if (type == Token.SET_REF_OP) {
                addIcode(Icode_DUP);
                stackChange(1);
                addToken(Token.GET_REF);
                stackChange(-1);
            }
            visitExpression(child, 0);
            addToken(Token.SET_REF);
            stackChange(-1);
            break;
          case Token.STRICT_SETNAME:
          case Token.SETNAME:
            {
                String name = child.getString();
                visitExpression(child, 0);
                child = child.getNext();
                visitExpression(child, 0);
                addStringOp(type, name);
                stackChange(-1);
            }
            break;
          case Token.SETCONST:
            {
                String name = child.getString();
                visitExpression(child, 0);
                child = child.getNext();
                visitExpression(child, 0);
                addStringOp(Icode_SETCONST, name);
                stackChange(-1);
            }
            break;
          case Token.TYPEOFNAME:
            {
                int index = -1;
                if (itsInFunctionFlag && !itsData.itsNeedsActivation)
                    index = scriptOrFn.getIndexForNameNode(node);
                if (index == -1) {
                    addStringOp(Icode_TYPEOFNAME, node.getString());
                    stackChange(1);
                } else {
                    addVarOp(Token.GETVAR, index);
                    stackChange(1);
                    addToken(Token.TYPEOF);
                }
            }
            break;
          case Token.BINDNAME:
          case Token.NAME:
          case Token.STRING:
            addStringOp(type, node.getString());
            stackChange(1);
            break;
          case Token.INC:
          case Token.DEC:
            visitIncDec(node, child);
            break;
          case Token.NUMBER:
            {
                double num = node.getDouble();
                int inum = (int)num;
                if (inum == num) {
                    if (inum == 0) {
                        addIcode(Icode_ZERO);
                        if (1.0 / num < 0.0) {
                            addToken(Token.NEG);
                        }
                    } else if (inum == 1) {
                        addIcode(Icode_ONE);
                    } else if ((short)inum == inum) {
                        addIcode(Icode_SHORTNUMBER);
                        addUint16(inum & 0xFFFF);
                    } else {
                        addIcode(Icode_INTNUMBER);
                        addInt(inum);
                    }
                } else {
                    int index = getDoubleIndex(num);
                    addIndexOp(Token.NUMBER, index);
                }
                stackChange(1);
            }
            break;
          case Token.GETVAR:
            {
                if (itsData.itsNeedsActivation) Kit.codeBug();
                int index = scriptOrFn.getIndexForNameNode(node);
                addVarOp(Token.GETVAR, index);
                stackChange(1);
            }
            break;
          case Token.SETVAR:
            {
                if (itsData.itsNeedsActivation) Kit.codeBug();
                int index = scriptOrFn.getIndexForNameNode(child);
                child = child.getNext();
                visitExpression(child, 0);
                addVarOp(Token.SETVAR, index);
            }
            break;
          case Token.SETCONSTVAR:
            {
                if (itsData.itsNeedsActivation) Kit.codeBug();
                int index = scriptOrFn.getIndexForNameNode(child);
                child = child.getNext();
                visitExpression(child, 0);
                addVarOp(Token.SETCONSTVAR, index);
            }
            break;
          case Token.NULL:
          case Token.THIS:
          case Token.THISFN:
          case Token.FALSE:
          case Token.TRUE:
            addToken(type);
            stackChange(1);
            break;
          case Token.ENUM_NEXT:
          case Token.ENUM_ID:
            addIndexOp(type, getLocalBlockRef(node));
            stackChange(1);
            break;
          case Token.REGEXP:
            {
                int index = node.getExistingIntProp(Node.REGEXP_PROP);
                addIndexOp(Token.REGEXP, index);
                stackChange(1);
            }
            break;
          case Token.ARRAYLIT:
          case Token.OBJECTLIT:
            visitLiteral(node, child);
            break;
          case Token.ARRAYCOMP:
            visitArrayComprehension(node, child, child.getNext());
            break;
          case Token.REF_SPECIAL:
            visitExpression(child, 0);
            addStringOp(type, (String)node.getProp(Node.NAME_PROP));
            break;
          case Token.REF_MEMBER:
          case Token.REF_NS_MEMBER:
          case Token.REF_NAME:
          case Token.REF_NS_NAME:
            {
                int memberTypeFlags = node.getIntProp(Node.MEMBER_TYPE_PROP, 0);
                int childCount = 0;
                do {
                    visitExpression(child, 0);
                    ++childCount;
                    child = child.getNext();
                } while (child != null);
                addIndexOp(type, memberTypeFlags);
                stackChange(1 - childCount);
            }
            break;
          case Token.DOTQUERY:
            {
                int queryPC;
                updateLineNumber(node);
                visitExpression(child, 0);
                addIcode(Icode_ENTERDQ);
                stackChange(-1);
                queryPC = iCodeTop;
                visitExpression(child.getNext(), 0);
                addBackwardGoto(Icode_LEAVEDQ, queryPC);
            }
            break;
          case Token.DEFAULTNAMESPACE :
          case Token.ESCXMLATTR :
          case Token.ESCXMLTEXT :
            visitExpression(child, 0);
            addToken(type);
            break;
          case Token.YIELD:
            if (child != null) {
                visitExpression(child, 0);
            } else {
                addIcode(Icode_UNDEF);
                stackChange(1);
            }
            addToken(Token.YIELD);
            addUint16(node.getLineno() & 0xFFFF);
            break;
          case Token.WITHEXPR: {
            Node enterWith = node.getFirstChild();
            Node with = enterWith.getNext();
            visitExpression(enterWith.getFirstChild(), 0);
            addToken(Token.ENTERWITH);
            stackChange(-1);
            visitExpression(with.getFirstChild(), 0);
            addToken(Token.LEAVEWITH);
            break;
          }
          default:
            throw badTree(node);
        }
        if (savedStackDepth + 1 != stackDepth) {
            Kit.codeBug();
        }
    }


Input:
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        setContentView(R.layout.main);
        lightsOut();
        final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        final String url = prefs.getString("url", "file:///android_asset/default.html");
        final boolean interactive = prefs.getBoolean("interactive", false);
        Log.v("WebViewDream", String.format("loading %s in %s mode",
                url, interactive ? "interactive" : "noninteractive"));
        setInteractive(interactive);
        WebView webview = (WebView) findViewById(R.id.webview);
        webview.setWebViewClient(new LinkLauncher());
        WebSettings webSettings = webview.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webview.loadUrl(url);
    }

Output:
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        setContentView(R.layout.main);
        setFullscreen(true);
        final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        final String url = prefs.getString("url", "file:///android_asset/default.html");
        final boolean interactive = prefs.getBoolean("interactive", false);
        Log.v("WebViewDream", String.format("loading %s in %s mode",
                url, interactive ? "interactive" : "noninteractive"));
        setInteractive(interactive);
        WebView webview = (WebView) findViewById(R.id.webview);
        webview.setWebViewClient(new LinkLauncher());
        WebSettings webSettings = webview.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webview.loadUrl(url);
    }


Input:
    protected void execute() {
        if (TrackingCamera.targetGoal == null){
            leftShootingMotors.setSetpoint(1000);
            rightShootingMotors.setSetpoint(1000);
            System.out.println("No target set");
            return;
        }
        tgtHght = TrackingCamera.targetGoal.boundingRectHeight;
        tgtHghtFt = 1.5;
        vertFOV = tgtHghtFt / tgtHght * ttlHght;
        vertVA = 47*pi/180;
        horVA = 47*pi/180;
        tgtWdth = TrackingCamera.targetGoal.boundingRectWidth;
        tgtWdthFt = 2.0;
        horFOV = tgtWdthFt / tgtWdth * ttlWdth;
        leftRight = Math.abs(TrackingCamera.targetGoal.center_mass_x - (ttlHght/2));
        upDown = Math.abs(TrackingCamera.targetGoal.center_mass_y - (ttlWdth/2));
        wdth1Px = (ttlHght/2) - leftRight;
        hght1Px = (ttlWdth/2) - upDown;
        horThet1 = horVA * wdth1Px/ttlWdth;
        vertThet1 = vertVA * hght1Px/ttlHght;
        TrackingCamera.d1 = (hght1Px) / Math.tan(vertThet1);
        TrackingCamera.d2 = (wdth1Px) / Math.tan(horThet1);
        TrackingCamera.distanceToTarget = (TrackingCamera.d1 + TrackingCamera.d2) / 2;
        if (TrackingCamera.distanceToTarget > 60 || TrackingCamera.distanceToTarget <= 0)
            TrackingCamera.distanceToTarget = 60;
        d = TrackingCamera.distanceToTarget;
        TrackingCamera.launchSpeed = 60 * (d / Math.sqrt((11 / 6 - d) / -16.1) / (2 / 3 * pi));
        leftShootingMotors.setSetpoint(TrackingCamera.launchSpeed);
        rightShootingMotors.setSetpoint(TrackingCamera.launchSpeed);
        System.out.println();
        System.out.println("D1: "+TrackingCamera.d1);
        System.out.println("D2: "+TrackingCamera.d2);
        System.out.println("D: "+d);
        System.out.println("Camera Launch Speed: "+TrackingCamera.launchSpeed);
        System.out.println();
    }

Output:
    protected void execute() {
        if (TrackingCamera.targetGoal == null){
            leftShootingMotors.setSetpoint(1000);
            rightShootingMotors.setSetpoint(1000);
            System.out.println("No target set");
            return;
        }
        tgtHght = TrackingCamera.targetGoal.boundingRectHeight;
        tgtHghtFt = 1.5;
        vertFOV = tgtHghtFt / tgtHght * ttlHght;
        vertVA = 47*pi/180;
        horVA = 47*pi/180;
        tgtWdth = TrackingCamera.targetGoal.boundingRectWidth;
        tgtWdthFt = 2.0;
        horFOV = tgtWdthFt / tgtWdth * ttlWdth;
        leftRight = Math.abs(TrackingCamera.targetGoal.center_mass_x - (ttlHght/2));
        upDown = Math.abs(TrackingCamera.targetGoal.center_mass_y - (ttlWdth/2));
        wdth1Px = (ttlWdth/2) - leftRight;
        hght1Px = (ttlHght/2) - upDown;
        horThet1 = horVA * wdth1Px/ttlWdth;
        vertThet1 = vertVA * hght1Px/ttlHght;
        TrackingCamera.d1 = (hght1Px) / Math.tan(vertThet1);
        TrackingCamera.d2 = (wdth1Px) / Math.tan(horThet1);
        TrackingCamera.distanceToTarget = (TrackingCamera.d1 + TrackingCamera.d2) / 2;
        if (TrackingCamera.distanceToTarget > 60 || TrackingCamera.distanceToTarget <= 0)
            TrackingCamera.distanceToTarget = 60;
        d = TrackingCamera.distanceToTarget;
        TrackingCamera.launchSpeed = 60 * (d / Math.sqrt((11 / 6 - d) / -16.1) / (2 / 3 * pi));
        leftShootingMotors.setSetpoint(TrackingCamera.launchSpeed);
        rightShootingMotors.setSetpoint(TrackingCamera.launchSpeed);
        System.out.println();
        System.out.println("D1: "+TrackingCamera.d1);
        System.out.println("D2: "+TrackingCamera.d2);
        System.out.println("D: "+d);
        System.out.println("Camera Launch Speed: "+TrackingCamera.launchSpeed);
        System.out.println();
    }


Input:
    protected AbstractHttpClient http() {
        if(null == http) {
            final HttpParams params = new BasicHttpParams();
            HttpProtocolParams.setVersion(params, org.apache.http.HttpVersion.HTTP_1_1);
            HttpProtocolParams.setContentCharset(params, getEncoding());
            HttpProtocolParams.setUserAgent(params, getUserAgent());
            AuthParams.setCredentialCharset(params, "ISO-8859-1");
            HttpConnectionParams.setTcpNoDelay(params, true);
            HttpConnectionParams.setSoTimeout(params, timeout());
            HttpConnectionParams.setSocketBufferSize(params, 8192);
            HttpClientParams.setRedirecting(params, true);
            HttpClientParams.setAuthenticating(params, true);
            SchemeRegistry registry = new SchemeRegistry();
            if(host.getProtocol().isSecure()) {
                org.apache.http.conn.ssl.SSLSocketFactory factory = new SSLSocketFactory(
                        new CustomTrustSSLProtocolSocketFactory(this.getTrustManager()).getSSLContext());
                factory.setHostnameVerifier(org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
                registry.register(
                        new Scheme(host.getProtocol().getScheme(), factory, host.getPort()));
            }
            else {
                registry.register(
                        new Scheme(host.getProtocol().getScheme(), PlainSocketFactory.getSocketFactory(), host.getPort()));
            }
            if("https".equals(this.getHost().getProtocol().getScheme())) {
                if(Preferences.instance().getBoolean("connection.proxy.enable")) {
                    final Proxy proxy = ProxyFactory.instance();
                    if(proxy.isHTTPSProxyEnabled(host)) {
                        ConnRouteParams.setDefaultProxy(params, new HttpHost(proxy.getHTTPSProxyHost(), proxy.getHTTPSProxyPort()));
                    }
                }
            }
            else if("http".equals(this.getHost().getProtocol().getScheme())) {
                if(Preferences.instance().getBoolean("connection.proxy.enable")) {
                    final Proxy proxy = ProxyFactory.instance();
                    if(proxy.isHTTPProxyEnabled(host)) {
                        ConnRouteParams.setDefaultProxy(params, new HttpHost(proxy.getHTTPProxyHost(), proxy.getHTTPProxyPort()));
                    }
                }
            }
            ClientConnectionManager manager = new SingleClientConnManager(params, registry);
            http = new DefaultHttpClient(manager, params);
            this.configure(http);
        }
        return http;
    }

Output:
    protected AbstractHttpClient http() {
        if(null == http) {
            final HttpParams params = new BasicHttpParams();
            HttpProtocolParams.setVersion(params, org.apache.http.HttpVersion.HTTP_1_1);
            HttpProtocolParams.setContentCharset(params, getEncoding());
            HttpProtocolParams.setUserAgent(params, getUserAgent());
            AuthParams.setCredentialCharset(params, "ISO-8859-1");
            HttpConnectionParams.setTcpNoDelay(params, true);
            HttpConnectionParams.setSoTimeout(params, timeout());
            HttpConnectionParams.setSocketBufferSize(params, 8192);
            HttpClientParams.setRedirecting(params, true);
            HttpClientParams.setAuthenticating(params, true);
            SchemeRegistry registry = new SchemeRegistry();
            registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), host.getPort()));
            if("https".equals(this.getHost().getProtocol().getScheme())) {
                org.apache.http.conn.ssl.SSLSocketFactory factory = new SSLSocketFactory(
                        new CustomTrustSSLProtocolSocketFactory(this.getTrustManager()).getSSLContext());
                factory.setHostnameVerifier(org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
                registry.register(new Scheme(host.getProtocol().getScheme(), factory, host.getPort()));
            }
            if(Preferences.instance().getBoolean("connection.proxy.enable")) {
                final Proxy proxy = ProxyFactory.instance();
                if("https".equals(this.getHost().getProtocol().getScheme())) {
                    if(proxy.isHTTPSProxyEnabled(host)) {
                        ConnRouteParams.setDefaultProxy(params, new HttpHost(proxy.getHTTPSProxyHost(), proxy.getHTTPSProxyPort()));
                    }
                }
                if("http".equals(this.getHost().getProtocol().getScheme())) {
                    if(proxy.isHTTPProxyEnabled(host)) {
                        ConnRouteParams.setDefaultProxy(params, new HttpHost(proxy.getHTTPProxyHost(), proxy.getHTTPProxyPort()));
                    }
                }
            }
            ClientConnectionManager manager = new SingleClientConnManager(params, registry);
            http = new DefaultHttpClient(manager, params);
            this.configure(http);
        }
        return http;
    }


Input:
    protected IStatus run(IProgressMonitor monitor) {
        instances.remove(project.getFullPath().toPortableString());
        try {
            Project model = Workspace.getProject(project.getLocation().toFile());
            Collection< ? extends Builder> builders = model.getSubBuilders();
            Map<String,SortedSet<Version>> allExports = new HashMap<String,SortedSet<Version>>();
            Set<String> allContained = new HashSet<String>();
            for (Builder builder : builders) {
                try {
                    builder.build();
                    Packages exports = builder.getExports();
                    if (exports != null) {
                        for (Entry<PackageRef,Attrs> export : exports.entrySet()) {
                            Version version;
                            String versionStr = export.getValue().get(Constants.VERSION_ATTRIBUTE);
                            try {
                                version = Version.parseVersion(versionStr);
                                String pkgName = Processor.removeDuplicateMarker(export.getKey().getFQN());
                                SortedSet<Version> versions = allExports.get(pkgName);
                                if (versions == null) {
                                    versions = new TreeSet<Version>();
                                    allExports.put(pkgName, versions);
                                }
                                versions.add(version);
                            } catch (IllegalArgumentException e) {
                            }
                        }
                    }
                    Packages contained = builder.getContained();
                    for (PackageRef pkgRef : contained.keySet()) {
                        String pkgName = Processor.removeDuplicateMarker(pkgRef.getFQN());
                        allContained.add(pkgName);
                    }
                } catch (Exception e) {
                    logger.logWarning(MessageFormat.format("Unable to process exported packages for builder of {0}.", builder.getPropertiesFile()), e);
                }
            }
            Central.setProjectPackageModel(project, allExports, allContained);
            Display display = PlatformUI.getWorkbench().getDisplay();
            SWTConcurrencyUtil.execForDisplay(display, true, new Runnable() {
                public void run() {
                    PlatformUI.getWorkbench().getDecoratorManager().update("bndtools.packageDecorator");
                }
            });
        } catch (Exception e) {
            logger.logWarning("Error persisting package model for project: " + project.getName(), e);
        }
        return Status.OK_STATUS;
    }

Output:
    protected IStatus run(IProgressMonitor monitor) {
        instances.remove(project.getFullPath().toPortableString());
        try {
            Project model = Workspace.getProject(project.getLocation().toFile());
            if (model == null) {
                return Status.OK_STATUS;
            }
            Collection< ? extends Builder> builders = model.getSubBuilders();
            Map<String,SortedSet<Version>> allExports = new HashMap<String,SortedSet<Version>>();
            Set<String> allContained = new HashSet<String>();
            for (Builder builder : builders) {
                try {
                    builder.build();
                    Packages exports = builder.getExports();
                    if (exports != null) {
                        for (Entry<PackageRef,Attrs> export : exports.entrySet()) {
                            Version version;
                            String versionStr = export.getValue().get(Constants.VERSION_ATTRIBUTE);
                            try {
                                version = Version.parseVersion(versionStr);
                                String pkgName = Processor.removeDuplicateMarker(export.getKey().getFQN());
                                SortedSet<Version> versions = allExports.get(pkgName);
                                if (versions == null) {
                                    versions = new TreeSet<Version>();
                                    allExports.put(pkgName, versions);
                                }
                                versions.add(version);
                            } catch (IllegalArgumentException e) {
                            }
                        }
                    }
                    Packages contained = builder.getContained();
                    for (PackageRef pkgRef : contained.keySet()) {
                        String pkgName = Processor.removeDuplicateMarker(pkgRef.getFQN());
                        allContained.add(pkgName);
                    }
                } catch (Exception e) {
                    logger.logWarning(MessageFormat.format("Unable to process exported packages for builder of {0}.", builder.getPropertiesFile()), e);
                }
            }
            Central.setProjectPackageModel(project, allExports, allContained);
            Display display = PlatformUI.getWorkbench().getDisplay();
            SWTConcurrencyUtil.execForDisplay(display, true, new Runnable() {
                public void run() {
                    PlatformUI.getWorkbench().getDecoratorManager().update("bndtools.packageDecorator");
                }
            });
        } catch (Exception e) {
            logger.logWarning("Error persisting package model for project: " + project.getName(), e);
        }
        return Status.OK_STATUS;
    }


Input:
	public void onCreate(Activity activity, Bundle savedInstanceState) {
		PackageManager manager = activity.getBaseContext().getPackageManager();
		String[] keys = {"tapJoyAppID", "tapJoySecretKey"};
		try {
			Bundle meta = manager.getApplicationInfo(activity.getApplicationContext().getPackageName(),
					PackageManager.GET_META_DATA).metaData;
			for (String k : keys) {
				if (meta.containsKey(k)) {
					manifestKeyMap.put(k, meta.get(k).toString());
				}
			}
		} catch (Exception e) {
			logger.log("Exception while loading manifest keys:", e);
		}
		String tapJoyAppID = manifestKeyMap.get("tapJoyAppID");
		String tapJoySecretKey = manifestKeyMap.get("tapJoySecretKey");
		logger.log("{tapjoy} Installing TapJoy for appID:", tapJoyAppID);
		TapjoyLog.enableLogging(true);
		TapjoyConnect.requestTapjoyConnect(_ctx, tapJoyAppID, tapJoySecretKey);
	}

Output:
	public void onCreate(Activity activity, Bundle savedInstanceState) {
		PackageManager manager = activity.getBaseContext().getPackageManager();
		String[] keys = {"tapjoyAppID", "tapjoySecretKey"};
		try {
			Bundle meta = manager.getApplicationInfo(activity.getApplicationContext().getPackageName(),
					PackageManager.GET_META_DATA).metaData;
			for (String k : keys) {
				if (meta.containsKey(k)) {
					manifestKeyMap.put(k, meta.get(k).toString());
				}
			}
		} catch (Exception e) {
			logger.log("Exception while loading manifest keys:", e);
		}
		String tapJoyAppID = manifestKeyMap.get("tapjoyAppID");
		String tapJoySecretKey = manifestKeyMap.get("tapjoySecretKey");
		logger.log("{tapjoy} Installing for appID:", tapJoyAppID);
		TapjoyLog.enableLogging(true);
		TapjoyConnect.requestTapjoyConnect(_ctx, tapJoyAppID, tapJoySecretKey);
	}


Input:
    public void setLocale(Locale locale)
    {
        Locale oldLocale = this.locale;
        this.locale = locale;
        firePropertyChange("locale", locale, oldLocale);
    }

Output:
    public void setLocale(Locale locale)
    {
        Locale oldLocale = this.locale;
        this.locale = locale;
        firePropertyChange("locale", oldLocale, locale);
    }


Input:
	public static void main(String[] args) {
		try {
			try {
				CORE_LOCATION = CredentialLoader.class.getClassLoader()
						.getResource("resources/irma_configuration/").toURI();
			} catch (URISyntaxException e) {
				e.printStackTrace();
				throw new RuntimeException(e.toString());
			}
			Card card = getCardFromDb(args[0]);
			Random rand = new Random();
			byte[] credentialPin = new byte[4];
			for(int i = 0; i < 4; i++) {
				credentialPin[i] = (byte) (rand.nextInt(10) + 0x30);
			}
			byte[] cardPin = new byte[6];
			for(int i = 0; i < 6; i++) {
				cardPin[i] = (byte) (rand.nextInt(10) + 0x30);
			}
			System.out.println("CORE_LOCATION: " + CORE_LOCATION);
			CredentialInformation.setCoreLocation(CORE_LOCATION);
			DescriptionStore.setCoreLocation(CORE_LOCATION);
			Attributes attributes = new Attributes();
			attributes.add("userID", card.getUserID().getBytes());
			attributes.add("securityHash", hash(card.getUserID(), Integer.toString(card.getCardId())));
			IssueCredentialInformation ici = new IssueCredentialInformation("Surfnet", "root");
			IdemixIssueSpecification spec = ici.getIdemixIssueSpecification();
			IdemixPrivateKey isk = ici.getIdemixPrivateKey();
			CardTerminal terminal = TerminalFactory.getDefault().terminals().list().get(0);
			IdemixService is = new IdemixService(new TerminalCardService(terminal));
			IdemixCredentials ic = new IdemixCredentials(is);
			ic.connect();
			is.sendPin(TestSetup.DEFAULT_CRED_PIN);
			ic.issue(spec, isk, attributes, null);
			System.exit(0);
		}
		catch(Exception e) {
			System.err.println("Exception in Credential Loader: " + e.toString());
			e.printStackTrace();
			System.exit(1);
		}
	}

Output:
	public static void main(String[] args) {
		try {
			CORE_LOCATION= new File(System
					.getProperty("user.dir")).toURI()
					.resolve("irma_configuration/");
			Card card = getCardFromDb(args[0]);
			Random rand = new Random();
			byte[] credentialPin = new byte[4];
			for(int i = 0; i < 4; i++) {
				credentialPin[i] = (byte) (rand.nextInt(10) + 0x30);
			}
			byte[] cardPin = new byte[6];
			for(int i = 0; i < 6; i++) {
				cardPin[i] = (byte) (rand.nextInt(10) + 0x30);
			}
			System.out.println("CORE_LOCATION: " + CORE_LOCATION);
			CredentialInformation.setCoreLocation(CORE_LOCATION);
			DescriptionStore.setCoreLocation(CORE_LOCATION);
			Attributes attributes = new Attributes();
			attributes.add("userID", card.getUserID().getBytes());
			attributes.add("securityHash", hash(card.getUserID(), Integer.toString(card.getCardId())));
			IssueCredentialInformation ici = new IssueCredentialInformation("Surfnet", "root");
			IdemixIssueSpecification spec = ici.getIdemixIssueSpecification();
			IdemixPrivateKey isk = ici.getIdemixPrivateKey();
			CardTerminal terminal = TerminalFactory.getDefault().terminals().list().get(0);
			IdemixService is = new IdemixService(new TerminalCardService(terminal));
			IdemixCredentials ic = new IdemixCredentials(is);
			ic.connect();
			is.sendPin(TestSetup.DEFAULT_CRED_PIN);
			ic.issue(spec, isk, attributes, null);
			System.exit(0);
		}
		catch(Exception e) {
			System.err.println("Exception in Credential Loader: " + e.toString());
			e.printStackTrace();
			System.exit(1);
		}
	}


Input:
    private void updateColony(Colony colony) {
        final Specification spec = getSpecification();
        final GoodsType foodType = spec.getPrimaryFoodType();
        final UnitType colonistType
            = spec.getUnitType("model.unit.freeColonist");
        final ImageLibrary lib = getCanvas().getImageLibrary();
        final String cac = colony.getId();
        List<Tile> exploreTiles = new ArrayList<Tile>();
        List<Tile> clearTiles = new ArrayList<Tile>();
        List<Tile> plowTiles = new ArrayList<Tile>();
        List<Tile> roadTiles = new ArrayList<Tile>();
        colony.getColonyTileTodo(exploreTiles, clearTiles, plowTiles,
            roadTiles);
        boolean plowMe = plowTiles.size() > 0
            && plowTiles.get(0) == colony.getTile();
        int newFood = colony.getAdjustedNetProductionOf(foodType);
        boolean famine = newFood < 0
            && colony.getGoodsCount(foodType) / -newFood <= 3;
        int newColonist = (newFood == 0) ? 0
            : (newFood < 0) ? colony.getGoodsCount(foodType) / newFood - 1
            : (Settlement.FOOD_PER_COLONIST - colony.getGoodsCount(foodType))
                / newFood + 1;
        int pop = colony.getUnitCount();
        int grow, bonus = colony.getProductionBonus();
        if (bonus < 0) {
            int i;
            for (i = 1; i < pop; i++) {
                if (colony.governmentChange(pop - i) == 1) break;
            }
            grow = -i;
        } else {
            int i;
            for (i = 1; i < pop; i++) {
                if (colony.governmentChange(pop + i) == -1) break;
            }
            grow = i - 1;
        }
        JButton b = colourButton(cac, colony.getName(), null,
            (bonus <= -2) ? cAlarm
            : (bonus == -1) ? cWarn
            : (bonus == 0) ? cPlain
            : (bonus == 1) ? cExport
            : cGood,
            null);
        if (famine) {
            b.setFont(b.getFont().deriveFont(Font.BOLD));
        }
        reportPanel.add(b, "newline");
        if (exploreTiles.size() > 0) {
            b = colourButton(cac, Integer.toString(exploreTiles.size()),
                null, cAlarm,
                stpl("report.colony.exploring.description")
                    .addName("%colony%", colony.getName())
                    .addAmount("%amount%", exploreTiles.size()));
            reportPanel.add(b);
        } else {
            reportPanel.add(new JLabel(""));
        }
        if (plowTiles.size() > 0) {
            b = colourButton(cac, Integer.toString(plowTiles.size()),
                null, cAlarm,
                stpl("report.colony.plowing.description")
                    .addName("%colony%", colony.getName())
                    .addAmount("%amount%", plowTiles.size()));
            if (plowMe) {
                b.setFont(b.getFont().deriveFont(Font.BOLD));
            }
            reportPanel.add(b);
        } else {
            reportPanel.add(new JLabel(""));
        }
        if (roadTiles.size() > 0) {
            b = colourButton(cac, Integer.toString(roadTiles.size()),
                null, cAlarm,
                stpl("report.colony.roadBuilding.description")
                    .addName("%colony%", colony.getName())
                    .addAmount("%amount%", roadTiles.size()));
            reportPanel.add(b);
        } else {
            reportPanel.add(new JLabel(""));
        }
        final int adjustment = colony.getWarehouseCapacity()
            / GoodsContainer.CARGO_SIZE;
        for (GoodsType g : goodsTypes) {
            int p = colony.getAdjustedNetProductionOf(g);
            ExportData exportData = colony.getExportData(g);
            int low = exportData.getLowLevel() * adjustment;
            int high = exportData.getHighLevel() * adjustment;
            int amount = colony.getGoodsCount(g);
            Color c;
            StringTemplate tip;
            if (p < 0) {
                if (amount < low) {
                    int turns = amount / p + 1;
                    c = cAlarm;
                    tip = stpl("report.colony.production.low.description")
                        .addName("%colony%", colony.getName())
                        .add("%goods%", g.getNameKey())
                        .addAmount("%amount%", p)
                        .addAmount("%turns%", turns);
                } else {
                    c = cWarn;
                    tip = stpl("report.colony.production.description")
                            .addName("%colony%", colony.getName())
                            .add("%goods%", g.getNameKey())
                        .addAmount("%amount%", p);
                }
            } else if (p == 0) {
                if (colony.getProductionOf(g) == 0) {
                    c = null;
                    tip = null;
                } else {
                    c = cPlain;
                    tip = stpl("report.colony.production.description")
                        .addName("%colony%", colony.getName())
                        .add("%goods%", g.getNameKey())
                        .addAmount("%amount%", p);
                }
            } else if (exportData.isExported()) {
                c = cExport;
                tip = stpl("report.colony.production.export.description")
                    .addName("%colony%", colony.getName())
                    .add("%goods%", g.getNameKey())
                    .addAmount("%amount%", p)
                    .addAmount("%export%", exportData.getExportLevel());
            } else if (g != foodType
                && amount + p > colony.getWarehouseCapacity()) {
                c = cAlarm;
                int waste = amount + p - colony.getWarehouseCapacity();
                tip = stpl("report.colony.production.waste.description")
                    .addName("%colony%", colony.getName())
                    .add("%goods%", g.getNameKey())
                    .addAmount("%amount%", p)
                    .addAmount("%waste%", waste);
            } else if (g != foodType && amount > high) {
                int turns = (colony.getWarehouseCapacity() - amount) / p;
                c = cWarn;
                tip = stpl("report.colony.production.high.description")
                    .addName("%colony%", colony.getName())
                    .add("%goods%", g.getNameKey())
                    .addAmount("%amount%", p)
                    .addAmount("%turns%", turns);
            } else {
                c = cGood;
                tip = stpl("report.colony.production.description")
                    .addName("%colony%", colony.getName())
                    .add("%goods%", g.getNameKey())
                    .addAmount("%amount%", p);
            }
            if (c == null) reportPanel.add(new JLabel(""));
            else {
                b = colourButton(cac, Integer.toString(p), null, c, tip);
                reportPanel.add(b);
            }
        }
        HashMap<UnitType, Suggestion> improve
            = new HashMap<UnitType, Suggestion>();
        HashMap<UnitType, Suggestion> want
            = new HashMap<UnitType, Suggestion>();
        List<Unit> teachers = new ArrayList<Unit>();
        List<Unit> notWorking = new ArrayList<Unit>();
        for (Unit u : colony.getTile().getUnitList()) {
            if (u.getState() != UnitState.FORTIFIED
                && u.getState() != UnitState.SENTRY) {
                notWorking.add(u);
            }
        }
        for (WorkLocation wl : colony.getWorkLocations()) {
            if (wl instanceof ColonyTile) {
                if (!((ColonyTile) wl).canBeWorked()) continue;
            } else if (wl instanceof Building) {
                if (((Building) wl).canTeach()) {
                    teachers.addAll(wl.getUnitList());
                    continue;
                }
            }
            UnitType expert;
            GoodsType work;
            boolean needsWorker = wl.getUnitCount() < wl.getUnitCapacity();
            int delta;
            for (Unit u : wl.getUnitList()) {
                if (u.getTeacher() != null) {
                    continue;
                } else if ((work = u.getWorkType()) == null) {
                    notWorking.add(u);
                    needsWorker = true;
                } else if ((expert = spec.getExpertForProducing(work)) != null
                    && expert != u.getType()
                    && (delta = wl.getPotentialProduction(expert, work)
                        - wl.getPotentialProduction(u.getType(), work)) > 0
                    && wantGoods(wl, work, u, expert)) {
                    addSuggestion(improve, u.getType(), expert,
                        work, delta);
                }
            }
            if (needsWorker
                && (work = bestProduction(wl, colonistType)) != null
                && (expert = spec.getExpertForProducing(work)) != null
                && (delta = wl.getPotentialProduction(expert, work)) > 0
                && wantGoods(wl, work, null, expert)) {
                addSuggestion(want, null, expert, work, delta);
            }
        }
        List<UnitType> couldWork = new ArrayList<UnitType>();
        for (Unit u : notWorking) {
            GoodsType t = u.getWorkType();
            WorkLocation wl = (u.getLocation() instanceof Building
                || u.getLocation() instanceof ColonyTile)
                ? (WorkLocation) u.getLocation()
                : null;
            GoodsType w = bestProduction(wl, colonistType);
            if (w == null || w != t) couldWork.add(u.getType());
        }
        if (newColonist > 0) {
            b = colourButton(cac, Integer.toString(newColonist),
                null, cGood,
                stpl("report.colony.arriving.description")
                    .addName("%colony%", colony.getName())
                    .add("%unit%", colonistType.getNameKey())
                    .addAmount("%turns%", newColonist));
            reportPanel.add(b);
        } else if (newColonist < 0) {
            b = colourButton(cac, Integer.toString(-newColonist),
                null, (newColonist >= -3) ? cAlarm : cWarn,
                stpl("report.colony.starving.description")
                    .addName("%colony%", colony.getName())
                    .addAmount("%turns%", -newColonist));
            reportPanel.add(b);
        } else {
            reportPanel.add(new JLabel(""));
        }
        BuildableType build = colony.getCurrentlyBuilding();
        int fields = 1 + teachers.size();
        String layout = (fields > 1) ? "split " + fields : null;
        String qac = BUILDQUEUE + colony.getId();
        if (build == null) {
            b = colourButton(qac, Messages.message("nothing"),
                null, cAlarm,
                stpl("report.colony.making.noconstruction.description")
                    .addName("%colony%", colony.getName()));
            b.setFont(b.getFont().deriveFont(Font.BOLD));
        } else {
            int turns = colony.getTurnsToComplete(build);
            String name = Messages.message(build.getNameKey());
            if (turns == FreeColObject.UNDEFINED) {
                b = colourButton(qac, name, null, cAlarm,
                    stpl("report.colony.making.noconstruction.description")
                        .addName("%colony%", colony.getName()));
            } else if (turns >= 0) {
                turns++;
                name += " " + Integer.toString(turns);
                b = colourButton(qac, name, null, cGood,
                    stpl("report.colony.making.constructing.description")
                        .addName("%colony%", colony.getName())
                        .add("%buildable%", build.getNameKey())
                        .addAmount("%turns%", turns));;
            } else if (turns < 0) {
                turns = -turns;
                name += " " + Integer.toString(turns);
                b = colourButton(qac, name, null, cAlarm,
                    stpl("report.colony.making.block.description")
                        .addName("%colony%", colony.getName())
                        .add("%buildable%", build.getNameKey())
                        .addAmount("%turns%", turns));
            }
        }
        reportPanel.add(b, layout);
        layout = null;
        Collections.sort(teachers, teacherComparator);
        for (Unit u : teachers) {
            int left = u.getNeededTurnsOfTraining()
                - u.getTurnsOfTraining();
            JLabel teach;
            if (left <= 0) {
                b = colourButton(cac, Integer.toString(0),
                    lib.getUnitImageIcon(u.getType(), Role.DEFAULT,
                        true, 0.333), cAlarm,
                    stpl("report.colony.making.noteach.description")
                        .addName("%colony%", colony.getName())
                        .addStringTemplate("%teacher%", u.getLabel()));
            } else {
                b = colourButton(cac, Integer.toString(left),
                    lib.getUnitImageIcon(u.getType(), Role.DEFAULT,
                        true, 0.333), Color.BLACK,
                    stpl("report.colony.making.educating.description")
                        .addName("%colony%", colony.getName())
                        .addStringTemplate("%teacher%", u.getLabel())
                        .addAmount("%turns%", left));
            }
            reportPanel.add(b);
        }
        if (fields <= 0) reportPanel.add(new JLabel(""));
        if (!improve.isEmpty()) {
            addUnits(improve, couldWork, colony, grow);
        } else {
            reportPanel.add(new JLabel(""));
        }
        if (grow < 0) {
            b = colourButton(cac, Integer.toString(-grow), null, cAlarm,
                stpl("report.colony.shrinking.description")
                    .addName("%colony%", colony.getName())
                    .addAmount("%amount%", -grow));
            reportPanel.add(b);
        } else if (grow > 0) {
            b = colourButton(cac, Integer.toString(grow), null, cGood,
                stpl("report.colony.growing.description")
                    .addName("%colony%", colony.getName())
                    .addAmount("%amount%", grow));
            reportPanel.add(b);
        } else {
            reportPanel.add(new JLabel(""));
        }
        if (!want.isEmpty()) {
            grow = Math.min(grow, colony.getNetProductionOf(foodType)
                / Settlement.FOOD_PER_COLONIST);
            addUnits(want, couldWork, colony, grow);
        } else {
            reportPanel.add(new JLabel(""));
        }
    }

Output:
    private void updateColony(Colony colony) {
        final Specification spec = getSpecification();
        final GoodsType foodType = spec.getPrimaryFoodType();
        final UnitType colonistType
            = spec.getUnitType("model.unit.freeColonist");
        final ImageLibrary lib = getCanvas().getImageLibrary();
        final String cac = colony.getId();
        List<Tile> exploreTiles = new ArrayList<Tile>();
        List<Tile> clearTiles = new ArrayList<Tile>();
        List<Tile> plowTiles = new ArrayList<Tile>();
        List<Tile> roadTiles = new ArrayList<Tile>();
        colony.getColonyTileTodo(exploreTiles, clearTiles, plowTiles,
            roadTiles);
        boolean plowMe = plowTiles.size() > 0
            && plowTiles.get(0) == colony.getTile();
        int newFood = colony.getAdjustedNetProductionOf(foodType);
        boolean famine = newFood < 0
            && colony.getGoodsCount(foodType) / -newFood <= 3;
        int newColonist = (newFood == 0) ? 0
            : (newFood < 0) ? colony.getGoodsCount(foodType) / newFood - 1
            : (Settlement.FOOD_PER_COLONIST - colony.getGoodsCount(foodType))
                / newFood + 1;
        int pop = colony.getUnitCount();
        int grow, bonus = colony.getProductionBonus();
        if (bonus < 0) {
            int i;
            for (i = 1; i < pop; i++) {
                if (colony.governmentChange(pop - i) == 1) break;
            }
            grow = -i;
        } else {
            int i;
            for (i = 1; i < pop; i++) {
                if (colony.governmentChange(pop + i) == -1) break;
            }
            grow = i - 1;
        }
        JButton b = colourButton(cac, colony.getName(), null,
            (bonus <= -2) ? cAlarm
            : (bonus == -1) ? cWarn
            : (bonus == 0) ? cPlain
            : (bonus == 1) ? cExport
            : cGood,
            null);
        if (famine) {
            b.setFont(b.getFont().deriveFont(Font.BOLD));
        }
        reportPanel.add(b, "newline");
        if (exploreTiles.size() > 0) {
            b = colourButton(cac, Integer.toString(exploreTiles.size()),
                null, cAlarm,
                stpl("report.colony.exploring.description")
                    .addName("%colony%", colony.getName())
                    .addAmount("%amount%", exploreTiles.size()));
            reportPanel.add(b);
        } else {
            reportPanel.add(new JLabel(""));
        }
        if (plowTiles.size() > 0) {
            b = colourButton(cac, Integer.toString(plowTiles.size()),
                null, cAlarm,
                stpl("report.colony.plowing.description")
                    .addName("%colony%", colony.getName())
                    .addAmount("%amount%", plowTiles.size()));
            if (plowMe) {
                b.setFont(b.getFont().deriveFont(Font.BOLD));
            }
            reportPanel.add(b);
        } else {
            reportPanel.add(new JLabel(""));
        }
        if (roadTiles.size() > 0) {
            b = colourButton(cac, Integer.toString(roadTiles.size()),
                null, cAlarm,
                stpl("report.colony.roadBuilding.description")
                    .addName("%colony%", colony.getName())
                    .addAmount("%amount%", roadTiles.size()));
            reportPanel.add(b);
        } else {
            reportPanel.add(new JLabel(""));
        }
        final int adjustment = colony.getWarehouseCapacity()
            / GoodsContainer.CARGO_SIZE;
        for (GoodsType g : goodsTypes) {
            int p = colony.getAdjustedNetProductionOf(g);
            ExportData exportData = colony.getExportData(g);
            int low = exportData.getLowLevel() * adjustment;
            int high = exportData.getHighLevel() * adjustment;
            int amount = colony.getGoodsCount(g);
            Color c;
            StringTemplate tip;
            if (p < 0) {
                if (amount < low) {
                    int turns = -amount / p + 1;
                    c = cAlarm;
                    tip = stpl("report.colony.production.low.description")
                        .addName("%colony%", colony.getName())
                        .add("%goods%", g.getNameKey())
                        .addAmount("%amount%", p)
                        .addAmount("%turns%", turns);
                } else {
                    c = cWarn;
                    tip = stpl("report.colony.production.description")
                            .addName("%colony%", colony.getName())
                            .add("%goods%", g.getNameKey())
                        .addAmount("%amount%", p);
                }
            } else if (p == 0) {
                if (colony.getProductionOf(g) == 0) {
                    c = null;
                    tip = null;
                } else {
                    c = cPlain;
                    tip = stpl("report.colony.production.description")
                        .addName("%colony%", colony.getName())
                        .add("%goods%", g.getNameKey())
                        .addAmount("%amount%", p);
                }
            } else if (exportData.isExported()) {
                c = cExport;
                tip = stpl("report.colony.production.export.description")
                    .addName("%colony%", colony.getName())
                    .add("%goods%", g.getNameKey())
                    .addAmount("%amount%", p)
                    .addAmount("%export%", exportData.getExportLevel());
            } else if (g != foodType
                && amount + p > colony.getWarehouseCapacity()) {
                c = cAlarm;
                int waste = amount + p - colony.getWarehouseCapacity();
                tip = stpl("report.colony.production.waste.description")
                    .addName("%colony%", colony.getName())
                    .add("%goods%", g.getNameKey())
                    .addAmount("%amount%", p)
                    .addAmount("%waste%", waste);
            } else if (g != foodType && amount > high) {
                int turns = (colony.getWarehouseCapacity() - amount) / p;
                c = cWarn;
                tip = stpl("report.colony.production.high.description")
                    .addName("%colony%", colony.getName())
                    .add("%goods%", g.getNameKey())
                    .addAmount("%amount%", p)
                    .addAmount("%turns%", turns);
            } else {
                c = cGood;
                tip = stpl("report.colony.production.description")
                    .addName("%colony%", colony.getName())
                    .add("%goods%", g.getNameKey())
                    .addAmount("%amount%", p);
            }
            if (c == null) reportPanel.add(new JLabel(""));
            else {
                b = colourButton(cac, Integer.toString(p), null, c, tip);
                reportPanel.add(b);
            }
        }
        HashMap<UnitType, Suggestion> improve
            = new HashMap<UnitType, Suggestion>();
        HashMap<UnitType, Suggestion> want
            = new HashMap<UnitType, Suggestion>();
        List<Unit> teachers = new ArrayList<Unit>();
        List<Unit> notWorking = new ArrayList<Unit>();
        for (Unit u : colony.getTile().getUnitList()) {
            if (u.getState() != UnitState.FORTIFIED
                && u.getState() != UnitState.SENTRY) {
                notWorking.add(u);
            }
        }
        for (WorkLocation wl : colony.getWorkLocations()) {
            if (wl instanceof ColonyTile) {
                if (!((ColonyTile) wl).canBeWorked()) continue;
            } else if (wl instanceof Building) {
                if (((Building) wl).canTeach()) {
                    teachers.addAll(wl.getUnitList());
                    continue;
                }
            }
            UnitType expert;
            GoodsType work;
            boolean needsWorker = wl.getUnitCount() < wl.getUnitCapacity();
            int delta;
            for (Unit u : wl.getUnitList()) {
                if (u.getTeacher() != null) {
                    continue;
                } else if ((work = u.getWorkType()) == null) {
                    notWorking.add(u);
                    needsWorker = true;
                } else if ((expert = spec.getExpertForProducing(work)) != null
                    && expert != u.getType()
                    && (delta = wl.getPotentialProduction(expert, work)
                        - wl.getPotentialProduction(u.getType(), work)) > 0
                    && wantGoods(wl, work, u, expert)) {
                    addSuggestion(improve, u.getType(), expert,
                        work, delta);
                }
            }
            if (needsWorker
                && (work = bestProduction(wl, colonistType)) != null
                && (expert = spec.getExpertForProducing(work)) != null
                && (delta = wl.getPotentialProduction(expert, work)) > 0
                && wantGoods(wl, work, null, expert)) {
                addSuggestion(want, null, expert, work, delta);
            }
        }
        List<UnitType> couldWork = new ArrayList<UnitType>();
        for (Unit u : notWorking) {
            GoodsType t = u.getWorkType();
            WorkLocation wl = (u.getLocation() instanceof Building
                || u.getLocation() instanceof ColonyTile)
                ? (WorkLocation) u.getLocation()
                : null;
            GoodsType w = bestProduction(wl, colonistType);
            if (w == null || w != t) couldWork.add(u.getType());
        }
        if (newColonist > 0) {
            b = colourButton(cac, Integer.toString(newColonist),
                null, cGood,
                stpl("report.colony.arriving.description")
                    .addName("%colony%", colony.getName())
                    .add("%unit%", colonistType.getNameKey())
                    .addAmount("%turns%", newColonist));
            reportPanel.add(b);
        } else if (newColonist < 0) {
            b = colourButton(cac, Integer.toString(-newColonist),
                null, (newColonist >= -3) ? cAlarm : cWarn,
                stpl("report.colony.starving.description")
                    .addName("%colony%", colony.getName())
                    .addAmount("%turns%", -newColonist));
            reportPanel.add(b);
        } else {
            reportPanel.add(new JLabel(""));
        }
        BuildableType build = colony.getCurrentlyBuilding();
        int fields = 1 + teachers.size();
        String layout = (fields > 1) ? "split " + fields : null;
        String qac = BUILDQUEUE + colony.getId();
        if (build == null) {
            b = colourButton(qac, Messages.message("nothing"),
                null, cAlarm,
                stpl("report.colony.making.noconstruction.description")
                    .addName("%colony%", colony.getName()));
            b.setFont(b.getFont().deriveFont(Font.BOLD));
        } else {
            int turns = colony.getTurnsToComplete(build);
            String name = Messages.message(build.getNameKey());
            if (turns == FreeColObject.UNDEFINED) {
                b = colourButton(qac, name, null, cAlarm,
                    stpl("report.colony.making.noconstruction.description")
                        .addName("%colony%", colony.getName()));
            } else if (turns >= 0) {
                turns++;
                name += " " + Integer.toString(turns);
                b = colourButton(qac, name, null, cGood,
                    stpl("report.colony.making.constructing.description")
                        .addName("%colony%", colony.getName())
                        .add("%buildable%", build.getNameKey())
                        .addAmount("%turns%", turns));;
            } else if (turns < 0) {
                turns = -turns;
                name += " " + Integer.toString(turns);
                b = colourButton(qac, name, null, cAlarm,
                    stpl("report.colony.making.block.description")
                        .addName("%colony%", colony.getName())
                        .add("%buildable%", build.getNameKey())
                        .addAmount("%turns%", turns));
            }
        }
        reportPanel.add(b, layout);
        layout = null;
        Collections.sort(teachers, teacherComparator);
        for (Unit u : teachers) {
            int left = u.getNeededTurnsOfTraining()
                - u.getTurnsOfTraining();
            JLabel teach;
            if (left <= 0) {
                b = colourButton(cac, Integer.toString(0),
                    lib.getUnitImageIcon(u.getType(), Role.DEFAULT,
                        true, 0.333), cAlarm,
                    stpl("report.colony.making.noteach.description")
                        .addName("%colony%", colony.getName())
                        .addStringTemplate("%teacher%", u.getLabel()));
            } else {
                b = colourButton(cac, Integer.toString(left),
                    lib.getUnitImageIcon(u.getType(), Role.DEFAULT,
                        true, 0.333), Color.BLACK,
                    stpl("report.colony.making.educating.description")
                        .addName("%colony%", colony.getName())
                        .addStringTemplate("%teacher%", u.getLabel())
                        .addAmount("%turns%", left));
            }
            reportPanel.add(b);
        }
        if (fields <= 0) reportPanel.add(new JLabel(""));
        if (!improve.isEmpty()) {
            addUnits(improve, couldWork, colony, grow);
        } else {
            reportPanel.add(new JLabel(""));
        }
        if (grow < 0) {
            b = colourButton(cac, Integer.toString(-grow), null, cAlarm,
                stpl("report.colony.shrinking.description")
                    .addName("%colony%", colony.getName())
                    .addAmount("%amount%", -grow));
            reportPanel.add(b);
        } else if (grow > 0) {
            b = colourButton(cac, Integer.toString(grow), null, cGood,
                stpl("report.colony.growing.description")
                    .addName("%colony%", colony.getName())
                    .addAmount("%amount%", grow));
            reportPanel.add(b);
        } else {
            reportPanel.add(new JLabel(""));
        }
        if (!want.isEmpty()) {
            grow = Math.min(grow, colony.getNetProductionOf(foodType)
                / Settlement.FOOD_PER_COLONIST);
            addUnits(want, couldWork, colony, grow);
        } else {
            reportPanel.add(new JLabel(""));
        }
    }


Input:
	protected void onCreate(Bundle savedInstanceState) {
		Log.v("cr3", "creating OptionsDialog");
		CoolReader.dumpHeapAllocation();
		Log.v("cr3", "calling gc");
		System.gc();
		CoolReader.dumpHeapAllocation();
		Log.v("cr3", "creating options dialog");
		setTitle(null);
        setCancelable(true);
        setCanceledOnTouchOutside(true);
        mInflater = LayoutInflater.from(getContext());
        mTabs = (TabHost)mInflater.inflate(R.layout.options, null);
		mTabs.setup();
		mOptionsStyles = new OptionsListView(getContext());
		mOptionsStyles.add(new ListOption(this, getString(R.string.options_font_face), ReaderView.PROP_FONT_FACE).add(mFontFaces).setDefaultValue(mFontFaces[0]).setIconId(R.drawable.cr3_option_font_face));
		mOptionsStyles.add(new ListOption(this, getString(R.string.options_font_size), ReaderView.PROP_FONT_SIZE).add(mFontSizes).setDefaultValue("24").setIconId(R.drawable.cr3_option_font_size));
		mOptionsStyles.add(new BoolOption(this, getString(R.string.options_font_embolden), ReaderView.PROP_FONT_WEIGHT_EMBOLDEN).setDefaultValue("0").setIconId(R.drawable.cr3_option_text_bold));
		mOptionsStyles.add(new BoolOption(this, getString(R.string.options_font_embolden), ReaderView.PROP_FONT_WEIGHT_EMBOLDEN).setDefaultValue("0").setIconId(R.drawable.cr3_option_text_bold));
		mOptionsStyles.add(new ListOption(this, getString(R.string.options_font_antialias), ReaderView.PROP_FONT_ANTIALIASING).add(mAntialias, mAntialiasTitles).setDefaultValue("2"));
		mOptionsStyles.add(new ListOption(this, getString(R.string.options_interline_space), ReaderView.PROP_INTERLINE_SPACE).addPercents(mInterlineSpaces).setDefaultValue("100"));
		mOptionsStyles.add(new NightModeOption(this, getString(R.string.options_inverse_view), ReaderView.PROP_NIGHT_MODE));
		mOptionsStyles.add(new ColorOption(this, getString(R.string.options_color_text), ReaderView.PROP_FONT_COLOR, 0x000000));
		mOptionsStyles.add(new ColorOption(this, getString(R.string.options_color_background), ReaderView.PROP_BACKGROUND_COLOR, 0xFFFFFF));
		mOptionsStyles.add(new TextureOptions(this, getString(R.string.options_background_texture)));
		mBacklightLevelsTitles[0] = getString(R.string.options_app_backlight_screen_default);
		mOptionsStyles.add(new ListOption(this, getString(R.string.options_app_backlight_screen), ReaderView.PROP_APP_SCREEN_BACKLIGHT).add(mBacklightLevels, mBacklightLevelsTitles).setDefaultValue("-1"));
		mOptionsStyles.add(new HyphenationOptions(this, getString(R.string.options_hyphenation_dictionary)));
		mOptionsStyles.add(new BoolOption(this, getString(R.string.options_style_floating_punctuation), ReaderView.PROP_FLOATING_PUNCTUATION).setDefaultValue("1"));
		mOptionsStyles.add(new BoolOption(this, getString(R.string.options_font_kerning), ReaderView.PROP_FONT_KERNING_ENABLED).setDefaultValue("0"));
		mOptionsPage = new OptionsListView(getContext());
		mOptionsPage.add(new ListOption(this, getString(R.string.options_view_mode), ReaderView.PROP_PAGE_VIEW_MODE).add(mViewModes, mViewModeTitles).setDefaultValue("1"));
		mOptionsPage.add( new StatusBarOption(this, getString(R.string.options_page_titlebar)));
		mOptionsPage.add(new BoolOption(this, getString(R.string.options_page_footnotes), ReaderView.PROP_FOOTNOTES).setDefaultValue("1"));
		mOptionsPage.add(new ListOption(this, getString(R.string.options_page_orientation), ReaderView.PROP_APP_SCREEN_ORIENTATION).add(mOrientations, mOrientationsTitles).setDefaultValue("0").setIconId(android.R.drawable.ic_menu_always_landscape_portrait));
		mOptionsPage.add(new ListOption(this, getString(R.string.options_page_landscape_pages), ReaderView.PROP_LANDSCAPE_PAGES).add(mLandscapePages, mLandscapePagesTitles).setDefaultValue("1"));
		mOptionsPage.add(new ListOption(this, getString(R.string.options_page_animation), ReaderView.PROP_PAGE_ANIMATION).add(mAnimation, mAnimationTitles).setDefaultValue("1"));
		mOptionsPage.add(new ListOption(this, getString(R.string.options_page_margin_left), ReaderView.PROP_PAGE_MARGIN_LEFT).add(mMargins).setDefaultValue("5"));
		mOptionsPage.add(new ListOption(this, getString(R.string.options_page_margin_right), ReaderView.PROP_PAGE_MARGIN_RIGHT).add(mMargins).setDefaultValue("5"));
		mOptionsPage.add(new ListOption(this, getString(R.string.options_page_margin_top), ReaderView.PROP_PAGE_MARGIN_TOP).add(mMargins).setDefaultValue("5"));
		mOptionsPage.add(new ListOption(this, getString(R.string.options_page_margin_bottom), ReaderView.PROP_PAGE_MARGIN_BOTTOM).add(mMargins).setDefaultValue("5"));
		mOptionsApplication = new OptionsListView(getContext());
		mOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_fullscreen), ReaderView.PROP_APP_FULLSCREEN));
		mOptionsApplication.add(new DictOptions(this, getString(R.string.options_app_dictionary)));
		mOptionsApplication.add(new TapZoneOption(this, getString(R.string.options_app_tapzones_normal), ReaderView.PROP_APP_TAP_ZONE_ACTIONS_TAP));
		mOptionsApplication.add(new KeyMapOption(this, getString(R.string.options_app_key_actions)));
		mOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_show_cover_pages), ReaderView.PROP_APP_SHOW_COVERPAGES));
		mOptionsApplication.add(new BoolOption(this, getString(R.string.options_controls_enable_volume_keys), ReaderView.PROP_CONTROLS_ENABLE_VOLUME_KEYS).setDefaultValue("1"));
		mOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_double_tap_selection), ReaderView.PROP_APP_DOUBLE_TAP_SELECTION).setDefaultValue("0"));
		mOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_tapzone_hilite), ReaderView.PROP_APP_TAP_ZONE_HILIGHT).setDefaultValue("0"));
		mOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_trackball_disable), ReaderView.PROP_APP_TRACKBALL_DISABLED).setDefaultValue("0"));
		mOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_scan_book_props), ReaderView.PROP_APP_BOOK_PROPERTY_SCAN_ENABLED).setDefaultValue("1"));
		mOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_backlight_lock_enabled), ReaderView.PROP_APP_SCREEN_BACKLIGHT_LOCK).setDefaultValue("0"));
		mOptionsApplication.add(new ListOption(this, getString(R.string.options_controls_flick_brightness), ReaderView.PROP_APP_FLICK_BACKLIGHT_CONTROL).add(mFlickBrightness, mFlickBrightnessTitles).setDefaultValue("1"));
		mOptionsStyles.refresh();
		mOptionsPage.refresh();
		mOptionsApplication.refresh();
		TabHost.TabSpec tsStyles = mTabs.newTabSpec("Styles");
		tsStyles.setIndicator("",
				getContext().getResources().getDrawable(android.R.drawable.ic_menu_view));
		tsStyles.setContent(this);
		mTabs.addTab(tsStyles);
		TabHost.TabSpec tsPage = mTabs.newTabSpec("Page");
		tsPage.setIndicator("", getContext().getResources().getDrawable(android.R.drawable.ic_menu_crop));
		tsPage.setContent(this);
		mTabs.addTab(tsPage);
		TabHost.TabSpec tsApp = mTabs.newTabSpec("App");
		tsApp.setIndicator("",
				getContext().getResources().getDrawable(android.R.drawable.ic_menu_manage));
		tsApp.setContent(this);
		mTabs.addTab(tsApp);
		TabHost.TabSpec tsControls = mTabs.newTabSpec("Controls");
		tsControls.setIndicator(getContext().getResources().getString(R.string.tab_options_controls), getContext().getResources().getDrawable(android.R.drawable.ic_menu_manage));
		tsControls.setContent(this);
		setView(mTabs);
		mOldProperties = new Properties(mProperties);
		setOnCancelListener(new OnCancelListener() {
			public void onCancel(DialogInterface dialog) {
				askApply();
			}
		});
		super.onCreate(savedInstanceState);
		Log.v("cr3", "OptionsDialog is created");
	}

Output:
	protected void onCreate(Bundle savedInstanceState) {
		Log.v("cr3", "creating OptionsDialog");
		CoolReader.dumpHeapAllocation();
		Log.v("cr3", "calling gc");
		System.gc();
		CoolReader.dumpHeapAllocation();
		Log.v("cr3", "creating options dialog");
		setTitle(null);
        setCancelable(true);
        setCanceledOnTouchOutside(true);
        mInflater = LayoutInflater.from(getContext());
        mTabs = (TabHost)mInflater.inflate(R.layout.options, null);
		mTabs.setup();
		mOptionsStyles = new OptionsListView(getContext());
		mOptionsStyles.add(new ListOption(this, getString(R.string.options_font_face), ReaderView.PROP_FONT_FACE).add(mFontFaces).setDefaultValue(mFontFaces[0]).setIconId(R.drawable.cr3_option_font_face));
		mOptionsStyles.add(new ListOption(this, getString(R.string.options_font_size), ReaderView.PROP_FONT_SIZE).add(mFontSizes).setDefaultValue("24").setIconId(R.drawable.cr3_option_font_size));
		mOptionsStyles.add(new BoolOption(this, getString(R.string.options_font_embolden), ReaderView.PROP_FONT_WEIGHT_EMBOLDEN).setDefaultValue("0").setIconId(R.drawable.cr3_option_text_bold));
		mOptionsStyles.add(new ListOption(this, getString(R.string.options_font_antialias), ReaderView.PROP_FONT_ANTIALIASING).add(mAntialias, mAntialiasTitles).setDefaultValue("2"));
		mOptionsStyles.add(new ListOption(this, getString(R.string.options_interline_space), ReaderView.PROP_INTERLINE_SPACE).addPercents(mInterlineSpaces).setDefaultValue("100"));
		mOptionsStyles.add(new NightModeOption(this, getString(R.string.options_inverse_view), ReaderView.PROP_NIGHT_MODE));
		mOptionsStyles.add(new ColorOption(this, getString(R.string.options_color_text), ReaderView.PROP_FONT_COLOR, 0x000000));
		mOptionsStyles.add(new ColorOption(this, getString(R.string.options_color_background), ReaderView.PROP_BACKGROUND_COLOR, 0xFFFFFF));
		mOptionsStyles.add(new TextureOptions(this, getString(R.string.options_background_texture)));
		mBacklightLevelsTitles[0] = getString(R.string.options_app_backlight_screen_default);
		mOptionsStyles.add(new ListOption(this, getString(R.string.options_app_backlight_screen), ReaderView.PROP_APP_SCREEN_BACKLIGHT).add(mBacklightLevels, mBacklightLevelsTitles).setDefaultValue("-1"));
		mOptionsStyles.add(new HyphenationOptions(this, getString(R.string.options_hyphenation_dictionary)));
		mOptionsStyles.add(new BoolOption(this, getString(R.string.options_style_floating_punctuation), ReaderView.PROP_FLOATING_PUNCTUATION).setDefaultValue("1"));
		mOptionsStyles.add(new BoolOption(this, getString(R.string.options_font_kerning), ReaderView.PROP_FONT_KERNING_ENABLED).setDefaultValue("0"));
		mOptionsPage = new OptionsListView(getContext());
		mOptionsPage.add(new ListOption(this, getString(R.string.options_view_mode), ReaderView.PROP_PAGE_VIEW_MODE).add(mViewModes, mViewModeTitles).setDefaultValue("1"));
		mOptionsPage.add( new StatusBarOption(this, getString(R.string.options_page_titlebar)));
		mOptionsPage.add(new BoolOption(this, getString(R.string.options_page_footnotes), ReaderView.PROP_FOOTNOTES).setDefaultValue("1"));
		mOptionsPage.add(new ListOption(this, getString(R.string.options_page_orientation), ReaderView.PROP_APP_SCREEN_ORIENTATION).add(mOrientations, mOrientationsTitles).setDefaultValue("0").setIconId(android.R.drawable.ic_menu_always_landscape_portrait));
		mOptionsPage.add(new ListOption(this, getString(R.string.options_page_landscape_pages), ReaderView.PROP_LANDSCAPE_PAGES).add(mLandscapePages, mLandscapePagesTitles).setDefaultValue("1"));
		mOptionsPage.add(new ListOption(this, getString(R.string.options_page_animation), ReaderView.PROP_PAGE_ANIMATION).add(mAnimation, mAnimationTitles).setDefaultValue("1"));
		mOptionsPage.add(new ListOption(this, getString(R.string.options_page_margin_left), ReaderView.PROP_PAGE_MARGIN_LEFT).add(mMargins).setDefaultValue("5"));
		mOptionsPage.add(new ListOption(this, getString(R.string.options_page_margin_right), ReaderView.PROP_PAGE_MARGIN_RIGHT).add(mMargins).setDefaultValue("5"));
		mOptionsPage.add(new ListOption(this, getString(R.string.options_page_margin_top), ReaderView.PROP_PAGE_MARGIN_TOP).add(mMargins).setDefaultValue("5"));
		mOptionsPage.add(new ListOption(this, getString(R.string.options_page_margin_bottom), ReaderView.PROP_PAGE_MARGIN_BOTTOM).add(mMargins).setDefaultValue("5"));
		mOptionsApplication = new OptionsListView(getContext());
		mOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_fullscreen), ReaderView.PROP_APP_FULLSCREEN));
		mOptionsApplication.add(new DictOptions(this, getString(R.string.options_app_dictionary)));
		mOptionsApplication.add(new TapZoneOption(this, getString(R.string.options_app_tapzones_normal), ReaderView.PROP_APP_TAP_ZONE_ACTIONS_TAP));
		mOptionsApplication.add(new KeyMapOption(this, getString(R.string.options_app_key_actions)));
		mOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_show_cover_pages), ReaderView.PROP_APP_SHOW_COVERPAGES));
		mOptionsApplication.add(new BoolOption(this, getString(R.string.options_controls_enable_volume_keys), ReaderView.PROP_CONTROLS_ENABLE_VOLUME_KEYS).setDefaultValue("1"));
		mOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_double_tap_selection), ReaderView.PROP_APP_DOUBLE_TAP_SELECTION).setDefaultValue("0"));
		mOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_tapzone_hilite), ReaderView.PROP_APP_TAP_ZONE_HILIGHT).setDefaultValue("0"));
		mOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_trackball_disable), ReaderView.PROP_APP_TRACKBALL_DISABLED).setDefaultValue("0"));
		mOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_scan_book_props), ReaderView.PROP_APP_BOOK_PROPERTY_SCAN_ENABLED).setDefaultValue("1"));
		mOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_backlight_lock_enabled), ReaderView.PROP_APP_SCREEN_BACKLIGHT_LOCK).setDefaultValue("0"));
		mOptionsApplication.add(new ListOption(this, getString(R.string.options_controls_flick_brightness), ReaderView.PROP_APP_FLICK_BACKLIGHT_CONTROL).add(mFlickBrightness, mFlickBrightnessTitles).setDefaultValue("1"));
		mOptionsStyles.refresh();
		mOptionsPage.refresh();
		mOptionsApplication.refresh();
		TabHost.TabSpec tsStyles = mTabs.newTabSpec("Styles");
		tsStyles.setIndicator("",
				getContext().getResources().getDrawable(android.R.drawable.ic_menu_view));
		tsStyles.setContent(this);
		mTabs.addTab(tsStyles);
		TabHost.TabSpec tsPage = mTabs.newTabSpec("Page");
		tsPage.setIndicator("", getContext().getResources().getDrawable(android.R.drawable.ic_menu_crop));
		tsPage.setContent(this);
		mTabs.addTab(tsPage);
		TabHost.TabSpec tsApp = mTabs.newTabSpec("App");
		tsApp.setIndicator("",
				getContext().getResources().getDrawable(android.R.drawable.ic_menu_manage));
		tsApp.setContent(this);
		mTabs.addTab(tsApp);
		TabHost.TabSpec tsControls = mTabs.newTabSpec("Controls");
		tsControls.setIndicator(getContext().getResources().getString(R.string.tab_options_controls), getContext().getResources().getDrawable(android.R.drawable.ic_menu_manage));
		tsControls.setContent(this);
		setView(mTabs);
		mOldProperties = new Properties(mProperties);
		setOnCancelListener(new OnCancelListener() {
			public void onCancel(DialogInterface dialog) {
				askApply();
			}
		});
		super.onCreate(savedInstanceState);
		Log.v("cr3", "OptionsDialog is created");
	}


Input:
	public void before(Method method, Object[] args, Object target) throws Throwable {
		String methodName = method.getName();
		if (methodName.startsWith("save") || methodName.startsWith("create")) {
			if (args == null || args.length == 0)
				return;
			Object mainArgument = args[0];
			if (mainArgument == null)
				return;
			Reflect reflect = new Reflect(OpenmrsObject.class);
			if (reflect.isSuperClass(mainArgument)) {
				String other = null;
				if (args.length > 1)
					other = (String) args[1];
				recursivelyHandle(SaveHandler.class, (OpenmrsObject) mainArgument, other);
			}
			else if (Reflect.isCollection(mainArgument) && isOpenmrsObjectCollection(mainArgument)) {
				String other = null;
				if (args.length > 1)
					other = (String) args[1];
				Collection<OpenmrsObject> openmrsObjects = (Collection<OpenmrsObject>) mainArgument;
				for (OpenmrsObject object : openmrsObjects) {
					recursivelyHandle(SaveHandler.class, object, other);
				}
			}
		} else if (methodName.startsWith("void")) {
			Voidable voidable = (Voidable) args[0];
			String voidReason = (String) args[1];
			recursivelyHandle(VoidHandler.class, voidable, voidReason);
		} else if (methodName.startsWith("unvoid")) {
			Voidable voidable = (Voidable) args[0];
			Date originalDateVoided = voidable.getDateVoided();
			recursivelyHandle(UnvoidHandler.class, voidable, Context.getAuthenticatedUser(), originalDateVoided, null, null);
		} else if (methodName.startsWith("retire")) {
			Retireable retirable = (Retireable) args[0];
			String retireReason = (String) args[1];
			recursivelyHandle(RetireHandler.class, retirable, retireReason);
		} else if (methodName.startsWith("unretire")) {
			Retireable retirable = (Retireable) args[0];
			Date originalDateRetired = retirable.getDateRetired();
			recursivelyHandle(UnretireHandler.class, retirable, Context.getAuthenticatedUser(), originalDateRetired, null,
			    null);
		}
	}

Output:
	public void before(Method method, Object[] args, Object target) throws Throwable {
		String methodName = method.getName();
		if (methodName.startsWith("save") || methodName.startsWith("create")) {
			if (args == null || args.length == 0)
				return;
			Object mainArgument = args[0];
			if (mainArgument == null)
				return;
			Reflect reflect = new Reflect(OpenmrsObject.class);
			if (reflect.isSuperClass(mainArgument)) {
				String other = null;
				if (args.length > 1 && args[1] instanceof String)
					other = (String) args[1];
				recursivelyHandle(SaveHandler.class, (OpenmrsObject) mainArgument, other);
			}
			else if (Reflect.isCollection(mainArgument) && isOpenmrsObjectCollection(mainArgument)) {
				String other = null;
				if (args.length > 1)
					other = (String) args[1];
				Collection<OpenmrsObject> openmrsObjects = (Collection<OpenmrsObject>) mainArgument;
				for (OpenmrsObject object : openmrsObjects) {
					recursivelyHandle(SaveHandler.class, object, other);
				}
			}
		} else if (methodName.startsWith("void")) {
			Voidable voidable = (Voidable) args[0];
			String voidReason = (String) args[1];
			recursivelyHandle(VoidHandler.class, voidable, voidReason);
		} else if (methodName.startsWith("unvoid")) {
			Voidable voidable = (Voidable) args[0];
			Date originalDateVoided = voidable.getDateVoided();
			recursivelyHandle(UnvoidHandler.class, voidable, Context.getAuthenticatedUser(), originalDateVoided, null, null);
		} else if (methodName.startsWith("retire")) {
			Retireable retirable = (Retireable) args[0];
			String retireReason = (String) args[1];
			recursivelyHandle(RetireHandler.class, retirable, retireReason);
		} else if (methodName.startsWith("unretire")) {
			Retireable retirable = (Retireable) args[0];
			Date originalDateRetired = retirable.getDateRetired();
			recursivelyHandle(UnretireHandler.class, retirable, Context.getAuthenticatedUser(), originalDateRetired, null,
			    null);
		}
	}