List of usage examples for org.apache.commons.lang StringUtils isNumeric
public static boolean isNumeric(String str)
Checks if the String contains only unicode digits.
From source file:com.facebook.plugin.ui.AccountKitInstallDependenciesForm.java
@Override public boolean commitForm() { AccountKitModuleConfigurator.AvailableModule selectedModule = (AccountKitModuleConfigurator.AvailableModule) moduleSelector .getSelectedItem();/*from w ww .j a v a 2 s . c o m*/ if (selectedModule == null) { Messages.showErrorDialog(project, "Please select a module to continue.", "Install Failed"); return false; } if (selectedModule.getInstallationType() == AccountKitModuleConfigurator.InstallationType.CannotInstall) { Messages.showErrorDialog(project, "Cannot install AccountKit on module " + selectedModule.getModule().getName() + " because it either is not an Android module " + "or is not built using Gradle.", "Install Failed"); return false; } if (selectedModule .getInstallationType() == AccountKitModuleConfigurator.InstallationType.AlreadyInstalled) { return true; } if (StringUtils.isBlank(appNameField.getText())) { Messages.showErrorDialog(project, "App Name cannot be blank.", "Install Failed"); return false; } if (StringUtils.isBlank(appIdField.getText()) || !StringUtils.isNumeric(appIdField.getText())) { Messages.showErrorDialog(project, "App Id must be a valid number.", "Install Failed"); return false; } if (StringUtils.isBlank(clientTokenField.getText())) { Messages.showErrorDialog(project, "Client Token cannot be blank.", "Install Failed"); return false; } AccountKitModuleConfigurator accountKitModuleConfigurator = new AccountKitModuleConfigurator( appNameField.getText(), appIdField.getText(), clientTokenField.getText()); if (!accountKitModuleConfigurator.isConfigured(selectedModule.getModule())) { try { accountKitModuleConfigurator.doConfigure(selectedModule.getModule()); } catch (Exception e) { Messages.showErrorDialog(project, "Something went wrong while installing module " + selectedModule.getModule().getName() + ": \n" + e.getMessage(), "Install Failed"); } } return true; }
From source file:ch.ksfx.web.pages.publishing.PublicationViewer.java
public Object onActivate(EventContext eventContext) { Integer fromCache = 0;//from w w w . j a v a 2 s . c o m String stringContext = ""; List<String> uriParameters = new ArrayList<String>(); //For Fallback Reasons if (eventContext.getCount() == 1) { stringContext = eventContext.get(String.class, 0); } else { fromCache = eventContext.get(Integer.class, 0); stringContext = eventContext.get(String.class, 1); } if (eventContext.getCount() > 2) { for (Integer i = 2; i < eventContext.getCount(); i++) { uriParameters.add(eventContext.get(String.class, i)); } } if (StringUtils.isNumeric(stringContext)) { return activatePublishingConfigurationForId(Long.parseLong(stringContext), fromCache, uriParameters); } else { return activatePublishingConfigurationOrPublishingResourceForUri(stringContext, fromCache, uriParameters); } }
From source file:net.duckling.common.util.CommonUtils.java
/** * <p>String??Integer?id</p> */*from w ww . ja v a2s .c o m*/ * <pre> * CommonUtils.string2Int(null) = setDefault * CommonUtils.string2Int("") = setDefault * CommonUtils.string2Int("12.3") = setDefault * CommonUtils.string2Int("a") = setDefault * CommonUtils.string2Int("123") = 123 * </pre> * * @param sid * @param setDefault ?,?setDefault * @return Integer */ public static int string2Id(String sid, int setDefault) { return StringUtils.isEmpty(sid) ? setDefault : StringUtils.isNumeric(sid) ? Integer.parseInt(sid) : setDefault; }
From source file:fr.paris.lutece.plugins.stock.modules.billetterie.web.SubscriptionProductJspBean.java
/** * Create the subscription for the user//from w ww . j a va 2 s . c om * @param request the HTTP request * @param currentUser the user who subscribe * @return an error if occur, null otherwise */ public String doSubscribeToProduct(HttpServletRequest request, LuteceUser currentUser) { String strIdProduct = request.getParameter(PARAMETER_PRODUCT_ID); if (StringUtils.isNotEmpty(strIdProduct) && StringUtils.isNumeric(strIdProduct)) { String strEmailHome = currentUser.getUserInfo(LuteceUser.HOME_INFO_ONLINE_EMAIL); String strEmailBusiness = currentUser.getUserInfo(LuteceUser.BUSINESS_INFO_ONLINE_EMAIL); String strEmail = !strEmailHome.equals("") ? strEmailHome : strEmailBusiness; _subscriptionProductService.doSaveSubscriptionProduct(strEmail, strIdProduct); } return null; }
From source file:net.mindengine.oculus.frontend.web.controllers.test.TestSearchController.java
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override/*from w ww . j a va 2 s. com*/ protected Map referenceData(HttpServletRequest request, Object command, Errors errors) throws Exception { TestSearchFilter filter = (TestSearchFilter) command; filter.setColumns(columnFactory.getColumnList()); Map map = new HashMap<String, Object>(); map.put("columns", columnFactory.getColumnList()); if (filter.getProject() != null && filter.getProject().equals("0")) { filter.setProject(""); } /* * Collecting customization search criteria parameters */ filter.setCustomizations(CustomizationUtils.collectCustomizationSearchCriteriaParameters(request)); Boolean customizationsAvailable = false; if (filter.getProject() != null && !filter.getProject().isEmpty()) { if (StringUtils.isNumeric(filter.getProject())) { List<Map<String, Object>> customizations = CustomizationUtils.fetchCustomizationGroups( customizationDAO, userDAO, Long.parseLong(filter.getProject()), Customization.UNIT_TEST, filter.getCustomizations()); map.put("customizations", customizations); if (customizations.size() > 0) { customizationsAvailable = true; } /* * Fetching a list of subprojects for the specified project */ Long projectId = Long.parseLong(filter.getProject()); map.put("subprojects", projectDAO.getSubprojects(projectId)); } } map.put("customizationsAvailable", customizationsAvailable); map.put("tests", testDAO.searchTests(filter)); map.put("rootProjects", projectDAO.getRootProjects()); map.put("columnFactory", columnFactory); map.put("searchFilter", filter); map.put("title", getTitle()); return map; }
From source file:edu.ku.brc.af.tasks.subpane.formeditor.JGoodiesDefItem.java
/** * @param defArg//from ww w . ja v a2s .c o m * @param isRow */ public void parse(final String defArg, final boolean isRow) { String def = defArg; if (StringUtils.isEmpty(def)) { def = "p"; //$NON-NLS-1$ } else { def = defArg.toLowerCase(); } if (def.startsWith("min")) //$NON-NLS-1$ { minMax = MINMAX_TYPE.Min; parseMinMax(def); } else if (def.startsWith("max")) //$NON-NLS-1$ { minMax = MINMAX_TYPE.Max; parseMinMax(def); } else { String adjustedDef = def; int inx = 0; for (String pfx : prefixes) { if (def.startsWith(pfx)) { adjustedDef = def.substring(pfx.length() + 1, def.length()); align = prefixeVals[inx]; break; } inx++; } if (StringUtils.isNumeric(adjustedDef.substring(0, 1))) { parseNum(adjustedDef); isPreferredSize = false; } else { isPreferredSize = true; } } isGrow = def.endsWith(":g") || def.endsWith(":grow"); //$NON-NLS-1$ //$NON-NLS-2$ }
From source file:eu.eidas.node.specific.derivation.DeriveIsAgeOver.java
/** * Checks if the value provided is numeric. * /*from ww w . ja v a2 s.co m*/ * @param minAges List containing a value. * @return True if the value is numeric, false otherwise. */ private boolean isAgeValid(final List<String> minAges) { if (minAges.size() == 1 && minAges.get(0) != null) { return StringUtils.isNumeric(minAges.get(0)); } return false; }
From source file:br.com.nordestefomento.jrimum.domkee.financeiro.banco.febraban.guia.CodigoDeIdentificacaoFebraban.java
private boolean isCodigoValido(String codigo) { boolean result = false; if (StringUtils.isNotEmpty(codigo) && StringUtils.isNumeric(codigo)) { int codigoAsInteger = Integer.parseInt(codigo); if (codigoAsInteger > 0 && codigoAsInteger < 9999) { result = true;/*from w ww .j a va2 s . c om*/ } } return result; }
From source file:eu.stork.peps.auth.commons.PEPSUtil.java
/** * Validates the input paramValue identified by the paramName. * /*w w w . ja va2 s . c om*/ * @param paramName The name of the parameter to validate. * @param paramValue The value of the parameter to validate. * * @return true if the parameter is valid. */ public static boolean isValidParameter(final String paramName, final String paramValue) { final String validationParam = PEPSUtil.getConfig(PEPSParameters.VALIDATION_ACTIVE.toString()); boolean retVal = true; final String paramConf = MAX_PARAM_PREFIX + paramName + MAX_PARAM_SUFFIX; if (PEPSValues.TRUE.toString().equals(validationParam)) { final String paramSizeStr = PEPSUtil.getConfig(paramConf); // Checking if the parameter size exists and if it's numeric if (StringUtils.isNumeric(paramSizeStr)) { final int maxParamSize = Integer.valueOf(paramSizeStr); if (StringUtils.isEmpty(paramValue) || paramValue.length() > maxParamSize) { retVal = false; LOG.warn("Invalid parameter [" + paramName + "] value " + paramValue); } } else { retVal = false; LOG.error("Missing " + paramConf + " configuration in the pepsUtils.properties configuration file"); } } return retVal; }
From source file:de.cosmocode.palava.legacy.UtilityJobImpl.java
@Override public long getOptLong(String key, long defaultValue) { if (hasArgument(key)) { final String val = getOptional(key); if (StringUtils.isNumeric(val)) { return Long.parseLong(val); }//w w w . ja va2 s. c om } return defaultValue; }