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.olamy.puzzle.robot.input.cli.RobotMoverInputBuilderCli.java

@Override
public RobotMoverInput getRobotMoverInput() throws RobotMoverInputException {
    try {/*from w ww.  j  a  va  2 s  .  com*/
        Console console = System.console();
        PrintWriter writer = console.writer();
        writer.write("Hello in robot mover, have Fun ! " + SystemUtils.LINE_SEPARATOR);
        // so we could accept the user to configure the size of the table
        /**
         writer.write( "Initial Table (sample 5 5) : " );
         console.flush();
         String tablePos = console.readLine();
         Table table = RobotOrderUtils.buildTable( tablePos );
         */
        RobotMoverInput moverInput = new RobotMoverInput(Table.DEFAULT_TABLE);

        moverInput.setRobotOrder(getRobotOrder(console, writer, moverInput.getTable()));

        return moverInput;
    } catch (Exception e) {
        throw new RobotMoverInputException(e.getMessage(), e);
    }
}

From source file:org.olamy.puzzle.robot.input.cli.RobotMoverInputBuilderCli.java

private RobotOrder getRobotOrder(Console console, PrintWriter writer, Table table)
        throws UnknownOrientationException, OutOfTableException {
    writer.write("Robot start position and orientation (sample PLACE 1,2,EAST ) : ");
    console.flush();/*from  ww  w .  j ava 2  s. c  om*/
    String robotStart = console.readLine();
    RobotOrder robotOrder = RobotOrderUtils.buildRobotOrderStart(robotStart, table);

    writer.write("Robot orders (sample RIGHT, LEFT, MOVE, REPORT ) (end input with empty line) : "
            + SystemUtils.LINE_SEPARATOR);
    console.flush();
    return robotOrder.setOrders(readOrders(console, writer));
}

From source file:org.openlegacy.designtime.generators.GenerateUtil.java

public static void replicateTemplate(File file, Object model, String placeHolderStart, String placeHolderEnd,
        String existingCodeplaceHolderStart, String existingCodePlaceHolderEnd) {
    try {//  w  w  w  .ja  va  2  s  .  co  m
        StringBuilder fileContent = new StringBuilder(FileUtils.readFileToString(file));

        int placeHolderReplaceMarkerStart = fileContent.indexOf(existingCodeplaceHolderStart) - 1;
        int placeHolderReplaceMarkerEnd = fileContent.indexOf(existingCodePlaceHolderEnd)
                + existingCodePlaceHolderEnd.length();

        if (placeHolderReplaceMarkerStart > 0 && placeHolderReplaceMarkerStart > 0) {
            fileContent.delete(placeHolderReplaceMarkerStart, placeHolderReplaceMarkerEnd);
        }

        int templateMarkerStart = fileContent.indexOf(placeHolderStart);
        int templateMarkerEnd = fileContent.indexOf(placeHolderEnd) - 2;

        if (templateMarkerStart < 0 || templateMarkerEnd < 0) {
            return;
        }
        // replace tokens within the place holder tag
        String definitionTemplate = fileContent.substring(templateMarkerStart + placeHolderStart.length(),
                templateMarkerEnd);

        String definitionTemplateNew = generate(model, new StringReader(definitionTemplate));
        fileContent = fileContent.insert(templateMarkerStart,
                MessageFormat.format("{0}{1}{2}{3}", existingCodeplaceHolderStart, definitionTemplateNew,
                        existingCodePlaceHolderEnd, SystemUtils.LINE_SEPARATOR));

        FileUtils.write(file, fileContent);

    } catch (IOException e) {
        throw (new GenerationException(e));
    }
}

From source file:org.openlegacy.designtime.terminal.analyzer.modules.table.TableColumnFact.java

@Override
public String toString() {
    StringBuilder sb = new StringBuilder();
    for (TerminalField terminalField : fields) {
        sb.append(terminalField);/*w  w  w .  j a  v  a  2s . c o  m*/
        sb.append(SystemUtils.LINE_SEPARATOR);
    }
    return sb.toString();
}

From source file:org.openlegacy.terminal.render.DefaultRpcImageRenderer.java

