Example usage for java.lang String join

List of usage examples for java.lang String join

Introduction

In this page you can find the example usage for java.lang String join.

Prototype

public static String join(CharSequence delimiter, Iterable<? extends CharSequence> elements) 

Source Link

Document

Returns a new String composed of copies of the CharSequence elements joined together with a copy of the specified delimiter .

Usage

From source file:com.blackducksoftware.integration.hub.detect.detector.maven.MavenCliExtractor.java

public Extraction extract(final File directory, final String mavenExe) {
    try {/*from  w w w .  j av  a  2s  .  c o m*/
        String mavenCommand = detectConfiguration.getProperty(DetectProperty.DETECT_MAVEN_BUILD_COMMAND,
                PropertyAuthority.None);
        if (StringUtils.isNotBlank(mavenCommand)) {
            mavenCommand = mavenCommand.replace("dependency:tree", "");
            if (StringUtils.isNotBlank(mavenCommand)) {
                mavenCommand = mavenCommand.trim();
            }
        }

        final List<String> arguments = new ArrayList<>();
        if (StringUtils.isNotBlank(mavenCommand)) {
            arguments.addAll(Arrays.asList(mavenCommand.split(" ")));
        }
        arguments.add("dependency:tree");

        final Executable mvnExecutable = new Executable(directory, mavenExe, arguments);
        final ExecutableOutput mvnOutput = executableRunner.execute(mvnExecutable);

        if (mvnOutput.getReturnCode() == 0) {

            final String mavenScope = detectConfiguration.getProperty(DetectProperty.DETECT_MAVEN_SCOPE,
                    PropertyAuthority.None);
            final String excludedModules = detectConfiguration
                    .getProperty(DetectProperty.DETECT_MAVEN_EXCLUDED_MODULES, PropertyAuthority.None);
            final String includedModules = detectConfiguration
                    .getProperty(DetectProperty.DETECT_MAVEN_INCLUDED_MODULES, PropertyAuthority.None);
            final List<MavenParseResult> mavenResults = mavenCodeLocationPackager.extractCodeLocations(
                    directory.toString(), mvnOutput.getStandardOutput(), mavenScope, excludedModules,
                    includedModules);

            final List<DetectCodeLocation> codeLocations = mavenResults.stream().map(it -> it.codeLocation)
                    .collect(Collectors.toList());

            final Optional<MavenParseResult> firstWithName = mavenResults.stream()
                    .filter(it -> StringUtils.isNoneBlank(it.projectName)).findFirst();

            final Extraction.Builder builder = new Extraction.Builder().success(codeLocations);
            if (firstWithName.isPresent()) {
                builder.projectName(firstWithName.get().projectName);
                builder.projectVersion(firstWithName.get().projectVersion);
            }
            return builder.build();
        } else {
            final Extraction.Builder builder = new Extraction.Builder()
                    .failure(String.format("Executing command '%s' returned a non-zero exit code %s",
                            String.join(" ", arguments), mvnOutput.getReturnCode()));
            return builder.build();
        }
    } catch (final Exception e) {
        return new Extraction.Builder().exception(e).build();
    }
}

From source file:org.apache.calcite.adapter.elasticsearch.EmbeddedElasticsearchPolicy.java

void insertBulk(String index, List<ObjectNode> documents) throws IOException {
    Objects.requireNonNull(index, "index");
    Objects.requireNonNull(documents, "documents");

    if (documents.isEmpty()) {
        // nothing to process
        return;/*from w  w w.j a  v  a2  s. c o m*/
    }

    List<String> bulk = new ArrayList<>(documents.size() * 2);
    for (ObjectNode doc : documents) {
        bulk.add("{\"index\": {} }"); // index/type will be derived from _bulk URI
        bulk.add(mapper().writeValueAsString(doc));
    }

    final StringEntity entity = new StringEntity(String.join("\n", bulk) + "\n", ContentType.APPLICATION_JSON);

    final String uri = String.format(Locale.ROOT, "/%s/%s/_bulk?refresh", index, index);

    restClient().performRequest("POST", uri, Collections.emptyMap(), entity);
}

From source file:com.amazonaws.services.kinesis.aggregators.configuration.ExternalConfigurationModel.java

