List of usage examples for org.apache.commons.lang3 StringUtils trimToNull
public static String trimToNull(final String str)
Removes control characters (char <= 32) from both ends of this String returning null if the String is empty ("") after the trim or if it is null .
From source file:org.gbif.ipt.model.AgentBase.java
/** * @param primaryContactPhone the primaryContactPhone to set *///from w ww .j a v a 2s. c o m public void setPrimaryContactPhone(@Nullable String primaryContactPhone) { this.primaryContactPhone = StringUtils.trimToNull(primaryContactPhone); }
From source file:org.gbif.ipt.model.AgentBase.java
/** * @param primaryContactType the primaryContactType to set *//* w ww.j a va 2s . c o m*/ public void setPrimaryContactType(@Nullable String primaryContactType) { this.primaryContactType = StringUtils.trimToNull(primaryContactType); }
From source file:org.gbif.ipt.model.Ipt.java
/** * @param description the description to set *//*from ww w . j a va 2s.com*/ public void setDescription(@Nullable String description) { this.description = StringUtils.trimToNull(description); }
From source file:org.gbif.ipt.model.Ipt.java
/** * @param language the language to set */ public void setLanguage(@Nullable String language) { this.language = StringUtils.trimToNull(language); }
From source file:org.gbif.ipt.model.Ipt.java
/** * @param logoUrl the logoUrl to set */ public void setLogoUrl(@Nullable String logoUrl) { this.logoUrl = StringUtils.trimToNull(logoUrl); }
From source file:org.gbif.ipt.model.Organisation.java
/** * @param alias the alias to set */ public void setAlias(@Nullable String alias) { this.alias = StringUtils.trimToNull(alias); }
From source file:org.gbif.ipt.model.Organisation.java
/** * @param nodeContactEmail the nodeContactEmail to set *//*ww w .j a va2s .co m*/ public void setNodeContactEmail(@Nullable String nodeContactEmail) { this.nodeContactEmail = StringUtils.trimToNull(nodeContactEmail); }
From source file:org.gbif.ipt.model.Organisation.java
/** * @param nodeKey the nodeKey to set */ public void setNodeKey(@Nullable String nodeKey) { this.nodeKey = StringUtils.trimToNull(nodeKey); }
From source file:org.gbif.ipt.model.Organisation.java
/** * @param nodeName the nodeName to set */ public void setNodeName(@Nullable String nodeName) { this.nodeName = StringUtils.trimToNull(nodeName); }
From source file:org.gbif.ipt.model.Resource.java
/** * Construct the resource citation from various parts for the version specified. * </br>// w ww. j ava 2 s. c o m * The citation format is: * Creators (PublicationYear): Title. Version. Publisher. ResourceType. Identifier * * @param version resource version to use in citation * @param homepage homepage URI * * @return generated resource citation string */ public String generateResourceCitation(@NotNull BigDecimal version, @NotNull URI homepage) { StringBuilder sb = new StringBuilder(); // make list of verified authors (having first and last name) List<String> verifiedAuthorList = Lists.newArrayList(); for (Agent creator : getEml().getCreators()) { String authorName = getAuthorName(creator); if (authorName != null) { verifiedAuthorList.add(authorName); } } // add comma separated authors Iterator<String> iter = verifiedAuthorList.iterator(); while (iter.hasNext()) { sb.append(iter.next()); if (iter.hasNext()) { sb.append(", "); } } // add year resource was first published (captured in EML dateStamp) int publicationYear = getPublicationYear(getEml().getDateStamp()); if (publicationYear > 0) { sb.append(" ("); sb.append(publicationYear); sb.append("): "); } // add title sb.append((StringUtils.trimToNull(getTitle()) == null) ? getShortname() : StringUtils.trim(getTitle())); sb.append(". "); // add version sb.append("v"); sb.append(version.toPlainString()); sb.append(". "); // add publisher String publisher = (getOrganisation() == null) ? null : StringUtils.trimToNull(getOrganisation().getName()); if (publisher != null) { sb.append(publisher); sb.append(". "); } // add ResourceTypeGeneral/ResourceType, e.g. Dataset/Occurrence, Dataset/Checklist sb.append("Dataset"); if (getCoreType() != null) { sb.append("/"); sb.append(StringUtils.capitalize(getCoreType().toLowerCase())); } sb.append(". "); // add DOI as the identifier. DataCite recommends using linkable, permanent URL if (getDoi() != null) { sb.append(getDoi().getUrl()); } // otherwise add the citation identifier instead else if (getEml().getCitation() != null && !Strings.isNullOrEmpty(getEml().getCitation().getIdentifier())) { sb.append(getEml().getCitation().getIdentifier()); } // otherwise use its IPT homepage as the identifier else { sb.append(homepage.toString()); } return sb.toString(); }