Examples of asNumber()


Examples of com.creativewidgetworks.goldparser.parser.Variable.asNumber()

        Variable rValue = rightExpression.getValue();

        boolean b = false;
        if (theOperator.equals("==")) {
           if (bothValuesAreNumbers()) {
               b = lValue.asNumber().compareTo(rValue.asNumber()) == 0;
               result = new Variable(Boolean.valueOf(b));
           } else if (bothValuesAreBooleans()) {
               b = lValue.asBool() == rValue.asBool();
               result = new Variable(Boolean.valueOf(b));
           } else if (bothValuesAreTimestamps()) {
View Full Code Here

Examples of com.creativewidgetworks.goldparser.parser.Variable.asNumber()

           } else {
               theParser.raiseParserException(Simple3.formatMessage("error.type_mismatch"));
           }
        } else if (theOperator.equals("<>")) {
            if (bothValuesAreNumbers()) {
                b = lValue.asNumber().compareTo(rValue.asNumber()) != 0;
                result = new Variable(Boolean.valueOf(b));
            } else if (bothValuesAreBooleans()) {
                b = lValue.asBool() != rValue.asBool();
                result = new Variable(Boolean.valueOf(b));
            } else if (bothValuesAreTimestamps()) {
View Full Code Here

Examples of com.creativewidgetworks.goldparser.parser.Variable.asNumber()

            } else {
                theParser.raiseParserException(Simple3.formatMessage("error.type_mismatch"));
            }
        } else if (theOperator.equals("<")) {
            if (bothValuesAreNumbers()) {
                b = lValue.asNumber().compareTo(rValue.asNumber()) < 0;
                result = new Variable(Boolean.valueOf(b));
            } else if (bothValuesAreTimestamps()) {
                b = lValue.asTimestamp().compareTo(rValue.asTimestamp()) < 0;
                result = new Variable(Boolean.valueOf(b));
            } else if (oneOrBothValuesAreStrings()) {
View Full Code Here

Examples of com.creativewidgetworks.goldparser.parser.Variable.asNumber()

            } else {
                theParser.raiseParserException(Simple3.formatMessage("error.type_mismatch"));
            }
        } else if (theOperator.equals("<=")) {
            if (bothValuesAreNumbers()) {
                b = lValue.asNumber().compareTo(rValue.asNumber()) <= 0;
                result = new Variable(Boolean.valueOf(b));
            } else if (bothValuesAreTimestamps()) {
                b = lValue.asTimestamp().compareTo(rValue.asTimestamp()) <= 0;
                result = new Variable(Boolean.valueOf(b));
            } else if (oneOrBothValuesAreStrings()) {
View Full Code Here

Examples of com.creativewidgetworks.goldparser.parser.Variable.asNumber()

            } else {
                theParser.raiseParserException(Simple3.formatMessage("error.type_mismatch"));
            }
        } else if (theOperator.equals(">")) {
            if (bothValuesAreNumbers()) {
                b = lValue.asNumber().compareTo(rValue.asNumber()) > 0;
                result = new Variable(Boolean.valueOf(b));
            } else if (bothValuesAreTimestamps()) {
                b = lValue.asTimestamp().compareTo(rValue.asTimestamp()) > 0;
                result = new Variable(Boolean.valueOf(b));
            } else if (oneOrBothValuesAreStrings()) {
View Full Code Here

Examples of com.creativewidgetworks.goldparser.parser.Variable.asNumber()

            } else {
                theParser.raiseParserException(Simple3.formatMessage("error.type_mismatch"));
            }
        } else if (theOperator.equals(">=")) {
            if (bothValuesAreNumbers()) {
                b = lValue.asNumber().compareTo(rValue.asNumber()) >= 0;
                result = new Variable(Boolean.valueOf(b));
            } else if (bothValuesAreTimestamps()) {
                b = lValue.asTimestamp().compareTo(rValue.asTimestamp()) >= 0;
                result = new Variable(Boolean.valueOf(b));
            } else if (oneOrBothValuesAreStrings()) {
View Full Code Here

Examples of com.creativewidgetworks.goldparser.parser.Variable.asNumber()

            } else {
                theParser.raiseParserException(Simple3.formatMessage("error.type_mismatch"));
            }
        } else if (theOperator.equals("+")) {
            if (bothValuesAreNumbers()) {
                result = new Variable(lValue.asNumber().add(rValue.asNumber()));
            } else {
                // I prefer to overload + depending upon type
                result = new Variable(lValue.toString() + rValue.toString());
            }
        } else if (theOperator.equals("-")) {
View Full Code Here

Examples of com.creativewidgetworks.goldparser.parser.Variable.asNumber()

                // I prefer to overload + depending upon type
                result = new Variable(lValue.toString() + rValue.toString());
            }
        } else if (theOperator.equals("-")) {
            if (bothValuesAreNumbers()) {
                result = new Variable(lValue.asNumber().subtract(rValue.asNumber()));
            } else {
                theParser.raiseParserException(Simple3.formatMessage("error.type_mismatch"));
            }
        } else if (theOperator.equals("&")) {
            // String concatenation
View Full Code Here

Examples of com.creativewidgetworks.goldparser.parser.Variable.asNumber()

            } else {
                theParser.raiseParserException(Simple3.formatMessage("error.type_mismatch"));
            }
        } else if (theOperator.equals("*")) {
            if (bothValuesAreNumbers()) {
                result = new Variable(lValue.asNumber().multiply(rValue.asNumber()));
            } else {
                theParser.raiseParserException(Simple3.formatMessage("error.type_mismatch"));
            }
        } else if (theOperator.equals("/")) {
            if (bothValuesAreNumbers()) {
View Full Code Here

Examples of com.creativewidgetworks.goldparser.parser.Variable.asNumber()

        } else if (theOperator.equals("/")) {
            if (bothValuesAreNumbers()) {
                try {
                    // This path will strip off extraneous decimal places, but will fail
                    // with numbers that repeat (e.g.,  1/3 = .33333333333)
                    result = new Variable(lValue.asNumber().divide(rValue.asNumber()));
                } catch (Exception e) {
                    // This path will handle the repeating numbers
                    result = new Variable(lValue.asNumber().divide(rValue.asNumber(),PRECISION, ROUNDING_MODE));
                }
            } else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.