EXDROutputStream
Date: 2022-09-03

com.parctechnologies.eclipse

## Class EXDROutputStream

- java.lang.Object
- - java.io.OutputStream
  - - java.io.FilterOutputStream
    - - com.parctechnologies.eclipse.EXDROutputStream

- All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

      public class EXDROutputStream
      extends java.io.FilterOutputStream

  A stream which can write EXDR format. An EXDROutputStream can be constructed from any instance of the OutputStream class and extends it to be able to write outgoing data in the EXDR (ECLiPSe eXternal Data Representation) format.

  Use the method `write(Object)` to convert Java CompoundTerm objects and instances of other relevant Java classes into EXDR format so that data can be read in by ECLiPSe.

  EXDROutputStream also uses a buffer: rather than writing to the underlying OutputStream byte-by-byte, EXDR data is written to the buffer and then copied to the OutputStream when a whole term has been completed.

  Note that EXDROutputStream objects are often constructed using ToEclipseQueues.

  See Also:
    `CompoundTerm`, `ToEclipseQueue`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `EXDROutputStream(java.io.OutputStream s)` Construct an EXDROutputStream which will write EXDR to a named OutputStream.
    `EXDROutputStream(java.io.OutputStream s, boolean compressStrings)` Construct an EXDROutputStream which will write EXDR with optionally compressed strings to a named OutputStream.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `enableCompression(boolean compress)` Enable / disable string compression for subsequently written terms.
    `void` | `flush()` Flushes the underlying OutputStream.
    `void` | `write(java.lang.Object o)` Write an Object to the underlying stream in EXDR format.

    - ### Methods inherited from class java.io.FilterOutputStream

      `close, write, write, write`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### EXDROutputStream

          public EXDROutputStream(java.io.OutputStream s)

      Construct an EXDROutputStream which will write EXDR to a named OutputStream.

    - #### EXDROutputStream

          public EXDROutputStream(java.io.OutputStream s,
                                  boolean compressStrings)

      Construct an EXDROutputStream which will write EXDR with optionally compressed strings to a named OutputStream.

  - ### Method Detail

    - #### write

          public void write(java.lang.Object o)
                     throws java.io.IOException

      Write an Object to the underlying stream in EXDR format. The Object (or if it is a compound term, its arguments, nested however deep) can be of any of the following acceptable EXDR output types:
      - `null` - this is interpreted as a variable in ECLiPSe.
      - String objects.
      - Anything implementing the CompoundTerm interface whose arguments are also instances of acceptable EXDR output types.
      - Integer objects.
      - Double or Float objects: these are interpreted as floats on the ECLiPSe side. Note that attempts to write Not-a-number (NaN) will raise an IllegalArgumentException.
      - Any object implementing the Collection interface whose elements are all instances of acceptable EXDR output types. The collection is interpreted as an ECLiPSe list.
      This is an atomic action, so that different threads writing to the same stream do not garble the data.
      Throws:
        `java.lang.IllegalArgumentException` - if the parameter is of an unrecognised class, or if Not-a-number (NaN)-valued Floats or Doubles are supplied.
        `java.io.IOException`

    - #### flush

          public void flush()
                     throws java.io.IOException

      Flushes the underlying OutputStream.
      Specified by:
        `flush` in interface `java.io.Flushable`
      Overrides:
        `flush` in class `java.io.FilterOutputStream`
      Throws:
        `java.io.IOException`

    - #### enableCompression

          public void enableCompression(boolean compress)

      Enable / disable string compression for subsequently written terms.