Example usage for org.apache.commons.lang StringUtils trimToEmpty

List of usage examples for org.apache.commons.lang StringUtils trimToEmpty

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils trimToEmpty.

Prototype

public static String trimToEmpty(String str) 

Source Link

Document

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.

Usage

From source file:de.hybris.platform.secureportaladdon.cockpit.label.CMSSiteLabelProvider.java

@Override
protected String getItemLabel(final CMSSiteModel cmsSite, final String languageIso) {
    return StringUtils.trimToEmpty(cmsSite.getName(LocaleUtils.toLocale(languageIso)));
}

From source file:de.fhg.iais.asc.sipmaker.SipMakerDynamicClass.java

public static String fullClassName(final String packageName, final String className) {
    StringBuilder fullName = new StringBuilder(120); // pre-set of guessed size reduces expandCapacity() and increases performance

    final String trimedPackageName = StringUtils.trimToNull(packageName);
    if (trimedPackageName != null) {
        fullName.append(trimedPackageName);
        if (!trimedPackageName.endsWith(".")) {
            fullName.append(".");
        }//from  www .ja va2s  . co m
    }
    fullName.append(StringUtils.trimToEmpty(className));

    return fullName.toString();
}

From source file:com.haulmont.cuba.core.sys.persistence.DbmsType.java

public static String getVersion(String storeName) {
    String propName = "cuba.dbmsVersion";
    if (!Stores.isMain(storeName))
        propName = propName + "_" + storeName;

    return StringUtils.trimToEmpty(AppContext.getProperty(propName));
}

From source file:com.stepstone.sonar.plugin.coldfusion.cflint.xml.TagAttribute.java

protected Optional<String> getAttributeValue(String name, XMLStreamReader stream) {

    for (int i = 0; i < stream.getAttributeCount(); i++) {

        if (name.equalsIgnoreCase(stream.getAttributeLocalName(i))) {
            return Optional.of(StringUtils.trimToEmpty(stream.getAttributeValue(i)));
        }/*from   w  ww  .  j  a  va  2 s.c  o  m*/
    }

    return Optional.absent();
}

From source file:dmh.swing.huxley.action.InsertHeadingAction.java

@Override
public int manipulateText(Document document, int start, int end) {
    try {/*from w  w w  .  j  av a  2  s .  c om*/
        final int offset = start;
        final int length = end - start;

        // Extract the selected text.
        String title = StringUtils.trimToEmpty(document.getText(offset, length));
        document.remove(offset, length);

        // Add the header.
        String bar = StringUtils.repeat(token, 40);
        String insertText = "\n " + title + "\n" + bar + "\n";
        document.insertString(offset, insertText, null);

        // Return the caret position.
        return start + ("".equals(title) ? 2 : insertText.length());
    } catch (BadLocationException e) {
        // This indicates a programming error.
        throw new RuntimeException(e);
    }
}

From source file:de.hybris.platform.acceleratorfacades.customerlocation.impl.DefaultCustomerLocationFacade.java

@Override
public void setUserLocationData(final UserLocationData userLocationData) {
    userLocationData.setSearchTerm(StringUtils.trimToEmpty(userLocationData.getSearchTerm()));
    getCustomerLocationService().setUserLocation(userLocationData);
}

From source file:com.alibaba.otter.manager.biz.utils.RegexUtils.java

public static String findFirst(String originalStr, String regex) {
    if (StringUtils.isBlank(originalStr) || StringUtils.isBlank(regex)) {
        return StringUtils.EMPTY;
    }/*from  w  w  w  . j  a v a 2  s.co  m*/

    PatternMatcher matcher = new Perl5Matcher();
    if (matcher.contains(originalStr, patterns.get(regex))) {
        return StringUtils.trimToEmpty(matcher.getMatch().group(0));
    }
    return StringUtils.EMPTY;
}

From source file:dmh.swing.huxley.action.WrapTextAction.java

@Override
public int manipulateText(Document document, int start, int end) {
    try {/*  w ww.  ja  v  a 2 s .  co  m*/
        final int offset = start;
        final int length = end - start;

        // Extract the selected text.
        String selectedText = StringUtils.trimToEmpty(document.getText(offset, length));
        document.remove(offset, length);

        // Re-insert the text, wrapped in tokens.
        String insertText = prefixToken + selectedText + suffixToken;
        document.insertString(offset, insertText, null);

        // Return the caret position.
        return start + ("".equals(selectedText) ? 1 : insertText.length());
    } catch (BadLocationException e) {
        // This indicates a programming error.
        throw new RuntimeException(e);
    }
}

From source file:com.alibaba.cobar.client.router.rules.AbstractEntityAttributeRule.java

public AbstractEntityAttributeRule(String typePattern, String action, String attributePattern) {
    super(typePattern, action);
    Validate.notEmpty(StringUtils.trimToEmpty(attributePattern));

    this.attributePattern = attributePattern;
}

From source file:nc.noumea.mairie.appock.core.utility.TelUtil.java

/**
 * Formatte un numro de tlphone, en se basant sur la librairie google libPhoneNumber. Si le numro n'est pas reconnu, le numro est retourn tel quel
 * sans les blancs devant/derrire.//from w w w .  j  a  v a  2 s  .  c o m
 * 
 * @param tel numro de tlphone  traiter
 * @return "" si le tlphone en entre est "vide" (null ou blanc)
 */
public static String formatteTel(String tel) {
    if (StringUtils.isBlank(tel)) {
        return "";
    }
    try {
        PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
        PhoneNumber phoneNumber = phoneUtil.parse(tel, FORMAT_PHONE_NC);
        return phoneUtil.format(phoneNumber, PhoneNumberFormat.NATIONAL);
    } catch (Exception e) {
        // en cas d'erreur, on se contente de retourner le tel pass en entre, sans les blancs devant/derrire
        return StringUtils.trimToEmpty(tel);
    }
}