Preemitters

In this section:

A preemitter is a Java class designed to convert from an outgoing XML document to a non-XML format. A standard preemitter is provided with the system capable of calling an iWay transform to accomplish this conversion. This "emit-ready" document then passes through the encryption services and is emitted based on the protocol. Preemitters can be associated with listeners, documents, or directly with XDDocuments within a business agent.

An example of a preemitter is a class that accepts an XML document and converts it to EDI.

Preemitters can be chained, so that the output of the first preemitter is passed to the second preemitter. This facility is useful in cases in which the outgoing document must be processed in its native format before final emit processing. The first preemitter accepts the document as an XDDocument (the internal form of a document) and must convert it to a byte stream. Subsequent preemitters accept byte streams and emit byte streams.

The preemitter may implement init() and term() calls, and must implement an input method.


Top of page

x
public byte[ ] transform(XDDocument d) throws XDException

This is responsible for transforming the incoming document into an output byte stream. It is the first preemitter in the chain.


Top of page

x
public byte[ ] transform(byte[ ] b) throws XDException

This is responsible for subsequent transforming of the outbound byte stream into another processed byte stream. This method is called for preemitters following the first preemitter, which uses the transform (XDDocument) signature to convert from document form to flat form for transmission.

Example, replace all 'X' characters with a new line.

public byte[] transform(byte[] b) throws XDException
{
    // for each character message, replace X with new line
    for (int j=0;j<b.length;j++)
    {
        if (b[i]=='X')
        {
            b[i]='\n';
        }
    }
    return b;
}

iWay Software