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.orange.ocara.ui.activity.CreateSiteActivity.java

protected String getSiteName() {
    return StringUtils.trim(siteName.getText().toString());
}

From source file:com.indoqa.lang.util.DateRangeParser.java

public static String getStringRepresentationOfOffset(long offset) {
    if (offset == 0) {
        return "";
    }//  w  w  w .jav  a2 s .  c  o m

    long currentOffset = offset;
    StringBuffer result = new StringBuffer();

    List<Entry<String, Long>> conversionUnitsSortedDesc = getConversionUnitsSortedDesc();
    for (Entry<String, Long> entry : conversionUnitsSortedDesc) {
        String unitLabel = entry.getKey();
        Long unitConversion = entry.getValue();

        if (currentOffset < unitConversion) {
            continue;
        }

        long unitValue = currentOffset / unitConversion;
        result.append(unitValue);
        result.append(unitLabel);
        result.append(" ");

        if (currentOffset % unitConversion == 0) {
            break;
        }

        currentOffset = currentOffset % unitConversion;
    }

    return StringUtils.trim(result.toString());
}

From source file:com.wxine.android.model.Community.java

public Set<String> getScopes() {
    try {//from   w w w  . ja  v  a  2 s  . c om
        String[] array = scope.split(",");
        for (String a : array) {
            if (StringUtils.isNotBlank(a)) {
                scopes.add(StringUtils.trim(StringUtils.strip(a)));
            }
        }
    } catch (Exception e) {
    }
    return scopes;
}

From source file:it.volaconnoi.bean.RouteManagerBean.java

@Override
public List<Route> getRoutesByInputParameters(String source, String destination, String date,
        String travel_class, String date_flexi) {
    TypedQuery<Route> query = em.createNamedQuery("Route.findByInputParameters", Route.class);

    List<Route> routes_list = query.setParameter("source", StringUtils.trim(WordUtils.capitalizeFully(source)))
            .setParameter("dest", StringUtils.trim(WordUtils.capitalizeFully(destination)))
            .setParameter("startDate",
                    utilBean.getFormattedDate(date, "00", "00", !StringUtils.isNotEmpty(date_flexi) ? 0 : +2),
                    TemporalType.TIMESTAMP)
            .setParameter("endDate",
                    utilBean.getFormattedDate(date, "23", "59", !StringUtils.isNotEmpty(date_flexi) ? 0 : +2),
                    TemporalType.TIMESTAMP)
            .setParameter("travel_class", travel_class).getResultList();

    //la flessibilit si intende due giorni avanti la data inserita dall'utente

    return routes_list;
}

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

private String extractImageData(String data) {
    String ret = data;/*from   w  w  w  . j  ava2  s  .  c om*/
    // data:image/png;base64,iV
    if (ret.startsWith("data:") == true) {
        ret = ret.substring("data:".length());
    }
    if (ret.startsWith("image") == true) {
        int idx = ret.indexOf(';');
        if (idx != -1) {
            String mimet = ret.substring(0, idx);
            ret = ret.substring(idx + 1);
        }
    }
    if (ret.startsWith("base64,") == true) {
        ret = ret.substring("base64,".length());
    }
    ret = StringUtils.trim(ret);
    return ret;
}

From source file:com.xpn.xwiki.XWikiConfig.java

/**
 * {@inheritDoc}/*w  w  w  .java 2  s.co m*/
 * <p>
 * This method trims the spaces around the value.
 * </p>
 * 
 * @see java.util.Properties#getProperty(java.lang.String)
 */
@Override
public String getProperty(String key) {
    return StringUtils.trim(super.getProperty(key));
}

From source file:com.devicehive.dao.riak.model.RiakUser.java

public void setGoogleLogin(String googleLogin) {
    this.googleLogin = StringUtils.trim(googleLogin);
}

From source file:ductive.console.groovy.GroovyInterpreter.java

public Object interpret(String code) {
    String importSpec = StringUtils.join(imports, "\n");

    String executeCode = importSpec + "true\n" + code; // i don't know why dummy 'true' is required...
    Script script = parse(executeCode, generateScriptName());

    Binding ctx = getContext();/* w  w w. j  ava  2  s. c om*/

    MetaClass clazz = ((GroovyObject) script).getMetaClass();

    script.setBinding(ctx);
    Object result = script.evaluate(executeCode);

    for (MetaMethod m : clazz.getMethods()) {
        String name = m.getName();

        if (!m.getDeclaringClass().getTheClass().equals(clazz.getTheClass()))
            continue;

        if (ArrayUtils.contains(ArrayUtils.toArray("main", "run"), name) || name.startsWith("super$")
                || name.startsWith("class$") || name.startsWith("$") || name.startsWith("__$"))
            continue;

        if (log.isTraceEnabled())
            log.trace(String.format("defined function '%s'", m.getName()));

        ctx.setVariable(m.getName(), new MethodClosure(clazz.invokeConstructor(new Object[] {}), m.getName()));
    }

    if (StringUtils.trim(code).startsWith("import "))
        registerImport(code);

    return result;
}

From source file:com.orange.ocara.ui.activity.CreateSiteActivity.java

protected String getSiteStreet() {
    return StringUtils.trim(siteStreet.getText().toString());
}

From source file:com.ottogroup.bi.asap.resman.pipeline.PipelineManager.java

/**
 * Instantiates the provided pipeline on a set of processing nodes
 * @param pipelineConfiguration/*from  ww  w.java 2  s . c  o  m*/
 * @return
 * @throws RequiredInputMissingException
 * @throws RemoteClientConnectionFailedException 
 * @throws IOException 
 */
public PipelineDeploymentProfile instantiatePipeline(final MicroPipelineConfiguration pipelineConfiguration)
        throws RequiredInputMissingException, PipelineAlreadyRegisteredException {

    ///////////////////////////////////////////////////////////
    // validate input
    if (pipelineConfiguration == null)
        throw new RequiredInputMissingException("Missing required pipeline configuration");
    String pid = StringUtils.lowerCase(StringUtils.trim(pipelineConfiguration.getId()));
    if (this.pipelineDeployments.containsKey(pid))
        throw new PipelineAlreadyRegisteredException("A pipeline already exists for identifier '"
                + pipelineConfiguration.getId() + "'. To replace an existing pipeline use updateOrInstantiate");
    // TODO validate pipeline configuration
    //
    ///////////////////////////////////////////////////////////

    final PipelineDeploymentProfile profile = processingNodeManager.instantiatePipeline(
            new PipelineDeploymentProfile(pipelineConfiguration.getId(), pipelineConfiguration));
    this.pipelineDeployments.put(StringUtils.lowerCase(StringUtils.trim(pipelineConfiguration.getId())),
            profile);

    return profile;
}