## 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.

Inner 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.

Field Summary
`private LinkedList` `buffer`
`private int` `buffSize`
`private static boolean` `DEBUG` Debug flag
`private InputStream` `inputStream`
`private int` `lastOffset`
`private Object` `object`
`private PipedOutputStream` `outputStream`
`private int` `size`

Fields inherited from class java.lang.Thread
`contextClassLoader, daemon, eetop, group, inheritableThreadLocals, inheritedAccessControlContext, MAX_PRIORITY, MIN_PRIORITY, name, NORM_PRIORITY, priority, single_step, stillborn, stopThreadPermission, target, threadInitNumber, threadLocals, threadQ`

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

`<clinit>, activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, exit, getContextClassLoader, getName, getPriority, getThreadGroup, init, interrupt, interrupt0, interrupted, isAlive, isDaemon, isInterrupted, isInterrupted, join, join, join, nextThreadNum, registerNatives, resume, resume0, setContextClassLoader, setDaemon, setName, setPriority, setPriority0, sleep, sleep, start, stop, stop, stop0, suspend, suspend0, toString, yield`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### DEBUG

    private static final boolean DEBUG

  Debug flag

### 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

Constructor Detail

### ObjectWriter

    public ObjectWriter(Object obj)
                 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
  Overrides:
    `run` in class `Thread`