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

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

Introduction

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

Prototype

public static String trimToEmpty(final 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:com.esri.geoportal.harvester.csw.CswBrokerDefinitionAdaptor.java

/**
 * Creates instance of the adaptor./*from  ww w . j a v a2  s .  c  om*/
 *
 * @param def broker definition
 * @throws InvalidDefinitionException if invalid definition
 */
public CswBrokerDefinitionAdaptor(EntityDefinition def) throws InvalidDefinitionException {
    super(def);
    this.credAdaptor = new CredentialsDefinitionAdaptor(def);
    this.botsAdaptor = new BotsBrokerDefinitionAdaptor(def);
    if (StringUtils.trimToEmpty(def.getType()).isEmpty()) {
        def.setType(CswConnector.TYPE);
    } else if (!CswConnector.TYPE.equals(def.getType())) {
        throw new InvalidDefinitionException("Broker definition doesn't match");
    } else {
        try {
            hostUrl = new URL(get(P_HOST_URL));
        } catch (MalformedURLException ex) {
            throw new InvalidDefinitionException(String.format("Invalid %s: %s", P_HOST_URL, get(P_HOST_URL)),
                    ex);
        }
        ProfilesProvider of = new ProfilesProvider();
        IProfiles profiles = of.newProfiles();
        profile = profiles.getProfileById(this.get(P_PROFILE_ID));
        if (profile == null) {
            throw new InvalidDefinitionException(
                    String.format("Invalid %s: %s", P_PROFILE_ID, get(P_PROFILE_ID)));
        }
    }
}

From source file:net.lmxm.ute.configuration.ConfigurationInterpolator.java

/**
 * Generate property maps.// www  . ja  va2  s . c o  m
 * 
 * @param configuration the configuration
 * @return the map
 */
private static Map<PropertyType, String[]> generatePropertyMaps(final Configuration configuration) {
    final String prefix = "generatePropertyMaps() :";

    LOGGER.debug("{} entered, configuration={}", prefix, configuration);

    final List<String> propertyNames = new ArrayList<String>();
    final List<String> propertyValues = new ArrayList<String>();

    for (final Preference preference : configuration.getPreferences()) {
        propertyNames.add("${pref." + preference.getId() + "}");
        propertyValues.add(StringUtils.trimToEmpty(preference.getValue()));
    }

    for (final Property property : configuration.getProperties()) {
        propertyNames.add("${" + property.getId() + "}");
        propertyValues.add(StringUtils.trimToEmpty(property.getValue()));
    }

    for (final Entry<String, String> entry : System.getenv().entrySet()) {
        propertyNames.add("${env." + entry.getKey() + "}");
        propertyValues.add(StringUtils.trimToEmpty(entry.getValue()));
    }

    final Map<PropertyType, String[]> propertyMaps = new HashMap<PropertyType, String[]>();

    propertyMaps.put(PropertyType.NAME, propertyNames.toArray(new String[0]));
    propertyMaps.put(PropertyType.VALUE, propertyValues.toArray(new String[0]));

    LOGGER.debug("{} returning {}", prefix, propertyMaps);

    return propertyMaps;
}

From source file:com.omertron.subbabaapi.model.SubBabaContent.java

public void setDownload(String download) {
    this.download = StringUtils.trimToEmpty(download);
}

From source file:ke.co.tawi.babblesms.server.beans.contact.Contact.java

/**
 * @param statusUuid the statusUuid to set
 */
public void setStatusUuid(String statusUuid) {
    this.statusUuid = StringUtils.trimToEmpty(statusUuid);
}

From source file:ke.co.tawi.babblesms.server.beans.notification.Notification.java

/**
 * @param published - the published to set
 */
public void setPublished(String published) {
    this.published = StringUtils.trimToEmpty(published);
}

From source file:ke.co.tawi.babblesms.server.utils.StringUtil.java

/**
 * Converts a String {@link Map} into a String, for example for logging purposes
 * /*from  w ww.j  av a2s .  c  om*/
 * @param map
 * @return a String representation of a Map.
 */
public static String mapToString(Map<String, String> map) {
    StringBuilder stringBuilder = new StringBuilder();

    for (String key : map.keySet()) {
        if (stringBuilder.length() > 0) {
            stringBuilder.append("&");
        }
        String value = map.get(key);

        stringBuilder.append(StringUtils.trimToEmpty(key));
        stringBuilder.append("=");
        stringBuilder.append(StringUtils.trimToEmpty(value));
    }

    return stringBuilder.toString();
}

From source file:kenh.xscript.database.elements.Connection.java

public void process(@Attribute(ATTRIBUTE_VARIABLE) String var, @Attribute(ATTRIBUTE_SOURCE) DataSource source,
        @Attribute(ATTRIBUTE_AUTO_COMMIT) boolean autoCommit) throws UnsupportedScriptException {
    var = StringUtils.trimToEmpty(var);

    if (StringUtils.isBlank(var)) {
        UnsupportedScriptException ex = new UnsupportedScriptException(this, "Variable name is empty.");
        throw ex;
    }//from   w w  w. j a  v  a  2  s  .co  m

    if (source == null) {
        UnsupportedScriptException ex = new UnsupportedScriptException(this, "Data source is empty.");
        throw ex;
    }

    try {
        kenh.xscript.database.wrap.Connection conn = new kenh.xscript.database.wrap.Connection(
                source.getConnection());
        conn.setAutoCommit(autoCommit);
        this.saveVariable(var, conn, null);

    } catch (SQLException e) {
        throw new UnsupportedScriptException(this, e);
    }
}

From source file:ke.co.tawi.babblesms.server.beans.account.Account.java

/**
 * 
 * @param name 
 */
public void setName(String name) {
    this.name = StringUtils.trimToEmpty(name);
}

From source file:com.omertron.subbabaapi.model.SubBabaContent.java

public void setUploadDate(String uploadDate) {
    this.uploadDate = StringUtils.trimToEmpty(uploadDate);
}

From source file:com.github.benhaixiao.commons.serializer.test.EntLiveInfo.java

public void setLiveName(String liveName) {
    this.liveName = StringUtils.trimToEmpty(liveName);
}