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.qmetry.qaf.automation.ui.selenium.webdriver.GetCssPropertyCommand.java

@Override
protected String handleSeleneseCommand(WebDriver driver, String attributeLocator, String value) {
    int atSign = attributeLocator.lastIndexOf("@");
    String elementLocator = attributeLocator.substring(0, atSign);
    String property = attributeLocator.substring(atSign + 1);
    if (!(StringUtils.isNumeric(value) || "true".equals(value) || "false".equals(value) || value.startsWith("'")
            || value.startsWith("\""))) {
        value = "'" + value + "'";
    }//  ww w.j av  a2 s . co m
    Object res = js.executeScript(driver, "var res  = arguments[0].currentStyle? arguments[0].currentStyle['"
            + property
            + "']:window.getComputedStyle? document.defaultView.getComputedStyle(arguments[0],null).getPropertyValue('"
            + property + "'): ''; return res;", finder.findElement(driver, elementLocator));
    return (String) res;
}

From source file:ips1ap101.lib.core.db.util.Reporter.java

private static int getLimiteFilasFuncionSelect(String informe, UsuarioActual usuario) {
    Integer limiteFilas = Utils.getReportRowsLimit(informe, FORMATO_GUARDAR, usuario);
    if (limiteFilas != null) {
        return limiteFilas;
    }//  ww  w. j av a2s. com
    String string = BaseBundle.getLimiteFilasFuncionReport(informe);
    int limite = StringUtils.isNotBlank(string) && StringUtils.isNumeric(string) ? Integer.valueOf(string) : -1;
    return limite < 0 ? LIMITE_FILAS_FUNCION_SELECT : limite;
}

From source file:com.openshift.internal.restclient.model.ServicePort.java

@Override
public void setTargetPort(String name) {
    if (StringUtils.isNumeric(name)) {
        setTargetPort((Integer.parseInt(name)));
        return;//from w ww .  ja v a 2  s.  co  m
    }
    set(getNode(), KEY_MAP, PROPERTY_TARGET_PORT, name);
}

From source file:com.greenline.guahao.web.module.home.controllers.json.patient.JsonPatientController.java

/**
 * json//from   w  ww.  j  ava  2s . c  o  m
 * 
 * @param model
 * @param patientId
 * @return OperationJsonObject
 */
@MethodRemark(value = "remark=json,method=ajax,patientId=id")
@RequestMapping(value = JsonPathConstants.J_PATIENT_DEL_PATH, method = RequestMethod.GET)
public @ResponseBody BaseJsonObject patientDel(ModelMap model, @PathVariable("pid") String patientId) {
    BaseJsonObject json = new BaseJsonObject(Boolean.FALSE, MobileMsgConstants.M_PATIENT_DEL_SUC);
    // id
    String decodePatientId = DESUtil.DESDecode(patientId, EncodeKeyConstants.PATIENT_ENCODE_KEY);
    if (!StringUtils.isNumeric(decodePatientId)) {
        // id?
        json.setHasError(Boolean.TRUE);
        json.setCode(ReservationConstants.RESERVATION_ERROR_CODE_JSON);
        json.setMessage("?");
    } else {
        PatientInfoDO patientInfoDO = patientManager.getPatientByPatientId(Long.parseLong(decodePatientId));
        if (null != patientInfoDO) {
            Long userId = UserCookieUtil.getUserId(request);
            if (!userId.toString().equals(String.valueOf(patientInfoDO.getUser_id()))) {
                // ??
                json.setHasError(Boolean.TRUE);
                json.setCode(ReservationConstants.RESERVATION_ERROR_CODE_JSON);
                json.setMessage("?");
            } else {
                PatientResult pr = patientManager.removePatient(Long.valueOf(decodePatientId));
                if (pr.isSystemError()) {
                    json.setHasError(Boolean.TRUE);
                    json.setMessage(pr.getResponseDesc());
                }
            }
        }
    }
    return json;
}

From source file:com.redhat.rhn.frontend.action.kickstart.KickstartPackageProfileSetupAction.java

/**
 *
 * {@inheritDoc}/*  w  w  w .  ja v a2  s. com*/
 */
