|
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.ResequencingWriter<K>
public class ResequencingWriter<K>
A Writer that is a Resequencer with the capacity to
accept data in a sequence that differs from the sequence of actual output.
Warning:
ResequencingWriterStack violates the Writer
contract because a Resequencer cannot be flushed.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface ca.gorman.io.Resequencer |
|---|
Resequencer.Buffer<K>, Resequencer.Mark<K>, Resequencer.MarkGroup<K>, Resequencer.SpillBuffer |
| Field Summary |
|---|
| Fields inherited from class java.io.Writer |
|---|
lock |
| Constructor Summary | |
|---|---|
ResequencingWriter(Writer writer)
Construct with a private internal MarkGroup and default temporary stoage. |
|
ResequencingWriter(Writer writer,
int bufferSize,
Resequencer.SpillBuffer spillBuffer)
Construct with a private internal MarkGroup and specified temporary storage. |
|
ResequencingWriter(Writer writer,
Resequencer.MarkGroup<K> markGroup)
Construct with an external MarkGroup and default temporary storage. |
|
ResequencingWriter(Writer writer,
Resequencer.MarkGroup<K> markGroup,
int bufferSize,
Resequencer.SpillBuffer spillBuffer)
Construct with an external MarkGroup and specified temporary storage. |
|
| Method Summary | |
|---|---|
void |
close()
Send all data to final destination. |
void |
flush()
Unsupported operation, failure mode depends on isFlushThrowsException. |
Resequencer.Mark<K> |
getMark(K key)
Get an existing Mark. |
Resequencer.MarkGroup<K> |
getMarkGroup()
Get the MarkGroup used by this Resequencer. |
boolean |
isFlushThrowsException()
Indicate whether flush will
throw UnsupportedOperationException or fail silently (the default). |
Resequencer.Mark<K> |
mark()
Create a Mark without a key. |
Resequencer.Mark<K> |
mark(K key)
Get the Mark for a specific key, creating a new
Mark if one does not already exist. |
void |
setFlushThrowsException(boolean b)
Choose whether flush will throw
UnsupportedOperationException or fail silently (the default). |
void |
write(char[] ch,
int off,
int len)
Write len chars of an array, beginning from
char[off]. |
void |
write(int ch)
Write one char. |
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 a new Mark if one
does not already exist. |
| Methods inherited from class java.io.Writer |
|---|
append, append, append, write, write, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ResequencingWriter(Writer writer,
Resequencer.MarkGroup<K> markGroup,
int bufferSize,
Resequencer.SpillBuffer spillBuffer)
Construct with an external MarkGroup and specified temporary storage. ResequencingWriter will throw an exception if closed before the MarkGroup has been closed.
writer - destination for output from this WritermarkGroup - an external MarkGroupspillBuffer - a "spill" buffer to hold overflow from the memory
bufferbufferSize - maximum size of the internal memory buffer
NullPointerException - if writer is null.
NullPointerException - if markGroup is null.
IllegalArgumentException - if memoryLimit < 0
NullPointerException - if spillBuffer is null.
public ResequencingWriter(Writer writer,
Resequencer.MarkGroup<K> markGroup)
Construct with an external MarkGroup and default temporary storage. ResequencingWriter will throw an exception if closed before the MarkGroup has been closed.
writer - destination for output from this WritermarkGroup - an external MarkGroup
NullPointerException - if writer is null or markGroup is nullResequencer.MarkGroup,
Resequencer.Mark
public ResequencingWriter(Writer writer,
int bufferSize,
Resequencer.SpillBuffer spillBuffer)
Construct with a private internal MarkGroup and specified temporary storage. ResequencingWriter will close the internal MarkGroup automatically at the appropriate time.
writer - destination for output from this WriterspillBuffer - a "spill" buffer to hold overflow from the memory
bufferbufferSize - maximum size of the internal memory buffer
NullPointerException - if writer is null.
IllegalArgumentException - if memoryLimit < 0
NullPointerException - if spillBuffer is null.public ResequencingWriter(Writer writer)
Construct with a private internal MarkGroup and default temporary stoage. ResequencingWriter will close the internal MarkGroup automatically at the appropriate time.
writer - destination for output from this Writer
NullPointerException - if writer is null.| Method Detail |
|---|
public Resequencer.MarkGroup<K> getMarkGroup()
Resequencer
Get the MarkGroup used by this Resequencer.
getMarkGroup in interface Resequencer<K>public Resequencer.Mark<K> getMark(K key)
Resequencer
Get an existing Mark.
This method should be delegated to the Buffer that supports the Resequencer.
getMark in interface Resequencer<K>public Resequencer.Mark<K> mark()
Resequencer
Create a Mark without a key. This method returns a new
Mark each time it is invoked. The only way to obtain the
same Mark again is to assign it to a variable for later
use.
This method should be delegated to the Buffer that supports the Resequencer.
mark in interface Resequencer<K>public Resequencer.Mark<K> mark(K key)
Resequencer
Get the Mark for a specific key, creating a new
Mark if one does not already exist. This method returns
the same Mark each time it is invoked with the same key.
This method should be delegated to the Buffer that supports the Resequencer.
mark in interface Resequencer<K>key - Identifies the mark to be retrieved or created
public void writeMark(K key)
throws IOException
Resequencer
Write a Mark representing data that will be
supplied at some other time, creating a new Mark if one
does not already exist. The Mark will be replaced by data
when this Resequencer is closed.
This method should be delegated to the Buffer that supports the Resequencer.
writeMark in interface Resequencer<K>key - the key that identifies the place mark within the
MarkGroup used by this
Resequencer
IOException
public void write(Resequencer.Mark<K> mark)
throws IOException
Resequencer
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.
This method should be delegated to the Buffer that supports the Resequencer.
write in interface Resequencer<K>mark - The Mark to be written,
IOException
public void write(char[] ch,
int off,
int len)
throws IOException
Write len chars of an array, beginning from
char[off].
write in class WriterIOException
public void write(int ch)
throws IOException
Write one char. The value written is the 16 lowest-order bits of ch.
write in class WriterIOException
public void close()
throws IOException
Send all data to final destination. A second pass is made through all the data, replacing all markers by the current data values in the corresponding mark buffers.
close in interface Closeableclose in class WriterIOException - when an I/O error occurs, or when the MarkGroup
had not been closed.
public void flush()
throws IOException
Unsupported operation, failure mode depends on
isFlushThrowsException.
flush in interface Flushableflush in class WriterUnsupportedOperationException - when this method is invoked
and isFlushThrowsException returns true.
IOExceptionisFlushThrowsException(),
setFlushThrowsException(boolean)public boolean isFlushThrowsException()
Resequencer
Indicate whether flush will
throw UnsupportedOperationException or fail silently (the default).
A Resequencer cannot be flushed because it retains all data
until the supporting Writer is closed.
isFlushThrowsException in interface Resequencer<K>flush will throw
UnsupportedOperationException, false if flush
will be ignored.Resequencer.setFlushThrowsException(boolean)public void setFlushThrowsException(boolean b)
Resequencer
Choose whether flush will throw
UnsupportedOperationException or fail silently (the default).
A Resequencer cannot be flushed because it retains all data
until the supporting Writer is closed.
setFlushThrowsException in interface Resequencer<K>b - true to throw UnsupportedOperationException,
false (default) to simply ignore
flush.Resequencer.isFlushThrowsException()
|
GXPARSE download | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||