Custom Field Serializers

This topic contains example code to implement a custom field serializer in a message definition to take field data from the parsed data container and return additional data into the outgoing message, along with any specified wire formatting.

To do so, you must provide a Java class that implements the com.sybase.jtf.serializer.api.ICustomSerializerField interface. This interface is contained in the sgen.jar file, which is provided with the WorkSpace Message Designer. As shown in the following fragment, the code must implement the method serializeField() that is contained in the interface.
package com.sybase.jtf.serializer.api;

/**
 * This interface allows the user to define their own method to write to the 
 * output message.
 */
public interface ICustomSerializerField
{
        /**
         * This method allows the user to define a way to modify the data in a field
         * and write the modified data to the message directly.  The byte array that 
         * is returned will be added to the output message.
         * 
         * @param fieldData      An array of bytes that contains the data
         *                                in the field named in the message definition.
         *                                Note that this will be a null reference if
         *                                no field is named in the message definition.
         * @throws SerializationException Thrown if this method fails for any reason
         *                                (as defined by the user).  A call to the
         *                                method Exception.getMessage() will be made
         *                                if the exception is considered fatal to
         *                                the serialization of the message being 
         *                                processed.
         */
        public byte[] serializeField(byte[] fieldData) throws SerializationException;
}
Related tasks
Implementing a Custom Field Serializer

Send your feedback on this help topic to Sybase Technical Publications: pubs@sybase.com

Your comments will be sent to the technical publications staff at Sybase, Inc. For product-related issues or technical support, contact Sybase Technical Support at 1-800-8SYBASE.