public ActionForward execute(ActionMapping mapping, ActionForm formIn, HttpServletRequest request,
        HttpServletResponse response) {

    RequestContext context = new RequestContext(request);

    KickstartData ks = KickstartFactory.lookupKickstartDataByIdAndOrg(context.getCurrentUser().getOrg(),
            context.getRequiredParam("ksid"));

    request.setAttribute(RequestContext.KICKSTART, ks);
    ListHelper helper = new ListHelper(this, request);
    helper.execute();

    if (context.wasDispatched("kickstart.packageprofile.jsp.submit")) {
        String selected = ListTagHelper.getRadioSelection(helper.getListName(), request);
        if (StringUtils.isNumeric(selected)) {
            Profile prof = ProfileManager.lookupByIdAndOrg(new Long(selected),
                    context.getCurrentUser().getOrg());
            ks.getKickstartDefaults().setProfile(prof);

            Map<String, Object> params = new HashMap<String, Object>();
            params.put("ksid", ks.getId());
            getStrutsDelegate().saveMessage(UPDATE_METHOD, request);
            return getStrutsDelegate().forwardParams(mapping.findForward("success"), params);
        }
    } else if (context.wasDispatched("kickstart.packageprofile.jsp.clear")) {
        ks.getKickstartDefaults().setProfile(null);
        KickstartFactory.saveKickstartData(ks);
        request.setAttribute("ksid", ks.getId());
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("ksid", ks.getId());
        getStrutsDelegate().saveMessage(CLEAR_METHOD, request);
        return getStrutsDelegate().forwardParams(mapping.findForward("success"), params);

    }
    if (ks.getKickstartDefaults().getProfile() != null) {
        ListTagHelper.selectRadioValue(helper.getListName(),
                ks.getKickstartDefaults().getProfile().getId().toString(), request);
    }
    return mapping.findForward(RhnHelper.DEFAULT_FORWARD);
}

From source file:br.gov.jfrj.siga.model.dao.HibernateUtil.java

public static void iniciarTransacao() {

    // bruno.lacerda@avantiprima.com.br
    // Resolucao do erro Session is Closed ao comitar uma transacao pois se o ThreadTransaction
    // nao for nulo a threadTransaction pode ter sido obtida em uma sessao do hibernate diferente 
    // da atual e por este motivo a sessao pode estar fechada.

    Transaction tx = HibernateUtil.threadTransaction.get();
    //Transaction tx = HibernateUtil.getSessao().beginTransaction();

    if (tx == null) {
        tx = HibernateUtil.getSessao().beginTransaction();

        // bruno.lacerda@avantiprima.com.br
        String strTimeout = SigaBaseProperties.getString("jta.transaction.timeout.value");
        if (StringUtils.isNumeric(strTimeout)) {
            tx.setTimeout(Integer.parseInt(strTimeout));
        }//from  ww w  . j a v  a 2s . c  o  m

    }
    HibernateUtil.threadTransaction.set(tx);
}

From source file:fr.paris.lutece.plugins.directory.web.DoDownloadFile.java

/**
 * Write in the http response the file to upload
 * @param request the http request/*from  w  w w.  j  ava  2  s . c  o  m*/
 * @param response The http response
 * @return Error Message
 *
 */
