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

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

Introduction

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

Prototype

public static String trim(final String str) 

Source Link

Document

Removes control characters (char <= 32) from both ends of this String, handling null by returning null .

The String is trimmed using String#trim() .

Usage

From source file:com.callidusrobotics.object.ItemData.java

public String getId() {
    return StringUtils.trim(StringUtils.lowerCase(identifier, Locale.ENGLISH));
}

From source file:io.wcm.devops.conga.plugins.sling.fileheader.OsgiConfigFileHeader.java

@Override
protected String sanitizeComment(String line) {
    if (StringUtils.equals(line, "") || StringUtils.contains(line, "*****")) {
        return null;
    }//w w w . j ava 2 s  .  c om
    return StringUtils.trim(line);
}

From source file:com.ottogroup.bi.spqr.pipeline.component.source.RandomNumberTestSource.java

/**
 * @see com.ottogroup.bi.spqr.pipeline.component.MicroPipelineComponent#initialize(java.util.Properties)
 *///w ww  .  ja  v a2s . c o  m
public void initialize(Properties properties)
        throws RequiredInputMissingException, ComponentInitializationFailedException {
    this.maxNumGenerated = Integer.parseInt(StringUtils.trim(properties.getProperty(CFG_MAX_NUM_GENERATED)));
    try {
        this.seed = Long.parseLong(StringUtils.trim(properties.getProperty(CFG_SEED)));
    } catch (Exception e) {
        //
    }
    this.content = (properties.containsKey(CFG_CONTENT) ? properties.getProperty(CFG_CONTENT).getBytes()
            : new byte[0]);

    this.running = true;

}

From source file:de.micromata.genome.gwiki.controls.GWikiSearchBoxActionBean.java

public Object onLinkAutocomplete() {
    String q = StringUtils.trim(wikiContext.getRequestParameter("q"));
    String pageType = wikiContext.getRequestParameter("pageType");
    String queryexpr = SearchUtils.createLinkExpression(q, false, pageType);
    JsonArray jsonarr = JsonBuilder.array();
    renderSearchOps(jsonarr, q);//from   ww w . j  a  v  a  2 s.c  om

    SearchQuery query = new SearchQuery(queryexpr, wikiContext.getWikiWeb());

    query.setMaxCount(1000);
    query.setWithSampleText(false);

    QueryResult qr = filter(query);

    StringBuilder sb = new StringBuilder();
    // int size = qr.getResults().size();

    for (SearchResult sr : qr.getResults()) {
        if (sr.getElementInfo().isViewable() == false) {
            continue;
        }
        String t = wikiContext.getTranslatedProp(WebUtils.escapeHtml(sr.getElementInfo().getTitle())) + "<br/>("
                + WebUtils.escapeHtml(sr.getPageId()) + ")";
        jsonarr.add(JsonBuilder.map("key", sr.getPageId(), "label", t));
    }
    String ret = jsonarr.toString();
    wikiContext.getResponse().setContentType("application/json");
    wikiContext.append(ret);
    wikiContext.flush();
    return noForward();
}

From source file:com.ottogroup.bi.streaming.source.kafka.KafkaConsumerBuilder.java

/**
 * Adds a new key/value pair to properties
 * @param key//from w w  w . j a v a  2  s  .c o  m
 * @param value
 * @return
 */
public KafkaConsumerBuilder<T> addProperty(final String key, final String value) {
    if (StringUtils.isNotBlank(key) && value != null)
        this.properties.put(StringUtils.lowerCase(StringUtils.trim(key)), value);
    return this;
}

From source file:it.attocchi.web.config.SoftwareProperties.java

/**
 * Inizializza i Valori della BL e della PersistenceUnit
 *//*from  ww w .  jav a  2s. c om*/
public static void init(ServletContext servletContext) {

    if (jpaDbProps == null) {

        InputStream fileProperties = servletContext.getResourceAsStream(WEB_INF_CONFIG_PROPERTIES);
        if (fileProperties != null) {

            logger.warn("Loading " + WEB_INF_CONFIG_PROPERTIES);
            properties = PropertiesUtils.getProperties(fileProperties);

            if (properties != null) {

                // RapportoServerBL.connString =
                // properties.getProperty("connString");
                // RapportoServerBL.driverClass =
                // properties.getProperty("driverClass");
                // RapportoServerBL.userName =
                // properties.getProperty("userName");
                // RapportoServerBL.password =
                // properties.getProperty("password");

                connString = StringUtils.trim(properties.getProperty(PROPERTY_connString));
                driverClass = StringUtils.trim(properties.getProperty(PROPERTY_driverClass));
                userName = StringUtils.trim(properties.getProperty(PROPERTY_userName));
                password = StringUtils.trim(properties.getProperty(PROPERTY_password));

                jpaDbProps = new HashMap<String, String>();

                jpaDbProps.put("javax.persistence.jdbc.url", connString);
                jpaDbProps.put("javax.persistence.jdbc.driver", driverClass);
                jpaDbProps.put("javax.persistence.jdbc.user", userName);
                jpaDbProps.put("javax.persistence.jdbc.password", password);

                /*
                 * Se uno dei Parametri da File e' nullo annullo tutti gli
                 * oggetti
                 */
                if (StringUtils.isEmpty(connString) || StringUtils.isEmpty(driverClass)) {
                    properties = null;
                    jpaDbProps = null;

                    logger.warn("SoftwareConfig loaded but Empty Database Configuration");
                }
            }
        }
    } else {
        logger.warn("SoftwareConfig already inizialized");
    }
}

