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

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

Introduction

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

Prototype

public static String join(Collection<?> collection, String separator) 

Source Link

Document

Joins the elements of the provided Collection into a single String containing the provided elements.

Usage

From source file:com.admc.jcreole.marker.TagMarker.java

/**
 * Removes the single character at the indicated point, then, if there
 * are any class names to be written, inserts the list at that point.
 *///w w  w  .j  a  v a2  s.  c  om
public void updateBuffer() {
    super.updateBuffer();
    if (cssClasses.size() < 1)
        return;
    String classesString = StringUtils.join(cssClasses, ' ');
    targetSb.insert(offset, writeAttr ? (" class=\"" + classesString + '\"') : (" " + classesString));
}

From source file:com.adobe.acs.commons.reports.models.ReferencesModel.java

@Override
public String getValue(Object result) {
    resource = (Resource) result;
    init();/*from  ww  w. ja v  a  2s.c om*/
    List<String> refStrings = new ArrayList<String>();
    for (Reference reference : referenceList) {
        refStrings.add(reference.getType() + " - " + reference.getTarget().getPath());
    }
    return StringUtils.join(refStrings, ";");
}

From source file:jenkins.model.queue.CompositeCauseOfBlockage.java

@Override
public String getShortDescription() {
    return StringUtils.join(uniqueReasons.keySet(), "; ");
}

From source file:com.ailk.oci.ocnosql.client.query.TestOCNoSqlQueryAPI.java

@Test
public void queryGetSigleKey() {
    System.out.println("begin hbase get ");
    ClientAdaptor client = new ClientAdaptor();
    List<String[]> list = client.queryByRowkey(conn, rowkey, Arrays.asList(tablename), null, null,
            columnfamilies);//from  w w w .  j  a v  a 2  s  .  c om
    System.out.println("lenth is " + list.size());
    for (String[] result : list) {
        System.out.println("result is " + StringUtils.join(result, ";"));
    }
}

From source file:com.asual.summer.core.faces.RepeatComponentRenderer.java

public void encodeBegin(FacesContext context, UIComponent component) throws IOException {

    String componentTag = ComponentUtils.getComponentTag(component);
    RepeatComponent repeatComponent = ((RepeatComponent) component);
    ResponseWriter writer = context.getResponseWriter();

    if (componentTag != null) {

        writer.startElement(componentTag, component);

        Map<String, Object> attrs;

        if (ComponentUtils.getComponentClass((Component) component) == null) {
            attrs = ComponentUtils.getAttributes((Component) component, componentTag);
        } else {/*from   www.  ja va2  s.  c o  m*/
            attrs = new HashMap<String, Object>();
        }

        List<String> classes = ComponentUtils.getComponentClasses((Component) component);
        if (classes.size() != 0) {
            attrs.put("class", StringUtils.join(classes, " "));
        }

        for (String key : attrs.keySet()) {
            if (ComponentUtils.shouldWriteAttribute((Component) component, key) && attrs.get(key) != null) {
                ComponentUtils.writeAttribute(writer, key, attrs.get(key));
            }
        }

        Object value = repeatComponent.getValue();
        if ((value == null || ObjectUtils.size(value) == 0) && repeatComponent.getDataEmpty() != null) {
            if (componentTag.matches("tbody")) {
                writer.startElement("tr", repeatComponent);
            }
            if (componentTag.matches("tbody|tr")) {
                writer.startElement("td", repeatComponent);
            }
            writer.write(repeatComponent.getDataEmpty());
            if (componentTag.matches("tbody|tr")) {
                writer.endElement("td");
            }
            if (componentTag.matches("tbody")) {
                writer.endElement("tr");
            }
        }
    }

    if (!StringUtils.isEmpty(repeatComponent.getDataEmptyOption())) {
        writer.startElement("option", repeatComponent);
        writer.writeAttribute("value", "", null);
        writer.write(repeatComponent.getDataEmptyOption());
        writer.endElement("option");
    }
}

From source file:edu.uiowa.icts.bluebutton.json.view.EncountersMetaFinder.java

public String getOrganizations() {
    TreeSet<String> orgSet = new TreeSet<String>();
    for (Encounter e : this.list) {
        if (e.getLocation() != null && e.getLocation().getOrganization() != null) {
            orgSet.add(e.getLocation().getOrganization());
        }/*ww w  .j ava 2s  . com*/
    }
    if (orgSet.size() > 0) {
        return StringUtils.join(orgSet, ", ");
    }
    return null;
}

From source file:eu.annocultor.converter.ConverterHandlerDataObjectsTest.java

public void testDO() throws Exception {
    final Path recordSeparatingPath = new Path("");
    task = Factory.makeTask("bibliopolis", "terms", "Bibliopolis, KB", Namespaces.DC, new TestEnvironment());
    objectRule = ObjectRuleImpl.makeObjectRule(task, recordSeparatingPath, new Path(fieldId), new Path(""),
            null, true);/* w w w .j  a  v a2  s .c om*/

    assertEquals(1, task.getRuleForSourcePath(recordSeparatingPath).size());

    ConverterHandler defaultHandler = new ConverterHandler(task) {

        @Override
        protected void processDataObject() throws Exception {
            ListOfValues values = getValues(new Path(fieldName));
            Collections.sort(values);
            dataObjects.add(StringUtils.join(values, ","));
        }
    };
    ConverterHandlerDataObjects handler = new ConverterHandlerDataObjects(defaultHandler, recordSeparatingPath);

    // non-aggregating (default)
    handler.setAggregate(false);
    imitateDataInsertionSequence(handler);

    // checks
    assertEquals(4, dataObjects.size());
    assertEquals("2A,2B", dataObjects.get(1));
    assertEquals("1A", dataObjects.get(2));

    // aggregating
    handler.setAggregate(true);
    imitateDataInsertionSequence(handler);

    // checks
    assertEquals(3, dataObjects.size());
    assertEquals("1A,2A,2B", dataObjects.get(1));
    assertEquals("3A", dataObjects.get(2));
}

