gate.util
Class ObjectWriter

java.lang.Object
  extended by java.lang.Thread
      extended by 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
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ObjectWriter(Object obj)
           
 
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, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ObjectWriter

public ObjectWriter(Object obj)
             throws IOException
Throws:
IOException
Method Detail

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

Specified by:
run in interface Runnable
Overrides:
run in class Thread