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

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

Introduction

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

Prototype

public static boolean isNumeric(String str) 

Source Link

Document

Checks if the String contains only unicode digits.

Usage

From source file:com.chortitzer.web.bas.controller.BonificacionConverter.java

@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
    try {/*from   w w w  . j a  va2 s. c  o  m*/
        if (value != null && value.trim().length() > 0 && StringUtils.isNumeric(value)) {
            return tblDalBonificacionesRepository.findOne(Integer.parseInt(value));
        } else {
            return null;
        }
    } catch (Exception ex) {
        LOGGER.error(Thread.currentThread().getStackTrace()[1].getMethodName(), ex);
        FacesContext.getCurrentInstance().addMessage(null,
                new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error!", ex.getMessage()));
        return null;
    }

}

From source file:net.sourceforge.fenixedu.domain.IdentificationDocumentExtraDigit.java

public IdentificationDocumentExtraDigit(final Person person, final String identificationDocumentExtraDigit) {
    setPerson(person);//from   w  w  w . j  a  v a 2s  . c  om
    if (identificationDocumentExtraDigit == null || identificationDocumentExtraDigit.isEmpty()
            || identificationDocumentExtraDigit.length() != 1
            || !StringUtils.isNumeric(identificationDocumentExtraDigit)) {
        throw new DomainException("label.identificationDocumentExtraDigit.invalid.format");
    }
    setValue(identificationDocumentExtraDigit);
}

From source file:com.enonic.cms.core.structure.SiteProperties.java

public Integer getPropertyAsInteger(final SitePropertyNames key) {
    String svalue = StringUtils.trimToNull(properties.getProperty(key.getKeyName()));

    if (svalue != null && !StringUtils.isNumeric(svalue)) {
        throw new NumberFormatException(
                "Invalid value of property " + key + " = " + svalue + " in site-" + siteKey + ".properties");
    }/*from www  .  j  a  v a  2  s  .  c o  m*/

    return svalue == null ? null : new Integer(svalue);
}

From source file:com.ewcms.plugin.vote.manager.web.ResultServlet.java

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    ServletOutputStream out = null;//from   w  w  w  . ja  v a 2s .  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);
            VoteFacable voteFac = (VoteFacable) wac.getBean("voteFac");

            String ipAddr = req.getRemoteAddr();

            output = voteFac.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:net.sourceforge.fenixedu.domain.curriculum.Grade.java

public Grade(String grade) {
    if (grade == null || grade.equals("") || grade.equals(GradeScale.NA)) {
        this.gradeValue = GradeScale.NA;
        this.gradeType = GradeType.GRADENA;
    } else if (StringUtils.isNumeric(grade)) {
        Integer numericGrade = Integer.parseInt(grade);
        initNumeric(numericGrade);/*from  w w  w  .j  a va 2s. co  m*/
    } else if (grade.equals(GradeScale.AP)) {
        this.gradeValue = grade;
        this.gradeType = GradeType.GRADEAP;
    } else {
        this.gradeValue = GradeScale.RE;
        this.gradeType = GradeType.GRADERE;
    }
}

From source file:com.abiquo.api.tracer.hierarchy.AbstractHierarchyProcessor.java

@Override
public void process(final String uri, final Map<String, String> resourceData) {
    String resourcePrefix = getIdentifierPrefix();
    String resourceId = getIdentifier(uri);

    // If the resource prefix is not found, ignore this processor
    if (resourceId != null && !resourceId.isEmpty() && StringUtils.isNumeric(resourceId)) {
        String resourceName = getResourceName(resourceId);

        if (resourceName == null || StringUtils.isBlank(resourceName)) {
            resourceName = StringUtils.EMPTY;
        }/*from   w ww.ja v a 2 s  .c  om*/

        resourceData.put(resourcePrefix, resourceId + "|" + resourceName);
    }
}

From source file:de.tudarmstadt.ukp.dkpro.core.io.brat.internal.model.BratEventArgument.java

public static BratEventArgument parse(String aLine) {
    Matcher m = PATTERN.matcher(aLine);

    if (!m.matches()) {
        throw new IllegalArgumentException("Illegal event argument format [" + aLine + "]");
    }/*  ww w.  jav a  2s .  c om*/

    int index = 0;
    if (StringUtils.isNumeric(m.group(INDEX))) {
        index = Integer.valueOf(m.group(INDEX));
    }

    return new BratEventArgument(m.group(SLOT), index, m.group(TARGET));
}

From source file:com.impetus.kundera.graph.ObjectGraphUtils.java

/**
 * /*from   w w  w .j  a va 2  s  .  c  om*/
 * @param id
 * @param idField
 * @return
 */
private static boolean isIdSet(Object id, Field idField) {
    // return true, if it is non blank and not zero in case of numeric
    // value.

    if (id != null) {
        return !(NumericUtils.checkIfZero(id.toString(), idField.getType())
                || (StringUtils.isNumeric(id.toString()) && StringUtils.isBlank(id.toString())));
    }
    return false;
}

From source file:ml.shifu.shifu.util.ExprAnalyzer.java

public String[] getVarsInExpr() {
    char[] processed = expr.toCharArray();
    removeQuota(processed, '\'');
    removeQuota(processed, '\"');
    removeNonValueChar(processed);/*from  www.ja  v a 2  s.co m*/
    removeObjMethod(processed);

    String formatStr = new String(processed);
    String[] vars = formatStr.split("[ ]");
    List<String> result = new ArrayList<String>();

    for (String var : vars) {
        String fvar = StringUtils.trimToEmpty(var);
        if (StringUtils.isNotBlank(fvar) && !"and".equals(fvar) && !"or".equals(fvar)
                && !StringUtils.isNumeric(fvar)) {
            result.add(fvar);
        }
    }
    return result.toArray(new String[0]);
}

From source file:mondrian.spi.impl.VectorwiseDialect.java

@Override
protected String generateOrderByNulls(String expr, boolean ascending, boolean collateNullsLast) {
    // expr may be a column number
    if (StringUtils.isNumeric(expr)) {
        expr = new Integer(expr).toString();
    }/*from www  .  j  a v a2s  .co  m*/
    return super.generateOrderByNulls(expr, ascending, collateNullsLast);
}