Example usage for org.apache.commons.lang SystemUtils LINE_SEPARATOR

List of usage examples for org.apache.commons.lang SystemUtils LINE_SEPARATOR

Introduction

In this page you can find the example usage for org.apache.commons.lang SystemUtils LINE_SEPARATOR.

Prototype

String LINE_SEPARATOR

To view the source code for org.apache.commons.lang SystemUtils LINE_SEPARATOR.

Click Source Link

Document

The line.separator System Property.

Usage

From source file:org.sonar.plugins.scmactivity.LocalModificationChecker.java

void doCheck() {
    TimeProfiler profiler = new TimeProfiler().start("Check for local modifications");
    try {//from  w  w  w .j  av  a 2  s.  com
        for (File sourceDir : config.getSourceDirs()) {
            // limitation of http://jira.codehaus.org/browse/SONAR-2266, the directory existence must be checked
            if (sourceDir.exists()) {
                LoggerFactory.getLogger(getClass()).debug("Check directory: " + sourceDir);
                StatusScmResult result = manager.status(repository.getScmRepository(),
                        new ScmFileSet(sourceDir));

                if (!result.isSuccess()) {
                    throw new SonarException(
                            "Unable to check for local modifications: " + result.getProviderMessage());
                }

                if (!result.getChangedFiles().isEmpty()) {
                    Joiner joiner = Joiner.on(SystemUtils.LINE_SEPARATOR + "\t");
                    throw new SonarException("Fail to load SCM data as there are local modifications: "
                            + SystemUtils.LINE_SEPARATOR + "\t" + joiner.join(result.getChangedFiles()));
                }
            }
        }

    } catch (ScmException e) {
        throw new SonarException("Unable to check for local modifications", e);

    } finally {
        profiler.stop();
    }
}

From source file:org.sonar.server.debt.DebtModelXMLExporterTest.java

@Test
public void export_empty() {
    assertThat(underTest.export(Collections.emptyList())).isEqualTo("<sqale/>" + SystemUtils.LINE_SEPARATOR);
}

From source file:org.sonar.server.debt.DebtModelXMLExporterTest.java

@Test
public void pretty_print_exported_xml() {
    List<RuleDebt> rules = newArrayList(new RuleDebt().setRuleKey(RuleKey.of("checkstyle", "Regexp"))
            .setFunction(DebtRemediationFunction.Type.LINEAR.name()).setCoefficient("3d"));
    assertThat(underTest.export(rules)).isEqualTo("<sqale>" + SystemUtils.LINE_SEPARATOR + "  <chc>"
            + SystemUtils.LINE_SEPARATOR + "    <rule-repo>checkstyle</rule-repo>" + SystemUtils.LINE_SEPARATOR
            + "    <rule-key>Regexp</rule-key>" + SystemUtils.LINE_SEPARATOR + "    <prop>"
            + SystemUtils.LINE_SEPARATOR + "      <key>remediationFunction</key>" + SystemUtils.LINE_SEPARATOR
            + "      <txt>LINEAR</txt>" + SystemUtils.LINE_SEPARATOR + "    </prop>"
            + SystemUtils.LINE_SEPARATOR + "    <prop>" + SystemUtils.LINE_SEPARATOR
            + "      <key>remediationFactor</key>" + SystemUtils.LINE_SEPARATOR + "      <val>3</val>"
            + SystemUtils.LINE_SEPARATOR + "      <txt>d</txt>" + SystemUtils.LINE_SEPARATOR + "    </prop>"
            + SystemUtils.LINE_SEPARATOR + "  </chc>" + SystemUtils.LINE_SEPARATOR + "</sqale>"
            + SystemUtils.LINE_SEPARATOR);
}

From source file:org.sonar.server.measure.MeasureFilterEngine.java

private String log(MeasureFilterContext context, MeasureFilterResult result) {
    StringBuilder log = new StringBuilder();
    log.append(SystemUtils.LINE_SEPARATOR);
    log.append("request: ").append(context.getData()).append(SystemUtils.LINE_SEPARATOR);
    log.append(" result: ").append(result.toString());
    return log.toString();
}

From source file:org.spiffyui.maven.plugins.GwtCompileMojo.java

private int getLocalWorkers() {
    if (localWorkers > 0) {
        return localWorkers;
    }//from   ww  w. j  a  v a 2  s.c  o  m
    // workaround to GWT issue 4031 whith IBM JDK
    // @see
    // http://code.google.com/p/google-web-toolkit/issues/detail?id=4031
    if (System.getProperty("java.vendor").startsWith("IBM")) {
        StringBuilder sb = new StringBuilder("Build is using IBM JDK, localWorkers set to 1 as a workaround");
        sb.append(SystemUtils.LINE_SEPARATOR);
        sb.append("see http://code.google.com/p/google-web-toolkit/issues/detail?id=4031");
        getLog().info(sb.toString());
        return 1;
    }
    return Runtime.getRuntime().availableProcessors();
}

From source file:phex.gui.dialogs.AboutDialog.java

