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.sonicle.webtop.core.versioning.SqlScript.java

private void readFile(InputStreamReader readable) throws IOException {
    this.statements = new ArrayList<>();
    String lines[] = null;//from   w w  w  .j  ava  2s.  co m
    StringBuilder sbsql = null;

    Scanner s = new Scanner(readable);
    s.useDelimiter("(;( )?(\r)?\n)");
    while (s.hasNext()) {
        String block = s.next();
        block = StringUtils.replace(block, "\r", "");
        if (!StringUtils.isEmpty(block)) {
            // Remove remaining ; at the end of the block (only if this block is the last one)
            if (!s.hasNext() && StringUtils.endsWith(block, ";"))
                block = StringUtils.left(block, block.length() - 1);

            sbsql = new StringBuilder();
            lines = StringUtils.split(block, "\n");
            for (String line : lines) {
                if (CommentLine.matches(line))
                    continue;
                sbsql.append(StringUtils.trim(line));
                sbsql.append(" ");
            }
            if (sbsql.length() > 0)
                statements.add(sbsql.toString());
        }
    }
}

From source file:com.ottogroup.bi.spqr.pipeline.MicroPipelineManager.java

/**
 * Initializes the micro pipeline manager
 * @param processingNodeId identifier of node this manager lives on
 * @param componentRepository reference to {@link ComponentRepository} which provides access to all {@link MicroPipelineComponent}
 * @param maxNumberOfThreads max. number of threads assigned to {@link ExecutorService} (1 = single threaded, n = fixed number of threads, other = cached thread pool)
 * @throws RequiredInputMissingException   
 *///from   w  w  w  .  ja  va 2  s.c om
public MicroPipelineManager(final String processingNodeId, final ComponentRepository componentRepository,
        final int maxNumberOfThreads) throws RequiredInputMissingException {

    //////////////////////////////////////////////////////////////////////////////
    // validate provided input
    if (componentRepository == null)
        throw new RequiredInputMissingException("Missing required component repository");
    if (StringUtils.isBlank(processingNodeId))
        throw new RequiredInputMissingException("Missing required processing node identifier");
    //
    //////////////////////////////////////////////////////////////////////////////

    this.processingNodeId = StringUtils.lowerCase(StringUtils.trim(processingNodeId));
    this.microPipelineFactory = new MicroPipelineFactory(this.processingNodeId, componentRepository);

    if (maxNumberOfThreads == 1)
        this.executorService = Executors.newSingleThreadExecutor();
    else if (maxNumberOfThreads > 1)
        this.executorService = Executors.newFixedThreadPool(maxNumberOfThreads);
    else
        this.executorService = Executors.newCachedThreadPool();

}

From source file:com.ottogroup.bi.asap.operator.json.aggregator.JsonContentAggregatorResult.java

/**
 * Adds the aggregated value for a given field value to the map holding all aggregation values for that specific field. Example: (field='cs-host', fieldValue='www.otto.de', aggregationValue=5)
 * @param field/*from   ww w.j  a  v  a  2s.com*/
 * @param fieldValue
 * @param aggregationValue
 * @throws RequiredInputMissingException
 */
public void addAggregatedValue(final String field, final String fieldValue, final long aggregationValue)
        throws RequiredInputMissingException {

    ///////////////////////////////////////////////////////////////////////////////////////////
    // validate provided input
    if (StringUtils.isBlank(field))
        throw new RequiredInputMissingException("Missing required input for parameter 'field'");
    if (StringUtils.isBlank(fieldValue))
        throw new RequiredInputMissingException("Missing required input for parameter 'fieldValue'");
    //
    ///////////////////////////////////////////////////////////////////////////////////////////

    String fieldKey = StringUtils.lowerCase(StringUtils.trim(field));
    Map<String, Long> fieldAggregationValues = this.aggregatedValues.get(fieldKey);
    if (fieldAggregationValues == null)
        fieldAggregationValues = new HashMap<>();
    fieldAggregationValues.put(fieldValue, aggregationValue);
    this.aggregatedValues.put(fieldKey, fieldAggregationValues);
}

From source file:com.yqboots.dict.core.DataDictManagerImpl.java

/**
 * {@inheritDoc}/* w  w w  . ja va2s.c  o  m*/
 */
@Override
public Page<DataDict> getDataDicts(final String wildcardName, final Pageable pageable) {
    final String searchStr = StringUtils.trim(StringUtils.defaultString(wildcardName));

    return dataDictRepository.findByNameLikeIgnoreCase(DBUtils.wildcard(searchStr), pageable);
}

From source file:com.activiti.web.rest.client.JobClientResource.java

/**
 * GET /rest/activiti/jobs/{jobId}/exception-stracktrace -> return job stacktrace
 *///w w w. j ava2  s.  c o m