public static String doDownloadFile(HttpServletRequest request, HttpServletResponse response) {
    Plugin plugin = PluginService.getPlugin(DirectoryPlugin.PLUGIN_NAME);
    String strIdFile = request.getParameter(PARAMETER_ID_FILE);
    int nIdFile = DirectoryUtils.CONSTANT_ID_NULL;

    if (StringUtils.isBlank(strIdFile) || !StringUtils.isNumeric(strIdFile)) {
        String strIdDirectoryRecord = request.getParameter(DirectoryUtils.PARAMETER_ID_DIRECTORY_RECORD);
        String strIdEntry = request.getParameter(DirectoryUtils.PARAMETER_ID_ENTRY);

        if ((StringUtils.isBlank(strIdDirectoryRecord) || !StringUtils.isNumeric(strIdDirectoryRecord))
                && (StringUtils.isBlank(strIdEntry) || !StringUtils.isNumeric(strIdEntry))) {
            return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_DURING_DOWNLOAD_FILE,
                    AdminMessage.TYPE_STOP);
        }

        int nIdDirectoryRecord = DirectoryUtils.convertStringToInt(strIdDirectoryRecord);
        int nIdEntry = DirectoryUtils.convertStringToInt(strIdEntry);
        RecordFieldFilter rfFilter = new RecordFieldFilter();
        rfFilter.setIdRecord(nIdDirectoryRecord);
        rfFilter.setIdEntry(nIdEntry);

        List<RecordField> listRecordFields = RecordFieldHome.getRecordFieldList(rfFilter, plugin);

        if ((listRecordFields != null) && !listRecordFields.isEmpty()) {
            RecordField recordField = listRecordFields.get(0);

            if ((recordField != null) && (recordField.getFile() != null)) {
                nIdFile = recordField.getFile().getIdFile();
            }
        }

        if ((nIdFile == DirectoryUtils.CONSTANT_ID_NULL) || (nIdFile == DirectoryUtils.CONSTANT_ID_ZERO)) {
            return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_DURING_DOWNLOAD_FILE,
                    AdminMessage.TYPE_STOP);
        }
    } else {
        nIdFile = DirectoryUtils.convertStringToInt(strIdFile);
    }

    File file = FileHome.findByPrimaryKey(nIdFile, plugin);
    PhysicalFile physicalFile = (file != null)
            ? PhysicalFileHome.findByPrimaryKey(file.getPhysicalFile().getIdPhysicalFile(), plugin)
            : null;

    if (physicalFile != null) {
        try {
            byte[] byteFileOutPut = physicalFile.getValue();
            DirectoryUtils.addHeaderResponse(request, response, file.getTitle());

            String strMimeType = file.getMimeType();

            if (strMimeType == null) {
                strMimeType = FileSystemUtil.getMIMEType(file.getTitle());
            }

            response.setContentType(strMimeType);
            response.setContentLength(byteFileOutPut.length);

            OutputStream os = response.getOutputStream();
            os.write(byteFileOutPut);
            os.close();
        } catch (IOException e) {
            AppLogService.error(e);
        }
    }

    return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_DURING_DOWNLOAD_FILE,
            AdminMessage.TYPE_STOP);
}

From source file:com.qmetry.qaf.automation.ui.selenium.webdriver.SetAttributeCommand.java

@Override
protected Void handleSeleneseCommand(WebDriver driver, String attributeLocator, String value) {
    int atSign = attributeLocator.lastIndexOf("@");
    String elementLocator = attributeLocator.substring(0, atSign);
    String attributeName = attributeLocator.substring(atSign + 1);
    if (!(StringUtils.isNumeric(value) || "true".equals(value) || "false".equals(value) || value.startsWith("'")
            || value.startsWith("\""))) {
        value = "\"" + value + "\"";
    }//from  ww w .  jav a 2  s .com
    try {
        ((QAFExtendedWebDriver) driver).findElement(elementLocator)
                .executeScript("setAttribute('" + attributeName + "'," + value + ")");
    } catch (Exception e) {
        if (attributeName.equalsIgnoreCase("style")) {
            ((QAFExtendedWebDriver) driver).findElement(elementLocator)
                    .executeScript("style.setAttribute('cssText'," + value + ")");
        } else if (attributeName.equalsIgnoreCase("class")) {
            ((QAFExtendedWebDriver) driver).findElement(elementLocator).executeScript("className=" + value);
        } else {
            js.executeScript(driver, "arguments[0]." + attributeName + " = arguments[1]",
                    finder.findElement(driver, elementLocator), value);
        }
    }

    return null;
}

From source file:fr.paris.lutece.portal.service.page.PageExtendableResourceService.java

/**
 * {@inheritDoc}/*www.  ja  v  a2  s .c om*/
 */
@Override
public IExtendableResource getResource(String strIdResource, String strResourceType) {
    if (StringUtils.isNotBlank(strIdResource) && StringUtils.isNumeric(strIdResource)) {
        int nIdPage = Integer.parseInt(strIdResource);

        return PageHome.getPage(nIdPage);
    }

    return null;
}

From source file:com.drevelopment.couponcodes.bukkit.BukkitServerModTransformer.java

@Override
public boolean isNumeric(String string) {
    return StringUtils.isNumeric(string);
}