List of usage examples for org.apache.commons.lang StringUtils length
public static int length(String str)
0
if the String is null
. From source file:org.jrimum.bopepo.campolivre.AbstractCampoLivre.java
/** * <p>//from www .j av a 2s. com * Verifica se o nosso nmero do ttulo tem o tamanho determinado, caso * contrrio lana uma {@code IllegalArgumentException} com a mensagem * <tt>"Tamanho do nosso nmero [%s] diferente do esperado [%s]!"</tt>. * </p> * * @param titulo * @param length * - Tamanho que deve ser * * @since 0.2 */ protected final static void checkTamanhoDoNossoNumero(Titulo titulo, int length) { checkTamanhoNossoNumero(titulo, length, format("Tamanho [%s] do nosso nmero [\"%s\"] diferente do esperado [%s]!", StringUtils.length(titulo.getNossoNumero()), titulo.getNossoNumero(), length)); }
From source file:org.jrimum.bopepo.campolivre.AbstractCampoLivre.java
/** * <p>//from w ww .j av a 2 s . co m * Verifica se o dgito do nosso nmero do ttulo tem o tamanho determinado, caso * contrrio lana uma {@code IllegalArgumentException} com a mensagem * <tt>"Tamanho [%s] do dgito do nosso nmero [\"%s\"] diferente do esperado [%s]!"</tt>. * </p> * * @param titulo * @param length * - Tamanho que deve ser * * @since 0.2 */ protected final static void checkTamanhoDigitoDoNossoNumero(Titulo titulo, int length) { checkTamanhoDigitoDoNossoNumero(titulo, length, format("Tamanho [%s] do dgito do nosso nmero [\"%s\"] diferente do esperado [%s]!", StringUtils.length(titulo.getDigitoDoNossoNumero()), titulo.getDigitoDoNossoNumero(), length)); }
From source file:org.kuali.kfs.fp.businessobject.lookup.DisbursementPayeeLookupableHelperServiceImpl.java
/** * Determines if a String is "filled enough", i.e. if a wildcard is present, has a length greater than the defined minimum length (3 characters, plus a wildcard). * @param s the String to test//from w w w . ja v a 2 s . c om * @return true if the given String is "filled" by the definition above, false otherwise */ protected boolean filledEnough(String s) { return !containsLookupWildcard(s) || StringUtils.length(s) >= getNameLengthWithWildcardRequirement(); }
From source file:org.kuali.kfs.module.external.kc.service.impl.LetterOfCreditFundServiceImpl.java
@Override public Collection findMatching(Map fieldValues) { AwardMethodOfPaymentDTO criteria = new AwardMethodOfPaymentDTO(); List<AwardMethodOfPaymentDTO> result = null; try {/*from w w w.j av a2 s .c o m*/ if (fieldValues.containsKey("letterOfCreditFundGroupCode") && StringUtils.length((String) fieldValues.get("letterOfCreditFundGroupCode")) > 0) { result = this.getWebService().getMatchingMethodOfPaymentsForBasisOfPayment( (String) fieldValues.get("letterOfCreditFundGroupCode")); } else { criteria.setMethodOfPaymentCode((String) fieldValues.get("letterOfCreditFundCode")); criteria.setDescription((String) fieldValues.get("letterOfCreditFundDescription")); result = this.getWebService().getMatchingMethodOfPayments(criteria); } } catch (WebServiceException ex) { GlobalVariablesExtractHelper.insertError(KcConstants.WEBSERVICE_UNREACHABLE, getConfigurationService().getPropertyValueAsString(KFSConstants.KC_APPLICATION_URL_KEY)); } List<LetterOfCreditFund> methods = new ArrayList<LetterOfCreditFund>(); if (result != null) { for (AwardMethodOfPaymentDTO dto : result) { methods.add(fundFromDTO(dto)); } } return methods; }
From source file:org.kuali.student.enrollment.class2.scheduleofclasses.sort.impl.ActivityOfferingCodeComparator.java
/** * Sorts the activity code in alphabetical order like a,b,c.....x,y,z,aa,ab....az,ba etc. * * @param o1//from www . j a v a2 s. c om * @param o2 * @return */ @Override public int compare(ActivityOfferingWrapper o1, ActivityOfferingWrapper o2) { if (StringUtils.length(o1.getActivityCode()) > StringUtils.length(o2.getActivityCode())) { return 1; } else if (StringUtils.length(o1.getActivityCode()) < StringUtils.length(o2.getActivityCode())) { return -1; } else { return o1.getActivityCode().compareTo(o2.getActivityCode()); } }
From source file:org.openhab.binding.plugwise.protocol.InitialiseResponseMessage.java
@Override protected void parsePayLoad() { Pattern RESPONSE_PATTERN = Pattern.compile("(\\w{16})(\\w{2})(\\w{2})(\\w{16})(\\w{4})(\\w{2})"); Matcher matcher = RESPONSE_PATTERN.matcher(payLoad); if (matcher.matches()) { MAC = matcher.group(1);//from ww w . j a v a 2s . c om unknown1 = matcher.group(2); online = (Integer.parseInt(matcher.group(3), 16) == 1); networkID = matcher.group(4); shortNetworkID = matcher.group(5); unknown2 = matcher.group(6); // now some serious protocol reverse-engineering assumption. Circle+ MAC = networkID with first two bytes replaced by 00 circlePlusMAC = "00" + StringUtils.right(networkID, StringUtils.length(networkID) - 2); } else { logger.debug("Plugwise protocol InitialiseResponse error: {} does not match", payLoad); } }
From source file:org.openmrs.module.clinicalsummary.evaluator.velocity.VelocityUtils.java
/** * Format the name of a concept with the best name for the locale or a shorter name for the concept * * @param concept the concept//from w w w .ja v a2s .co m * @return concept name with a relatively shorter name */ public String format(final Concept concept) { if (concept == null) return StringUtils.EMPTY; // use the best name as the default name String name = concept.getName(Context.getLocale()).getName(); // when the name is too long, then use the concept's short name for display if (StringUtils.length(name) > 10) { ConceptName conceptName = concept.getShortNameInLocale(Context.getLocale()); if (conceptName != null) name = conceptName.getName(); } return StringEscapeUtils.escapeXml(name); }
From source file:org.openmrs.module.clinicalsummary.rule.flowsheet.FlowsheetUtils.java
/** * Format the name of a concept with the best name for the locale or a shorter name for the concept * * @param concept the concept/*from www .j av a2 s. c o m*/ * @return concept name with a relatively shorter name */ public static String format(final Concept concept) { if (concept == null) return StringUtils.EMPTY; // use the best name as the default name String name = concept.getName(Context.getLocale()).getName(); // when the name is too long, then use the concept's short name for display if (StringUtils.length(name) > 10) { ConceptName conceptName = concept.getShortNameInLocale(Context.getLocale()); if (conceptName != null) name = conceptName.getName(); } return name; }
From source file:org.opentestsystem.authoring.testauth.service.impl.ItemImportHelper.java
private String createItemGroup(final String assessmentId, final ItemLocation itemLocation, final String passageId, final String passageName) { final String groupName = "Passage: " + passageId + " - " + passageName; LOGGER.info("Creating item group " + groupName); final ItemGroup newGroup = new ItemGroup(); if (itemLocation instanceof AdaptiveItemLocation) { newGroup.setLocationId(itemLocation.getSegmentId()); newGroup.setLocationType(ItemGroupLocationType.SEGMENT); } else if (itemLocation instanceof FixedFormItemLocation) { newGroup.setLocationId(itemLocation.getFormPartitionId()); newGroup.setLocationType(ItemGroupLocationType.FORM_PARTITION); }//from w w w . j a v a2 s. c o m newGroup.setGroupName(StringUtils.length(groupName) > 60 ? groupName.substring(0, 59) : groupName); newGroup.setAssessmentId(assessmentId); newGroup.setPassageId(passageId); newGroup.setPassageName(passageName); newGroup.setMaxResponses(0); newGroup.setMaxitems(0); final ItemGroup created = this.itemGroupService.saveItemGroup(newGroup); return created.getId(); }
From source file:org.osframework.contract.date.fincal.definition.CentralBank.java
/** * Set ISO-3166 country code for this central bank. * /*from www.ja v a2s . c o m*/ * @param country ISO-3166 country code for this central bank * @throws IllegalArgumentException if country is not a supported ISO-3166 * alpha2 country code */ public void setCountry(String country) { if (StringUtils.isBlank(country) || (2 != StringUtils.length(country.trim()))) { throw new IllegalArgumentException("Invalid ISO-3166 alpha2 country code"); } this.country = StringUtils.upperCase(country.trim(), Locale.ENGLISH); }