Example usage for java.lang System lineSeparator

List of usage examples for java.lang System lineSeparator

Introduction

In this page you can find the example usage for java.lang System lineSeparator.

Prototype

String lineSeparator

To view the source code for java.lang System lineSeparator.

Click Source Link

Usage

From source file:com.igormaznitsa.jhexed.swing.editor.ui.exporters.JavaConstantExporter.java

private static void nextLine(final StringBuilder buffer) {
      buffer.append(System.lineSeparator());
  }

From source file:com.stratio.crossdata.sh.utils.ConsoleUtils.java

/**
 * Convert QueryResult {@link com.stratio.crossdata.common.result.QueryResult} structure to String.
 *
 * @param queryResult {@link com.stratio.crossdata.common.result.QueryResult} from execution.
 * @return String representing the result.
 *//*from  w  ww . ja v a  2  s  .c o m*/

private static String stringQueryResult(QueryResult queryResult) {
    if ((queryResult.getResultSet() == null) || queryResult.getResultSet().isEmpty()) {
        return System.lineSeparator() + "0 results returned";
    }

    ResultSet resultSet = queryResult.getResultSet();

    Map<String, Integer> colWidths = calculateColWidths(resultSet);

    String bar = StringUtils.repeat('-', getTotalWidth(colWidths) + (colWidths.values().size() * 3) + 1);

    StringBuilder sb = new StringBuilder(System.lineSeparator());
    sb.append("Partial result: ");
    sb.append(!queryResult.isLastResultSet());
    sb.append(System.lineSeparator());
    sb.append(bar).append(System.lineSeparator());
    sb.append("| ");
    List<String> columnNames = new ArrayList<>();
    for (ColumnMetadata columnMetadata : resultSet.getColumnMetadata()) {
        sb.append(StringUtils.rightPad(columnMetadata.getName().getColumnNameToShow(),
                colWidths.get(columnMetadata.getName().getColumnNameToShow()) + 1)).append("| ");
        columnNames.add(columnMetadata.getName().getColumnNameToShow());
    }

    sb.append(System.lineSeparator());
    sb.append(bar);
    sb.append(System.lineSeparator());

    for (Row row : resultSet) {
        sb.append("| ");
        for (String columnName : columnNames) {
            String str = String.valueOf(row.getCell(columnName.toLowerCase()).getValue());
            sb.append(StringUtils.rightPad(str, colWidths.get(columnName.toLowerCase())));
            sb.append(" | ");
        }
        sb.append(System.lineSeparator());
    }
    sb.append(bar).append(System.lineSeparator());
    return sb.toString();
}

From source file:net.di2e.ecdr.search.transform.atom.response.AtomResponseTransformer.java

@Override
public SourceResponse processSearchResponse(InputStream inputStream, QueryRequest request, String siteName) {
    List<Result> resultList = new ArrayList<Result>();

    ClassLoader tccl = Thread.currentThread().getContextClassLoader();
    Parser parser = null;/*  w ww. j a v  a 2  s. co  m*/
    Document<Feed> atomDoc;
    try {

        Thread.currentThread().setContextClassLoader(AtomResponseTransformer.class.getClassLoader());
        parser = ABDERA.getParser();
        if (LOGGER.isTraceEnabled()) {
            StringWriter writer = new StringWriter();
            try {
                IOUtils.copy(inputStream, writer);
                LOGGER.trace("Transforming the following atom feed into a DDF SourceResponse:{}{}",
                        System.lineSeparator(), writer);
                inputStream = IOUtils.toInputStream(writer.toString());
            } catch (IOException e) {
                LOGGER.trace("Could not print out atom stream for log: {}", e.getMessage());
            }
        }
        atomDoc = parser.parse(new InputStreamReader(inputStream));
    } finally {
        Thread.currentThread().setContextClassLoader(tccl);
    }

    Feed feed = atomDoc.getRoot();

    List<Entry> entries = feed.getEntries();
    int size = entries.size();
    for (Entry entry : entries) {
        if (isValidEntry(entry)) {
            Metacard metacard = entryToMetacard(entry, siteName);
            resultList.add(metacardToResult(entry, metacard));
        } else {
            LOGGER.debug("Skipping invalid entry: {}", entry);
            size--;
        }
    }

    long totalResults = size;
    Element totalResultsElement = atomDoc.getRoot().getExtension(OpenSearchConstants.TOTAL_RESULTS);

    if (totalResultsElement != null) {
        try {
            totalResults = Long.parseLong(totalResultsElement.getText());
        } catch (NumberFormatException e) {
            LOGGER.warn("Received invalid number of results from Atom response ["
                    + totalResultsElement.getText() + "]", e);
        }
    }

    Map<String, Serializable> responseProperties = null;

    return new SourceResponseImpl(request, responseProperties, resultList, totalResults);
}

