|
GXPARSE hosted by |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.Writer
ca.gorman.io.Resequencer.Buffer<K>
public abstract static class Resequencer.Buffer<K>
Buffer to hold Marks
with keys of type
K
and character data until all character data have been
written, and all Marks
have been associated with data
values.
A Buffer
contains a fast primary buffer with limited
capacity aand spills the overflow to a slower
secondary buffer
that has unlimited
capacity.
Field Summary |
---|
Fields inherited from class java.io.Writer |
---|
lock |
Constructor Summary | |
---|---|
protected |
Resequencer.Buffer(Writer writer,
Resequencer.MarkGroup<K> markGroup)
Superclass constructor for use by subclass constructor. |
protected |
Resequencer.Buffer(Writer writer,
Resequencer.MarkGroup<K> markGroup,
int bufferSize,
Resequencer.SpillBuffer spillBuffer)
Superclass constructor for use by subclass constructor. |
Method Summary | ||
---|---|---|
void |
close()
Close this Buffer and send output to final destination. |
|
void |
flush()
Unsupported operation. |
|
Resequencer.Mark<K> |
getMark(K key)
Get an existing Mark . |
|
Resequencer.MarkGroup<K> |
getMarkGroup()
Get the MarkGroup that serves this
Buffer . |
|
protected boolean |
isClosed()
Indicate whether this Buffer is closed. |
|
protected boolean |
isSpilling()
Indicate whether the fast buffer has filled and the overflow buffer contains data. |
|
Resequencer.Mark<K> |
mark()
Create a Mark without a key. |
|
Resequencer.Mark<K> |
mark(K key)
Get the Mark coresponding to a key, creating the
Mark if it does not already exist. |
|
static
|
newInstance(Writer writer,
Resequencer.MarkGroup<K> markGroup)
Create a new Buffer using defaults for the fast buffer
and the overflow buffer. |
|
static
|
newInstance(Writer writer,
Resequencer.MarkGroup<K> markGroup,
int bufferSize,
Resequencer.SpillBuffer spillBuffer)
Create a new Buffer specifying the fast buffer and the
overflow buffer. |
|
void |
write(char[] cbuf,
int off,
int len)
Write data to the Buffer . |
|
void |
write(Resequencer.Mark<K> mark)
Write a Mark representing data that will be
supplied at some other time. |
|
void |
writeMark(K key)
Write a Mark representing data that will be
supplied at some other time, creating the Mark if it
does not exist. |
Methods inherited from class java.io.Writer |
---|
append, append, append, write, write, write, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected Resequencer.Buffer(Writer writer, Resequencer.MarkGroup<K> markGroup)
Superclass constructor for use by subclass constructor. Uses a
default sized memory block as the primary buffer and a
temporary file
as the
secondary buffer
for overflow from
the primary buffer. The default memory block size is chosen for
good performance when a small number of
Resequencers
are in use, and some of them may
hold large amounts of data.
markGroup
- The MarkGroup
that this Buffer
will use.writer
- The final destination for output when this
this Buffer
is closed.
NullPointerException
- if writer
or
markGroup
is nullprotected Resequencer.Buffer(Writer writer, Resequencer.MarkGroup<K> markGroup, int bufferSize, Resequencer.SpillBuffer spillBuffer)
Superclass constructor for use by subclass constructor. Uses a
memory block as the primary buffer and a
secondary buffer
for overflow from
the primary buffer.
markGroup
- The MarkGroup
that this Buffer
will use.writer
- The final destination for output when this
this Buffer
is closed.bufferSize
- Number of characters to allocate in memory as
a primary buffer.spillBuffer
- the secondary buffer for overflow from the
primary buffer.
NullPointerException
- if writer
,
markGroup
or spillBuffer
is null
IllegalArgumentException
- if bufferSize
< 0Method Detail |
---|
public static <K> Resequencer.Buffer<K> newInstance(Writer writer, Resequencer.MarkGroup<K> markGroup, int bufferSize, Resequencer.SpillBuffer spillBuffer)
Create a new Buffer
specifying the fast buffer and the
overflow buffer.
writer
- The Writer
that serves as a final
destination for output.markGroup
- The MarkGroup
used by the
Buffer
bufferSize
- Size of fast buffer.spillBuffer
- the overflow buffer.
NullPointerException
- if writer
,
markGroup
or spillBuffer
is null
IllegalArgumentException
- if bufferSize
< 0public static <K> Resequencer.Buffer<K> newInstance(Writer writer, Resequencer.MarkGroup<K> markGroup)
Create a new Buffer
using defaults for the fast buffer
and the overflow buffer.
writer
- The Writer
that serves as a final
destination for output.markGroup
- The MarkGroup
used by the
Buffer
NullPointerException
- if writer
or
markGroup
is nullpublic Resequencer.MarkGroup<K> getMarkGroup()
Get the MarkGroup
that serves this
Buffer
.
public void flush() throws IOException
Unsupported operation. This Buffer
cannot be flushed
because it holds Marks
and allows them to
be updated at any time prior to closing
this Buffer
flush
in interface Flushable
flush
in class Writer
UnsupportedOperationException
IOException
public void close() throws IOException
Close this Buffer
and send output to final destination.
When a subclass method overrides this method, the subclass method
must invoke the superclass method.
close
in interface Closeable
close
in class Writer
IOException
public Resequencer.Mark<K> getMark(K key)
Get an existing Mark
.
NoSuchElementException
- if the Mark does not exist.public Resequencer.Mark<K> mark()
Create a Mark
without a key.
public Resequencer.Mark<K> mark(K key)
Get the Mark
coresponding to a key, creating the
Mark
if it does not already exist.
key
- Identifies the mark to be retrieved or createdpublic void writeMark(K key) throws IOException
Write a Mark
representing data that will be
supplied at some other time, creating the Mark
if it
does not exist. The Mark
will be replaced by data when
this Buffer
is closed.
key
- the key that identifies the place mark within the
MarkGroup
used by this
Buffer
IOException
public void write(Resequencer.Mark<K> mark) throws IOException
Write a Mark
representing data that will be
supplied at some other time. The Mark
will be replaced by
data when this Resequencer
is closed.
mark
- The Mark
to be written,
NullPointerException
- if mark
is null
IOException
public void write(char[] cbuf, int off, int len) throws IOException
Write data to the Buffer
.
write
in class Writer
IOException
protected boolean isClosed()
Indicate whether this Buffer
is closed.
protected boolean isSpilling()
Indicate whether the fast buffer has filled and the overflow buffer contains data.
|
GXPARSE download | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |