/** * Creates a new table writer with the specified amount of spaces as column separator. * * @param out Writer object to provide the underlying stream, or {@code null} if there is no * underlying stream. If {@code out} is null, then the {@link #toString} method is the only * way to get the table's content. * @param spaces Amount of white spaces to use as column separator. */ public TableWriter(final Writer out, final int spaces) { this(out, Utilities.spaces(spaces)); }
/** * Sets the indentation to the specified value. * * @param width The new indentation. */ public void setIndentation(final int width) { synchronized (lock) { margin = Utilities.spaces(width); } }
/** * Writes spaces for a tab character. * * @throws IOException If an I/O error occurs. */ private void expand() throws IOException { final int width = tabWidth - (column % tabWidth); out.write(Utilities.spaces(width)); column += width; }
/** * Invoked when a new line is begining. The default implementation writes the current line * number. * * @throws IOException If an I/O error occurs */ @Override protected void beginNewLine() throws IOException { final String number = String.valueOf(current++); out.write('['); out.write(Utilities.spaces(width - number.length())); out.write(number); out.write("] "); } }
/** * Print this {@code Element} as a tree. This method is used for debugging purpose only. * * @param out The output stream. * @param level The indentation level (usually 0). */ public void print(final PrintWriter out, final int level) { final int tabWidth = 4; out.print(Utilities.spaces(tabWidth * level)); out.println(keyword); if (list == null) { return; } final int size = list.size(); for (int j = 0; j < size; j++) { final Object object = list.get(j); if (object instanceof Element) { ((Element) object).print(out, level + 1); } else { out.print(Utilities.spaces(tabWidth * (level + 1))); out.println(object); } } } }
/** * Add a separator to the buffer, if needed. * * @param newLine if {@code true}, add a line separator too. */ private void appendSeparator(final boolean newLine) { int length = buffer.length(); char c; do { if (length == bufferBase) { return; } c = buffer.charAt(--length); if (c == symbols.open || c == symbols.openArray) { return; } } while (Character.isWhitespace(c) || c == symbols.space); buffer.append(symbols.separator).append(symbols.space); if (newLine && indentation != 0) { buffer.append(System.getProperty("line.separator", "\n")) .append(Utilities.spaces(margin)); lineChanged = true; } }
/** * Lists resources to the specified stream. If a resource has more than one line, only the first * line will be written. This method is used mostly for debugging purposes. * * @param out The destination stream. * @param values The resources to list. * @throws IOException if an output operation failed. */ private static void list(final Writer out, final String[] values) throws IOException { final String lineSeparator = System.getProperty("line.separator", "\n"); for (int i = 0; i < values.length; i++) { String value = values[i]; if (value == null) { continue; } int indexCR = value.indexOf('\r'); if (indexCR < 0) indexCR = value.length(); int indexLF = value.indexOf('\n'); if (indexLF < 0) indexLF = value.length(); final String number = String.valueOf(i); out.write(Utilities.spaces(5 - number.length())); out.write(number); out.write(":\t"); out.write(value.substring(0, Math.min(indexCR, indexLF))); out.write(lineSeparator); } }
err.println(); err.print(Utilities.spaces(errorOffset - base)); err.println('^');
/** * Returns a string representation of the specified matrix. The returned string is * implementation dependent. It is usually provided for debugging purposes only. */ static String toString(final Matrix matrix) { final int numRow = matrix.getNumRow(); final int numCol = matrix.getNumCol(); StringBuffer buffer = new StringBuffer(); final int columnWidth = 12; final String lineSeparator = System.getProperty("line.separator", "\n"); final FieldPosition dummy = new FieldPosition(0); final NumberFormat format = NumberFormat.getNumberInstance(); format.setGroupingUsed(false); format.setMinimumFractionDigits(6); format.setMaximumFractionDigits(6); for (int j = 0; j < numRow; j++) { for (int i = 0; i < numCol; i++) { final int position = buffer.length(); buffer = format.format(matrix.getElement(j, i), buffer, dummy); final int spaces = Math.max(columnWidth - (buffer.length() - position), 1); buffer.insert(position, Utilities.spaces(spaces)); } buffer.append(lineSeparator); } return buffer.toString(); }
final Class<?> type) { final StringBuilder buffer = new StringBuilder(status); buffer.append(Utilities.spaces(Math.max(1, 7 - status.length()))) .append('(') .append(Classes.getShortName(category));
table.write('\n'); if (recursive != null) { final String nextIndent = Utilities.spaces(indent.length() + 2); format(table, recursive.getImplementationHints(), nextIndent, done);
/** * Creates a new table writer with the specified amount of spaces as column separator. * * @param out Writer object to provide the underlying stream, or {@code null} if there is no * underlying stream. If {@code out} is null, then the {@link #toString} method is the * only way to get the table's content. * @param spaces Amount of white spaces to use as column separator. */ public TableWriter(final Writer out, final int spaces) { this(out, Utilities.spaces(spaces)); }
/** * Sets the indentation to the specified value. * * @param width The new indentation. */ public void setIndentation(final int width) { synchronized (lock) { margin = Utilities.spaces(width); } }
/** * Writes spaces for a tab character. * * @throws IOException If an I/O error occurs. */ private void expand() throws IOException { final int width = tabWidth - (column % tabWidth); out.write(Utilities.spaces(width)); column += width; }
/** * Invoked when a new line is begining. The default implementation writes the * current line number. * * @throws IOException If an I/O error occurs */ @Override protected void beginNewLine() throws IOException { final String number = String.valueOf(current++); out.write('['); out.write(Utilities.spaces(width - number.length())); out.write(number); out.write("] "); } }
/** * Lists resources to the specified stream. If a resource has more than one line, only * the first line will be written. This method is used mostly for debugging purposes. * * @param out The destination stream. * @param values The resources to list. * @throws IOException if an output operation failed. */ private static void list(final Writer out, final String[] values) throws IOException { final String lineSeparator = System.getProperty("line.separator", "\n"); for (int i=0; i<values.length; i++) { String value = values[i]; if (value == null) { continue; } int indexCR=value.indexOf('\r'); if (indexCR<0) indexCR=value.length(); int indexLF=value.indexOf('\n'); if (indexLF<0) indexLF=value.length(); final String number = String.valueOf(i); out.write(Utilities.spaces(5-number.length())); out.write(number); out.write(":\t"); out.write(value.substring(0, Math.min(indexCR,indexLF))); out.write(lineSeparator); } }
buffer.append(Utilities.spaces(Math.max(1, 7-status.length()))) .append('(').append(Classes.getShortName(category)); if (key != null) {