/**
 * //from  ww w .  j  a v  a2  s .  co m
 */
private void prepareComponent() {
    CloseEventHandler closeEventHandler = new CloseEventHandler();
    addWindowListener(closeEventHandler);

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    JPanel contentPanel = new JPanel();
    //JPanel contentPanel = new FormDebugPanel();
    contentPane.add(contentPanel, BorderLayout.CENTER);

    CellConstraints cc = new CellConstraints();
    FormLayout layout = new FormLayout("4dlu, fill:d:grow, 4dlu", // columns
            "p, p, 2dlu, p, 4dlu, p, 4dlu"); //row
    PanelBuilder contentPB = new PanelBuilder(layout, contentPanel);

    Object[] objArr = { PrivateNetworkConstants.PRIVATE_BUILD_ID + VersionUtils.getProgramVersion(),
            VersionUtils.getBuild() };
    DialogBanner banner = new DialogBanner("Phex",
            Localizer.getFormatedString("AboutPhex_VersionInfo", objArr));
    contentPB.add(banner, cc.xywh(1, 1, 3, 1));

    contentPB.add(new JSeparator(), cc.xywh(1, 2, 3, 1));

    JTabbedPane tabbedPane = new JTabbedPane();
    contentPB.add(tabbedPane, cc.xy(2, 4));

    JButton closeBtn = new JButton(Localizer.getString("Close"));
    closeBtn.addActionListener(closeEventHandler);
    contentPB.add(ButtonBarFactory.buildCloseBar(closeBtn), cc.xy(2, 6));

    JPanel aboutPanel = new JPanel();
    layout = new FormLayout("4dlu, fill:d:grow, 4dlu", // columns
            "4dlu, p, 4dlu"); //row
    PanelBuilder aboutPB = new PanelBuilder(layout, aboutPanel);
    tabbedPane.addTab(Localizer.getString("AboutPhex_About"), aboutPanel);

    Object[] objArr2 = { Res.getStr("Program.Url") };
    HTMLMultiLinePanel aboutHtml = new HTMLMultiLinePanel(
            Localizer.getFormatedString("AboutPhex_AboutText", objArr2));
    aboutPB.add(aboutHtml, cc.xy(2, 2));

    JPanel envPanel = new JPanel();
    layout = new FormLayout("2dlu, fill:d:grow, 2dlu", // columns
            "2dlu, p, 2dlu, p, 2dlu"); //row
    PanelBuilder envPB = new PanelBuilder(layout, envPanel);
    tabbedPane.addTab(Localizer.getString("AboutPhex_Environment"), envPanel);

    environmentInfo = new JTextArea(12, 55);
    environmentInfo.setEditable(false);
    envPB.add(new JScrollPane(environmentInfo), cc.xy(2, 2));

    StringBuffer envTextBuffer = new StringBuffer();
    Properties pros = System.getProperties();
    ArrayList<String> list = new ArrayList(pros.keySet());
    Collections.sort(list);
    Iterator<String> iterator = list.iterator();
    while (iterator.hasNext()) {
        String key = iterator.next();
        String value = (String) pros.get(key);
        envTextBuffer.append(key).append(" = ").append(value).append(SystemUtils.LINE_SEPARATOR);
    }
    environmentInfo.setText(envTextBuffer.toString());
    environmentInfo.setCaretPosition(0);

    JButton copyBtn = new JButton(Localizer.getString("Copy"));
    copyBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Toolkit.getDefaultToolkit().getSystemClipboard()
                    .setContents(new StringSelection(environmentInfo.getText()), null);
        }
    });
    envPB.add(ButtonBarFactory.buildLeftAlignedBar(copyBtn), cc.xy(2, 4));

    pack();
    setLocationRelativeTo(getParent());
}

From source file:phex.gui.dialogs.LogBufferDialog.java

/**
 * /*from w w w .j  a  v a 2s.c  o  m*/
 */
private void prepareComponent() {
    CloseEventHandler closeEventHandler = new CloseEventHandler();
    addWindowListener(closeEventHandler);

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    JPanel contentPanel = new JPanel();
    //JPanel contentPanel = new FormDebugPanel();
    contentPane.add(contentPanel, BorderLayout.CENTER);

    CellConstraints cc = new CellConstraints();
    FormLayout layout = new FormLayout("4dlu, fill:d:grow, 4dlu", // columns
            "p, p, 2dlu, fill:p:grow, 4dlu, p, 4dlu"); //row
    PanelBuilder contentPB = new PanelBuilder(layout, contentPanel);

    DialogBanner banner = new DialogBanner(Localizer.getString("LogBufferDialog_Log"),
            Localizer.getString("LogBufferDialog_DisplayLog"));
    contentPB.add(banner, cc.xywh(1, 1, 3, 1));

    contentPB.add(new JSeparator(), cc.xywh(1, 2, 3, 1));

    JTextArea logArea = new JTextArea(40, 100);
    logArea.setEditable(false);
    contentPB.add(new JScrollPane(logArea), cc.xy(2, 4));

    JButton closeBtn = new JButton(Localizer.getString("Close"));
    closeBtn.addActionListener(closeEventHandler);
    contentPB.add(ButtonBarFactory.buildCloseBar(closeBtn), cc.xy(2, 6));

    StringBuffer textBuffer = new StringBuffer();
    Iterator iterator = logEntries.iterator();
    while (iterator.hasNext()) {
        LogRecord record = (LogRecord) iterator.next();
        textBuffer.append(dateFormat.format(new Date(record.getTimestamp()))).append("::")
                .append(record.getMessage()).append(SystemUtils.LINE_SEPARATOR);
    }
    logArea.setText(textBuffer.toString());
    //logArea.setCaretPosition(0);

    pack();
    setLocationRelativeTo(getParent());
}

