Examples of BillingException


Examples of org.wso2.carbon.billing.core.BillingException

        if (cashString.contains(".")) {
            String wholeNumberStr = cashString.substring(0, cashString.indexOf("."));
            if (wholeNumberStr.trim().equals("")) {
                String msg = "Whole number can not be empty";
                throw new BillingException(msg);
            }
            if (notNumbersPattern.matcher(wholeNumberStr).find()) {
                String msg = "The whole number expected to have only 0-9 characters.: " +
                                wholeNumberStr + " is not a number. ";
                throw new BillingException(msg);
            }
           
            String decimalNumberStr = cashString.substring(cashString.indexOf(".") + 1);
            if (notNumbersPattern.matcher(decimalNumberStr).find()) {
                String msg = "The decimal number expected to have only 0-9 characters.: " +
                                decimalNumberStr + " is not a number. ";
                throw new BillingException(msg);
            }
            if (decimalNumberStr.length() == 0) {
                String msg = "String after the decimal point is zero.";
                throw new BillingException(msg);
            } else if (decimalNumberStr.length() > 2) {
                String msg = "String after the decimal point is greater than 2";
                throw new BillingException(msg);
            } else if (decimalNumberStr.length() == 1) {
                decimalNumberStr += "0";
            }
           
            wholeNumber = Integer.parseInt(wholeNumberStr);
            decimalNumber = Integer.parseInt(decimalNumberStr);
           
        } else {
            if (notNumbersPattern.matcher(cashString).find()) {
                String msg = "The cash string to have only 0-9 characters.: " + cashString +
                                " is not a number. ";
                throw new BillingException(msg);
            }
           
            wholeNumber = Integer.parseInt(cashString);
            decimalNumber = 0;
        }
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.