private void drawText(String source, Graphics graphics) {
    String newline = SystemUtils.LINE_SEPARATOR;

    String[] lines = source.split(newline);
    int rowNumber = 1;
    graphics.setColor(imageBackgroundColor);
    for (String line : lines) {
        int startY = toHeight(rowNumber);

        if (drawLineNumbers) {
            // draw row number
            graphics.setColor(imageSorroundingTextColor);
            graphics.drawString(String.valueOf(String.format("%2d", rowNumber)), 0, startY);
        }/*from   www  .  j a  va 2s .  c  o  m*/

        line = line.replaceAll("\t", "  ");
        graphics.drawString(line, 100, startY);
        rowNumber++;
    }
}

From source file:org.openlegacy.terminal.render.DefaultTerminalSnapshotTextRenderer.java

@Override
public void render(TerminalSnapshot terminalSnapshot, OutputStream outputStream) {
    boolean decorated = true;

    String text = terminalSnapshot.getText();
    String newline = SystemUtils.LINE_SEPARATOR;
    int rows = terminalSnapshot.getSize().getRows();
    StringBuilder out = new StringBuilder();
    if (decorated) {
        generateColumnNumbers(terminalSnapshot, newline, out);
    }/*from   ww  w.j a  v  a2s . co  m*/
    for (int i = 0; i < rows; i++) {
        int beginIndex = i * terminalSnapshot.getSize().getColumns();
        if (decorated) {
            out.append(i + 1);
            if (decorated) {
                if ((i + 1) < 10) {
                    out.append(" ");
                }
                out.append("|");
            }
        }
        if (decorated) {
            out.append(text.substring(beginIndex, beginIndex + terminalSnapshot.getSize().getColumns()));
            out.append("|");
        }
        out.append(newline);
    }
    if (decorated) {
        out.append("___________________________________________________________________________________");
    }
    if (decorated) {
        out.append(newline);
        generateColumnNumbers(terminalSnapshot, newline, out);
    }

    drawFieldsSeperators(terminalSnapshot, out);
    drawEditableFields(terminalSnapshot, out,
            FieldsQuery.queryFields(terminalSnapshot, EditableFieldsCriteria.instance()));

    try {
        // append new line so snapshot will be rendered from start of line in logs
        outputStream.write(SystemUtils.LINE_SEPARATOR.getBytes());
        outputStream.write(out.toString().getBytes(CharEncoding.UTF_8));
    } catch (IOException e) {
        throw (new OpenLegacyRuntimeException(e));
    }

}

From source file:org.openlegacy.terminal.render.DefaultTerminalSnapshotTextRenderer.java

private static int calculatePositionOnPainter(TerminalPosition position, ScreenSize screenSize) {
    int fieldStartBufferLocation = (screenSize.getColumns() + 4 + SystemUtils.LINE_SEPARATOR.length()) // 6- line numbers + |
            // + NL
            // -1 - 0 base, +3 - header
            * (position.getRow() - 1 + 3) + position.getColumn() - 1;
    return fieldStartBufferLocation;
}

From source file:org.openlegacy.terminal.support.SnapshotUtils.java

public static String getRenderedText(TerminalSnapshot snapshot, TerminalPosition startPosition,
        TerminalPosition endPosition) {// w ww.j  a  v  a2 s  .  c o  m
    int beginIndex = ((startPosition.getRow() - 1) * snapshot.getSize().getColumns())
            + (startPosition.getColumn() - 1);
    int rows = endPosition.getRow() - startPosition.getRow() + 1;
    int length = endPosition.getColumn() - startPosition.getColumn() + 1;
    StringBuilder sb = new StringBuilder();
    String snapshotText = snapshot.getText();
    if (StringUtils.isEmpty(snapshotText)) {
        return sb.toString();
    }
    for (int i = 0; i < rows; i++) {
        if ((snapshotText.length() < beginIndex) || (snapshotText.length() < (beginIndex + length))) {
            return sb.toString();
        }
        String text = snapshotText.substring(beginIndex, beginIndex + length);
        sb.append(text);
        if ((i + 1) < rows) {
            sb.append(SystemUtils.LINE_SEPARATOR);
        }
        beginIndex += snapshot.getSize().getColumns();
    }
    return sb.toString();
}

From source file:org.openmicroscopy.shoola.util.ui.omeeditpane.OMEWikiComponent.java

/**
 * Replaces the line separator by space when saving the data.
 * //from  ww w. j  ava2  s .c o  m
 * @param value       The value to handle.
 * @param removeSpace    Pass <code>true</code> to remove the spaces,
 *                   <code>false</code> otherwise.
 * @return See above.
 */
