|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gnu.iou.linebuf
Line oriented string buffer, or dynamic string array container. Plus string utility methods. For an array of strings this is faster than a Vector which is synchronized and generalized (not String).
This uses character arrays internally because more intensive
use of the line buffer transforms Strings to character arrays and
back into String objects and then back into character arrays. And
in the very common `toString()'
case a String will be
concatenated as character arrays, too.
Field Summary | |
protected char[][] |
buf
|
static char[] |
default_line_separator
|
protected int |
p
|
static java.lang.String |
sys_line_separator
|
Constructor Summary | |
linebuf()
Default growth factor of ten. |
|
linebuf(int growthfactor)
|
|
linebuf(java.lang.Object obj)
|
|
linebuf(java.lang.String line)
Append argument line. |
|
linebuf(java.lang.String[] lineset)
Append argument lines. |
|
linebuf(java.lang.String[] lineset,
java.lang.String line_sep)
Append argument lines. |
|
linebuf(java.lang.String prefix,
java.util.Enumeration lineset,
java.lang.String line_sep)
Append argument lines. |
|
linebuf(java.lang.String prefix,
java.lang.Object[] lineset,
java.lang.String line_sep)
Append argument lines. |
|
linebuf(java.lang.String prefix,
java.lang.String[] lineset,
java.lang.String line_sep)
Append argument lines. |
Method Summary | |
linebuf |
append(char[] line)
Append line, return this. |
linebuf |
append(char[] line,
int ofs,
int len)
Append line, return this. |
linebuf |
append(java.lang.Object o)
|
linebuf |
append(java.lang.Object[] oary)
Will insert null line elements. |
linebuf |
append(java.lang.String line)
Append line, return this. |
linebuf |
append(java.lang.String[] lines)
Will insert null line elements. |
linebuf |
append(java.lang.String s,
java.lang.String delimiters)
Split input string `s' on delimiter characters, and add each resulting token as an element- line. |
void |
backspace(int rowidx,
int colidx)
|
void |
delete(int rowidx,
int colidx)
|
static char[] |
detab(char[] scary)
|
static char[] |
detab(char[] scary,
int ofs,
int len)
|
static char[] |
detab(java.lang.String s)
Convert each tab to five spaces. |
static java.lang.String |
indent(int lvl,
java.lang.String text)
Insert 'lvl' tabs before each line of a multiline text, else return text (use leveltabs for a single line). |
void |
index_append(int idx,
char[] val)
|
void |
index_append(int idx,
java.lang.String val)
|
char[] |
index_cary(int idx)
|
void |
index_column_overwrite(int idx,
char[] col,
int col0,
int colw)
Use the first `colw' characters of
`col' to overwrite the "[col0,colw)"
segment of the line. |
void |
index_column_overwrite(int idx,
java.lang.String col,
int col0,
int colw)
Use the first `colw' characters of
`col' to overwrite the "[col0,colw)"
segment of the line. |
void |
index_prepend(int idx,
java.lang.String val)
|
int |
index()
|
java.lang.String |
index(int idx)
|
void |
index(int idx,
char[] val)
|
void |
index(int idx,
java.lang.String val)
|
void |
insert(char key,
int rowidx,
int colidx)
|
linebuf |
invert()
Invert (reverse) the order of strings in the linebuffer. |
static linebuf |
invert(java.lang.String s,
linebuf lb,
java.lang.String delimiters)
|
static java.lang.String[] |
invert(java.lang.String s,
java.lang.String delim)
|
int |
length()
Number of lines. |
void |
line_append(java.lang.String s)
|
java.lang.String |
line_separator()
|
linebuf |
line_separator(java.lang.String sep)
Reset the line separator used by `toString'. |
linebuf |
lines_append(java.lang.String val)
Convenience method to append string value to elements currently in the line buffer. |
linebuf |
lines_prepend(java.lang.String val)
Convenience method to prepend string value to elements currently in the line buffer. |
void |
pop()
Delete the first line |
linebuf |
println()
Append null line, return this. |
linebuf |
reset()
Discard content, reuse buffer. |
static java.lang.String[] |
space_quoted(java.lang.String line)
Parse series of space separated, optionally quoted strings. |
static char[] |
sptab(java.lang.String s)
Convert each tab to a space. |
char[] |
toCharArray()
Terminate each line with the line separator string, by default this is the local platform newline (eg, CRLF (Mac/ Win) or LF (Unix)). |
char[][] |
toCharCharArray()
Returns lines or null. |
java.lang.String |
toString()
Terminate each line with the line separator string, by default this is the local platform newline (eg, CRLF (Mac/ Win) or LF (Unix)). |
static java.lang.String |
toString(java.lang.Object obj)
|
static java.lang.String |
toString(java.lang.Object[] oary)
|
static java.lang.String[] |
toStringArray_term(java.lang.String s,
java.lang.String term)
Use the `term' argument literally, not as a set of delimiter characters but as a whole term delimiting substrings in `s'. |
java.lang.String[] |
toStringArray()
Returns lines or null. |
static java.lang.String[] |
toStringArray(java.io.DataInputStream din)
|
static java.lang.String[] |
toStringArray(java.util.Enumeration en)
|
static linebuf |
toStringArray(java.util.Enumeration en,
linebuf lb)
|
static java.lang.String[] |
toStringArray(java.lang.Object o)
|
static java.lang.String[] |
toStringArray(java.lang.String s)
Parses input using default delimiters of carriage return and newline (CR and LF). |
static java.lang.String[] |
toStringArray(java.lang.String s,
char sep)
|
static linebuf |
toStringArray(java.lang.String s,
linebuf lb)
Uses default delimiters of carriage return and newline (CR and LF). |
static linebuf |
toStringArray(java.lang.String s,
linebuf lb,
java.lang.String delimiters)
|
static java.lang.String[] |
toStringArray(java.lang.String s,
java.lang.String delimiters)
|
static java.lang.String |
toStringline(java.lang.Object o)
Convert multiline object descriptor onto a single line. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final char[] default_line_separator
public static java.lang.String sys_line_separator
protected char[][] buf
protected int p
Constructor Detail |
public linebuf(int growthfactor)
growthfactor
- Set internal buffer allocation unit length
(number of lines).public linebuf()
public linebuf(java.lang.String line)
line
- One line to append.public linebuf(java.lang.Object obj)
public linebuf(java.lang.String[] lineset)
lineset
- Lines to append.public linebuf(java.lang.String[] lineset, java.lang.String line_sep)
lineset
- Lines to append.line_sep
- Linebuf string element (line) separator.public linebuf(java.lang.String prefix, java.lang.Object[] lineset, java.lang.String line_sep)
prefix
- Output prefix.lineset
- Lines to append using
Object.toString().
line_sep
- Linebuf string element (line) separator.public linebuf(java.lang.String prefix, java.lang.String[] lineset, java.lang.String line_sep)
prefix
- Output prefix.lineset
- Lines to append.line_sep
- Linebuf string element (line) separator.public linebuf(java.lang.String prefix, java.util.Enumeration lineset, java.lang.String line_sep)
prefix
- Output prefix.lineset
- Lines to append using
Object.toString().
line_sep
- Linebuf string element (line) separator.Method Detail |
public int index()
public java.lang.String index(int idx)
idx
- Line index in this buffer.public char[] index_cary(int idx)
idx
- Line index in this buffer.public void index(int idx, java.lang.String val)
idx
- Line index in this buffer.val
- Line textpublic void index(int idx, char[] val)
idx
- Line index in this buffer.val
- Line textpublic void index_prepend(int idx, java.lang.String val)
idx
- Line index in this buffer.val
- Line text to prepend to any current text in linepublic void index_append(int idx, java.lang.String val)
idx
- Line index in this buffer.val
- Line textpublic void index_append(int idx, char[] val)
idx
- Line index in this buffer.val
- Line textpublic void line_append(java.lang.String s)
public void index_column_overwrite(int idx, java.lang.String col, int col0, int colw)
`colw'
characters of
`col'
to overwrite the "[col0,colw)"
segment of the line.idx
- Line index in this buffer.col
- Column textcol0
- Column specification first column indexcolw
- Column specification widthpublic void index_column_overwrite(int idx, char[] col, int col0, int colw)
`colw'
characters of
`col'
to overwrite the "[col0,colw)"
segment of the line.idx
- Line index in this buffer.col
- Column textcol0
- Column specification first column indexcolw
- Column specification widthpublic linebuf lines_prepend(java.lang.String val)
Makes null elements non- null!
val
- String value to prepend to existing elements of the
buffer.public linebuf lines_append(java.lang.String val)
Makes null elements non- null!
val
- String value to append to existing elements of the
buffer.public linebuf println()
public linebuf append(char[] line)
Will insert null lines.
public linebuf append(char[] line, int ofs, int len)
Will insert null lines.
public linebuf append(java.lang.String line)
Will insert null lines.
public linebuf append(java.lang.String[] lines)
public linebuf append(java.lang.Object[] oary)
public linebuf append(java.lang.Object o)
public linebuf append(java.lang.String s, java.lang.String delimiters)
public java.lang.String[] toStringArray()
public char[][] toCharCharArray()
public linebuf line_separator(java.lang.String sep)
public java.lang.String line_separator()
public linebuf invert()
Reminder: Not MT SAFE, although MT robust. Works on a copy of the internal buffer, then replaces the internal buffer with the inverted one. Changes made to the internal buffer by another thread during this operation will be lost.
public java.lang.String toString()
toString
in class java.lang.Object
public char[] toCharArray()
public linebuf reset()
public int length()
public void backspace(int rowidx, int colidx)
public void pop()
public void delete(int rowidx, int colidx)
public void insert(char key, int rowidx, int colidx)
public static final java.lang.String toString(java.lang.Object[] oary)
public static final java.lang.String toString(java.lang.Object obj)
public static final java.lang.String[] toStringArray(java.lang.Object o)
public static final java.lang.String[] toStringArray(java.io.DataInputStream din) throws java.io.IOException
public static final java.lang.String[] toStringArray(java.util.Enumeration en)
public static final linebuf toStringArray(java.util.Enumeration en, linebuf lb)
public static final java.lang.String[] toStringArray(java.lang.String s)
public static final java.lang.String[] toStringArray(java.lang.String s, java.lang.String delimiters)
public static final linebuf toStringArray(java.lang.String s, linebuf lb)
public static final linebuf toStringArray(java.lang.String s, linebuf lb, java.lang.String delimiters)
public static final java.lang.String[] toStringArray(java.lang.String s, char sep)
public static final java.lang.String[] toStringArray_term(java.lang.String s, java.lang.String term)
s
- String sourceterm
- Substring delimiterpublic static final java.lang.String[] invert(java.lang.String s, java.lang.String delim)
public static final linebuf invert(java.lang.String s, linebuf lb, java.lang.String delimiters)
public static final java.lang.String indent(int lvl, java.lang.String text)
public static final java.lang.String[] space_quoted(java.lang.String line)
public static final java.lang.String toStringline(java.lang.Object o)
public static final char[] detab(java.lang.String s)
s
- String to detabifypublic static final char[] detab(char[] scary)
public static final char[] detab(char[] scary, int ofs, int len)
public static final char[] sptab(java.lang.String s)
`index_column_overwrite'
which in the context of
column formatting with spaces, truncates any tabs for "belt
& braces" safety.s
- String to detabifyindex_column_overwrite(int, java.lang.String, int, int)
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |