Example usage for org.apache.commons.lang.math NumberUtils isDigits

List of usage examples for org.apache.commons.lang.math NumberUtils isDigits

Introduction

In this page you can find the example usage for org.apache.commons.lang.math NumberUtils isDigits.

Prototype

public static boolean isDigits(String str) 

Source Link

Document

Checks whether the String contains only digit characters.

Null and empty String will return false.

Usage

From source file:MainClass.java

public static void main(String[] args) {

    //Check if a String contains only digits
    System.out.println("Is Digits >>> " + NumberUtils.isDigits("123.123"));

}

From source file:MathUtilsTrial.java

public static void main(String[] args) {

    // Check if a String contains only digits
    System.out.println("Is Digits >>> " + NumberUtils.isDigits("123.123"));

    // Check if a String is a valid number
    System.out.println("Is Number >>> " + NumberUtils.isNumber("123.123"));

    // Get MAX value from an array
    System.out.println("MAX >>> " + NumberUtils.max(new double[] { 3.33, 8.88, 1.11 }));

}

From source file:com.intuit.tank.report.JobReport.java

public static void main(String[] args) {
    StringUtils.trim(null);//from   www. ja va  2s. c o  m
    System.out.println(NumberUtils.isDigits(StringUtils.trim("123 ")));
    System.out.println(NumberUtils.toInt(StringUtils.trim("123 ")));
}

From source file:com.intuit.tank.harness.functions.MonetaryFunctions.java

/**
 * Is this a valid Monetary function request
 * /*from  w w w  .  jav a 2s. c om*/
 * @param values
 *            The command
 * @return TRUE if valid format; FALSE otherwise
 */
public static boolean isValid(String[] values) {
    try {
        if (values[2].equalsIgnoreCase("randompositive")
                || values[2].equalsIgnoreCase("randomnegative") && NumberUtils.isDigits(values[3])) {
            return true;
        }
        return false;
    } catch (Exception ex) {
        return false;
    }
}

From source file:com.intuit.tank.harness.functions.NumericFunctions.java

/**
 * Is this a valid Numeric function request
 * //  w w  w  .  j  av a 2  s .  com
 * @param values
 *            The command
 * @return TRUE if valid format; FALSE otherwise
 */
static public boolean isValid(String[] values) {
    try {
        if (values[2].equalsIgnoreCase("randompositivewhole")
                || values[2].equalsIgnoreCase("randomnegativewhole")) {
            if (NumberUtils.isDigits(values[3])) {
                return true;
            }
        }
        if (values[2].equalsIgnoreCase("randompositivefloat")
                || values[2].equalsIgnoreCase("randomnegativefloat") || values[2].equalsIgnoreCase("mod")) {
            if (NumberUtils.isDigits(values[3]) && NumberUtils.isDigits(values[4])) {
                return true;
            }
        }
        if (values[2].equalsIgnoreCase("add") || values[2].equalsIgnoreCase("subtract")) {
            if (NumberUtils.isNumber(values[3]) && NumberUtils.isNumber(values[4])) {
                for (int i = 5; i < values.length; i++) {
                    if (values[i] != null) {
                        if (!NumberUtils.isNumber(values[i])) {
                            return false;
                        }
                    } else {
                        return true;
                    }
                }
            }
        }
        return false;
    } catch (Exception ex) {
        return false;
    }
}

From source file:com.leixl.easyframework.web.CookieUtils.java

/**
 * cookie??/*w  ww  . j ava2s.c om*/
 * 
 * _cookie_page_sizecookie name
 * 
 * @param request
 *            HttpServletRequest
 * @return default:20 max:200
 */
public static int getPageSize(HttpServletRequest request) {
    Assert.notNull(request);
    Cookie cookie = getCookie(request, COOKIE_PAGE_SIZE);
    int count = 0;
    if (cookie != null) {
        if (NumberUtils.isDigits(cookie.getValue())) {
            count = Integer.parseInt(cookie.getValue());
        }
    }
    if (count <= 0) {
        count = DEFAULT_SIZE;
    } else if (count > MAX_SIZE) {
        count = MAX_SIZE;
    }
    return count;
}

From source file:com.jeet.cli.Admin.java

private static void askInput() {
    System.out.println("1. List of Files.");
    System.out.println("2. Upload Files.");
    System.out.println("3. Exit.");
    System.out.print("Please select option: ");
    String choise = null;//from   w w  w  . j  ava  2  s .  c  o  m
    try {
        choise = bufferRead.readLine();
    } catch (IOException ioe) {
        System.out.println("Error in reading option.");
        System.out.println("Please try again.");
        askInput();
    }
    if (choise != null && NumberUtils.isDigits(choise)) {
        switch (choise) {
        case "1":
            listFiles();
            break;
        case "2":
            uploadFile();
            break;
        case "3":
            System.exit(0);
            break;
        default:
            System.err.println("Please select from provided options only.");
            askInput();
        }
    } else {
        System.err.println("Please enter digits only.");
        askInput();
    }
}

From source file:de.tudarmstadt.ukp.dkpro.core.flextag.features.character.ContainsNumber.java

static boolean containsNumber(String aToken) {
    for (char c : aToken.toCharArray()) {
        if (NumberUtils.isDigits("" + c)) {
            return true;
        }//from w  ww .j  av  a  2s.  co m
    }
    return false;
}

From source file:com.intuit.tank.runner.method.TimerRunner.java

/**
* 
*///from  w  w w.j  av a  2  s  .com
public String execute() {
    TimerStep testStep = (TimerStep) tsc.getTestStep();
    if (testStep.isStart()) {
        tsc.getTimerMap().start(testStep.getValue());
    } else {
        TankResult tankResult = tsc.getTimerMap().end(testStep.getValue());
        if (tankResult != null
                && NumberUtils.isDigits(APITestHarness.getInstance().getAgentRunData().getJobId())) {
            APITestHarness.getInstance().queueTimingResult(tankResult);
        }
    }
    return TankConstants.HTTP_CASE_PASS;
}

From source file:com.wso2telco.services.dep.sandbox.util.CommonUtil.java

public static void validatePositiveNumber(String number, String parameterName) throws SandboxException {
    if (!StringUtils.isEmpty(number) && !NumberUtils.isDigits(number)) {
        throw new SandboxException(SandboxErrorType.INVALID_INPUT_VALUE);
    }//from  www .  j a  v a2 s .  c o  m
}