From source file:de.micromata.genome.chronos.util.ClassJobDefinition.java

/**
 * Instantiates a new class job definition.
 *
 * @param classNameToStart the class name to start
 *///from w w  w.  j av a2 s  .  c  o m
@SuppressWarnings("unchecked")
public ClassJobDefinition(final String classNameToStart) {
    try {
        classToStart = (Class<? extends FutureJob>) Class.forName(StringUtils.trim(classNameToStart));
    } catch (Exception ex) {
        throw new RuntimeException("Failure loading class in ClassJobDefinition: " + ex.getMessage(), ex);
    }
}

From source file:com.ifunshow.dbc.util.DBHelper.java

public static String decideDriverString(String dbType) {
    String driver = null;/*w ww  . jav a 2 s  .com*/
    if ("oracle".equalsIgnoreCase(StringUtils.trim(dbType))) {
        driver = "oracle.jdbc.OracleDriver";
    } else if ("teradata".equalsIgnoreCase(StringUtils.trim(dbType))) {
        driver = "com.ncr.teradata.TeraDriver";
    } else if ("db2".equalsIgnoreCase(StringUtils.trim(dbType))) {
        driver = "com.ibm.db2.jcc.DB2Driver";
    } else if ("mysql".equalsIgnoreCase(StringUtils.trim(dbType))) {
        driver = "com.mysql.jdbc.Driver";
    }

    return driver;
}

From source file:br.com.binarti.simplesearchexpr.builders.mongodb.SimpleSearchMongoDBBuilder.java

@Override
public DBObject build(SimpleSearchExpression searchExpression) {
    BasicDBObject root = new BasicDBObject();
    if (searchExpression.getOperations().isEmpty()) {
        return root;
    }//  w  ww . j  a  v  a  2 s  .  c  o  m
    for (SimpleSearchRelationalOperation op : searchExpression.getOperations()) {
        final String field = op.getField().getFieldExpr();
        final Object value = op.getValue();
        switch (op.getOperator()) {
        case EQUALS:
            root.put(field, value);
            break;
        case LIKE:
            root.put(field,
                    new BasicDBObject("$regex", StringUtils.trim((String) value)).append("$options", "i"));
            break;
        case INTERVAL:
            Iterator<Object> it = op.getValueAsCollection().iterator();
            Object value1 = it.next();
            Object value2;
            if (it.hasNext()) {
                value2 = it.next();
            } else {
                value2 = value1;
            }
            root.append(field, new BasicDBObject("$gte", value1).append("$lte", value2));
            break;
        case LIST:
            root.append(field, new BasicDBObject("$in", mongoList(op.getValueAsCollection())));
            break;
        default:
            throw new SimpleSearchExpressionException("Operator " + op.getOperator() + " not supported");
        }
    }
    return root;
}

From source file:com.norconex.commons.lang.time.YearMonthDayInterval.java

/**
 * Constructs a YearMonthDayInterval out of a string.  The recommended
 * string format is <code>yyyy-MM-dd - yyyy-MM-dd</code>, but any 
 * characters in between the start and end are accepted as long as there 
 * is a space after the start YearMontDay and before the end YearMonthDay.
 * @param interval the interval to parse
 *///from w ww . ja  v a2 s.c  om
public YearMonthDayInterval(String interval) {
    String trimmed = StringUtils.trim(interval);
    String startStr = StringUtils.substringBefore(trimmed, " ");
    String endStr = StringUtils.substringAfterLast(trimmed, " ");
    if (StringUtils.isBlank(startStr) || StringUtils.isBlank(endStr)) {
        throw new IllegalArgumentException("String YearMonthDay interval cannot be null or empty.");
    }
    this.start = new YearMonthDay(startStr);
    this.end = new YearMonthDay(endStr);
}