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:edu.usu.sdl.openstorefront.service.search.UserRatingSearchHandler.java
@Override protected ValidationResult internalValidate() { ValidationResult validationResult = new ValidationResult(); for (SearchElement searchElement : searchElements) { if (StringUtils.isBlank(searchElement.getValue())) { validationResult.getRuleResults().add(getRuleResult("Value", "Required")); }/* w w w . j a va 2 s. c o m*/ if (StringUtils.isNumeric(searchElement.getValue()) == false) { validationResult.getRuleResults().add(getRuleResult("Value", "Must be a integer number")); } } return validationResult; }
From source file:eu.europeana.corelib.europeanastatic.cache.ImageInfo.java
public boolean deserialize(String in) throws IOException { if (StringUtils.isEmpty(in)) { return fail(in); }/*from w w w . j a va 2 s . c om*/ if (in.startsWith(DIMENSIONS)) { String[] dimensions = in.substring(DIMENSIONS.length()).trim().split(","); if (dimensions.length == 2 && StringUtils.isNumeric(dimensions[0]) && StringUtils.isNumeric(dimensions[1])) { width = Integer.parseInt(dimensions[0]); height = Integer.parseInt(dimensions[1]); } else { return fail(in); } } else { return fail(in); } return true; }
From source file:biblivre3.administration.reports.SummaryReport.java
@Override protected BaseReportDto getReportData(ReportsDTO dto) { Integer order = 1;//from w ww.j a va2 s . c o m if (StringUtils.isNotBlank(dto.getOrder()) && StringUtils.isNumeric(dto.getOrder().trim())) { order = Integer.valueOf(dto.getOrder().trim()); } switch (order) { case 1: this.index = 6; break; //dewey case 2: this.index = 0; break; //title case 3: this.index = 1; break; //author default: this.index = 6; //dewey } return new ReportsDAO().getSummaryReportData(dto.getDatabase()); }
From source file:fr.paris.lutece.plugins.customerprovisioning.services.ProvisioningService.java
/** * Process guid cuid./*from ww w. j ava2s . c o m*/ * * @param strGuid the str guid * @param strCuid the str cuid * @param userDto the user dto * @return the customer */ public static Customer processGuidCuid(String strGuid, String strCuid, UserDTO userDto) { AppLogService.error("\n" + "Provionning - Info : GUID : " + strGuid + "\n"); AppLogService.error("Provionning - Info : CID : " + strCuid + "\n"); AppLogService.error("Provionning - Info : user : " + userDto + "\n"); Customer gruCustomer = null; // CASE 1 NOT CID if ((strCuid == null) || StringUtils.isEmpty(strCuid) || !StringUtils.isNumeric(strCuid)) { // CASE 1.1 : no cid and no guid: break the flux and wait for a new flux with one of them if (((strCuid == null) || !StringUtils.isNumeric(strCuid)) && ((strGuid == null) || StringUtils.isEmpty(strGuid)) && (userDto == null)) { AppLogService .error("Provionning - Error : JSON doesnot contains any GUID nor Customer ID : " + strCuid); } // CASE 1.2 : no cid and guid: look for a mapping beween an existing guid else if ((strGuid != null) && !StringUtils.isEmpty(strGuid)) { AppLogService.error("Provionning - Info : CAS 1.2.1" + "\n"); gruCustomer = getCustomerByGuid(strGuid); if (gruCustomer == null) { gruCustomer = createCustomerByGuid(strGuid); AppLogService.info("Provionning - New user created into the GRU for the guid : " + strGuid + " its customer id is : " + gruCustomer.getId()); } } else if (userDto != null) { gruCustomer = createCustomerByGuid(userDto, strGuid); AppLogService.error("Provionning - Info : CAS 1.2.2" + "\n"); } } // CASE 2 : cid and (guid or no guid): find customer info in GRU database else if (StringUtils.isNumeric(strCuid)) { //MUST CONTROL IF COSTUMER CUID IS NUMBER FORMAT, ELSE : java.lang.NumberFormatException: For input string: AppLogService.error("Provionning - Info : CAS 2" + "\n"); gruCustomer = getCustomerByCuid(strCuid); if (gruCustomer == null) { AppLogService.error("Provionning - Error : No user found with the customer ID : " + strCuid); } } return gruCustomer; }
From source file:com.pureinfo.srm.view.function.ShowReseachCenterNames4User.java
/** * att/* w ww . jav a2 s .co m*/ * @see com.pureinfo.dolphinview.parser.function.FunctionHandlerDVImplBase#perform(java.lang.Object[], com.pureinfo.dolphinview.context.model.IDVContext) */ public Object perform(Object[] _args, IDVContext _context) throws PureException { FunctionHandlerUtil.validateArgsNum(_args, MIN_ARGS_NUM); String temp = _args[ARG_USER_ID].toString(); if (!StringUtils.isNumeric(temp)) { throw new PureException(PureException.INVALID_FORMAT, "user id must be numeric! >" + temp); } String sSep = _args[ARG_SEPARATOR].toString(); int nUserId = Integer.parseInt(temp); return doPerform(nUserId, sSep); }
From source file:net.sourceforge.fenixedu.domain.student.curriculum.CurriculumEntry.java
@Override public BigDecimal getWeigthTimesGrade() { final String grade = getGradeValue(); return StringUtils.isNumeric(grade) ? getWeigthForCurriculum().multiply(BigDecimal.valueOf(Double.valueOf(grade))) : null;/*from w ww. ja v a 2 s . c om*/ }
From source file:cognition.pipeline.commandline.CommandClient.java
@Override public void process(CommandLine cmd) { clientService.setServerAddress(cmd.getOptionValue("server")); if (cmd.hasOption("cognitionName")) { clientService.setCognitionName(cmd.getOptionValue("cognitionName")); }//w w w . ja v a2 s . co m if (cmd.hasOption("chunkSize")) { String chunkSize = cmd.getOptionValue("chunkSize"); if (!StringUtils.isNumeric(chunkSize)) { throw new IllegalArgumentException("The specified chunkSize must be an integer."); } clientService.setChunkSize(chunkSize); } clientService.startProcessing(); }
From source file:com.egt.core.db.util.Reporter.java
static int getLimiteFilasFuncionSelect(String informe) { String string = BundleInformes.getLimiteFilasFuncionSelect(informe); int limite = StringUtils.isNotBlank(string) && StringUtils.isNumeric(string) ? Integer.valueOf(string) : -1; return limite < 0 ? LIMITE_FILAS_FUNCION_SELECT : limite; }
From source file:net.sourceforge.fenixedu.domain.inquiries.QuestionScale.java
public static QuestionScale importFromString(String string) { if (string == null) { return null; }/*from ww w .jav a 2s .co m*/ List<MultiLanguageString> scalePortions = new ArrayList<MultiLanguageString>(); List<String> valuePortions = new ArrayList<String>(); for (int iter = 0; iter < string.length();) { int length = 0; int collonPosition = string.indexOf(':', iter + 3); if (StringUtils.isNumeric(string.substring(iter + 3, collonPosition))) { length = Integer.parseInt(string.substring(iter + 3, collonPosition)); String scalePortion = string.substring(collonPosition + 1, collonPosition + 1 + length); int index = scalePortion.indexOf(SCALE_VALUE_SEPARATOR); String value = scalePortion.substring(0, index); String scale = scalePortion.substring(index + 3); valuePortions.add(valuePortions.size(), value); scalePortions.add(scalePortions.size(), MultiLanguageString.importFromString(scale)); } iter = collonPosition + 1 + length; } return new QuestionScale(scalePortions.toArray(new MultiLanguageString[] {}), valuePortions.toArray(new String[] {})); }
From source file:net.firejack.platform.core.validation.condition.AbstractPackageMethodCondition.java
@Override public String defaultValue(Map<String, String> params) { String defaultValue = null;// www . j ava 2s.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); PackageModel packageRN = null; for (Long parentId : registryNodeIds) { RegistryNodeModel registryNode = registryNodeStore.findById(parentId); if (registryNode instanceof PackageModel) { packageRN = (PackageModel) registryNode; break; } } if (packageRN != null) { defaultValue = getDefaultValue(packageRN); } } } return defaultValue; }