Example usage for org.apache.commons.lang3 StringUtils isNumeric

List of usage examples for org.apache.commons.lang3 StringUtils isNumeric

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils isNumeric.

Prototype

public static boolean isNumeric(final CharSequence cs) 

Source Link

Document

Checks if the CharSequence contains only Unicode digits.

Usage

From source file:com.dgtlrepublic.anitomyj.StringHelper.java

/** Returns whether or not the {@code string is a numeric string}. */
public static boolean isNumericString(String string) {
    return StringUtils.isNumeric(string);
}

From source file:jongo.jdbc.LimitParam.java

/**
 * From the received parameters, try to obtain a LimitParam object. By default, the LimitParam
 * always has a limit of 25 and an offset (start) in 0.
 * @param pathParams// www .  j a v  a  2  s.com
 * @return 
 */
public static LimitParam valueOf(final MultivaluedMap<String, String> pathParams) {
    Integer l = null;
    if (StringUtils.isNumeric(pathParams.getFirst("limit"))) {
        l = Integer.valueOf(pathParams.getFirst("limit"));
    }

    Integer o = null;
    if (StringUtils.isNumeric(pathParams.getFirst("offset"))) {
        o = Integer.valueOf(pathParams.getFirst("offset"));
    }

    LimitParam instance;
    if (l == null) {
        instance = new LimitParam();
    } else {
        if (o == null) {
            instance = new LimitParam(l);
        } else {
            instance = new LimitParam(l, o);
        }
    }
    return instance;
}

From source file:com.bellman.bible.android.view.util.buttongrid.LayoutDesigner.java

RowColLayout calculateLayout(List<ButtonInfo> buttonInfoList) {
    RowColLayout rowColLayout = new RowColLayout();
    int numButtons = buttonInfoList.size();

    // is it the list of bible books
    if (buttonInfoList.size() == 66 && !StringUtils.isNumeric(buttonInfoList.get(0).name)) {
        // bible books
        if (isPortrait()) {
            rowColLayout = BIBLE_BOOK_LAYOUT;
        } else {// w  w w.  j a v a  2  s .  c o m
            rowColLayout = BIBLE_BOOK_LAYOUT_LAND;
        }
    } else {
        // a list of chapters or verses
        if (numButtons <= 50) {
            if (isPortrait()) {
                rowColLayout.rows = 10;
            } else {
                rowColLayout.rows = 5;
            }
        } else if (numButtons <= 100) {
            rowColLayout.rows = 10;
        } else {
            if (isPortrait()) {
                rowColLayout.rows = 15;
            } else {
                rowColLayout.rows = 10;
            }
        }
        rowColLayout.cols = (int) Math.ceil(((float) numButtons) / rowColLayout.rows);

        // if there are too few buttons/rows you just see a couple of large buttons on the screen so ensure there are enough rows to look nice
        int minCols = isPortrait() ? MIN_COLS : MIN_COLS_LAND;
        rowColLayout.cols = Math.max(minCols, rowColLayout.cols);
    }

    rowColLayout.columnOrder = isPortrait();

    Log.d(TAG, "Rows:" + rowColLayout.rows + " Cols:" + rowColLayout.cols);
    return rowColLayout;
}

From source file:com.cognifide.aet.job.common.comparators.w3chtml5.W3cHtml5IssueBuilder.java

public W3cHtml5IssueBuilder setColumn(String columnString) {
    if (StringUtils.isNumeric(columnString)) {
        this.column = Integer.valueOf(columnString);
    }//w  w w. j av a 2 s. c om
    return this;
}

From source file:com.mobius.software.mqtt.performance.commons.util.IdentifierParser.java

public static Integer parseIdentifierCounter(String clientID) {
    Integer counter = null;//from www .  j a va2s .  co m
    String[] regexSegmants = clientID.split(IDENTIFIER_SEPARATOR);
    for (String segment : regexSegmants) {
        if (StringUtils.isNumeric(segment))
            counter = Integer.parseInt(segment);
    }
    return counter;
}

From source file:comp.web.core.DataUtil.java

public List<Product> getProds(String cat, String prod, String from, String to) {
    logger.log(Level.FINER, "get prods with filter {0} {1} {2} {3}", new Object[] { cat, prod, from, to });

    if (StringUtils.isBlank(cat) && StringUtils.isBlank(prod) && StringUtils.isBlank(from)
            && StringUtils.isBlank(to)) {
        return Collections.emptyList();
    }//from w  w  w .  jav a 2s .  com

    String cat1 = StringUtils.stripToEmpty(cat) + "%";
    String prod1 = StringUtils.stripToEmpty(prod) + "%";
    double from1 = StringUtils.isNumeric(from) ? Double.parseDouble(from) : Double.MIN_VALUE;
    double to1 = StringUtils.isNumeric(to) ? Double.parseDouble(to) : Double.MAX_VALUE;

    EntityManager em = createEM();
    //        EntityTransaction tx = em.getTransaction();
    //        tx.begin();

    List<Product> products = em.createNamedQuery("priceList", Product.class).setParameter("cat", cat1)
            .setParameter("prod", prod1).setParameter("from", from1).setParameter("to", to1).getResultList();

    //        tx.commit();
    em.close();
    logger.log(Level.FINER, "get prods result size {0}", products.size());
    return products;
}

