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:org.kie.workbench.common.forms.migration.tool.pipelines.basic.impl.adapters.fields.TextAreaFieldAdapter.java

@Override
protected FieldDefinition getFieldDefinition(Field originalField) {
    TextAreaFieldDefinition fieldDefinition = new TextAreaFieldDefinition();
    if (!StringUtils.isEmpty(originalField.getHeight()) && StringUtils.isNumeric(originalField.getHeight())) {
        fieldDefinition.setRows(Integer.decode(originalField.getHeight()));
    }//from   w  ww . jav  a2 s .c o m
    return fieldDefinition;
}

From source file:org.krobot.util.UserUtils.java

/**
 * Resolve a user from a String.<br>
 * If it can be a nickname, use {@link #resolve(Guild, String)}<br><br>
 *
 * Example : "@Litarvan", "Litarvan", or "87279950075293696"<br>
 * returns the JDA User object of Litarvan.
 *
 * @param user A string (mention/username/id) of the user
 *             to resolve/*w w  w. j  a  v  a  2  s . c o m*/
 *
 * @return The resolved user or null if none was found
 */
@Nullable
public static User resolve(@NotNull String user) {
    user = user.trim();
    List<User> users = jda.getUsersByName(user, true);

    if (users.size() == 0 && user.startsWith("@")) {
        users = jda.getUsersByName(user.substring(1), true);
    }

    if (users.size() == 0 && StringUtils.isNumeric(user)) {
        return jda.getUserById(user);
    }

    return users.size() > 0 ? users.get(0) : null;
}

From source file:org.kuali.coeus.propdev.impl.location.CongressionalDistrict.java

public String getNewDistrictNumber() {
    if (StringUtils.isNumeric(newDistrictNumber)) {
        newDistrictNumber = StringUtils.leftPad(newDistrictNumber, CongressionalDistrict.DISTRICT_NUMBER_LENGTH,
                "0");
    }//www  . j  av a  2s .  c  om
    return newDistrictNumber;
}

From source file:org.kuali.coeus.propdev.impl.location.ProposalSiteRule.java

protected boolean isIndexValid(String indexStr, String indexName) {
    if (StringUtils.isEmpty(indexStr) || !StringUtils.isNumeric(indexStr)) {
        reportError("newPropLocation.location", KeyConstants.ERROR_PROPOSAL_SITES_INDEX_INVALID_FORMAT,
                indexName);/* w  ww.ja  v  a 2 s  . c  o  m*/
        return false;
    }
    return true;
}

From source file:org.kuali.kra.service.impl.AwardNumberServiceTest.java

@Test
/**//from  www  .j ava  2 s  .  c  o  m
 * This method checks that:
 *  - the number is 10 characters long
 *  - the first 6 characters are digits
 *  - the last 4 characters are "-001"
 */
public final void testGetNextAwardNumber() {
    AwardNumberService awardNumberService = createAwardNumberService();
    String awardNumber = awardNumberService.getNextAwardNumber();
    assertNotNull(awardNumber);
    assertEquals(12, awardNumber.length());
    String first6Chars = awardNumber.substring(0, 6);
    assertTrue(StringUtils.isNumeric(first6Chars));
    String last6chars = awardNumber.substring(6, 12);
    assertEquals("-00001", last6chars);
}

From source file:org.kuali.test.handlers.htmltag.KualiCapitalAssetTagHandler.java

/**
 *
 * @param node// ww  w  .  j a  va 2  s. co  m
 * @return
 */
@Override
public String getSubSectionName(Element node) {
    StringBuilder retval = new StringBuilder(32);

    String itemNum = "";
    if (getTagHandler().getSectionMatcher() == null) {
        itemNum = getItemNumberForLocation(node);
    } else {
        itemNum = Utils.getMatchedNodeText(getTagHandler().getSectionMatcher().getTagMatcherArray(), node);
    }

    if (StringUtils.isNotBlank(itemNum) && StringUtils.isNumeric(itemNum)) {
        retval.append(Utils.buildHtmlStyle(Constants.HTML_DARK_RED_STYLE, "[" + itemNum + "]"));
    }

    return retval.toString();
}

From source file:org.kuali.test.utils.Utils.java

/**
 *
 * @param tm/*  www .j a v  a  2  s . c o m*/
 * @param node
 * @return
 */
public static Element getMatchingParent(TagMatcher tm, Element node) {
    Element retval = null;

    Node parent = node.getParentNode();
    int cnt = 0;
    int totalCnt = Integer.MAX_VALUE;

    boolean limited = false;
    String sdef = tm.getSearchDefinition();
    if (StringUtils.isNotBlank(sdef)) {
        if (StringUtils.isNumeric(sdef)) {
            totalCnt = Integer.parseInt(sdef);
            limited = true;
        }
    }

    while ((cnt < totalCnt) && isElement(parent)) {
        if (parent.getNodeName().equalsIgnoreCase(tm.getTagName())) {
            cnt++;
            TagMatchAttribute[] attrs = null;
            if (tm.getMatchAttributes() != null) {
                attrs = tm.getMatchAttributes().getMatchAttributeArray();
            }

            if ((!limited || (cnt == totalCnt)) && isTagMatch((Element) parent, tm)) {
                retval = (Element) parent;
                break;
            }
        }

        parent = parent.getParentNode();
    }

    return retval;
}

From source file:org.labkey.trialshare.data.StudyPublicationBean.java

public void validate(Errors errors) {
    if (StringUtils.isEmpty(getTitle()))
        errors.rejectValue("title", ERROR_REQUIRED, "Title is required");
    if (StringUtils.isEmpty(getStatus()))
        errors.rejectValue("status", ERROR_REQUIRED, "Status is required");
    if (StringUtils.isEmpty(getPublicationType()))
        errors.rejectValue("publicationType", ERROR_REQUIRED, "Publication type is required");
    if (getPMID() != null && !StringUtils.isNumeric(getPMID())) {
        errors.rejectValue("pmid", ERROR_MSG, "PMID must be an integer");
    }//from   w  w w.  j a  v  a 2 s.c o m
    if (!StringUtils.isEmpty(getPMCID()) && !PMCID_PATTERN.matcher(getPMCID()).matches()) {
        errors.rejectValue("pmcid", ERROR_MSG, "Incorrect format for PMCID.  Expected PMC#");
    }
}

From source file:org.languagetool.rules.AbstractDateCheckFilter.java

private int getMonthFromArguments(Map<String, String> args) {
    String monthStr = getRequired("month", args);
    int month;//from  w ww  . j  a  v  a2  s .  co m
    if (StringUtils.isNumeric(monthStr)) {
        month = Integer.parseInt(monthStr);
    } else {
        month = getMonth(StringTools.trimSpecialCharacters(monthStr));
    }
    return month - 1;
}

From source file:org.languagetool.rules.AbstractFutureDateFilter.java

private int getMonthFromArguments(Map<String, String> args) {
    String monthStr = getRequired("month", args);
    int month;//from  ww w. ja  va2s.  c  o m
    if (StringUtils.isNumeric(monthStr)) {
        month = Integer.parseInt(monthStr);
    } else {
        month = getMonth(monthStr);
    }
    return month - 1;
}