List of usage examples for org.apache.commons.lang3 StringUtils trimToEmpty
public static String trimToEmpty(final String str)
Removes control characters (char <= 32) from both ends of this String returning an empty String ("") if the String is empty ("") after the trim or if it is null .
From source file:org.hspconsortium.cwf.api.security.BasicAuthInterceptor.java
public BasicAuthInterceptor(String id, BasicAuthConfigurator config) { super(id, "Basic"); String username = StringUtils.trimToNull(config.getUsername()); String password = StringUtils.trimToEmpty(config.getPassword()); this.credentials = username == null ? null : encode(username, password); }
From source file:org.jboss.arquillian.qunit.junit.model.QUnitTestImpl.java
public String getDescriptionName() { return (new StringBuilder()).append(StringUtils.trimToEmpty(this.moduleName)) .append(QUnitConstants.DELIMITER).append(StringUtils.trimToEmpty(this.name)).toString(); }
From source file:org.jnap.core.assets.HandlebarsAssetsHandler.java
@Override public void handle() { final Handlebars handlebars = new Handlebars(); try {/*from w ww . jav a2 s.c o m*/ Resource[] resources = this.resourceResolver.getResources(source); Resource destRes = new ServletContextResource(servletContext, destination); resetResource(destRes); BufferedWriter writer = new BufferedWriter( new FileWriterWithEncoding(destRes.getFile(), this.encoding, true)); writer.write("(function() {"); writer.write(IOUtils.LINE_SEPARATOR); writer.write("var template = Handlebars.template, "); writer.write("templates = Handlebars.templates = Handlebars.templates || {};"); writer.write(IOUtils.LINE_SEPARATOR); final Set<String> templateNames = new TreeSet<String>(); for (Resource resource : resources) { Template template = handlebars .compile(StringUtils.trimToEmpty(IOUtils.toString(resource.getInputStream()))); final String templateName = FilenameUtils.getBaseName(resource.getFilename()); templateNames.add(templateName); writer.write("templates[\"" + templateName + "\"] = "); writer.write("template("); writer.write(template.toJavaScript()); writer.write(");"); writer.write(IOUtils.LINE_SEPARATOR); } writer.write(IOUtils.LINE_SEPARATOR); if (this.bindToBackboneView) { writer.write("$(function() {"); writer.write(IOUtils.LINE_SEPARATOR); for (String templateName : templateNames) { writer.write(format("if (window[\"{0}\"]) {0}.prototype.template " + "= templates[\"{0}\"];", templateName)); writer.write(IOUtils.LINE_SEPARATOR); } writer.write("});"); writer.write(IOUtils.LINE_SEPARATOR); } writer.write("})();"); IOUtils.closeQuietly(writer); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.kalypso.model.wspm.pdb.db.version.UpdateScript.java
public String[] loadSQL() throws IOException { final Bundle bundle = Platform.getBundle(m_bundleID); final URL entry = bundle.getEntry(m_location); final String rawSQL = IOUtils.toString(entry, Charsets.UTF_8.name()); final Collection<String> noComments = new ArrayList<>(); final String[] lines = StringUtils.split(rawSQL, "\n\r"); //$NON-NLS-1$ for (final String line : lines) { final String trim = StringUtils.trimToEmpty(line); if (!trim.isEmpty() && !trim.startsWith("--")) //$NON-NLS-1$ {//from www .j a v a 2 s .c om noComments.add(trim); } } final String result = StringUtils.join(noComments, "\n"); //$NON-NLS-1$ return StringUtils.split(result, ';'); //$NON-NLS-1$ }
From source file:org.kalypsodeegree_impl.graphics.sld.SLDFactory.java
private static SortedMap<Double, ColorMapEntry> createColorMap(final Element colorMapElement) { final SortedMap<Double, ColorMapEntry> colorMap = new TreeMap<>(); if (colorMapElement == null) return null; final NodeList entryNodes = colorMapElement.getChildNodes(); for (int i = 0; i < entryNodes.getLength(); i++) { final Node entryNode = entryNodes.item(i); final String nodeName = entryNode.getNodeName(); final String namespaceUri = entryNode.getNamespaceURI(); if (entryNode instanceof Element && NS.SLD.equals(namespaceUri) && "ColorMapEntry".equals(nodeName)) //$NON-NLS-1$ {/*from w w w. j a v a2 s. c o m*/ final Element entryElement = (Element) entryNode; final String colorAttribute = entryElement.getAttribute("color"); //$NON-NLS-1$ final String opacityAttribite = entryElement.getAttribute("opacity"); //$NON-NLS-1$ final String quantityAttribute = entryElement.getAttribute("quantity"); //$NON-NLS-1$ final String labelAttribute = entryElement.getAttribute("label"); //$NON-NLS-1$ final Color color = Color.decode(colorAttribute); final Double opacity = NumberUtils.toDouble(opacityAttribite, 1.0); final Double quantity = NumberUtils.toDouble(quantityAttribute, Double.NaN); final String label = StringUtils.trimToEmpty(labelAttribute); if (Double.isNaN(quantity)) System.err.println( String.format("SLD-Parser: skipping quantity '%s', not a number.", quantityAttribute)); else { final ColorMapEntry colorMapEntryObject = new ColorMapEntry_Impl(color, opacity, quantity, label); colorMap.put(quantity, colorMapEntryObject); } } } return colorMap; }
From source file:org.kisoonlineapp.uc.view.TeilnehmerFilterFormView.java
public String formatTeilnehmerFilterForm(TeilnehmerFilterForm vff) { final StringBuilder sb = new StringBuilder(); if (vff != null) { append(sb, "Seite " + StringUtils.trimToEmpty(String.valueOf(vff.getPage() + 1))); if (vff.getExample() != null) { final Teilnehmer example = vff.getExample(); append(sb, example.getVorname()); append(sb, example.getNachname()); append(sb, example.getEmail()); append(sb, example.getTelefon()); }/*w ww. jav a2s .co m*/ } return sb.toString(); }
From source file:org.kisoonlineapp.uc.view.TeilnehmerFilterFormView.java
void append(StringBuilder sb, String s) { final String sTrimmed = StringUtils.trimToEmpty(s); if (sTrimmed.length() > 0) { if (sb.length() > 0) { sb.append(", "); }//from w ww . ja va 2 s .c om sb.append(sTrimmed); } }
From source file:org.kisoonlineapp.uc.view.VeranstalterFilterFormView.java
public String formatVeranstalterFilterForm(VeranstalterFilterForm vff) { final StringBuilder sb = new StringBuilder(); if (vff != null) { append(sb, "Seite " + StringUtils.trimToEmpty(String.valueOf(vff.getPage() + 1))); if (vff.getExample() != null) { final Veranstalter example = vff.getExample(); append(sb, example.getCode()); append(sb, example.getVorname()); append(sb, example.getNachname()); append(sb, example.getOrganisation()); }/*from w ww. ja v a 2 s. c om*/ } return sb.toString(); }
From source file:org.kisoonlineapp.uc.view.VeranstaltungFilterFormView.java
public String formatVeranstaltungFilterForm(VeranstaltungFilterForm vff) { final StringBuilder sb = new StringBuilder(); final StringBuilderUtil sbu = new StringBuilderUtil(); if (vff != null) { sbu.append(sb, "Seite " + StringUtils.trimToEmpty(String.valueOf(vff.getPage() + 1))); if (vff.getExample() != null) { final Veranstaltung example = vff.getExample(); sbu.append(sb, example.getCode()).append(sb, example.getName()) .append(sb, example.getBeschreibung()).append(sb, example.getGemeinde().getName()); }// ww w .j a v a 2 s . co m } return sb.toString(); }
From source file:org.kuali.coeus.common.impl.org.OrganizationRepositoryServiceImpl.java
@Override public String getCognizantFedAgency(OrganizationContract organization) { if (organization == null) { throw new IllegalArgumentException("organization is null"); }/*from w w w . j a va2 s. c o m*/ final StringBuilder fedAgency = new StringBuilder(); if (organization.getCognizantAuditor() != null) { RolodexContract rolodex = rolodexService.getRolodex(organization.getCognizantAuditor()); if (rolodex != null) { fedAgency.append(rolodex.getOrganization()); fedAgency.append(", "); fedAgency.append(StringUtils.trimToEmpty(rolodex.getFirstName())); fedAgency.append(" "); fedAgency.append(StringUtils.trimToEmpty(rolodex.getLastName())); fedAgency.append(" "); if (rolodex.getPhoneNumber() != null) { if (rolodex.getPhoneNumber().length() < 180) { fedAgency.append(rolodex.getPhoneNumber()); } else { fedAgency.append(rolodex.getPhoneNumber().substring(0, 180)); } } } } return fedAgency.toString(); }