Class SimpleAdapter

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void append​(java.lang.String data)
      Append data as a new line.
      void appendError​(java.lang.String data)
      Append one error record in a new line (if the error writer exists).
      void appendError​(java.lang.Throwable e)
      Append one error record from throwable in a new line (if the error writer exists).
      void appendLog​(char level, long lineNumber, java.lang.String data)
      Append one log in a new line (if the log writer exists).
      void appendLog​(java.lang.String data)
      Append one log in a new line (if the log writer exists).
      void close()
      Close the adapter streams
      void directProcess()
      Direct process.
      boolean getBooleanParameter​(java.lang.String param)
      Get an adapter boolean parameter's value.
      boolean getBooleanParameter​(java.lang.String param, boolean def)
      Get an adapter boolean parameter's value with default value.
      Console getConsole()
      Get console.
      java.io.OutputStream getErrorStream()
      Get optional error stream.
      java.io.PrintWriter getErrorWriter()
      Get optional error writer.
      Grant getGrant()
      Get adapter grant.
      java.io.BufferedReader getInputReader()
      Get data reader
      java.io.InputStream getInputStream()
      Get input data stream.
      int getIntParameter​(java.lang.String param)
      Get an adapter integer parameter's value.
      int getIntParameter​(java.lang.String param, int def)
      Get an adapter integer parameter's value with default value.
      java.io.OutputStream getLogStream()
      Get optional log stream.
      java.io.PrintWriter getLogWriter()
      Get optional log writer.
      long getLongParameter​(java.lang.String param)
      Get an adapter long integer parameter's value
      long getLongParameter​(java.lang.String param, long def)
      Get an adapter long integer parameter's value with default value.
      java.lang.String getName()
      Get adapter name.
      java.lang.String getOrigin()
      Get data origin.
      java.io.OutputStream getOutputStream()
      Get output data stream.
      java.io.PrintWriter getOutputWriter()
      Get output data writer.
      java.lang.Object getParameter​(java.lang.String param)
      Get an adapter parameter's value.
      java.lang.Object getParameter​(java.lang.String param, java.lang.Object def)
      Get adapter an parameter's value with optional default value.
      java.util.Map<java.lang.String,​java.lang.Object> getParameters()
      Get adapter parameters.
      int getProcessCount()
      Get processing count.
      char getStatus()
      Get adapter status.
      java.lang.String getTrackingId()
      Get tracking ID.
      void init​(java.lang.String name, Grant grant, java.io.InputStream inStream, java.io.OutputStream outStream, java.io.OutputStream errStream, java.io.OutputStream logStream, java.util.Map<java.lang.String,​java.lang.Object> params, java.lang.String trackId, java.lang.String origin)
      Adapter initialization.
      void postProcess()
      Post process.
      java.lang.String preProcess()
      Pre process.
      void setConsole​(Console console)
      Set console.
      void setErrorStream​(java.io.OutputStream es)
      Set error data stream.
      void setInputData​(byte[] data)
      Set input data byte array.
      void setInputStream​(java.io.InputStream is)
      Set input data stream.
      void setLogStream​(java.io.OutputStream ls)
      Set log stream.
      void setOutputStream​(java.io.OutputStream os)
      Set output data stream.
      void setParameter​(java.lang.String param, boolean value)
      Set an adapter parameter's boolean value.
      void setParameter​(java.lang.String param, int value)
      Set an adapter parameter's integer value.
      void setParameter​(java.lang.String param, long value)
      Set an adapter parameter's log integer value.
      void setParameter​(java.lang.String param, java.lang.Object value)
      Set an adapter parameter's value.
      void setProcessCount​(int processCount)
      Set processing count.
      void setStatus​(char status)
      Set adapter status.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getName

        public java.lang.String getName()
        Get adapter name.
        Returns:
        Adapter name
      • getGrant

        public Grant getGrant()
        Get adapter grant.
        Returns:
        Granr
      • getInputStream

        public java.io.InputStream getInputStream()
        Get input data stream.
        Specified by:
        getInputStream in interface AdapterInterface
        Returns:
        Input data stream
      • setInputStream

        public void setInputStream​(java.io.InputStream is)
        Set input data stream.
        Parameters:
        is - Input data stream
      • setInputData

        public void setInputData​(byte[] data)
        Set input data byte array.
        Parameters:
        data - Input data
      • getInputReader

        public java.io.BufferedReader getInputReader()
        Get data reader
        Returns:
        Data reader
      • getOutputStream

        public java.io.OutputStream getOutputStream()
        Get output data stream.
        Specified by:
        getOutputStream in interface AdapterInterface
        Returns:
        Output data stream
      • setOutputStream

        public void setOutputStream​(java.io.OutputStream os)
        Set output data stream.
        Parameters:
        os - Output stream
      • getOutputWriter

        public java.io.PrintWriter getOutputWriter()
        Get output data writer.
        Returns:
        Output data writer
      • setProcessCount

        public void setProcessCount​(int processCount)
        Set processing count.
        Parameters:
        processCount - Processing count (0 means no processing count, all data is processed at the end)
      • getProcessCount

        public int getProcessCount()
        Get processing count.
        Returns:
        Processing count (0 means no processing count, all data is processed at the end)
      • append

        public void append​(java.lang.String data)
        Append data as a new line.
        Parameters:
        data - Data
      • getStatus

        public char getStatus()
        Get adapter status.
        Specified by:
        getStatus in interface AdapterInterface
        Returns:
        Status (one of XMLSupervisor.STATUS_*)
      • setStatus

        public void setStatus​(char status)
        Set adapter status.
        Specified by:
        setStatus in interface AdapterInterface
        Parameters:
        status - Status (one of XMLSupervisor.STATUS_*)
      • getTrackingId

        public java.lang.String getTrackingId()
        Get tracking ID.
        Returns:
        Tracking ID
      • getOrigin

        public java.lang.String getOrigin()
        Get data origin.
        Returns:
        Data origin
      • getParameters

        public java.util.Map<java.lang.String,​java.lang.Object> getParameters()
        Get adapter parameters.
        Returns:
        Parameters
      • getParameter

        public java.lang.Object getParameter​(java.lang.String param)
        Get an adapter parameter's value.
        Parameters:
        param - Parameter name
        Returns:
        Parameter value
      • getParameter

        public java.lang.Object getParameter​(java.lang.String param,
                                             java.lang.Object def)
        Get adapter an parameter's value with optional default value.
        Parameters:
        param - Parameter name
        def - Default value
        Returns:
        Parameter value
      • getBooleanParameter

        public boolean getBooleanParameter​(java.lang.String param)
        Get an adapter boolean parameter's value.
        Parameters:
        param - Parameter name
        Returns:
        Parameter value
      • getBooleanParameter

        public boolean getBooleanParameter​(java.lang.String param,
                                           boolean def)
        Get an adapter boolean parameter's value with default value.
        Parameters:
        param - Parameter name
        def - Default value
        Returns:
        Parameter value
      • getIntParameter

        public int getIntParameter​(java.lang.String param)
        Get an adapter integer parameter's value.
        Parameters:
        param - Parameter name
        Returns:
        Parameter value
      • getIntParameter

        public int getIntParameter​(java.lang.String param,
                                   int def)
        Get an adapter integer parameter's value with default value.
        Parameters:
        param - Parameter name
        def - Default value
        Returns:
        Parameter value
      • getLongParameter

        public long getLongParameter​(java.lang.String param)
        Get an adapter long integer parameter's value
        Parameters:
        param - Parameter name
        Returns:
        Parameter value
      • getLongParameter

        public long getLongParameter​(java.lang.String param,
                                     long def)
        Get an adapter long integer parameter's value with default value.
        Parameters:
        param - Parameter name
        def - Default value
        Returns:
        Parameter value
      • setParameter

        public void setParameter​(java.lang.String param,
                                 java.lang.Object value)
        Set an adapter parameter's value.
        Parameters:
        param - Parameter name
        value - Parameter value
      • setParameter

        public void setParameter​(java.lang.String param,
                                 boolean value)
        Set an adapter parameter's boolean value.
        Parameters:
        param - Parameter name
        value - Parameter boolean value
      • setParameter

        public void setParameter​(java.lang.String param,
                                 int value)
        Set an adapter parameter's integer value.
        Parameters:
        param - Parameter name
        value - Parameter integer value
      • setParameter

        public void setParameter​(java.lang.String param,
                                 long value)
        Set an adapter parameter's log integer value.
        Parameters:
        param - Parameter name
        value - Parameter long integer value
      • getErrorStream

        public java.io.OutputStream getErrorStream()
        Get optional error stream.
        To send errors or any specific/rejected data for any future retry.
        Specified by:
        getErrorStream in interface AdapterInterface
        Returns:
        Error stream
      • setErrorStream

        public void setErrorStream​(java.io.OutputStream es)
        Set error data stream.
        Parameters:
        es - Error stream
      • getErrorWriter

        public java.io.PrintWriter getErrorWriter()
        Get optional error writer.
        to send errors or any specific/rejected data for any future retry.
        Returns:
        Error writer
      • appendError

        public void appendError​(java.lang.String data)
        Append one error record in a new line (if the error writer exists).
        Parameters:
        data - Data
      • appendError

        public void appendError​(java.lang.Throwable e)
        Append one error record from throwable in a new line (if the error writer exists).
        Parameters:
        e - Throwable
      • getLogStream

        public java.io.OutputStream getLogStream()
        Get optional log stream.
        to send any end-user trace, logs, errors.
        Specified by:
        getLogStream in interface AdapterInterface
        Returns:
        Log stream
      • setLogStream

        public void setLogStream​(java.io.OutputStream ls)
        Set log stream.
        Parameters:
        ls - Log stream
      • getLogWriter

        public java.io.PrintWriter getLogWriter()
        Get optional log writer.
        to send any end-user trace, logs, errors.
        Returns:
        Log writer
      • appendLog

        public void appendLog​(char level,
                              long lineNumber,
                              java.lang.String data)
        Append one log in a new line (if the log writer exists).
        Parameters:
        level - level
        lineNumber - Line number
        data - Data
      • appendLog

        public void appendLog​(java.lang.String data)
        Append one log in a new line (if the log writer exists).
        Parameters:
        data - Data
      • init

        public void init​(java.lang.String name,
                         Grant grant,
                         java.io.InputStream inStream,
                         java.io.OutputStream outStream,
                         java.io.OutputStream errStream,
                         java.io.OutputStream logStream,
                         java.util.Map<java.lang.String,​java.lang.Object> params,
                         java.lang.String trackId,
                         java.lang.String origin)
        Adapter initialization.
        Specified by:
        init in interface AdapterInterface
        Parameters:
        name - Adapter name
        grant - User rights
        inStream - Input stream of data
        outStream - Output stream of XML
        errStream - Optional error stream for rejected incoming data
        logStream - Optional stream to log info, errors...
        params - Adapter parameters
        trackId - Tracking ID
        origin - Origin of data
      • preProcess

        public java.lang.String preProcess()
        Pre process.
        Called before processing lines, by default it sends the XML header to output.
        Specified by:
        preProcess in interface AdapterInterface
        Returns:
        Error code to stop, or null to continue
      • directProcess

        public void directProcess()
                           throws PlatformException
        Direct process.
        Called each N lines in direct mode, by default is flushes output.
        Throws:
        PlatformException
      • postProcess

        public void postProcess()
        Post process.
        Called after processing lines, by default it sends the XML footer to output.
        Specified by:
        postProcess in interface AdapterInterface
      • close

        public void close()
        Close the adapter streams
        Specified by:
        close in interface AdapterInterface