From source file:com.ewcms.content.vote.web.ResultServlet.java

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    ServletOutputStream out = null;/*from  w  w w . java2s  .  c  o  m*/
    StringBuffer output = new StringBuffer();
    try {
        String id = req.getParameter("id");

        if (!id.equals("") && StringUtils.isNumeric(id)) {
            Long questionnaireId = new Long(id);

            ServletContext application = getServletContext();
            WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(application);
            QuestionnaireService questionnaireService = (QuestionnaireService) wac
                    .getBean("questionnaireService");

            String ipAddr = req.getRemoteAddr();

            output = questionnaireService.getQuestionnaireResultClientToHtml(questionnaireId,
                    getServletContext().getContextPath(), ipAddr);
        }
        out = resp.getOutputStream();
        resp.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html; charset=UTF-8");
        out.write(output.toString().getBytes("UTF-8"));
        out.flush();
    } finally {
        if (out != null) {
            out.close();
            out = null;
        }
    }
}

From source file:eu.europeana.querylog.clean.NumberFilter.java

public String clean(String query) {
    if (StringUtils.isNumeric(query))
        return null;
    return query;
}

From source file:ext.sns.auth.AccessTokenResponse.java

/**
 * ?AccessTokenResponse??responseStringnull
 * /*from  w w w .j  av  a2  s . co m*/
 * @param responseString 
 * @param responseType 
 * @return AccessTokenResponsenull - ??responseString
 */
public static AccessTokenResponse create(String responseString) {
    if (StringUtils.isBlank(responseString)) {
        return null;
    }

    AccessTokenResponse response = new AccessTokenResponse();
    response.setResultTypeByResponseStr(responseString);

    if (response.resultType == 1) {
        Map<String, String> responseMap = null;
        try {
            responseMap = parseResponseParam(responseString);
        } catch (RuntimeException e) {
            LOGGER.error("AccessTokenResponse?", e);
        }

        response.raw = responseString;
        response.accessToken = responseMap.get("access_token");

        String expiresInString = responseMap.get("expires_in");
        response.expiresIn = StringUtils.isNumeric(expiresInString) ? Long.valueOf(expiresInString) : null;

        response.refreshToken = responseMap.get("refresh_token");
        response.scope = responseMap.get("scope");
        response.tokenType = responseMap.get("token_type");

        response.resultObject = responseMap;
    } else if (response.resultType == 2) {
        JsonNode responseJSON = null;
        try {
            responseJSON = Json.parse(responseString);
        } catch (RuntimeException e) {
            LOGGER.error("AccessTokenResponse?", e);
        }

        response.raw = responseString;
        response.accessToken = responseJSON.has("access_token") ? responseJSON.get("access_token").asText()
                : null;

        String expiresInString = responseJSON.has("expires_in") ? responseJSON.get("expires_in").asText()
                : null;
        response.expiresIn = StringUtils.isNumeric(expiresInString) ? Long.valueOf(expiresInString) : null;

        response.refreshToken = responseJSON.has("refresh_token") ? responseJSON.get("refresh_token").asText()
                : null;
        response.scope = responseJSON.has("scope") ? responseJSON.get("scope").asText() : null;
        response.tokenType = responseJSON.has("token_type") ? responseJSON.get("token_type").asText() : null;

        response.resultObject = responseJSON;
    } else {
        return null;
    }

    return response;
}

From source file:io.apiman.gateway.engine.vertx.polling.fetchers.auth.AbstractOAuth2Base.java

protected static void createOrDescend(JsonObject root, Deque<String> keyPath, String value) {
    // If there are still key-path elements remaining to traverse.
    if (keyPath.size() > 1) {
        // If there's no object already at this key-path create a new JsonObject.
        if (root.getJsonObject(keyPath.peek()) == null) {
            JsonObject newJson = new JsonObject();
            String val = keyPath.pop();
            root.put(val, newJson);
            createOrDescend(newJson, keyPath, value);
        } else { // If there's already an existing object on key-path, grab it and traverse.
            createOrDescend(root.getJsonObject(keyPath.pop()), keyPath, value);
        }//from ww w .  j a va  2  s . co m
    } else { // Set the value.
        Boolean boolObj = BooleanUtils.toBooleanObject(value);
        if (boolObj != null) {
            root.put(keyPath.pop(), boolObj);
        } else if (StringUtils.isNumeric(value)) {
            root.put(keyPath.pop(), Long.parseLong(value));
        } else {
            root.put(keyPath.pop(), value);
        }
    }
}