private static void addTimeHorizons(JsonNode document, ExternalConfigurationModel model) throws Exception {
    JsonNode node = StreamAggregatorUtils.readJsonValue(document, "timeHorizons");
    if (node != null) {
        Iterator<JsonNode> timeHorizonValues = node.elements();
        while (timeHorizonValues.hasNext()) {
            String t = timeHorizonValues.next().asText();
            String timeHorizonName = null;
            int granularity = -1;
            boolean utc = false;

            // process UTC-shifting time horizons
            if (t.contains("-UTC")) {
                t = String.join("", t.split("-UTC"));
                utc = true;/*  www.  j a  v a 2 s .c o m*/
            }

            // process parameterised time horizons
            if (t.contains("MINUTES_GROUPED")) {
                String[] items = t.split("\\(");
                timeHorizonName = items[0];
                granularity = Integer.parseInt(items[1].replaceAll("\\)", ""));
            } else {
                timeHorizonName = t;
            }

            try {
                TimeHorizon th = TimeHorizon.valueOf(timeHorizonName);
                th.setUTC(utc);

                if (th.equals(TimeHorizon.MINUTES_GROUPED) && granularity == -1) {
                    throw new InvalidConfigurationException(
                            "Unable to create Grouped Minutes Time Horizon without configuration of Granularity using notation MINUTES_GROUPED(<granularity in minutes>)");
                } else {
                    if (th.equals(TimeHorizon.MINUTES_GROUPED)) {
                        th.setGranularity(granularity);
                    }
                }
                model.addTimeHorizon(th);
            } catch (Exception e) {
                throw new Exception(String.format("Unable to configure Time Horizon %s", t), e);
            }
        }
    }
}

From source file:gov.nist.healthcare.ttt.webapp.common.controller.GetCCDADocumentsController.java

public String getLink(String[] path) {
    String link = String.join("/", path).replace(" ", "%20");
    link = "https://raw.githubusercontent.com/siteadmin/2015-Certification-C-CDA-Test-Data/master/" + link;
    return link;/*from ww w . j a v a 2s.  com*/
}

From source file:grakn.core.console.ConsoleSession.java

private static String readFile(Path filePath) throws IOException {
    List<String> lines = Files.readAllLines(filePath, StandardCharsets.UTF_8);
    return String.join("\n", lines);
}

From source file:org.wildfly.swarm.plugin.FractionMetadata.java

@JsonIgnore
public String getDependenciesString() {
    return String.join(", ",
            getFractionDependencies().stream().map(e -> e.toString()).collect(Collectors.toList()));
}

From source file:dpfmanager.shell.interfaces.gui.fragment.wizard.Wizard1Fragment.java

public void init() {
    List<String> errors = new ArrayList<>();

    // Internal/* w ww. j  a v a2  s  .  c om*/
    List<String> paths = ImplementationCheckerLoader.getPathsList();
    for (String path : paths) {
        if (ImplementationCheckerLoader.isValid(path)) {
            addInternalCheckBox(path);
        } else {
            errors.add(path.substring(path.indexOf("/") + 1, path.length() - 4));
        }
    }

    // User configs
    File folder = new File(DPFManagerProperties.getIsosDir());
    for (final File fileEntry : folder.listFiles()) {
        if (fileEntry.isFile()) {
            if (fileEntry.getName().toLowerCase().endsWith(".xml")) {
                if (ImplementationCheckerLoader.isValid(fileEntry.getName())) {
                    addConfigCheckBox(fileEntry, false);
                } else {
                    errors.add(fileEntry.getName());
                }
            }
        }
    }

    // Inform errors
    if (errors.size() == 1) {
        context.send(BasicConfig.MODULE_MESSAGE, new AlertMessage(AlertMessage.Type.ERROR,
                DPFManagerProperties.getBundle().getString("w1errorReadingIso").replace("%1", errors.get(0))));
    } else if (errors.size() > 1) {
        context.send(BasicConfig.MODULE_MESSAGE,
                new AlertMessage(AlertMessage.Type.ERROR,
                        DPFManagerProperties.getBundle().getString("w1errorReadingMultipleIso"),
                        String.join(", ", errors)));
    }
}

From source file:eu.mrbussy.pdfsplitter.Application.java

/**
 * Show specific version information (console)
 *///from w  w w .  ja  va2  s  .c o m
private static void showVersion() {
    System.out.println(String.format("%1s version %2s\n", Application.NAME, Application.VERSION));

    System.out.println(getShortLicenseText());
    System.out.println("\nWritten by " + String.join(", ", Application.AUTHORS));

    System.exit(0);
}

From source file:edu.washington.gs.skyline.model.quantification.FoldChangeDataSet.java

public String toString() {
    List<String> lines = new ArrayList<>();
    lines.add("Subject,Run,Feature,Abundance,Control");
    for (int i = 0; i < getRowCount(); i++) {
        lines.add(StringUtils.join(new Object[] { getSubject(i), getRun(i), getFeature(i), getAbundance(i),
                isRowInControlGroup(i) }, ','));
    }/*from  w  ww  .  j a va  2  s.c o m*/
    return String.join("\n", lines);
}

From source file:com.blackducksoftware.integration.hub.detect.detector.nuget.NugetInspectorExtractor.java

