gate.util
Class ObjectWriter
java.lang.Object
java.lang.Thread
gate.util.ObjectWriter
- All Implemented Interfaces:
- Runnable
- public class ObjectWriter
- extends Thread
Writes an object to an PipedOutputStream wich can be connected to a
PipedInputStream.
Before writting the object it also writes it in a buffer and finds
out its size so it can be reported via getSize method.
All read/writes occur in separate threads to avoid a deadlock.
Nested Class Summary |
private class |
ObjectWriter.Writer
I need a thread to write the object so I can read it in an buffer
After that I know the size ana I can write it to the output stream
after I report the size. |
Method Summary |
InputStream |
getInputStream()
Returns a PipedInputStream from which the object given as parameter for
the constructor can be read. |
int |
getSize()
Obtains the object size. |
void |
run()
Writes all the buffers to the output stream |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
DEBUG
private static final boolean DEBUG
- Debug flag
- See Also:
- Constant Field Values
object
private Object object
inputStream
private InputStream inputStream
outputStream
private PipedOutputStream outputStream
size
private int size
lastOffset
private int lastOffset
buffer
private LinkedList buffer
buffSize
private int buffSize
ObjectWriter
public ObjectWriter(Object obj)
throws IOException
getInputStream
public InputStream getInputStream()
- Returns a PipedInputStream from which the object given as parameter for
the constructor can be read.
- Returns:
- a PipedInputStream connected to PipedOutputStream which writes
the object which this ObjectWriter was built for.
getSize
public int getSize()
- Obtains the object size.
- Returns:
- the size of the object recieved as parameter for the constructor.
run
public void run()
- Writes all the buffers to the output stream