Example usage for org.springframework.util StringUtils trimTrailingWhitespace

List of usage examples for org.springframework.util StringUtils trimTrailingWhitespace

Introduction

In this page you can find the example usage for org.springframework.util StringUtils trimTrailingWhitespace.

Prototype

public static String trimTrailingWhitespace(String str) 

Source Link

Document

Trim trailing whitespace from the given String .

Usage

From source file:info.naiv.lab.java.tool.sqlite.exporter.component.ValueHandlerImpl.java

/**
 *
 * @param field/* w  w  w  . j a  v  a 2s.  c o m*/
 * @param rowSet
 * @return
 * @throws SQLException
 */
@Override
public Object handleValue(Field field, ResultSet rowSet) throws SQLException {
    String name = field.getOriginalName();
    switch (field.getTypeInfo()) {
    case CHAR:
    case NCHAR:
        return StringUtils.trimTrailingWhitespace(rowSet.getString(name));
    case DATE:
        return Objects.toString(rowSet.getDate(name), null);
    case TIME:
        return Objects.toString(rowSet.getTime(name), null);
    case TIMESTAMP:
        return Objects.toString(rowSet.getTimestamp(name), null);
    default:
        return rowSet.getObject(name);
    }
}

From source file:org.alfresco.config.AlfrescoPropertiesPersister.java

private void strip(Properties props) {
    for (Enumeration<Object> keys = props.keys(); keys.hasMoreElements();) {
        String key = (String) keys.nextElement();
        String val = StringUtils.trimTrailingWhitespace(props.getProperty(key));
        if (logger.isTraceEnabled()) {
            logger.trace("Trimmed trailing whitespace for property " + key + " = " + val);
        }//from www . ja  v  a 2  s  . com
        props.setProperty(key, val);
    }
}

From source file:com.asual.summer.core.faces.FacesResponseWriter.java

private void printTextIfNecessary(boolean end) throws IOException {
    String textStr = textWriter.toString();
    if (StringUtils.hasText(textStr)) {
        String name = nodeDepth[depth];
        textStr = textStr.replaceAll("\t", INDENT);
        if (ComponentUtils.isStyleOrScript(name)) {
            textStr = Pattern.compile("^\\s{" + calculateIndent(textStr) + "}", Pattern.MULTILINE)
                    .matcher(textStr).replaceAll(getIndent(depth)).trim();
        }/*from   w w  w.j  a  v  a  2 s  . co m*/
        if (block.contains(name) && !pre.contains(name)) {
            Matcher m = Pattern.compile("^( *\\n)+.*", Pattern.DOTALL).matcher(textStr);
            if (m.matches()) {
                textStr = m.replaceFirst("$1") + getIndent(depth) + StringUtils.trimLeadingWhitespace(textStr);
            } else if (start) {
                textStr = "\n" + getIndent(depth) + StringUtils.trimLeadingWhitespace(textStr);
            }
            m = Pattern.compile(".*(\\n)+ *$", Pattern.DOTALL).matcher(textStr);
            if (m.matches()) {
                textStr = StringUtils.trimTrailingWhitespace(textStr) + m.replaceFirst("$1") + getIndent(depth);
            }
        }
        if (end) {
            textStr = StringUtils.trimTrailingWhitespace(textStr);
        }
        writer.write(textStr);
        textWriter.getBuffer().setLength(0);
        start = false;

        nodeDepth[depth + 1] = null;
        for (int i = 0; i < depth + 1; i++) {
            nodeDepthContent[i] = true;
        }
    }
}

From source file:se.alingsas.alfresco.repo.utils.byggreda.ByggRedaUtil.java

/**
 * Add a single property to a property map
 * /*  w  w w. j  a  v  a  2s  .  co m*/
 * @param properties
 * @param key
 * @param value
 */
private void addProperty(final Map<QName, Serializable> properties, final QName key, Serializable value) {
    // if no text, just exit
    if (value == null) {
        return;
    }

    // if no text, just exit
    if (!StringUtils.hasText(value.toString())) {
        return;
    }

    // trim all trailing spaces for strings
    if (value instanceof String) {
        value = StringUtils.trimTrailingWhitespace(value.toString());
    }

    properties.put(key, value);
}

From source file:org.geoserver.security.iride.IrideGeoServerUser.java

@Override
public String toString() {
    final StringBuilder sb = new StringBuilder(StringUtils.trimTrailingWhitespace(super.toString()));
    sb.append("; ").append("User Properties: ").append(this.getProperties());

    return sb.toString();
}

From source file:org.kuali.kfs.sys.batch.AbstractFlatFilePropertySpecificationBase.java

/**
 * Sets the property on the business object
 * @param value the substring of the parsed line to set
 * @param businessObject the business object to set the parsed line on
 * @param lineNumber the parsed line number
 *//* www  . j a v a2  s . c  om*/

@Override
public void setProperty(String value, Object businessObject, int lineNumber) {
    if (leftTrim) {
        value = StringUtils.trimLeadingWhitespace(value);
    }

    if (rightTrim) {
        value = StringUtils.trimTrailingWhitespace(value);
    }
    try {
        PropertyUtils.setProperty(businessObject, propertyName, getFormattedObject(value, businessObject));
    } catch (Exception e) {
        throw new RuntimeException("Exception occurred on line " + lineNumber + " while setting value " + value
                + " for property " + propertyName + ".", e);
    }
}