From source file:phex.query.QueryMsgToWriterMonitor.java

public void onMessage(QueryMsg query, Host sourceHost) {
    String searchString = query.getSearchString();
    if (searchString.length() > 0 && !searchString.equals("\\") && !searchString.startsWith("urn:sha1:")) {
        synchronized (this) {
            try {
                outputWriter.write(query.getSearchString());
                /*outputWriter.write( query.getSearchString() + "\t" +
                query.getHeader().getHopsTaken() + "\t" +
                query.getHeader().getTTL() + "\t");
                URN[] urns = query.getQueryURNs();
                for ( int i = 0; i < urns.length; i++ )
                {//from   ww w.  ja v  a2 s.  c  om
                if ( urns[i].isSha1Nid() )
                {
                    outputWriter.write( urns[i].getAsString() );
                    break;
                }
                }*/
                outputWriter.write(SystemUtils.LINE_SEPARATOR);
            } catch (IOException exp) {
                //                    NLogger.error( QueryMsgToWriterMonitor.class, 
                //                        exp.getMessage(), exp );
                outputWriter = null;
            }
        }
    }
}

From source file:pl.wroc.pwr.jbehaveplugin.editor.JBehaveContentAssistProcessor.java

@Override
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
    List<ICompletionProposal> result = new ArrayList<ICompletionProposal>();
    try {/*from   w  ww. j  a  v  a2  s  .  c om*/
        IDocument document = viewer.getDocument();
        ITypedRegion region = document.getPartition(offset);
        int partitionOffset = region.getOffset();
        int partitionLength = region.getLength();
        int index = offset - partitionOffset;

        String partitionText = document.get(partitionOffset, partitionLength);

        StyledText widget = viewer.getTextWidget();
        final int lineNo = widget.getLineAtOffset(region.getOffset());
        final int lineOffset = widget.getOffsetAtLine(lineNo);

        // TODO add support for multi-line step
        final String stepStart = partitionText.substring(0, widget.getCaretOffset());
        int lastLineBreakIndex = stepStart.lastIndexOf("\n") + 1;
        final String extractedStep = partitionText.substring(lastLineBreakIndex);

        IProject project = ((ExtendedFastPartitioner) viewer.getDocument().getDocumentPartitioner())
                .getProject();
        JavaAnalyzer analyzer = new JavaAnalyzer();
        analyzer.collectTypes(project);
        List<IAnnotation> jBehaveAnnotations = analyzer.getJBehaveAnnotations();

        String completedStep = extractedStep.split(" ")[0];

        if ("And".equals(completedStep)) {
            String substring = partitionText.substring(0, lastLineBreakIndex - 1);
            int i = substring.lastIndexOf("\n") + 1;
            String lastLine = substring.substring(i);
            completedStep = lastLine.split(" ")[0];
        }
        for (IAnnotation annotation : jBehaveAnnotations) {
            if (annotation.getElementName().equals(completedStep)) {
                String annotationText = annotation.getMemberValuePairs()[0].getValue().toString();
                String typedTextInEditor = extractedStep.substring(extractedStep.indexOf(' ') + 1,
                        extractedStep.indexOf("\n") == -1 ? extractedStep.length()
                                : extractedStep.indexOf(SystemUtils.LINE_SEPARATOR));
                if (annotationText.startsWith(typedTextInEditor)) {
                    int off = typedTextInEditor.length() == 0 ? 0 : typedTextInEditor.length();
                    CompletionProposal proposal = new CompletionProposal(
                            annotation.getMemberValuePairs()[0].getValue().toString().substring(off),
                            widget.getCaretOffset(), 0, widget.getCaretOffset());
                    result.add(proposal);
                }
            }
        }

    } catch (Exception e) {
        return null;
    }
    return result.toArray(new ICompletionProposal[0]);
}

From source file:pl.wroc.pwr.jbehaveplugin.storytemplate.StoryTemplateWizard.java

/**
 * We will initialize file contents with a sample text.
 *///from   w w w.  j  a  v a 2 s. c  om

private InputStream openContentStream() {
    String contents = "Given a calculator" + SystemUtils.LINE_SEPARATOR + "When i add $variable1 to $variable2"
            + SystemUtils.LINE_SEPARATOR + "Then the result should be $expected";
    return new ByteArrayInputStream(contents.getBytes());
}