See information about the latest product version
Custom Java
You can use the Custom Java™ transform to enter your own Java code to use in the mapping.
In the Graphical Data Mapping editor, select Custom Java from the Custom Transforms list. You can then use the transform properties to select a Java method on a Java class from a Java project in your workspace. Use the content assist in the Values column to help you assign the required elements of the source schema.
The Java class that you provide to the map must have a static method that returns the appropriate type for the value of the output element, and takes parameters of the appropriate type for the wired inputs.
For example, the following Java method could be used in a Custom Java transform that had three input elements, of types a xs:string, xs:decimal and xs:boolean and the output element being a xs:decimal:
public static BigDecimal calSomething(String memType, BigDecimal stdCost, boolean flag) {
BigDecimal actualCost = stdCost;
if (flag & memType.startsWith("gold")) {
BigDecimal discRate = new BigDecimal(0.9);
actualCost = actualCost.multiply(discRate);
}
return actualCost;
}
The following table shows the mappings between the Schema type, the Java type, and the WebSphere® Message Broker tree type:
Schema type | Java type | Broker message tree type |
---|---|---|
xs:anyURI | java.lang.String | CHARACTER |
xs:base64Binary | byte[] | BLOB |
xs:boolean | boolean, java.lang.Boolean | BOOLEAN |
xs:byte | byte, java.lang.Byte | INTEGER |
xs:date | javax.xml.datatype.XMLGregorianCalendar | DATE |
xs:dateTime | javax.xml.datatype.XMLGregorianCalendar | TIMESTAMP |
xs:dayTimeDuration | javax.xml.datatype.Duration | INTERVAL |
xs:decimal | java.math.BigDecimal | DECIMAL |
xs:double | double, java.lang.Double | FLOAT |
xs:duration | javax.xml.datatype.Duration | INTERVAL |
xs:float | float, java.lang.Float | FLOAT |
xs:gDay | javax.xml.datatype.XMLGregorianCalendar | DATE |
xs:gMonth | javax.xml.datatype.XMLGregorianCalendar | DATE |
xs:gMonthDay | javax.xml.datatype.XMLGregorianCalendar | DATE |
xs:gYear | javax.xml.datatype.XMLGregorianCalendar | DATE |
xs:gYearMonth | javax.xml.datatype.XMLGregorianCalendar | DATE |
xs:hexBinary | byte[] | BLOB |
xs:int | int, java.lang.Integer | INTEGER |
xs:integer | java.math.BigInteger | DECIMAL |
xs:long | long, java.lang.Long | INTEGER |
xs:negativeInteger | java.math.BigInteger | DECIMAL |
xs:nonNegativeInteger | java.math.BigInteger | DECIMAL |
xs:nonPositiveInteger | java.math.BigInteger | DECIMAL |
xs:normalizedString | java.lang.String | CHARACTER |
xs:positiveInteger | java.math.BigInteger | DECIMAL |
xs:short | short, java.lang.Short | INTEGER |
xs:string | java.lang.String | CHARACTER |
xs:time | javax.xml.datatype.XMLGregorianCalendar | TIME |
xs:unsignedByte | Short | INTEGER |
xs:unsignedInt | Long | INTEGER |
xs:unsignedLong | java.math.BigInteger | DECIMAL |
xs:unsignedShort | Int | INTEGER |
xs:yearMonthDuration | javax.xml.datatype.Duration | INTERVAL |
You can also create Custom Java transforms to process input and outputs that are arrays or complex types; these cannot be converted from a Schema type to a defined Java type shown in the previous table.
In this case, your Java class must use the MbElement class to reference the input or output element. For information about using Java and the MbElement class, see Using Java API classes for Custom Java mapping transforms.