Class StreamConnector

  • All Implemented Interfaces:
    ConnectorInterface, VersionInfoInterface

    public class StreamConnector
    extends Connector
    implements ConnectorInterface
    The Memory Stream Connector can read from or write to any Java(TM) stream, but is most often used to write into memory, where the formatted data can be retrieved later. The allocated buffer is retrieved/accessed as needed.
    • Constructor Detail

      • StreamConnector

        public StreamConnector()
        Class constructor
    • Method Detail

      • initialize

        public void initialize​(java.lang.Object o)
                        throws java.lang.Exception
        The Connector can only operate in Iterator mode, AddOnly mode, or Passive state. The behavior of the Connector depends on the way it has been initialized. initialize(null) This is the default behavior. The Connector writes into memory, and the formatted data can be retrieved with the method getDataBuffer(), only available in Memory Stream Connectors. Assuming the Connector is named MM, this code can be used anywhere (for example, Prolog, Epilog, all Hooks, script components, and even inside attribute mapping):
                var str = MM.connector.getDataBuffer();
                // use str for something.
                // To clear the data buffer and ready the Connector 
                                for more output, re-initialize
                MM.connector.initialize(null); 
                
         

        initialize(Reader r): The Connector reads from r. This can be used if you want to read from a stream.
        initialize(Writer w): The Connector writes to w.
        initialize(Socket s): The Connector can both read from and write to a Socket s.
        Specified by:
        initialize in interface ConnectorInterface
        Overrides:
        initialize in class Connector
        Parameters:
        o - null/Writer/Reader or Socket
        Throws:
        java.lang.Exception - if an error occurs
      • putEntry

        public void putEntry​(Entry entry)
                      throws java.lang.Exception
        Writes an entry using the provided parser
        Specified by:
        putEntry in interface ConnectorInterface
        Overrides:
        putEntry in class Connector
        Parameters:
        entry - the entry to be written
        Throws:
        java.lang.Exception - if no parser provided or an error occurs
      • getDataBuffer

        public java.lang.String getDataBuffer()
                                       throws java.lang.Exception
        Retrieves data from the buffer
        Returns:
        the buffered data
        Throws:
        java.lang.Exception - if an I/O error occurs
      • getVersion

        public java.lang.String getVersion()
        Return version information
        Specified by:
        getVersion in interface VersionInfoInterface
        Returns:
        version info