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:gov.nih.nci.caarray.application.util.Utils.java

/**
 * Get the background thread timeout./*from   w w w.  j av a2  s .  c om*/
 * @return the timeout val
 */
public static int getBackgroundThreadTransactionTimeout() {
    final String backgroundThreadTransactionTimeout = ConfigurationHelper.getConfiguration()
            .getString(ConfigParamEnum.BACKGROUND_THREAD_TRANSACTION_TIMEOUT.name());
    int timeout = DEFAULT_TIMEOUT_SECONDS;
    if (StringUtils.isNumeric(backgroundThreadTransactionTimeout)) {
        timeout = Integer.parseInt(backgroundThreadTransactionTimeout);
    }

    LOG.debug("Transaction Timeout = " + timeout);
    return timeout;
}

From source file:de.thischwa.pmcms.server.PreviewServlet.java

@Override
protected void doRequest(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    String idString = req.getParameter("id");
    if (StringUtils.isBlank(idString) || !StringUtils.isNumeric(idString))
        throw new IllegalArgumentException("'id' or type descriptor not found!");
    Integer id = Integer.valueOf(idString);

    SiteHolder siteHolder = InitializationManager.getBean(SiteHolder.class);
    APoormansObject<?> po = siteHolder.get(id);
    if (po == null)
        throw new NullPointerException("Can't work with po is null!");
    if (InstanceUtil.isSiteResource(po)) {
        try {/*  www  . j  a  v  a 2  s.  c  o m*/
            String html = velocityRenderer.render((ASiteResource) po);
            resp.getWriter().append(html);
        } catch (RenderingException e) {
            throw new IOExceptionWithCause(e);
        }
    } else {
        try {
            velocityRenderer.render(resp.getWriter(), (IRenderable) po, ViewMode.PREVIEW);
        } catch (RenderingException e) {
            throw new IOExceptionWithCause(e);
        }
    }
}

From source file:com.ewcms.web.pubsub.PubsubServlet.java

private void initInitialDelay() {
    String value = this.getInitParameter(INITIALDELAY_PARAM_NAME);
    if (StringUtils.isNumeric(value)) {
        initialDelay = Long.valueOf(value);
    }/*from w  w  w.  j a v a 2s . c  om*/
}

From source file:com.liusoft.util.hsqldb.HSQLEngineServlet.java

/**
 * HSQLDB??// www  .ja va 2s  .c  o m
 */
public void init() throws ServletException {
    String tPath = getInitParameter("path");
    if (StringUtils.isNotEmpty(tPath))
        path = tPath;
    String tDatabase = getInitParameter("database");
    if (StringUtils.isNotEmpty(tDatabase))
        database = tDatabase;
    String tPort = getInitParameter("port");
    if (StringUtils.isNumeric(tPort)) {
        int nPort = Integer.parseInt(tPort);
        if (nPort > 1024 && nPort < 65536)
            port = nPort;
    }
    String dataPath;
    if (path.startsWith("/"))
        dataPath = getServletContext().getRealPath(path);
    else
        dataPath = path;
    //?
    engine = HSQLEngine.getEngine(dataPath, port, database);
    engine.start();
    while (!engine.isRunning()) {
        try {
            Thread.sleep(200);
        } catch (Exception e) {
        }
    }
    log("HSQLEngine of DLOG4J started.");
}

From source file:com.haulmont.timesheets.global.TimeParser.java

public HoursAndMinutes parseToHoursAndMinutes(String time) {
    HoursAndMinutes result = new HoursAndMinutes();
    try {//from  w w  w . j  a  va2s .  c  om
        if (StringUtils.isBlank(time)) {
            return new HoursAndMinutes();
        }

        if (time.contains(":")) {
            String[] parts = time.split(":");
            result.addHours(Integer.parseInt(parts[0]));
            result.addMinutes(Integer.parseInt(parts[1]));
            return result;
        }

        if (time.matches("[0-9]{1,2} +[0-9]{1,2}")) {
            String[] parts = time.split(" ");
            result.addHours(Integer.parseInt(parts[0]));
            result.addMinutes(Integer.parseInt(parts[1]));
            return result;
        }

        if (StringUtils.isNumeric(time)) {
            result.addHours(Integer.parseInt(time));
            return result;
        }

        result.addHours(findHours(time));
        result.addMinutes(findMinutes(time));

        return result;
    } catch (NumberFormatException e) {
        return result;
    }
}

From source file:com.karusmc.commandwork.reference.help.HelpParser.java

public int getPage(String[] args) {
    int page = 1;

    if (args.length != 0 && StringUtils.isNumeric(args[args.length - 1])) {
        int number = Integer.parseInt(args[args.length - 1]);

        if (number > 0) {
            return number;
        }/*from   w w w. java2  s. c  o  m*/
    }

    return page;
}

From source file:io.gravitee.management.rest.spring.EmailConfiguration.java

@Bean
public JavaMailSenderImpl mailSender() {
    final JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
    javaMailSender.setHost(host);/*  w w w  .  j  a v  a2s . co  m*/
    if (StringUtils.isNumeric(port)) {
        javaMailSender.setPort(Integer.valueOf(this.port));
    }
    javaMailSender.setUsername(username);
    javaMailSender.setPassword(password);
    return javaMailSender;
}

From source file:fr.paris.lutece.plugins.document.utils.IntegerUtils.java

/**
 * Check if the given String is numeric/*w  ww.  ja v a 2s.co  m*/
 * @param strToCheck the String to check
 * @return true if it is numeric, false otherwise
 */
public static boolean isNumeric(String strToCheck) {
    return StringUtils.isNotBlank(strToCheck) && StringUtils.isNumeric(strToCheck);
}

From source file:com.digitalpebble.stormcrawler.filtering.depth.MaxDepthFilter.java

private int getDepth(Metadata sourceMetadata) {
    String depth = sourceMetadata.getFirstValue(MetadataTransfer.depthKeyName);
    if (StringUtils.isNumeric(depth)) {
        return Integer.parseInt(depth);
    } else {/* ww  w  .jav  a2 s  .c o  m*/
        return -1;
    }
}

From source file:net.firejack.platform.core.validation.condition.AbstractSystemMethodCondition.java

@Override
public String defaultValue(Map<String, String> params) {
    String defaultValue = null;/*from w  ww . j av  a2s . c  o m*/
    if (params != null) {
        String sParentId = params.get("parentId");
        if (StringUtils.isNumeric(sParentId)) {
            Long registryNodeId = Long.parseLong(sParentId);
            List<Long> registryNodeIds = new ArrayList<Long>();
            List<Object[]> collectionArrayIds = registryNodeStore.findAllIdAndParentId();
            registryNodeStore.findCollectionParentIds(registryNodeIds, registryNodeId, collectionArrayIds);
            SystemModel system = null;
            for (Long parentId : registryNodeIds) {
                RegistryNodeModel registryNode = registryNodeStore.findById(parentId);
                if (registryNode instanceof SystemModel) {
                    system = (SystemModel) registryNode;
                    break;
                }
                if (registryNode instanceof PackageModel) {
                    PackageModel packageRN = packageStore.findWithSystemById(parentId);
                    system = packageRN.getSystem();
                    break;
                }
            }
            if (system != null) {
                defaultValue = getDefaultValue(system);
            }
        }
    }
    return defaultValue;
}