Chapter 9. Data conversion 215
import com.ibm.edms.od.*;
public class  CustomTransform {
    public static HashMap transformData(HashMap odMap) throws Exception {
        System.out.println("Inside transformData method");
        // List this transform name from the XML file
        System.out.println("  Transform name: " + 
(String)odMap.get(ODTransform.TXFRM_REQ_NAME));
        // List the property keys and values ODWEK read from the transform XML
        // file and provided to this Custom Class
        System.out.println("  Transform properties:");
        Properties gtProps = (Properties)odMap.get(ODTransform.TXFRM_REQ_PROPS);
        Enumeration<?> enumeration = gtProps.keys();
        List<String> list = new ArrayList<String>();
        while (enumeration.hasMoreElements()) {
            list.add((String)enumeration.nextElement());
        }
        Collections.sort(list);
        for (String key : list)
            System.out.println(String.format("%25s = %-25s", key,
gtProps.getProperty(key)));
        // Retrieve the native document from ODWEK
        byte[] inDoc = (byte [])odMap.get(ODTransform.TXFRM_REQ_DATA);
        System.out.println("  Native document size: " + (inDoc == null ? null:
inDoc.length));
        // Retrieve the document resources from ODWEK
        byte[] inRes = (byte [])odMap.get(ODTransform.TXFRM_REQ_RES);
        System.out.println("  Native doc resource size: " + (inRes == null ? null:
inRes.length));
        // Normally this is where you do the transform or do something with the
byte data.
        // Let's just concat the resources if there are any to the doc
        byte[] transformedDoc;
        if (inRes != null) {
            transformedDoc  = new byte[inRes.length + inDoc.length];
            System.arraycopy(inRes, 0, transformedDoc, 0, inRes.length);
            System.arraycopy(inDoc, 0, transformedDoc, inRes.length,
inDoc.length);
        }
        else
            transformedDoc = inDoc;
        System.out.println("  Concatenated resources to doc size: " +
transformedDoc.length);
        // Send the transformed data back to ODWEK
        HashMap rtnMap = new HashMap();
        rtnMap.put(ODTransform.TXFRM_RESP_DATA, transformedDoc);
        return rtnMap;
    }
}
Example 9-4 on page 214 shows how to set up the HashMap to pass document byte arrays in 
and out of this custom interface, and how to define a custom Java class that contains the 
transformData() method.