List of usage examples for org.apache.commons.lang 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.
From source file:nl.knaw.huygens.timbuctoo.tools.importer.DefaultConverter.java
/** * Filters a notes text field by collapsing whitespace and removing leading and trailing whitespace. * Newlines are retained//from ww w . j a va 2 s.c o m * Returns {@code null} if the remaining text is empty. */ protected String filterNotesField(String text) { if (text == null) { return null; } if (text.contains("\\")) { text = text.replaceAll("\\\\r", NEWLINE); text = text.replaceAll("\\\\n", NEWLINE); } text = text.replaceAll("[ \\u00A0]+", " "); return StringUtils.stripToNull(text); }
From source file:org.ambraproject.action.user.UserActionSupport.java
protected UserProfile createProfileFromFields() throws Exception { UserProfile userProfile = new UserProfile(); userProfile.setDisplayName(this.displayName); userProfile.setEmail(this.email); userProfile.setTitle(this.title); userProfile.setSurname(this.surnames); userProfile.setGivenNames(this.givenNames); userProfile.setRealName(this.givenNames + " " + this.surnames); userProfile.setPositionType(this.positionType); userProfile.setOrganizationType(this.organizationType); userProfile.setOrganizationName(this.organizationName); userProfile.setPostalAddress(this.postalAddress); userProfile.setBiography(this.biographyText); userProfile.setInterests(this.interestsText); userProfile.setResearchAreas(this.researchAreasText); userProfile.setAlertsJournals(this.alertsJournals); final String homePageUrl = StringUtils.stripToNull(makeValidUrl(homePage)); userProfile.setHomePage(homePageUrl); final String weblogUrl = StringUtils.stripToNull(makeValidUrl(weblog)); userProfile.setWeblog(weblogUrl);//from ww w. jav a 2 s . c om userProfile.setCity(this.city); userProfile.setCountry(this.country); userProfile.setOrganizationVisibility(this.organizationVisibility); return userProfile; }
From source file:org.ambraproject.user.action.AdminUserProfileAction.java
protected UserProfile createProfileFromFields() throws Exception { UserProfile userProfile = new UserProfile(); userProfile.setDisplayName(this.displayName); userProfile.setEmail(this.email); userProfile.setTitle(this.title); userProfile.setSurname(this.surnames); userProfile.setGivenNames(this.givenNames); userProfile.setRealName(this.givenNames + " " + this.surnames); userProfile.setPositionType(this.positionType); userProfile.setOrganizationType(this.organizationType); userProfile.setOrganizationName(this.organizationName); userProfile.setPostalAddress(this.postalAddress); userProfile.setBiography(this.biographyText); userProfile.setInterests(this.interestsText); userProfile.setResearchAreas(this.researchAreasText); userProfile.setAlertsJournals(this.alertsJournals); final String homePageUrl = StringUtils.stripToNull(makeValidUrl(homePage)); userProfile.setHomePage(homePageUrl); final String weblogUrl = StringUtils.stripToNull(makeValidUrl(weblog)); userProfile.setWeblog(weblogUrl);//from w w w.j a va 2 s. co m userProfile.setCity(this.city); userProfile.setCountry(this.country); if (PRIVATE.equals(this.orgVisibility)) { userProfile.setOrganizationVisibility(false); } else if (PUBLIC.equals(this.orgVisibility)) { userProfile.setOrganizationVisibility(true); } else { userProfile.setOrganizationVisibility(false); } return userProfile; }
From source file:org.artifactory.descriptor.config.CentralConfigDescriptorImpl.java
@Override public void setServerName(String serverName) { this.serverName = StringUtils.stripToNull(serverName); }
From source file:org.jenkinsci.plugins.androidsigning.SignApksBuilder.java
@DataBoundSetter public void setAndroidHome(String x) { androidHome = StringUtils.stripToNull(x); }
From source file:org.jenkinsci.plugins.androidsigning.SignApksBuilder.java
@DataBoundSetter public void setZipalignPath(String x) { zipalignPath = StringUtils.stripToNull(x); }
From source file:org.jenkinsci.plugins.mesos.JenkinsScheduler.java
private CommandInfo.Builder getBaseCommandBuilder(Request request) { CommandInfo.Builder commandBuilder = CommandInfo.newBuilder(); String jenkinsCommand2Run = generateJenkinsCommand2Run(request.request.mem, request.request.slaveInfo.getJvmArgs(), request.request.slaveInfo.getJnlpArgs(), request.request.slave.name); if (request.request.slaveInfo.getContainerInfo() != null && request.request.slaveInfo.getContainerInfo().getUseCustomDockerCommandShell()) { // Ref http://mesos.apache.org/documentation/latest/upgrades // regarding setting the shell value, and the impact on the command to be // launched String customShell = request.request.slaveInfo.getContainerInfo().getCustomDockerCommandShell(); if (StringUtils.stripToNull(customShell) == null) { throw new IllegalArgumentException("Invalid custom shell argument supplied "); }/*from w ww . ja v a 2 s. c om*/ LOGGER.info(String.format("About to use custom shell: %s ", customShell)); commandBuilder.setShell(false); commandBuilder.setValue(customShell); List args = new ArrayList(); args.add(jenkinsCommand2Run); commandBuilder.addAllArguments(args); } else { LOGGER.info("About to use default shell ...."); commandBuilder.setValue(jenkinsCommand2Run); } commandBuilder.addUris(CommandInfo.URI.newBuilder().setValue(joinPaths(jenkinsMaster, SLAVE_JAR_URI_SUFFIX)) .setExecutable(false).setExtract(false)); return commandBuilder; }
From source file:org.kuali.rice.kns.web.struts.form.KualiDocumentFormBase.java
/** * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, * javax.servlet.http.HttpServletRequest) *///from www . j a va 2 s .c o m @Override public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { // check that annotation does not exceed 2000 characters setAnnotation(StringUtils.stripToNull(getAnnotation())); int diff = StringUtils.defaultString(getAnnotation()).length() - KRADConstants.DOCUMENT_ANNOTATION_MAX_LENGTH; if (diff > 0) { GlobalVariables.getMessageMap().putError("annotation", RiceKeyConstants.ERROR_DOCUMENT_ANNOTATION_MAX_LENGTH_EXCEEDED, new String[] { Integer.toString(KRADConstants.DOCUMENT_ANNOTATION_MAX_LENGTH), Integer.toString(diff) }); } return super.validate(mapping, request); }
From source file:org.nuclos.common.dal.vo.EntityMetaDataVO.java
public void setVirtualentity(String virtualentity) { this.virtualentity = StringUtils.stripToNull(virtualentity); }
From source file:org.nuclos.common.dal.vo.EntityMetaDataVO.java
public void setIdFactory(String idFactory) { this.idFactory = StringUtils.stripToNull(idFactory); }