List of usage examples for org.apache.commons.lang StringUtils defaultString
public static String defaultString(String str)
Returns either the passed in String, or if the String is null
, an empty String ("").
From source file:de.thischwa.pmcms.view.context.object.tagtool.GenericXhtmlTagTool.java
/** * Does the basic construction of the tag. *//*from ww w .j av a 2 s . c o m*/ protected String contructTag() { if (attributes.isEmpty()) throw new IllegalArgumentException("Attributes are missing!"); StringBuilder tag = new StringBuilder(); tag.append("<"); tag.append(name); for (String key : attributes.keySet()) { tag.append(String.format(" %s=\"%s\"", key, StringUtils.defaultString(attributes.get(key)))); } if (StringUtils.isBlank(value)) tag.append(" />"); else tag.append(">").append(value).append('<').append('/').append(name).append('>'); attributes.clear(); return tag.toString(); }
From source file:mitm.djigzo.web.validators.URIValidator.java
@Override public void validate(Field field, String type, MessageFormatter formatter, String value) throws ValidationException { value = StringUtils.trimToNull(value); if (value != null) { value = value.trim();//from w w w .j ava 2 s .co m URIType uriType = URIUtils.URIType.valueOf(StringUtils.defaultString(type).toUpperCase()); if (uriType == null) { uriType = URIType.FULL; } if (!URIUtils.isValidURI(value, uriType)) { throw new ValidationException(formatter.format(field.getLabel(), type)); } } }
From source file:com.bitium.confluence.config.SAMLConfig.java
public String getIdpRequired() { return StringUtils.defaultString((String) pluginSettings.get(IDP_REQUIRED_SETTING)); }
From source file:mitm.common.util.PhoneNumberUtils.java
/** * Adds the country code if phone number starts with 0. Returns null if phone * number is null. //from w ww. j a va 2 s . co m */ public static String addCountryCode(String phoneNumber, String countryCode) { if (phoneNumber == null) { return null; } phoneNumber = phoneNumber.trim(); if (StringUtils.isNotBlank(countryCode) && phoneNumber.startsWith("0")) { phoneNumber = StringUtils.defaultString(countryCode) + phoneNumber.substring(1); } return phoneNumber; }
From source file:herddb.cli.TextTableBuilder.java
@Override public String toString() { if (!hasResults) { return "Empty results set\n"; }//from ww w . ja v a 2 s . c om StringBuilder buf = new StringBuilder(); int[] colWidths = colWidths(); for (String[] row : rows) { buf.append("| "); for (int colNum = 0; colNum < row.length; colNum++) { buf.append(StringUtils.rightPad(StringUtils.defaultString(row[colNum]), colWidths[colNum])); buf.append(" | "); } buf.append('\n'); } return buf.toString(); }
From source file:dk.dma.msiproxy.model.MessageFilter.java
/** * Returns a key that uniquely defines the filter * @return a key that uniquely defines the filter *//*from ww w. jav a 2 s.c o m*/ public String getKey() { // Need to make sure that the types are enlisted in a deterministic order List<SeriesIdType> mainTypes = new ArrayList<>(this.mainTypes); Collections.sort(mainTypes); List<Type> types = new ArrayList<>(this.types); Collections.sort(types); return String.format("%s_%b_%s_%s_%s_%s", StringUtils.defaultString(lang), detailed, mainTypes.stream().map(Enum::toString).collect(Collectors.joining("-")), types.stream().map(Enum::toString).collect(Collectors.joining("-")), areaId == null ? "" : areaId.toString(), categoryId == null ? "" : categoryId.toString()); }
From source file:com.joshlong.lazyblogger.service.BlogService.java
public void setPassword(String password) { this.password = StringUtils.defaultString(password).trim(); }
From source file:com.apress.prospringintegration.batch.UserRegistrationValidationItemProcessor.java
public UserRegistration process(UserRegistration input) throws Exception { String zipCode = stripNonNumbers(input.getZip()); String telephone = stripNonNumbers(input.getPhoneNumber()); String state = StringUtils.defaultString(input.getState()); if (isTelephoneValid(telephone) && isZipCodeValid(zipCode) && isValidState(state)) { input.setZip(zipCode);// w w w . j ava 2s . c o m input.setPhoneNumber(telephone); System.out.println("input is valid, returning"); return input; } System.out.println("Returning null"); return null; }
From source file:info.magnolia.cms.i18n.LocaleDefinition.java
/** * Creates the locale for this definition if not yet set. *///from ww w.ja va 2 s . c o m public Locale getLocale() { if (locale == null && getLanguage() != null) { locale = new Locale(getLanguage(), StringUtils.defaultString(getCountry())); } return locale; }
From source file:edu.cornell.med.icb.goby.alignments.filters.PercentMismatchesQualityFilter.java
public void setParameters(final String parameters) { final String[] args = StringUtils.defaultString(parameters).split("[',=]"); qualityThresholdPercent = CLI.getDoubleOption(args, "threshold", 0.05d); System.err.println("Setting quality threshold to " + qualityThresholdPercent); }