public static String prepare(String value, boolean removeSpace) {
    String v = value.replaceAll(SystemUtils.LINE_SEPARATOR, " ");
    if (removeSpace)
        return v.replaceAll(" ", "");
    return v;
}

From source file:org.pentaho.di.trans.steps.excelinput.ExcelInputMetaTest.java

@Test
public void testGetXML() throws KettleException {
    Assert.assertEquals("    <header>N</header>" + SystemUtils.LINE_SEPARATOR + "    <noempty>N</noempty>"
            + SystemUtils.LINE_SEPARATOR + "    <stoponempty>N</stoponempty>" + SystemUtils.LINE_SEPARATOR
            + "    <filefield/>" + SystemUtils.LINE_SEPARATOR + "    <sheetfield/>" + SystemUtils.LINE_SEPARATOR
            + "    <sheetrownumfield/>" + SystemUtils.LINE_SEPARATOR + "    <rownumfield/>"
            + SystemUtils.LINE_SEPARATOR + "    <sheetfield/>" + SystemUtils.LINE_SEPARATOR + "    <filefield/>"
            + SystemUtils.LINE_SEPARATOR + "    <limit>0</limit>" + SystemUtils.LINE_SEPARATOR
            + "    <encoding/>" + SystemUtils.LINE_SEPARATOR
            + "    <add_to_result_filenames>N</add_to_result_filenames>" + SystemUtils.LINE_SEPARATOR
            + "    <accept_filenames>N</accept_filenames>" + SystemUtils.LINE_SEPARATOR + "    <accept_field/>"
            + SystemUtils.LINE_SEPARATOR + "    <accept_stepname/>" + SystemUtils.LINE_SEPARATOR + "    <file>"
            + SystemUtils.LINE_SEPARATOR + "      <name>1</name>" + SystemUtils.LINE_SEPARATOR
            + "      <filemask/>" + SystemUtils.LINE_SEPARATOR + "      <exclude_filemask/>"
            + SystemUtils.LINE_SEPARATOR + "      <file_required/>" + SystemUtils.LINE_SEPARATOR
            + "      <include_subfolders/>" + SystemUtils.LINE_SEPARATOR + "      <name>2</name>"
            + SystemUtils.LINE_SEPARATOR + "      <filemask/>" + SystemUtils.LINE_SEPARATOR
            + "      <exclude_filemask/>" + SystemUtils.LINE_SEPARATOR + "      <file_required/>"
            + SystemUtils.LINE_SEPARATOR + "      <include_subfolders/>" + SystemUtils.LINE_SEPARATOR
            + "      <name>3</name>" + SystemUtils.LINE_SEPARATOR + "      <filemask/>"
            + SystemUtils.LINE_SEPARATOR + "      <exclude_filemask/>" + SystemUtils.LINE_SEPARATOR
            + "      <file_required/>" + SystemUtils.LINE_SEPARATOR + "      <include_subfolders/>"
            + SystemUtils.LINE_SEPARATOR + "    </file>" + SystemUtils.LINE_SEPARATOR + "    <fields>"
            + SystemUtils.LINE_SEPARATOR + "      <field>" + SystemUtils.LINE_SEPARATOR
            + "        <name>1</name>" + SystemUtils.LINE_SEPARATOR + "        <type>String</type>"
            + SystemUtils.LINE_SEPARATOR + "        <length>1</length>" + SystemUtils.LINE_SEPARATOR
            + "        <precision>-1</precision>" + SystemUtils.LINE_SEPARATOR
            + "        <trim_type>none</trim_type>" + SystemUtils.LINE_SEPARATOR + "        <repeat>N</repeat>"
            + SystemUtils.LINE_SEPARATOR + "        <format/>" + SystemUtils.LINE_SEPARATOR
            + "        <currency/>" + SystemUtils.LINE_SEPARATOR + "        <decimal/>"
            + SystemUtils.LINE_SEPARATOR + "        <group/>" + SystemUtils.LINE_SEPARATOR + "      </field>"
            + SystemUtils.LINE_SEPARATOR + "      <field>" + SystemUtils.LINE_SEPARATOR
            + "        <name>2</name>" + SystemUtils.LINE_SEPARATOR + "        <type>String</type>"
            + SystemUtils.LINE_SEPARATOR + "        <length>2</length>" + SystemUtils.LINE_SEPARATOR
            + "        <precision>-1</precision>" + SystemUtils.LINE_SEPARATOR
            + "        <trim_type>none</trim_type>" + SystemUtils.LINE_SEPARATOR + "        <repeat>N</repeat>"
            + SystemUtils.LINE_SEPARATOR + "        <format/>" + SystemUtils.LINE_SEPARATOR
            + "        <currency/>" + SystemUtils.LINE_SEPARATOR + "        <decimal/>"
            + SystemUtils.LINE_SEPARATOR + "        <group/>" + SystemUtils.LINE_SEPARATOR + "      </field>"
            + SystemUtils.LINE_SEPARATOR + "    </fields>" + SystemUtils.LINE_SEPARATOR + "    <sheets>"
            + SystemUtils.LINE_SEPARATOR + "      <sheet>" + SystemUtils.LINE_SEPARATOR
            + "        <name>1</name>" + SystemUtils.LINE_SEPARATOR + "        <startrow>0</startrow>"
            + SystemUtils.LINE_SEPARATOR + "        <startcol>0</startcol>" + SystemUtils.LINE_SEPARATOR
            + "        </sheet>" + SystemUtils.LINE_SEPARATOR + "      <sheet>" + SystemUtils.LINE_SEPARATOR
            + "        <name>2</name>" + SystemUtils.LINE_SEPARATOR + "        <startrow>0</startrow>"
            + SystemUtils.LINE_SEPARATOR + "        <startcol>0</startcol>" + SystemUtils.LINE_SEPARATOR
            + "        </sheet>" + SystemUtils.LINE_SEPARATOR + "      <sheet>" + SystemUtils.LINE_SEPARATOR
            + "        <name>3</name>" + SystemUtils.LINE_SEPARATOR + "        <startrow>0</startrow>"
            + SystemUtils.LINE_SEPARATOR + "        <startcol>0</startcol>" + SystemUtils.LINE_SEPARATOR
            + "        </sheet>" + SystemUtils.LINE_SEPARATOR + "      <sheet>" + SystemUtils.LINE_SEPARATOR
            + "        <name>4</name>" + SystemUtils.LINE_SEPARATOR + "        <startrow>0</startrow>"
            + SystemUtils.LINE_SEPARATOR + "        <startcol>0</startcol>" + SystemUtils.LINE_SEPARATOR
            + "        </sheet>" + SystemUtils.LINE_SEPARATOR + "    </sheets>" + SystemUtils.LINE_SEPARATOR
            + "    <strict_types>N</strict_types>" + SystemUtils.LINE_SEPARATOR
            + "    <error_ignored>N</error_ignored>" + SystemUtils.LINE_SEPARATOR
            + "    <error_line_skipped>N</error_line_skipped>" + SystemUtils.LINE_SEPARATOR
            + "    <bad_line_files_destination_directory/>" + SystemUtils.LINE_SEPARATOR
            + "    <bad_line_files_extension/>" + SystemUtils.LINE_SEPARATOR
            + "    <error_line_files_destination_directory/>" + SystemUtils.LINE_SEPARATOR
            + "    <error_line_files_extension/>" + SystemUtils.LINE_SEPARATOR
            + "    <line_number_files_destination_directory/>" + SystemUtils.LINE_SEPARATOR
            + "    <line_number_files_extension/>" + SystemUtils.LINE_SEPARATOR + "    <shortFileFieldName/>"
            + SystemUtils.LINE_SEPARATOR + "    <pathFieldName/>" + SystemUtils.LINE_SEPARATOR
            + "    <hiddenFieldName/>" + SystemUtils.LINE_SEPARATOR + "    <lastModificationTimeFieldName/>"
            + SystemUtils.LINE_SEPARATOR + "    <uriNameFieldName/>" + SystemUtils.LINE_SEPARATOR
            + "    <rootUriNameFieldName/>" + SystemUtils.LINE_SEPARATOR + "    <extensionFieldName/>"
            + SystemUtils.LINE_SEPARATOR + "    <sizeFieldName/>" + SystemUtils.LINE_SEPARATOR
            + "    <spreadsheet_type/>" + SystemUtils.LINE_SEPARATOR, meta.getXML());
}