| Modifier and Type | Field and Description |
|---|---|
| private final StringBuffer | leftBuf
|
| private final IndentingWriter | leftColumn
|
| private final int | leftWidth
|
| private final Writer | out
|
| private final StringBuffer | rightBuf
|
| private final IndentingWriter | rightColumn
|
| Access | Constructor and Description |
|---|---|
| public | TwoColumnOutput(Writer
non-null; writer to send final output to> 0; width of the left column, in characters> 0; width of the right column, in charactersnon-null; spacer string to sit between the two columnsConstructs an instance. |
| public | TwoColumnOutput(OutputStream
non-null; stream to send final output to>= 1; width of the left column, in characters>= 1; width of the right column, in charactersnon-null; spacer string to sit between the two columnsConstructs an instance. |
| Modifier and Type | Method and Description |
|---|---|
| private static void | appendNewlineIfNecessary(StringBuffer
non-null; the buffer in questionnon-null; the writer to useAppends a newline to the given buffer via the given writer, but only if it isn't empty and doesn't already end with one. |
| public void | |
| private void | |
| private void | |
| public Writer | Returns: non-null; the left column writerGets the writer to use to write to the left column. |
| public Writer | Returns: non-null; the right column writerGets the writer to use to write to the right column. |
| private void | outputFullLines()
Outputs to the final destination as many full line pairs as there are in the pending output, removing those lines from their respective buffers. |
| public static String | Returns: non-null; an appropriately-formatted stringnon-null; first string> 0; width of the first columnnon-null; spacer stringnon-null; second string> 0; width of the second columnTurns the given two strings (with widths) and spacer into a formatted two-column string. |
| private static void | writeSpaces(Writer
non-null; where to write>= 0; the number of spaces to writeWrites the given number of spaces to the given writer. |
| leftBuf | back to summary |
|---|---|
| private final StringBuffer leftBuf
| |
| leftColumn | back to summary |
|---|---|
| private final IndentingWriter leftColumn
| |
| leftWidth | back to summary |
|---|---|
| private final int leftWidth
| |
| out | back to summary |
|---|---|
| private final Writer out
| |
| rightBuf | back to summary |
|---|---|
| private final StringBuffer rightBuf
| |
| rightColumn | back to summary |
|---|---|
| private final IndentingWriter rightColumn
| |
| TwoColumnOutput | back to summary |
|---|---|
| public TwoColumnOutput(Writer out, int leftWidth, int rightWidth, String spacer) Constructs an instance. | |
| TwoColumnOutput | back to summary |
|---|---|
| public TwoColumnOutput(OutputStream out, int leftWidth, int rightWidth, String spacer) Constructs an instance.
| |
| appendNewlineIfNecessary | back to summary |
|---|---|
| private static void appendNewlineIfNecessary(StringBuffer buf, Writer out) throws IOException Appends a newline to the given buffer via the given writer, but only if it isn't empty and doesn't already end with one.
| |
| flush | back to summary |
|---|---|
| public void flush() Flushes the output. If there are more lines of pending output in one column, then the other column will get filled with blank lines. | |
| flushLeft | back to summary |
|---|---|
| private void flushLeft() throws IOException Flushes the left column buffer, printing it and clearing the buffer. If the buffer is already empty, this does nothing. | |
| flushRight | back to summary |
|---|---|
| private void flushRight() throws IOException Flushes the right column buffer, printing it and clearing the buffer. If the buffer is already empty, this does nothing. | |
| getLeft | back to summary |
|---|---|
| public Writer getLeft() Gets the writer to use to write to the left column.
| |
| getRight | back to summary |
|---|---|
| public Writer getRight() Gets the writer to use to write to the right column.
| |
| outputFullLines | back to summary |
|---|---|
| private void outputFullLines() throws IOException Outputs to the final destination as many full line pairs as there are in the pending output, removing those lines from their respective buffers. This method terminates when at least one of the two column buffers is empty. | |
| toString | back to summary |
|---|---|
| public static String toString(String s1, int width1, String spacer, String s2, int width2) Turns the given two strings (with widths) and spacer into a formatted two-column string. | |
| writeSpaces | back to summary |
|---|---|
| private static void writeSpaces(Writer out, int amt) throws IOException Writes the given number of spaces to the given writer.
| |