Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.archive.util
Class PaddingStringBuffer

    java.lang.Object
      org.archive.util.PaddingStringBuffer

    public final class PaddingStringBuffer

extends java.lang.Object

StringBuffer-like utility which can add spaces to reach a certain column. It allows you to append `String`, `long` and `int`s to the buffer.

Note: This class counts from 1, not 0.

It uses a StringBuffer behind the scenes.

To write a string with multiple lines, it is advisible to use the `newline()` function. Regular appending of strings with newlines (\n) character should be safe though. Right appending of strings with such characters is not safe.

Author:
  Gordon Mohr

Field Summary
`(package private) java.lang.StringBuffer` | `buffer`
`(package private) int` | `linePos`

Constructor Summary
`PaddingStringBuffer()` Create a new PaddingStringBuffer

Method Summary
`PaddingStringBuffer` | `append(int i)` append an `int` to the buffer.
`PaddingStringBuffer` | `append(long lo)` append a `long` to the buffer.
`PaddingStringBuffer` | `append(java.lang.String string)` append a string directly to the buffer
`PaddingStringBuffer` | `newline()` Forces a new line in the buffer.
`PaddingStringBuffer` | `padTo(int col)` Pad to a given column.
`PaddingStringBuffer` | `raAppend(int col, int i)` Append an `int` right-aligned to the given column.
`PaddingStringBuffer` | `raAppend(int col, long lo)` Append a `long`, right-aligned to the given column.
`PaddingStringBuffer` | `raAppend(int col, java.lang.String string)` Append a string, right-aligned to the given columm.
`void` | `reset()` reset the buffer back to empty
`java.lang.String` | `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### buffer

    java.lang.StringBuffer buffer

### linePos

    int linePos

Constructor Detail

### PaddingStringBuffer

    public PaddingStringBuffer()

  Create a new PaddingStringBuffer

Method Detail

### append

    public PaddingStringBuffer append(java.lang.String string)

  append a string directly to the buffer

  Parameters:
    `string` - the string to append
  Returns:
    This wrapped buffer w/ the passed string appended.

### raAppend

    public PaddingStringBuffer raAppend(int col,
                                        java.lang.String string)

  Append a string, right-aligned to the given columm. If the buffer length is already greater than the column specified, it simply appends the string

  Parameters:
    `col` - the column to right-align to
    `string` - the string, must not contain multiple lines.
  Returns:
    This wrapped buffer w/ append string, right-aligned to the given column.

### padTo

    public PaddingStringBuffer padTo(int col)

  Pad to a given column. If the buffer size is already greater than the column, nothing is done.

  Parameters:
    `col` -
  Returns:
    The buffer padded to `i`.

### append

    public PaddingStringBuffer append(int i)

  append an `int` to the buffer.

  Parameters:
    `i` - the int to append
  Returns:
    This wrapped buffer with `i` appended.

### raAppend

    public PaddingStringBuffer raAppend(int col,
                                        int i)

  Append an `int` right-aligned to the given column. If the buffer length is already greater than the column specified, it simply appends the `int`.

  Parameters:
    `col` - the column to right-align to
    `i` - the int to append
  Returns:
    This wrapped buffer w/ appended int, right-aligned to the given column.

### append

    public PaddingStringBuffer append(long lo)

  append a `long` to the buffer.

  Parameters:
    `lo` - the `long` to append
  Returns:
    This wrapped buffer w/ appended long.

### raAppend

    public PaddingStringBuffer raAppend(int col,
                                        long lo)

  Append a `long`, right-aligned to the given column. If the buffer length is already greater than the column specified, it simply appends the `long`.

  Parameters:
    `col` - the column to right-align to
    `lo` - the long to append
  Returns:
    This wrapped buffer w/ appended long, right-aligned to the given column.

### reset

    public void reset()

  reset the buffer back to empty

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### newline

    public PaddingStringBuffer newline()

  Forces a new line in the buffer.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2008 Internet Archive. All Rights Reserved.