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:kenh.expl.functions.IsNumeric.java

public boolean process(String cs) {
    return StringUtils.isNumeric(cs);
}

From source file:minor.stockQuote.stockQuote.java

@Override
public void validate() {
    if (StringUtils.isEmpty(getStockQuote())) {
        addFieldError("StockQuote", "Stock Quote cannot be blank");
    }// w w  w.  ja  v a2s.c  o m
    if (StringUtils.isNumeric(getStockQuote())) {
        addFieldError("StockQuote", "Stock Quote cannot be numeric");
    }
    if (StringUtils.length(getStockQuote()) > 6) {
        addFieldError("StockQuote", "Invalid Ticker length");
    }
}

From source file:com.omertron.yamjtrakttv.tools.CompleteMoviesTools.java

/**
 * Parse the video element and extract the information from it.
 *
 * @param eVideo//from  www  . j  a  va 2s  .co m
 * @return
 */
public static Video parseVideo(Element eVideo) {
    Video v = new Video();
    v.setTitle(DOMHelper.getValueFromElement(eVideo, "title"));
    v.setYear(DOMHelper.getValueFromElement(eVideo, "year"));
    v.setType(DOMHelper.getValueFromElement(eVideo, "movieType"));
    v.setWatched(Boolean.parseBoolean(DOMHelper.getValueFromElement(eVideo, "watched")));

    String stringDate = DOMHelper.getValueFromElement(eVideo, "watchedDate");
    if (StringUtils.isNumeric(stringDate) && !"0".equals(stringDate)) {
        v.setWatchedDate(new Date(Long.parseLong(stringDate)));
    } else {
        LOG.debug("Invalid watched date '" + stringDate + "' using current date");
        v.setWatchedDate(new Date());
        // Because the date was set by us, let's add a small (1 second) delay to ensure that we don't get identical watched dates
        try {
            TimeUnit.SECONDS.sleep(DEFAULT_DELAY);
        } catch (InterruptedException ex) {
            // Don't care if we are interrupted or not.
        }
    }

    NodeList nlID = eVideo.getElementsByTagName("id");
    if (nlID.getLength() > 0) {
        Node nID;
        Element eID;
        for (int loop = 0; loop < nlID.getLength(); loop++) {
            nID = nlID.item(loop);
            if (nID.getNodeType() == Node.ELEMENT_NODE) {
                eID = (Element) nID;
                String moviedb = eID.getAttribute("movieDatabase");
                if (StringUtils.isNotBlank(moviedb)) {
                    v.addId(moviedb, eID.getTextContent());
                }
            }
        }
    }

    // TV specific processing
    if (v.isTvshow()) {
        v.addEpisodes(parseTvFiles(eVideo));
    }

    return v;
}

From source file:com.qq.tars.validate.SetGroupValidator.java

@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
    return StringUtils.isNotBlank(value) && (StringUtils.isNumeric(value) || "*".equals(value));
}

From source file:com.inkubator.hrm.web.converter.CityConverter.java

@Override
public Object getAsObject(FacesContext contet, UIComponent component, String value) {
    CityService cityService = (CityService) ServiceWebUtil.getService("cityService");
    if (!StringUtils.isNumeric(value)) {
        return null;
    }/*from   w  ww  . j  a  v a2  s .  c  o m*/
    Object object = null;
    try {
        Long id = Long.parseLong(value);
        object = cityService.getEntiyByPK(id);
        //            City city = cityService.getEntiyByPK(id);
        return object;
    } catch (Exception e) {
        LOGGER.error(e.getMessage());
        throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Input tidak valid", ""));
    }
}

From source file:com.inkubator.hrm.web.converter.MonthNumberAsStringConverter.java

@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
    String monthAsString = StringUtils.EMPTY;
    String data = value.toString();

    if (StringUtils.isNumeric(data)) {
        Integer month = Integer.valueOf(data);
        DateFormatSymbols dfs = new DateFormatSymbols(
                new Locale(FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString()));
        monthAsString = dfs.getMonths()[month - 1];
    }//from w ww .  jav a 2s  .c  o m

    return monthAsString;
}

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

public W3cHtml5IssueBuilder setLine(String lineString) {
    if (StringUtils.isNumeric(lineString)) {
        this.line = Integer.valueOf(lineString);
    }//from  w w  w.ja va 2  s .c o m
    return this;
}

From source file:com.github.britter.beanvalidators.strings.NumericConstraintValidator.java

@Override
public boolean isValid(final String value, final ConstraintValidatorContext context) {
    // Don't validate null, empty and blank strings, since these are validated by @NotNull, @NotEmpty and @NotBlank
    return StringUtils.isBlank(value) || StringUtils.isNumeric(value);
}

From source file:fr.penet.servlet.TitleStatsServlet.java

@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    resp.setContentType("text/plain");
    String shardsString = req.getParameter("shards");
    if (!StringUtils.isNumeric(shardsString)) {
        resp.getWriter().println("Error : empty shards parameter or not an integer");
        return;//w  ww. java 2 s . c om
    }
    int shards = Integer.parseInt(shardsString);

    String runIdString = req.getParameter("runId");
    if (!StringUtils.isNumeric(runIdString)) {
        resp.getWriter().println("Error : empty runId parameter or not an integer");
        return;
    }
    int runId = Integer.parseInt(runIdString);

    String runType = req.getParameter("type");
    CrawlDbInput input = new CrawlDbInput(runId, shards);
    TitleWordsMapper mapper = new TitleWordsMapper();
    Output<Map<String, List<Integer>>, Void> output;
    String jobName = "MR stats for " + runId;
    if (StringUtils.equals(runType, "sql-output")) {
        output = new CrawlDbOutputWords(runId);
        jobName += " (SQL)";
    } else {
        output = new CrawlDbOutputWordsDatastore(runId);
        jobName += " (datastore)";
    }
    MapSpecification<CrawlPage, Map<String, List<Integer>>, Void> spec = new MapSpecification.Builder<>(input,
            mapper, output).setJobName(jobName).build();
    // default settings should be ok
    MapSettings settings = new MapSettings.Builder().build();
    String jobId = MapJob.start(spec, settings);
    resp.getWriter().println("Mapper started. Job id : " + jobId);
}

From source file:gov.nih.nci.caintegrator.web.action.study.management.EditStudyLogAction.java

/**
 * {@inheritDoc}/*ww w .j a va  2s  .c  om*/
 */
public boolean acceptableParameterName(String parameterName) {
    return !(parameterName != null
            && (parameterName.startsWith("d-") || StringUtils.isNumeric(parameterName.substring(0, 1))));
}