From source file:com.semfapp.adamdilger.semf.SiteInstructionActivity.java

public void createPdf() {
    Document documentTemplate = Pdf.getTemplate(getApplicationContext(), data.getJobNumber());
    try {/*from  www  . ja va2  s.c om*/
        Document body = Jsoup.parse(getAssets().open("siteInstruction.html"), "utf-8",
                "http://www.example.com");

        Element site = body.getElementById("site");
        Element siteLocation = body.getElementById("site_location");
        Element recipient = body.getElementById("recipient");
        Element recipientEmail = body.getElementById("recipient_email");
        Element description = body.getElementById("description_list");

        String[] descriptionArray;
        descriptionArray = data.getDescription().split(System.lineSeparator());

        site.text(data.getSite());
        siteLocation.text(data.getLocation());
        recipient.html("<p>" + data.getRecipient() + "</p>");
        recipientEmail.html("<p>" + data.getRecipientEmail() + "</p>");

        //add each bullet from arrays as a <p>
        for (int x = 0; x < descriptionArray.length; x++) {
            String f = "";

            for (String bullet : descriptionArray) {
                f += "<p>" + bullet + "</p>";
            }

            description.html(f);
        }

        documentTemplate.getElementById("main").html(body.html());
    } catch (Exception e) {
        System.out.println("ERROR: " + e.toString());
    }

    name = Emailer.getSubject(Emailer.SITE_INSTRUCTION_CODE, data.getJobNumber());
    String filePath = MainActivity.pdf.createFilePath(this, name);

    MainActivity.pdf.createPdfToFile(this, documentTemplate.html(), filePath, data.getImageArray());

    pdfAttatchment = new File(filePath);
}

From source file:org.cloudml.connectors.CloudSigmaConnector.java

