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.xpn.xwiki.internal.XWikiCfgConfigurationSource.java

@Override
public <T> T getProperty(String key) {
    return (T) StringUtils.trim(this.properties.getProperty(key));
}

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

/**
 * Shuts down the pipeline on all processing node it has been deployed to
 * @param pipelineId//  w  w  w  . ja  v  a 2s . c  om
 * @return
 * @throws RequiredInputMissingException
 * @throws UnknownPipelineException
 */
public PipelineDeploymentProfile shutdownPipeline(final String pipelineId)
        throws RequiredInputMissingException, UnknownPipelineException {

    ///////////////////////////////////////////////////////////
    // validate input
    if (StringUtils.isBlank(pipelineId))
        throw new RequiredInputMissingException("Missing required pipeline identifier");
    String pid = StringUtils.lowerCase(StringUtils.trim(pipelineId));
    if (!this.pipelineDeployments.containsKey(pid))
        throw new UnknownPipelineException("Unknown pipeline '" + pipelineId + "'");
    //
    ///////////////////////////////////////////////////////////

    final PipelineDeploymentProfile profile = this.pipelineDeployments.remove(pid);
    return this.processingNodeManager.shutdownPipeline(profile);
}

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

/**
 * Instantiates and executes the {@link MicroPipeline} described by the given {@link MicroPipelineConfiguration}
 * @param configuration//from   w  w w. java2 s .c o m
 * @throws RequiredInputMissingException
 * @throws QueueInitializationFailedException
 * @throws ComponentInitializationFailedException
 * @throws PipelineInstantiationFailedException
 */
public String executePipeline(final MicroPipelineConfiguration configuration)
        throws RequiredInputMissingException, QueueInitializationFailedException,
        ComponentInitializationFailedException, PipelineInstantiationFailedException,
        NonUniqueIdentifierException {

    ///////////////////////////////////////////////////////////
    // validate input
    if (configuration == null)
        throw new RequiredInputMissingException("Missing required pipeline configuration");
    //
    ///////////////////////////////////////////////////////////

    String id = StringUtils.lowerCase(StringUtils.trim(configuration.getId()));
    if (this.pipelines.containsKey(id))
        throw new NonUniqueIdentifierException("A pipeline already exists for id '" + id + "'");

    MicroPipeline pipeline = this.microPipelineFactory.instantiatePipeline(configuration, this.executorService);
    if (pipeline != null)
        this.pipelines.put(id, pipeline);
    else
        throw new PipelineInstantiationFailedException("Failed to instantiate pipeline '"
                + configuration.getId() + "'. Reason: null returned by pipeline factory");

    if (logger.isDebugEnabled())
        logger.debug("pipeline registered[id=" + configuration.getId() + "]");

    return id;
}

From source file:com.mirth.connect.client.ui.reference.ClassVisitor.java