@RequestMapping(value = "/rest/activiti/jobs/{jobId}/stacktrace", method = RequestMethod.GET, produces = "text/plain")
public String getJobStacktrace(@PathVariable String jobId) throws BadRequestException {

    ServerConfig serverConfig = retrieveServerConfig();
    try {
        String trace = clientService.getJobStacktrace(serverConfig, jobId);
        if (trace != null) {
            trace = StringUtils.trim(trace);
        }
        return trace;
    } catch (ActivitiServiceException e) {
        throw new BadRequestException(e.getMessage());
    }
}

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

/**
 * Initializes the runtime environment using the provided input
 * @param processingNodeId/*from  w ww.j a  v a 2s  . co  m*/
 * @param pipelineId
 * @param emitter
 * @param queueConsumer
 * @throws RequiredInputMissingException
 */
public EmitterRuntimeEnvironment(final String processingNodeId, final String pipelineId, final Emitter emitter,
        final StreamingMessageQueueConsumer queueConsumer) throws RequiredInputMissingException {

    ///////////////////////////////////////////////////////////////////
    // validate input
    if (StringUtils.isBlank(processingNodeId))
        throw new RequiredInputMissingException("Missing required processing node identifier");
    if (StringUtils.isBlank(pipelineId))
        throw new RequiredInputMissingException("Missing required pipeline identifier");
    if (emitter == null)
        throw new RequiredInputMissingException("Missing required emitter");
    if (queueConsumer == null)
        throw new RequiredInputMissingException("Missing required input queue consumer");
    //
    ///////////////////////////////////////////////////////////////////

    this.processingNodeId = StringUtils.lowerCase(StringUtils.trim(processingNodeId));
    this.pipelineId = StringUtils.lowerCase(StringUtils.trim(pipelineId));
    this.emitterId = StringUtils.lowerCase(StringUtils.trim(emitter.getId()));
    this.emitter = emitter;
    this.queueConsumer = queueConsumer;

    this.running = true;

    if (logger.isDebugEnabled())
        logger.debug("emitter init [node=" + this.processingNodeId + ", pipeline=" + this.pipelineId
                + ", emitter=" + this.emitterId + "]");

}

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

public String getInternalSearchExpression() {
    filterExpression = StringUtils.trim(filterExpression);
    fixedFilterExpression = StringUtils.trim(fixedFilterExpression);
    if (StringUtils.isEmpty(filterExpression) == true) {
        return fixedFilterExpression;
    }/*from   ww w. j  a v a 2  s  .c  o m*/
    if (StringUtils.isEmpty(fixedFilterExpression) == true) {
        return filterExpression;
    }
    return fixedFilterExpression + " and " + filterExpression;
}

From source file:com.webbfontaine.valuewebb.utils.TTMailService.java

@Asynchronous
public void sendSMSForResponseOk(TtGen ttGen, Locale locale) {
    LocaleSelector.instance().setLocale(locale);
    if (!ApplicationProperties.isTestMode() && !StringUtils.isEmpty(ApplicationProperties.getSmsGateway())) {
        TTMailUtils ttMailUtils = new TTMailUtils(ttGen);
        Collection<String> recepients = ttMailUtils.getSMSRecepientsForResponseOk();

        if (recepients == null || recepients.isEmpty()) {
            LOGGER.warn("No sms recipients specified for Sending Response Ok message for TT {0}",
                    ttGen.getId());/*from  ww w  . ja  v a 2  s . com*/
        } else {
            for (String recepient : recepients) {
                recepient = StringUtils.trim(recepient);
                try {
                    EmailSender.sendMail(recepient, ttMailUtils.getResponseOkSMSBody(), false, null,
                            ApplicationProperties.getSmsFrom(), ApplicationProperties.getSmtpServer(),
                            ApplicationProperties.getSmtpServerPort(), ApplicationProperties.getSmsGateway());
                    LOGGER.info("TT ID: {0}. Sending SMS for ResponseOk to {1} done.", ttGen.getId(),
                            recepient);
                } catch (Exception e) {
                    LOGGER.error("TT ID: {0}. Error during sending sms to {1}", e, ttGen.getId(), recepient);
                }
            }
        }
    } else {
        LOGGER.info("Response Ok SMS message sending skipped for TT {0}. Conf: Test Mode {1}, SMS Gateway {2}",
                ttGen.getId(), ApplicationProperties.isTestMode(), ApplicationProperties.getSmsGateway());
    }
}

From source file:com.thoughtworks.go.domain.ArtifactPlan.java

public void setSrc(String src) {
    this.src = StringUtils.trim(src);
}

From source file:com.thoughtworks.go.domain.User.java

public void setEmail(String email) {
    this.email = StringUtils.trim(email);
}