private String readSshKey(String keyPath) {
    BufferedReader br;//from  ww  w .j a  v  a  2 s . c  o  m
    String key = "";
    try {
        br = new BufferedReader(new FileReader(keyPath));
        StringBuilder sb = new StringBuilder();
        String line = br.readLine();

        while (line != null) {
            sb.append(line);
            sb.append(System.lineSeparator());
            line = br.readLine();
        }
        key = sb.toString();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return key;
}

From source file:com.adguard.android.contentblocker.preferences.PreferenceDb.java

private void refreshItems() {
    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    for (PreferenceItem item : itemsList) {
        if (item.value instanceof Boolean) {
            item.value = prefs.getBoolean(item.name, (Boolean) item.value);
        } else if (item.value instanceof Integer) {
            item.value = prefs.getInt(item.name, (Integer) item.value);
        } else if (item.value instanceof String) {
            item.value = prefs.getString(item.name, (String) item.value);
        } else if (item.value instanceof String[]) {
            item.value = StringUtils.split(prefs.getString(item.name, (String) item.value),
                    System.lineSeparator());
        }//from   w  w  w.ja  va  2s  .c  om
    }
}

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

public List<MavenParseResult> extractCodeLocations(final String sourcePath, final String mavenOutputText,
        final String targetScope, final String excludedModules, final String includedModules) {
    final ExcludedIncludedFilter filter = new ExcludedIncludedFilter(excludedModules, includedModules);
    codeLocations = new ArrayList<>();
    currentMavenProject = null;//from  w w  w .  j  ava  2 s . com
    dependencyParentStack = new Stack<>();
    parsingProjectSection = false;
    currentGraph = new MutableMapDependencyGraph();

    level = 0;
    for (final String currentLine : mavenOutputText.split(System.lineSeparator())) {
        String line = currentLine.trim();
        if (!isLineRelevant(line)) {
            continue;
        }
        line = trimLogLevel(line);
        if (StringUtils.isBlank(line)) {
            continue;
        }
        if (isProjectSection(line)) {
            parsingProjectSection = true;
            continue;
        }
        if (!parsingProjectSection) {
            continue;
        }
        if (isDependencyTreeUpdates(line)) {
            continue;
        }

        if (parsingProjectSection && currentMavenProject == null) {
            // this is the first line of a new code location, the following lines will be the tree of dependencies for this code location
            currentGraph = new MutableMapDependencyGraph();
            final MavenParseResult mavenProject = createMavenParseResult(sourcePath, line, currentGraph);
            if (null != mavenProject && filter.shouldInclude(mavenProject.projectName)) {
                logger.trace(String.format("Project: %s", mavenProject.projectName));
                this.currentMavenProject = mavenProject;
                codeLocations.add(mavenProject);
            } else {
                logger.trace("Project: unknown");
                currentMavenProject = null;
                dependencyParentStack.clear();
                parsingProjectSection = false;
                level = 0;
            }
            continue;
        }

        final boolean finished = line.contains("--------");
        if (finished) {
            currentMavenProject = null;
            dependencyParentStack.clear();
            parsingProjectSection = false;
            level = 0;
            continue;
        }

        final int previousLevel = level;
        final String cleanedLine = calculateCurrentLevelAndCleanLine(line);
        final ScopedDependency dependency = textToDependency(cleanedLine);
        if (null == dependency) {
            continue;
        }
        if (currentMavenProject != null) {
            if (level == 1) {
                // a direct dependency, clear the stack and add this as a potential parent for the next line
                if (dependency.isInScope(targetScope)) {
                    logger.trace(String.format(
                            "Level 1 component %s:%s:%s:%s is in scope; adding it to hierarchy root",
                            dependency.externalId.group, dependency.externalId.name,
                            dependency.externalId.version, dependency.scope));
                    currentGraph.addChildToRoot(dependency);
                    inOutOfScopeTree = false;
                } else {
                    logger.trace(String.format(
                            "Level 1 component %s:%s:%s:%s is a top-level out-of-scope component; entering non-scoped tree",
                            dependency.externalId.group, dependency.externalId.name,
                            dependency.externalId.version, dependency.scope));
                    inOutOfScopeTree = true;
                }
                dependencyParentStack.clear();
                dependencyParentStack.push(dependency);
            } else {
                // level should be greater than 1
                if (level == previousLevel) {
                    // a sibling of the previous dependency
                    dependencyParentStack.pop();
                    addDependencyIfInScope(currentGraph, orphans, targetScope, inOutOfScopeTree,
                            dependencyParentStack.peek(), dependency);
                    dependencyParentStack.push(dependency);
                } else if (level > previousLevel) {
                    // a child of the previous dependency
                    addDependencyIfInScope(currentGraph, orphans, targetScope, inOutOfScopeTree,
                            dependencyParentStack.peek(), dependency);
                    dependencyParentStack.push(dependency);
                } else {
                    // a child of a dependency further back than 1 line
                    for (int i = previousLevel; i >= level; i--) {
                        dependencyParentStack.pop();
                    }
                    addDependencyIfInScope(currentGraph, orphans, targetScope, inOutOfScopeTree,
                            dependencyParentStack.peek(), dependency);
                    dependencyParentStack.push(dependency);
                }
            }
        }
    }
    addOrphansToGraph(currentGraph, orphans);

    return codeLocations;
}

From source file:com.hp.mqm.atrf.App.java

private void getCreationStatus(List<OctaneTestResultOutput> resultOutputs) {
    logger.info(System.lineSeparator());
    logger.info("PHASE : get creation statuses");
    sleep(10 * 1000);//wait at least 5 sec before to give time to octane to complete the creation
    for (int i = 0; i < resultOutputs.size(); i++) {
        OctaneTestResultOutput current = resultOutputs.get(i);
        getCreationStatusInternal(configuration, i + 1, current);
    }/*www  .j a  v a  2 s .  c  om*/
}

From source file:com.sdl.odata.client.caller.BasicEndpointCallerTest.java

@Test
public void getInputStream() throws ODataClientException, IOException {
    URL url = new URL(basePath + RESPONSE);
    InputStream stream = caller.getInputStream(singletonMap("Accept", JSON.getType()), url);
    StringBuilder sb = new StringBuilder();
    try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream))) {
        String line;//from   ww  w .ja v  a 2s .co  m
        while ((line = reader.readLine()) != null) {
            sb.append(line).append(System.lineSeparator());
        }
    }
    assertThat(sb.toString(), equalTo(URLTestUtils.loadTextFile(RESPONSE)));
}

From source file:io.cloudslang.lang.compiler.modeller.model.Metadata.java

private static void appendString(StringBuilder stringBuilder, String fieldValue, String spacing)
        throws IOException {
    List<String> lines = IOUtils.readLines(new StringReader(fieldValue));
    if (lines.size() > 1) {
        stringBuilder.append(System.lineSeparator());
        for (String line : lines) {
            stringBuilder.append(spacing).append(line).append(System.lineSeparator());
        }/*  ww w  .  j  a  v a 2 s . c  o m*/
    } else {
        stringBuilder.append(fieldValue).append(System.lineSeparator());
    }
}