@Override
public void visit(ClassOrInterfaceDeclaration n, Object arg) {
    String className = n.getName();
    String packageName = (String) arg;

    StringBuilder builder = new StringBuilder();
    builder.append("<html><body><b>");

    if (StringUtils.isNotBlank(packageName)) {
        builder.append("package ");
        builder.append(packageName);/*from w ww.  j av  a  2s  .com*/
    }

    builder.append("<br/><h3><a href=\"");
    builder.append(PlatformUI.SERVER_URL);
    builder.append(UIConstants.USER_API_LOCATION);

    if (StringUtils.isNotBlank(packageName)) {
        builder.append(packageName.replace(".", "/"));
        builder.append('/');
        builder.append(className);
        builder.append(".html");
    }

    builder.append("\">");
    builder.append(n.isInterface() ? "Interface " : "Class ");
    builder.append(className);
    builder.append("</a></h3></b><hr/><code>");

    if (ModifierSet.isPublic(n.getModifiers())) {
        builder.append("public ");
    } else {
        // Don't add references for non-public classes
        return;
    }

    if (ModifierSet.isStatic(n.getModifiers())) {
        builder.append("static ");
    }
    if (ModifierSet.isAbstract(n.getModifiers())) {
        builder.append("abstract ");
    }
    if (ModifierSet.isFinal(n.getModifiers())) {
        builder.append("final ");
    }
    if (ModifierSet.isNative(n.getModifiers())) {
        builder.append("native ");
    }
    if (ModifierSet.isSynchronized(n.getModifiers())) {
        builder.append("synchronized ");
    }
    if (ModifierSet.isTransient(n.getModifiers())) {
        builder.append("transient ");
    }
    if (ModifierSet.isVolatile(n.getModifiers())) {
        builder.append("volatile ");
    }

    if (n.isInterface()) {
        builder.append("interface ");
    } else {
        builder.append("class ");
    }

    builder.append(className);

    List<ClassOrInterfaceType> extendsList = n.getExtends();
    if (CollectionUtils.isNotEmpty(extendsList)) {
        ClassOrInterfaceType type = extendsList.get(0);
        builder.append("<br/>extends ");
        builder.append(type.getName());
    }

    List<ClassOrInterfaceType> implementsList = n.getImplements();
    if (CollectionUtils.isNotEmpty(implementsList)) {
        builder.append("<br/>implements ");
        for (Iterator<ClassOrInterfaceType> it = implementsList.iterator(); it.hasNext();) {
            ClassOrInterfaceType type = it.next();
            builder.append(type.getName());
            if (it.hasNext()) {
                builder.append(", ");
            }
        }
    }

    builder.append("</code><br/><br/>");

    if (n.getJavaDoc() != null) {
        String comment = StringUtils.trim(n.getJavaDoc().getContent());
        if (StringUtils.isNotBlank(comment)) {
            builder.append(encode(convertComment(comment)));
        }
    }

    String summary = builder.toString();

    references.add(new ClassReference(CodeTemplateContextSet.getGlobalContextSet(), null, className,
            inputTextList, summary));

    if (n.getMembers() != null) {
        for (BodyDeclaration member : n.getMembers()) {
            member.accept(this, className);
        }
    }
}

From source file:com.tech.utils.CustomCollectionUtil.java

/**
 * Converts comma separated value string to set of long values
 * // w w  w .  j a v  a 2s . c  o  m
 * @param csvString
 * @param seperator
 * @return itemSet
 */
public static Set<Long> convertStringToSet(String csvStr, String fieldSeperator) {
    Set<Long> itemSet = new HashSet<Long>();
    if (StringUtils.isNotEmpty(csvStr) && StringUtils.isNotBlank(csvStr)) {
        String[] itemsArray = StringUtils.split(csvStr, fieldSeperator);
        if (itemsArray != null && itemsArray.length > 0) {
            for (int i = 0; i < itemsArray.length; i++) {
                if (StringUtils.isNotEmpty(itemsArray[i]) && StringUtils.isNotBlank(itemsArray[i])) {
                    itemSet.add(Long.valueOf(StringUtils.trim(itemsArray[i])));
                }
            }
        }
    }
    return itemSet;
}

From source file:com.sonicle.webtop.core.util.ZPushManager.java

private List<ListRecord> parseListOutput(List<String> lines) {
    ArrayList<ListRecord> items = new ArrayList<>();

    int lineNo = 0, dataLine = -1;
    for (String line : lines) {
        lineNo++;//from w  w  w. j  a  va  2  s .  com
        if (StringUtils.containsIgnoreCase(line, "All synchronized devices")) {
            dataLine = lineNo + 4;
        }
        if ((dataLine != -1) && (lineNo >= dataLine) && !StringUtils.isBlank(StringUtils.trim(line))) {
            String[] tokens = StringUtils.split(line, " ", 2);
            String device = StringUtils.trim(tokens[0]);
            String users = StringUtils.trim(tokens[1]);
            items.add(new ListRecord(device, StringUtils.split(users, ",")));
        }
    }
    return items;
}

From source file:com.bekwam.resignator.commands.KeytoolCommand.java

