List of usage examples for org.apache.commons.lang3 StringUtils stripToNull
public static String stripToNull(String str)
Strips whitespace from the start and end of a String returning null if the String is empty ("") after the strip.
This is similar to #trimToNull(String) but removes whitespace.
From source file:com.redhat.jenkins.plugins.ci.messaging.ActiveMqMessagingProvider.java
@DataBoundSetter public void setBroker(String broker) { this.broker = StringUtils.strip(StringUtils.stripToNull(broker), "/"); }
From source file:at.bitfire.ical4android.AndroidTask.java
protected void populateTask(ContentValues values) throws FileNotFoundException, RemoteException, ParseException { task.uid = values.getAsString(Tasks._UID); task.summary = values.getAsString(Tasks.TITLE); task.location = values.getAsString(Tasks.LOCATION); if (values.containsKey(Tasks.GEO)) { String geo = values.getAsString(Tasks.GEO); if (geo != null) task.geoPosition = new Geo(geo); }//ww w .j a va2s . co m ; task.description = StringUtils.stripToNull(values.getAsString(Tasks.DESCRIPTION)); task.url = StringUtils.stripToNull(values.getAsString(Tasks.URL)); String organizer = values.getAsString(Tasks.ORGANIZER); if (!TextUtils.isEmpty(organizer)) try { task.organizer = new Organizer("mailto:" + values.getAsString(Tasks.ORGANIZER)); } catch (URISyntaxException e) { Log.w(TAG, "Invalid ORGANIZER email", e); } Integer priority = values.getAsInteger(Tasks.PRIORITY); if (priority != null) task.priority = priority; Integer classification = values.getAsInteger(Tasks.CLASSIFICATION); if (classification != null) switch (classification) { case Tasks.CLASSIFICATION_PUBLIC: task.classification = Clazz.PUBLIC; break; case Tasks.CLASSIFICATION_CONFIDENTIAL: task.classification = Clazz.CONFIDENTIAL; break; default: task.classification = Clazz.PRIVATE; } Long completed = values.getAsLong(Tasks.COMPLETED); if (completed != null) // COMPLETED must always be a DATE-TIME task.completedAt = new Completed(new DateTime(completed)); Integer percentComplete = values.getAsInteger(Tasks.PERCENT_COMPLETE); if (percentComplete != null) task.percentComplete = percentComplete; Integer status = values.getAsInteger(Tasks.STATUS); if (status != null) switch (status) { case Tasks.STATUS_IN_PROCESS: task.status = Status.VTODO_IN_PROCESS; break; case Tasks.STATUS_COMPLETED: task.status = Status.VTODO_COMPLETED; break; case Tasks.STATUS_CANCELLED: task.status = Status.VTODO_CANCELLED; break; default: task.status = Status.VTODO_NEEDS_ACTION; } boolean allDay = false; if (values.getAsInteger(Tasks.IS_ALLDAY) != null) allDay = values.getAsInteger(Tasks.IS_ALLDAY) != 0; String tzID = values.getAsString(Tasks.TZ); TimeZone tz = (tzID != null) ? DateUtils.tzRegistry.getTimeZone(tzID) : null; Long createdAt = values.getAsLong(Tasks.CREATED); if (createdAt != null) task.createdAt = createdAt; Long lastModified = values.getAsLong(Tasks.LAST_MODIFIED); if (lastModified != null) task.lastModified = lastModified; Long dtStart = values.getAsLong(Tasks.DTSTART); if (dtStart != null) { long ts = dtStart; Date dt; if (allDay) dt = new Date(ts); else { dt = new DateTime(ts); if (tz != null) ((DateTime) dt).setTimeZone(tz); } task.dtStart = new DtStart(dt); } Long due = values.getAsLong(Tasks.DUE); if (due != null) { long ts = due; Date dt; if (allDay) dt = new Date(ts); else { dt = new DateTime(ts); if (tz != null) ((DateTime) dt).setTimeZone(tz); } task.due = new Due(dt); } String duration = values.getAsString(Tasks.DURATION); if (duration != null) task.duration = new Duration(new Dur(duration)); String rDate = values.getAsString(Tasks.RDATE); if (rDate != null) task.getRDates().add((RDate) DateUtils.androidStringToRecurrenceSet(rDate, RDate.class, allDay)); String exDate = values.getAsString(Tasks.EXDATE); if (exDate != null) task.getExDates().add((ExDate) DateUtils.androidStringToRecurrenceSet(exDate, ExDate.class, allDay)); String rRule = values.getAsString(Tasks.RRULE); if (rRule != null) task.rRule = new RRule(rRule); }
From source file:com.thoughtworks.go.config.materials.ScmMaterial.java
private void setPasswordIfNotBlank(String password) { this.password = StringUtils.stripToNull(password); this.secretParamsForPassword = SecretParams.parse(password); this.encryptedPassword = StringUtils.stripToNull(encryptedPassword); if (this.password == null) { return;/* w w w . j a va2 s .c o m*/ } try { this.encryptedPassword = this.goCipher.encrypt(password); } catch (Exception e) { bomb("Password encryption failed. Please verify your cipher key.", e); } this.password = null; }
From source file:info.novatec.testit.livingdoc.agent.server.AgentConfiguration.java
private String getKeyStore(Properties properties, String defaultValue) { return StringUtils.stripToNull(properties.getProperty(KEYSTORE_PROPERTY_NAME, defaultValue)); }
From source file:com.sonymobile.jenkins.plugins.mq.mqnotifier.MQNotifierConfig.java
/** * Sets URI for MQ server./*from w ww. ja v a 2 s . co m*/ * * @param serverUri the URI. */ public void setServerUri(final String serverUri) { this.serverUri = StringUtils.strip(StringUtils.stripToNull(serverUri), "/"); }
From source file:info.novatec.testit.livingdoc.agent.server.AgentConfiguration.java
private String getKeyStorePassword(Properties properties) { return StringUtils.stripToNull(properties.getProperty(KEYSTORE_PASSWORD_PROPERTY_NAME, null)); }
From source file:li.klass.fhem.service.room.RoomListHolderService.java
FHEMWEBDevice findFHEMWEBDevice(List<FhemDevice> devices, Context context) { if (devices.isEmpty()) return new FHEMWEBDevice(); String qualifier = StringUtils .stripToNull(applicationProperties.getStringSharedPreference(FHEMWEB_DEVICE_NAME, null, context)); if (qualifier == null) { int port = connectionService.getPortOfSelectedConnection(context); Optional<FhemDevice> match = from(devices).filter(predicateFHEMWEBDeviceForPort(port)).first(); if (match.isPresent()) { return (FHEMWEBDevice) match.get(); }/*from w ww . ja va 2s . c o m*/ } qualifier = (qualifier == null ? DEFAULT_FHEMWEB_QUALIFIER : qualifier).toUpperCase(Locale.getDefault()); Optional<FhemDevice> match = from(devices).filter(predicateFHEMWEBDeviceForQualifier(qualifier)).first(); if (match.isPresent()) { return (FHEMWEBDevice) match.get(); } return (FHEMWEBDevice) devices.get(0); }
From source file:com.thoughtworks.go.config.materials.ScmMaterial.java
@PostConstruct public void ensureEncrypted() { this.userName = StringUtils.stripToNull(this.userName); setPasswordIfNotBlank(password);//from w ww. j av a 2 s.co m if (encryptedPassword != null) { setEncryptedPassword(goCipher.maybeReEncryptForPostConstructWithoutExceptions(encryptedPassword)); } }
From source file:com.thoughtworks.go.config.MailHost.java
@PostConstruct public void ensureEncrypted() { this.username = StringUtils.stripToNull(username); setPasswordIfNotBlank(password);//from w ww.j a v a 2s . c o m if (encryptedPassword != null) { setEncryptedPassword(goCipher.maybeReEncryptForPostConstructWithoutExceptions(encryptedPassword)); } }
From source file:com.thoughtworks.go.config.MailHost.java
private void setPasswordIfNotBlank(String password) { this.password = StringUtils.stripToNull(password); this.encryptedPassword = StringUtils.stripToNull(encryptedPassword); if (this.password == null) { return;// w w w . ja v a 2s .c om } try { this.encryptedPassword = this.goCipher.encrypt(password); } catch (Exception e) { bomb("Password encryption failed. Please verify your cipher key.", e); } this.password = null; }