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

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

Introduction

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

Prototype

public static String trim(String str) 

Source Link

Document

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

Usage

From source file:info.magnolia.rendering.template.configured.ConfiguredInheritance.java

@Override
public Boolean isInheritsProperties() {
    return isEnabled() != null && isEnabled()
            && StringUtils.equalsIgnoreCase(StringUtils.trim(properties), PROPERTIES_ALL);
}

From source file:fitnesse.responders.editing.SymbolicLinkResponder.java

private void addSymbolicLink(Request request, WikiPage page) throws Exception {
    String linkName = StringUtils.trim(request.getInput("linkName"));
    String linkPath = StringUtils.trim(request.getInput("linkPath"));

    PageData data = page.getData();//from   w  ww . jav a 2  s  .  c  om
    WikiPageProperty properties = data.getProperties();
    WikiPageProperty symLinks = getSymLinkProperty(properties);
    if (isValidLinkPathName(linkPath) && isValidWikiPageName(linkName, symLinks)) {
        symLinks.set(linkName, linkPath);
        page.commit(data);
        setRedirect(resource);
    }
}

From source file:info.magnolia.module.delta.SetPropertyTask.java

/**
 * {@inheritDoc}/*  w ww . j av  a 2 s  . co  m*/
 */
@Override
protected void doExecute(InstallContext installContext) throws RepositoryException, TaskExecutionException {

    HierarchyManager hm = installContext.getHierarchyManager(workspaceName);

    Content node = hm.getContent(nodePath);

    NodeData property = NodeDataUtil.getOrCreate(node, propertyName);

    String actualValue = property.getString();
    if (!StringUtils.equals(newValue, StringUtils.trim(actualValue))) {
        property.setValue(newValue);
    }
}

From source file:com.github.rnewson.couchdb.lucene.couchdb.View.java

private String trim(final String fun) {
    String result = fun;
    result = StringUtils.trim(result);
    result = StringUtils.removeStart(result, "\"");
    result = StringUtils.removeEnd(result, "\"");
    return result;
}

From source file:com.hangum.tadpole.engine.sql.util.SQLUtil.java

/**
 * ?    ?./*  w w  w  . j a v a 2  s. c  o m*/
 *  ? ?? ... -- / ** * / / * * /
 * 
 * @param strSQL
 * @return
 */
public static boolean isNotAllowed(String strSQL) {
    boolean isRet = false;
    String cmpSql = StringUtils.trim(removeComment(strSQL));

    for (String strNAllSQL : NOT_ALLOWED_SQL) {
        if (StringUtils.startsWithIgnoreCase(cmpSql, strNAllSQL)) {
            return true;
        }
    }

    return isRet;
}

From source file:com.alibaba.otter.manager.biz.monitor.impl.ProcessTimeoutRuleMonitor.java

private String checkTimeout(AlarmRule rule, Map<Long, Long> processTime) {
    if (!inPeriod(rule)) {
        return StringUtils.EMPTY;
    }/*from   w  ww .ja  va  2  s  .  c o  m*/

    String matchValue = rule.getMatchValue();
    matchValue = StringUtils.substringBeforeLast(matchValue, "@");
    Long maxSpentTime = Long.parseLong(StringUtils.trim(matchValue));
    List<Long> timeoutProcessIds = new LinkedList<Long>();
    Collections.sort(timeoutProcessIds);
    long maxSpent = 0;
    for (Entry<Long, Long> entry : processTime.entrySet()) {
        // maxSpentTime processTimevalue
        if (entry.getValue() >= (maxSpentTime * 1000)) {
            timeoutProcessIds.add(entry.getKey());
            maxSpent = maxSpent > entry.getValue() ? maxSpent : entry.getValue();
        }
    }

    if (CollectionUtils.isEmpty(timeoutProcessIds)) {
        return StringUtils.EMPTY;
    }

    String processIds = StringUtils.join(timeoutProcessIds, ",");
    String message = String.format(TIME_OUT_MESSAGE, rule.getPipelineId(), processIds, (maxSpent / 1000));
    sendAlarm(rule, message);
    return message;
}

From source file:com.adobe.acs.tools.csv.impl.Column.java

