Custom Parser Extensions

Example code to implement the custom parser extension in a message definition.

If you need to perform data scrubbing or other custom post-processing of a parsed field in a message definition, you can create a custom extension for the field parser. To do so, you must provide a Java class that implements the com.sybase.jtf.parser.api.IParseExtension interface. This interface is contained in the pgen.jar file, which is provided with the WorkSpace Message Designer. As shown in the following fragment, your code must implement the method extend() that is contained in this interface. The message parser calls your implementation of this method so that you can fine-tune or replace the results.
// package declaration
package com.sybase.jtf.parser.api;

/**
 * The IParseExtension interface provides an extension point in which 
 * clients can develop custom code to extend the field parsing 
 * capability of any IParser. Once a field has been parsed by an IParser, 
 * the extend() method of a class that implements the IParseExtension 
 * interface can be called on that field to allow for additional 
 * functionality such as custom modification, substitution, additional 
 * validation and data scrubbing.
 */
public interface IParseExtension {

        /**
         * Called on a parsed field to allow clients to extend the field 
         * parsing capability of an IParser. 
         * 
         * @param field The parsed field (represented as a byte array).
         * 
         * @return The modified field (represented as a byte array).
         */
        public byte[] extend(byte[] field);
}
Related tasks
Implementing a Custom Parser Extension
Developing a Message Definition
Developing a Custom Class to Transform a Message Definition Field
Implementing a Custom Field Parser
Implementing a Custom Field Serializer
Adding a Field to a Message Definition

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.