From source file:com.alu.e3.gateway.camel.processor.HttpMethodProcessorTest.java

@Test
public void testPermutations() throws Exception {
    proc.setAllowedHttpMethods(StringUtils.join(ALLOWED.iterator(), ","));

    checkAllowedMethods(ALLOWED);//from ww  w .  j a va2  s.c o m

    checkNotAllowedMethods(NOTALLOWED);
}

From source file:com.confighub.core.utils.FileUtils.java

public static String resolveFile(final Context context, final RepoFile file,
        Map<PropertyKey, Property> resolved, Map<String, String> passwords) throws ConfigException {
    boolean encrypt = false;
    String pass = "";
    if (file.isEncrypted()) {
        pass = passwords.get(file.getSecurityProfile().getName());
        if (null == pass || !file.getSecurityProfile().isSecretValid(pass)) {
            pass = file.getSecurityProfile().getDecodedPassword();
            encrypt = true;/*  w w  w  . j a  va 2s .c  om*/
        }

        file.decryptFile(pass);
    }

    Map<String, Property> propertyMap = new HashMap<>();
    Map<String, PropertyKey> keyMap = new HashMap<>();
    resolved.keySet().forEach(k -> {
        propertyMap.put(k.getKey(), resolved.get(k));
        keyMap.put(k.getKey(), k);
    });

    String fileContent = file.getContent();
    String patternString = "(?i)\\$\\{\\s*\\b(" + StringUtils.join(propertyMap.keySet(), "|") + ")\\b\\s*}";
    Pattern pattern = Pattern.compile(patternString);
    Matcher matcher = pattern.matcher(fileContent);

    StringBuffer sb = new StringBuffer();

    while (matcher.find()) {
        String key = matcher.group(1);
        Property property = propertyMap.get(key);

        // replace each key specification with the property value
        String value = "";

        if (null != property) {
            if (null != property.getAbsoluteFilePath() && PropertyKey.ValueDataType.FileEmbed
                    .equals(property.getPropertyKey().getValueDataType())) {
                RepoFile injectFile = context.resolveFullContextFilePath(property.getAbsoluteFilePath());
                if (null == injectFile)
                    value = "[ ERROR: No file resolved ]";
                else
                    value = resolveFile(context, injectFile, resolved, passwords);
            } else {
                if (property.isEncrypted()) {
                    String spName = keyMap.get(key).getSecurityProfile().getName();
                    if (passwords.containsKey(spName))
                        property.decryptValue(passwords.get(spName));
                }
                value = setValue(property);
            }
        }
        matcher.appendReplacement(sb, Matcher.quoteReplacement(value));
    }

    matcher.appendTail(sb);
    fileContent = sb.toString();

    // Remove all escapes \${...}
    fileContent = fileContent.replaceAll("\\\\\\$\\{", "\\$\\{");

    if (encrypt)
        fileContent = Encryption.encrypt(file.getSecurityProfile().getCipher(), fileContent, pass);

    return fileContent;
}

From source file:dataflow.docker.DockerProcess.java

/**
 * Wait for the process to finish and periodically grab the output.
 *
 * @param builder/*  w ww . java  2  s.  com*/
 * @param prefix
 * @param command
 * @param logger
 * @param outStream
 * @return
 */
public int waitForAndLogProcess(Logger logger, PrintStream outStream) {
    String commandText = StringUtils.join(command, " ");
    try {
        synchronized (process) {
            BufferedReader stdInput = new BufferedReader(new InputStreamReader(process.getInputStream()));

            BufferedReader stdError = new BufferedReader(new InputStreamReader(process.getErrorStream()));

            // In milliseconds.
            final long TIMEOUT = 1000;

            boolean wait = true;
            while (wait) {
                // We periodically check if the process has terminated and if not,
                // print out all the processes output
                process.wait(TIMEOUT);

                // Print all the output
                String line;

                while ((stdInput.ready()) && ((line = stdInput.readLine()) != null)) {
                    if (outStream != null) {
                        outStream.println(line);
                    } else {
                        logger.info(line);
                    }
                }
                while ((stdError.ready()) && ((line = stdError.readLine()) != null)) {
                    // TODO(jlewi): We should use logger.log and use function arguments
                    // to specify what priority the output should be logged at.
                    logger.error(line);
                }
                try {
                    process.exitValue();
                    // Process is done.
                    wait = false;
                } catch (IllegalThreadStateException e) {
                    // Process hasn't completed yet.
                }
            }

            logger.info("Exit Value: " + process.exitValue());
            if (process.exitValue() != 0) {
                logger.error("Command: " + commandText + " exited with non-zero status.");
            }
        }
        return process.exitValue();
    } catch (IOException e) {
        throw new RuntimeException("There was a problem executing the command:\n" + commandText
                + "\n. The Exception was:\n" + e.getMessage());
    } catch (InterruptedException e) {
        throw new RuntimeException("Execution was interupted. The command was:\n" + commandText
                + "\n. The Exception was:\n" + e.getMessage());
    }
}