private <T> T toObjectType(String data, Class<T> klass) {
    data = StringUtils.trim(data);

    if (Double.class.equals(klass)) {
        try {// w ww . j av a2 s .c  o  m
            return klass.cast(Double.parseDouble(data));
        } catch (NumberFormatException ex) {
            return null;
        }
    } else if (Long.class.equals(klass)) {
        try {
            return klass.cast(Long.parseLong(data));
        } catch (NumberFormatException ex) {
            return null;
        }
    } else if (Integer.class.equals(klass)) {
        try {
            return klass.cast(Long.parseLong(data));
        } catch (NumberFormatException ex) {
            return null;
        }
    } else if (StringUtils.equalsIgnoreCase("true", data)) {
        return klass.cast(Boolean.TRUE);
    } else if (StringUtils.equalsIgnoreCase("false", data)) {
        return klass.cast(Boolean.FALSE);
    } else if ((Date.class.equals(Date.class) || Calendar.class.equals(Calendar.class))
            && ISO_DATE_PATTERN.matcher(data).matches()) {
        return klass.cast(ISODateTimeFormat.dateTimeParser().parseDateTime(data).toCalendar(Locale.US));
    } else {
        return klass.cast(data);
    }
}

From source file:com.nridge.connector.common.con_com.transform.TContentClean.java

private String cleanSpaces(String aValue) {
    String cleanValue;/*ww  w  .j  av  a  2 s .co m*/

    if (StringUtils.isNotEmpty(aValue)) {
        String trimValue = StringUtils.trim(aValue);
        cleanValue = trimValue.replaceAll("\\s+", " ");
    } else
        cleanValue = StringUtils.EMPTY;

    return cleanValue;
}

From source file:com.healthcit.analytics.utils.CAHopeDataSourceUtils.java

/**
 * Generates a list of AbstractColumn columns associated with this query
 *//*from   www. ja v  a2  s .c  o m*/
private static List<AbstractColumn> getColumns(Query query, JSONObject resultSet,
        List<Map<String, Object>> columnDataArray) {

    QuerySelection querySelection = new QuerySelection();

    List<String> columnIds = new LinkedList<String>();

    // If no SELECT statement was associated with this query,
    // then generate a QuerySelection consisting of columns
    // Column1, Column2, Column3 etc.
    // based on the total possible number of columns 
    // associated with the query
    if (query.getSelection() == null) {
        // get the number of columns associated with the resultSet
        int numColumns = getNumberOfColumns(resultSet);

        // based on the number of columns, create a collection of column ids
        for (int index = 1; index <= numColumns; ++index) {

            String columnId = DEFAULT_COLUMN_PREFIX + index;

            columnIds.add(columnId);
        }
    }
    // Otherwise, the columns must come from a SELECT statement.
    // Since the order of the columns received on the server is not guaranteed
    // to match the original order of the columns (specified on the browser side);
    // we reset the QuerySelection with the correct ordering,
    // which has been ensured in the columnDataArray object.
    else {
        columnIds = Arrays.asList((String[]) getFullColumnNameList(columnDataArray));
    }

    // generate a new set of columns, and 
    // update the QuerySelection with the new set of columns
    for (String columnId : columnIds) {
        SimpleColumn column = new SimpleColumn(StringUtils.trim(columnId));

        querySelection.addColumn(column);
    }

    query.setSelection(querySelection);

    // return the columns associated with the query
    return query.getSelection().getColumns();
}

From source file:gov.nih.nci.cabig.caaers.esb.client.impl.CaaersCaXchangeMessageBroadcastServiceImpl.java

/**
 * Will send a COPPA message/*from   w w  w.j  a  v a 2  s.  com*/
 */
public String broadcastCOPPA(List<String> messages, Metadata metaData)
        throws gov.nih.nci.cabig.caaers.esb.client.BroadcastException {
    String result = null;
    try {
        CaXchangeMessageBroadcasterImpl broadCaster = new CaXchangeMessageBroadcasterImpl();
        String iHubURL = Configuration.LAST_LOADED_CONFIGURATION.get(Configuration.CAEXCHANGE_URL);
        log.info("ca exchage URL + " + iHubURL);
        iHubURL = StringUtils.trim(iHubURL);
        broadCaster.setCaXchangeURL(iHubURL);
        broadCaster.setDelegatedCredentialProvider(delegatedCredentialProvider);
        broadCaster.setMessageResponseHandlers(new CaXchangeMessageResponseHandlerSet());
        result = broadCaster.broadcastCoppaMessage(messages, metaData);
    } catch (edu.duke.cabig.c3pr.esb.BroadcastException e) {
        log.error("Error while broadcasting the message to COPPA", e);
        throw new gov.nih.nci.cabig.caaers.esb.client.BroadcastException(e);
    }
    return result;
}