Class EXDROutputStream

java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
com.parctechnologies.eclipse.EXDROutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class EXDROutputStream extends 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:
  • Constructor Details

    • EXDROutputStream

      public EXDROutputStream(OutputStream s)
      Construct an EXDROutputStream which will write EXDR to a named OutputStream.
    • EXDROutputStream

      public EXDROutputStream(OutputStream s, boolean compressStrings)
      Construct an EXDROutputStream which will write EXDR with optionally compressed strings to a named OutputStream.
  • Method Details

    • write

      public void write(Object o) throws 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:
      IllegalArgumentException - if the parameter is of an unrecognised class, or if Not-a-number (NaN)-valued Floats or Doubles are supplied.
      IOException
    • flush

      public void flush() throws IOException
      Flushes the underlying OutputStream.
      Specified by:
      flush in interface Flushable
      Overrides:
      flush in class FilterOutputStream
      Throws:
      IOException
    • enableCompression

      public void enableCompression(boolean compress)
      Enable / disable string compression for subsequently written terms.