public List<KeystoreEntry> parseKeystoreEntries(BufferedReader br) throws IOException {

    List<KeystoreEntry> entries = new ArrayList<>();

    String line = "";
    KeystoreListParseStateType parseState = KeystoreListParseStateType.HEADER;
    KeystoreEntry currEntry = null;//from  w w w. ja v a2  s .co m

    while (parseState != KeystoreListParseStateType.END && parseState != KeystoreListParseStateType.ERROR_END) {

        switch (parseState) {
        case START:
            parseState = KeystoreListParseStateType.HEADER;
            break;
        case HEADER:

            line = br.readLine();

            if (StringUtils.startsWith(line, "Your keystore")) {
                parseState = KeystoreListParseStateType.ENTRY;
            } else if (line == null) {
                parseState = KeystoreListParseStateType.ERROR_END;
            }

            break;
        case ENTRY:

            line = br.readLine();

            if (StringUtils.startsWith(line, "Certificate fingerprint")) {
                parseState = KeystoreListParseStateType.FP;
            } else {

                if (line == null) {

                    parseState = KeystoreListParseStateType.ERROR_END;

                } else if (StringUtils.isNotEmpty(line)) {
                    String[] toks = StringUtils.split(line, ",");
                    currEntry = new KeystoreEntry(StringUtils.trim(toks[0]),
                            StringUtils.trim(toks[1] + toks[2]), StringUtils.trim(toks[3]));
                }
            }

            break;
        case FP:

            if (StringUtils.isNotEmpty(line)) {
                StrTokenizer st = new StrTokenizer(line, ": ");
                if (st != null) {
                    String[] toks = st.getTokenArray();
                    currEntry = new KeystoreEntry(currEntry, toks[1]);
                    entries.add(currEntry);
                }
            }

            parseState = KeystoreListParseStateType.ENTRY;
            break;

        case ERROR_END:
        case END:
            break;
        }
    }

    return entries;
}

From source file:de.micromata.genome.gwiki.jetty.GWikiInitialSetup.java

protected boolean createNewProperties() {

    message("Welcome to GWiki.\n"
            + "You are running GWiki the first time.\nPlease answer following questions.\n"
            + "If the prompt has [defaultValue] you can also accept the defaultValue by hitting enter.\n\n");

    getConfigLocation(gwikiPropFileName);
    getHttpServer();//from ww w  . j a  v  a2  s .co m
    getFileSystem();

    if (ask("Generate System user?", true) == true) {
        props.put(GWikiSysUserAuthorization.LS_GWIKI_SYS_USER, getInput("user name", "gwikisys"));
        String pass;
        do {
            pass = StringUtils.trim(getInput("user password"));
            if (pass.length() < 5) {
                message("password should have at least 5 characters");
                continue;
            }
            break;
        } while (true);
        String salted = PasswordUtils.createSaltedPassword(pass);
        props.put(GWikiSysUserAuthorization.LS_GWIKI_SYS_PASSWORDHASH, salted);
    }
    String enableWebDAV = "false";
    if (ask("Enable User for WebDAV Access?", false) == true) {
        enableWebDAV = "true";
    }
    props.put("gwiki.enable.webdav", enableWebDAV);

    checkEmailServer();

    createContextFile();
    storeConfig();
    message("Configuration finished.\n");
    return true;
}

From source file:com.ottogroup.bi.spqr.metrics.MetricsHandler.java

/**
 * {@link JmxReporter#stop() Stops} the referenced {@link JmxReporter} and removes it from map
 * of managed jmx reporters/*www .  ja v  a  2  s  . c o m*/
 * @param id
 */
public void removeJmxReporter(final String id) {
    String key = StringUtils.lowerCase(StringUtils.trim(id));
    JmxReporter jmxReporter = this.jmxReporters.get(key);
    if (jmxReporter != null) {
        jmxReporter.stop();
        this.jmxReporters.remove(key);
    }
}

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

/**
 * Evaluates the referenced aggregated value against the provided value and saves the smaller one
 * @param field//from   ww  w .  ja  v  a  2s  .  c  o m
 * @param fieldValue
 * @param value
 * @throws RequiredInputMissingException
 */
public void evalMinAggregatedValue(final String field, final String fieldValue, final long value)
        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));
    String fieldValueKey = StringUtils.lowerCase(StringUtils.trim(fieldValue));
    Map<String, Long> fieldAggregationValues = this.aggregatedValues.get(fieldKey);
    if (fieldAggregationValues == null)
        fieldAggregationValues = new HashMap<>();
    long aggregationValue = (fieldAggregationValues.containsKey(fieldValueKey)
            ? fieldAggregationValues.get(fieldValueKey)
            : Integer.MAX_VALUE);
    if (value < aggregationValue) {
        fieldAggregationValues.put(fieldValueKey, value);
        this.aggregatedValues.put(fieldKey, fieldAggregationValues);
    }
}