List of usage examples for org.apache.commons.lang StringUtils isEmpty
public static boolean isEmpty(String str)
Checks if a String is empty ("") or null.
From source file:net.shopxx.dao.impl.MemberRankDaoImpl.java
public boolean nameExists(String name) { if (StringUtils.isEmpty(name)) { return false; }/*from www . j a va 2s . co m*/ String jpql = "select count(*) from MemberRank memberRank where lower(memberRank.name) = lower(:name)"; Long count = entityManager.createQuery(jpql, Long.class).setParameter("name", name).getSingleResult(); return count > 0; }
From source file:com.floreantpos.model.InventoryItem.java
public static InventoryItem fromCSV(String csvLine) { if (StringUtils.isEmpty(csvLine)) { return null; }/*w w w . jav a 2s . c o m*/ String[] strings = csvLine.split(","); //$NON-NLS-1$ InventoryItem inventoryItem = new InventoryItem(); int index = 0; try { // "NAME", "UNIT_PER_PACKAGE", "TOTAL_PACKAGES", "AVERAGE_PACKAGE_PRICE", "TOTAL_RECEPIE_UNITS", // "UNIT_PURCHASE_PRICE", "PACKAGE_BARCODE", "UNIT_BARCODE", "PACKAGE_DESC", "SORT_ORDER", "PACKAGE_REORDER_LEVEL", // "PACKAGE_REPLENISH_LEVEL","DESCRIPTION","UNIT_SELLING_PRICE" inventoryItem.setName(strings[index++]); inventoryItem.setUnitPerPackage(POSUtil.parseDouble(strings[index++])); inventoryItem.setTotalPackages(POSUtil.parseInteger(strings[index++])); inventoryItem.setAveragePackagePrice(POSUtil.parseDouble(strings[index++])); inventoryItem.setTotalRecepieUnits(POSUtil.parseDouble(strings[index++])); inventoryItem.setUnitPurchasePrice(POSUtil.parseDouble(strings[index++])); inventoryItem.setPackageBarcode(strings[index++]); inventoryItem.setUnitBarcode(strings[index++]); // inventoryItem.setPackagingUnit(strings[index++]); inventoryItem.setSortOrder(POSUtil.parseInteger(strings[index++])); inventoryItem.setPackageReorderLevel(POSUtil.parseInteger(strings[index++])); inventoryItem.setPackageReplenishLevel(POSUtil.parseInteger(strings[index++])); inventoryItem.setDescription(strings[index++]); inventoryItem.setUnitSellingPrice(POSUtil.parseDouble(strings[index++])); } catch (Exception e) { //e.printStackTrace(); } return inventoryItem; }
From source file:com.openshift.restclient.utils.Base64Coder.java
/** * Encodes the given string to a base64 encoded string. Returns * <code>null</code> if the given string is <code>null</code>. * /*from ww w. j av a 2 s. c o m*/ * @param unencoded * @return */ public static String encode(String unencoded) { if (StringUtils.isEmpty(unencoded)) { return unencoded; } return encode(unencoded.getBytes()); }
From source file:com.ansorgit.plugins.bash.lang.valueExpansion.ValueExpansionUtil.java
public static boolean isValid(String spec, boolean enhancedSyntax) { if (StringUtils.isEmpty(spec)) { return false; }/* w w w . java 2 s . c o m*/ try { split(spec, enhancedSyntax); } catch (IllegalArgumentException e) { return false; } return true; }
From source file:edu.harvard.med.screensaver.io.libraries.LibraryCopyPlateListParser.java
public static LibraryCopyPlateListParserResult parsePlateCopies(String plateCopyList) { LibraryCopyPlateListParserResult result = new LibraryCopyPlateListParserResult(); if (plateCopyList == null || StringUtils.isEmpty(plateCopyList.trim())) { result.addError("no search terms specified"); return result; }/*from w ww .ja v a 2s . c o m*/ plateCopyList = plateCopyList.trim(); Pattern numberCopyPattern = Pattern.compile("(^\\d+)([^\\-]*)$"); // modified, re [#2728] do not require whitespace or punctuation between plate and copy name Pattern numberRangePattern = Pattern.compile("^(\\d+)[-]+(\\d+)$"); // note [-]+ allows more than one dash // TODO: there may be other error patterns Pattern errorRangePattern = Pattern.compile("^(\\d+)[-]+$"); List<String> list = edu.harvard.med.screensaver.util.StringUtils.tokenizeQuotedWordList(plateCopyList); if (log.isDebugEnabled()) log.debug("parsed terms: " + Joiner.on(",").join(list)); for (String s : list) { if (numberCopyPattern.matcher(s).matches()) { Matcher m = numberCopyPattern.matcher(s); if (m.matches()) { // here, allow the plate-copy to be concatenated, as in "111A" result.addPlate(Integer.parseInt(m.group(1))); String temp = m.group(2); if (!StringUtils.isEmpty(temp)) { result.addCopy(temp); } } } else if (numberRangePattern.matcher(s).matches()) { Matcher m = numberRangePattern.matcher(s); if (m.matches()) { Integer first = Integer.parseInt(m.group(1)); Integer second = Integer.parseInt(m.group(2)); result.addPlateRange(Pair.newPair(first, second)); } else {/** nop **/ } } else { // implied: if the other patterns don't match, then this is the "copyMatcher" if (errorRangePattern.matcher(s).matches()) { result.addError("unparseable range: " + s); } else { // Remove the quote chars that were left in by the top level matcher s = s.replaceAll("\"|'+", ""); result.addCopy(s); } } } if (log.isDebugEnabled()) log.debug("parsed: " + result); return result; }
From source file:fr.hoteia.qalingo.web.mvc.viewbean.AbstractViewBean.java
protected String handleString(String string) { if (StringUtils.isEmpty(string)) { return ""; } return string; }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.manager.TransferEnrollments.java
@Atomic public static void run(final String destinationStudentCurricularPlanId, final String[] enrollmentIDsToTransfer, final String destinationCurriculumGroupID) { check(RolePredicates.MANAGER_OR_OPERATOR_PREDICATE); if (!StringUtils.isEmpty(destinationCurriculumGroupID)) { CurriculumGroup curriculumGroup = (CurriculumGroup) FenixFramework .getDomainObject(destinationCurriculumGroupID); StudentCurricularPlan studentCurricularPlan = curriculumGroup.getStudentCurricularPlan(); for (final String enrollmentIDToTransfer : enrollmentIDsToTransfer) { Enrolment enrolment = (Enrolment) FenixFramework.getDomainObject(enrollmentIDToTransfer); fixEnrolmentCurricularCourse(studentCurricularPlan, enrolment); enrolment.setCurriculumGroup(curriculumGroup); enrolment.setStudentCurricularPlan(null); }//from w ww . j a va 2 s .c o m } else { final StudentCurricularPlan studentCurricularPlan = FenixFramework .getDomainObject(destinationStudentCurricularPlanId); for (final String enrollmentIDToTransfer : enrollmentIDsToTransfer) { final Enrolment enrollment = (Enrolment) FenixFramework.getDomainObject(enrollmentIDToTransfer); fixEnrolmentCurricularCourse(studentCurricularPlan, enrollment); if (enrollment.getStudentCurricularPlan() != studentCurricularPlan) { enrollment.setStudentCurricularPlan(studentCurricularPlan); enrollment.setCurriculumGroup(null); } } } }
From source file:com.clican.pluto.common.resource.AutoDecisionResource.java
public AutoDecisionResource(String resource) { if (StringUtils.isEmpty(resource)) { new IllegalArgumentException("resource cannot be null"); }//from w w w . j a v a2s . c om if (log.isInfoEnabled()) { log.info("load resource [" + resource + "]"); } if (resource.startsWith(ClassPathResource.CLASS_PATH_RESOURCE_PREFIX)) { if (log.isInfoEnabled()) { log.info("load resource [" + resource + "] from class path"); } this.resource = new ClassPathResource(resource); } else if (resource.startsWith(FilePathResource.FILE_PATH_RESOURCE_PREFIX)) { if (log.isInfoEnabled()) { log.info("load resource [" + resource + "] from file path"); } this.resource = new FilePathResource(resource); } else { try { this.resource = new ClassPathResource(resource); } catch (Exception e) { log.debug("This is not a class path resource, try to find it in file path resource"); this.resource = new FilePathResource(resource); } } if (this.resource == null) { throw new IllegalArgumentException("resource cannot be found"); } }
From source file:com.assemblade.opendj.LdapUtils.java
public static void createSingleEntryModification(List<Modification> modifications, Entry currentEntry, String attributeName, String value) { AttributeType type = DirectoryServer.getAttributeType(attributeName); AttributeBuilder builder = new AttributeBuilder(type); if (currentEntry.hasAttribute(type)) { if (StringUtils.isEmpty(value)) { modifications.add(new Modification(ModificationType.DELETE, builder.toAttribute())); } else {/*from w w w. j av a 2 s. c o m*/ String oldValue = getSingleAttributeStringValue(currentEntry.getAttribute(attributeName)); if (!StringUtils.equals(oldValue, value)) { builder.add(value); modifications.add(new Modification(ModificationType.REPLACE, builder.toAttribute())); } } } else { if (StringUtils.isNotEmpty(value)) { builder.add(value); modifications.add(new Modification(ModificationType.ADD, builder.toAttribute())); } } }
From source file:guru.bubl.module.model.validator.IdentificationValidator.java
public Set<IdentificationError> validate(Identifier identification) { Set<IdentificationError> errors = new HashSet<>(); if (null == identification.getExternalResourceUri()) { errors.add(IdentificationError.EXTERNAL_URI_MANDATORY); return errors; }/*from w ww. j a va 2 s . c o m*/ if (StringUtils.isEmpty(identification.getExternalResourceUri().toString())) { errors.add(IdentificationError.EMPTY_EXTERNAL_URI); } return errors; }