public Extraction extract(final File targetDirectory, File outputDirectory, NugetInspector inspector,
        final ExtractionId extractionId) {
    try {//from w  w w  .  jav a  2 s. c  o m

        final List<String> options = new ArrayList<>(
                Arrays.asList("--target_path=" + targetDirectory.toString(),
                        "--output_directory=" + outputDirectory.getCanonicalPath(),
                        "--ignore_failure=" + detectConfiguration.getBooleanProperty(
                                DetectProperty.DETECT_NUGET_IGNORE_FAILURE, PropertyAuthority.None)));

        final String nugetExcludedModules = detectConfiguration
                .getProperty(DetectProperty.DETECT_NUGET_EXCLUDED_MODULES, PropertyAuthority.None);
        if (StringUtils.isNotBlank(nugetExcludedModules)) {
            options.add("--excluded_modules=" + nugetExcludedModules);
        }
        final String nugetIncludedModules = detectConfiguration
                .getProperty(DetectProperty.DETECT_NUGET_INCLUDED_MODULES, PropertyAuthority.None);
        if (StringUtils.isNotBlank(nugetIncludedModules)) {
            options.add("--included_modules=" + nugetIncludedModules);
        }
        final String[] nugetPackagesRepo = detectConfiguration
                .getStringArrayProperty(DetectProperty.DETECT_NUGET_PACKAGES_REPO_URL, PropertyAuthority.None);
        if (nugetPackagesRepo.length > 0) {
            final String packagesRepos = Arrays.asList(nugetPackagesRepo).stream()
                    .collect(Collectors.joining(","));
            options.add("--packages_repo_url=" + packagesRepos);
        }
        final String nugetConfigPath = detectConfiguration.getProperty(DetectProperty.DETECT_NUGET_CONFIG_PATH,
                PropertyAuthority.None);
        if (StringUtils.isNotBlank(nugetConfigPath)) {
            options.add("--nuget_config_path=" + nugetConfigPath);
        }
        if (logger.isTraceEnabled()) {
            options.add("-v");
        }

        final ExecutableOutput executableOutput = inspector.execute(targetDirectory, options);

        if (executableOutput.getReturnCode() != 0) {
            return new Extraction.Builder()
                    .failure(String.format("Executing command '%s' returned a non-zero exit code %s",
                            String.join(" ", options), executableOutput.getReturnCode()))
                    .build();
        }

        final List<File> dependencyNodeFiles = detectFileFinder.findFiles(outputDirectory,
                INSPECTOR_OUTPUT_PATTERN);

        final List<NugetParseResult> parseResults = new ArrayList<>();
        for (final File dependencyNodeFile : dependencyNodeFiles) {
            final NugetParseResult result = nugetInspectorPackager.createDetectCodeLocation(dependencyNodeFile);
            parseResults.add(result);
        }

        final List<DetectCodeLocation> codeLocations = parseResults.stream()
                .flatMap(it -> it.codeLocations.stream()).collect(Collectors.toList());

        if (codeLocations.size() <= 0) {
            logger.warn("Unable to extract any dependencies from nuget");
        }

        final Map<String, DetectCodeLocation> codeLocationsBySource = new HashMap<>();
        final DependencyGraphCombiner combiner = new DependencyGraphCombiner();

        codeLocations.stream().forEach(codeLocation -> {
            final String sourcePathKey = codeLocation.getSourcePath().toLowerCase();
            if (codeLocationsBySource.containsKey(sourcePathKey)) {
                logger.info(
                        "Multiple project code locations were generated for: " + targetDirectory.toString());
                logger.info("This most likely means the same project exists in multiple solutions.");
                logger.info(
                        "The code location's dependencies will be combined, in the future they will exist seperately for each solution.");
                final DetectCodeLocation destination = codeLocationsBySource.get(sourcePathKey);
                combiner.addGraphAsChildrenToRoot((MutableDependencyGraph) destination.getDependencyGraph(),
                        codeLocation.getDependencyGraph());
            } else {
                codeLocationsBySource.put(sourcePathKey, codeLocation);
            }
        });

        final List<DetectCodeLocation> uniqueCodeLocations = codeLocationsBySource.values().stream()
                .collect(Collectors.toList());

        final Extraction.Builder builder = new Extraction.Builder().success(uniqueCodeLocations);
        final Optional<NugetParseResult> project = parseResults.stream()
                .filter(it -> StringUtils.isNotBlank(it.projectName)).findFirst();
        if (project.isPresent()) {
            builder.projectName(project.get().projectName);
            builder.projectVersion(project.get().projectVersion);
        }
        return builder.build();
    } catch (final Exception e) {
        return new Extraction.Builder().exception(e).build();
    }
}