# Java Class Conversion

Java classes can be used as input and output types for transformations. Also, business process variables can be created from Java classes. However, not all the fields that can make up a Java class are supported. This section describes which fields of a Java class are supported.

When you use a Java class or primitive in a transformation, WebLogic Integration converts it into an internal representation of XML Schema data types. Java fields that are not supported are ignored. WebLogic Integration then uses this internal representation to transform your Java classes to and from XML and non-XML (MFL) documents

Note: This internal representation of the XML Schema is not exposed in WebLogic Workshop.

Note: The mapper functionality of WebLogic Workshop will only display the fields of a Java class that are supported.

For a Java class to be used in WebLogic Integration, it must first be available in the WebLogic Workshop project. To learn more about including Java class in your project, see Using Existing Applications.

Java classes are converted using the following procedure:

1. If the Java class is selected as an input type for a DTF, by default the name of the class becomes the name of the variable. (For example, if the class Book is selected as an input type, by default, the _BookDoc variable is created by the mapper.) If the Java class is selected as the output type of a DTF, the name of the class becomes the name of the XML document's root element.

All the Java fields that can be mapped are converted to the appropriate XML Schema elements in the new XML Schema. If a field cannot be mapped it is ignored. To learn more, see the following table.

2. For each field of the Java class, this conversion procedure is applied recursively to determine the type of each sub-element. Fields that are themselves Java classes will be sub-elements in the internal XML Schema. These sub-elements will have the same name in the XML schema as their name in the Java class. For an example, see Using Java Classes in Transformations.
3. Java fields of the class are converted according to the following rules:

- Public instance member variables of supported Java types are converted.

The following table describes the supported fields of Java classes and how these fields are converted to the internal XML Schema representation of the Java class. Also, the XML Schema data type can be converted back to the Java field unless otherwise noted.

Java Field | Converts to this XML Schema Data Type . . .
--- | ---
Java primitive types | equivalent XML data types For example, Java primitive float type is converted to a XML Schema float type.
java.lang.String | xsd:string
java.util.Date | xsd:dateTime
java.util.Calendar | xsd:dateTime
XML Bean classes | To learn more see, XMLBeans Support for Built-In Schema Types.
MflObject classes | The type of the corresponding XML Schema
Java arrays | xsd:sequence of specified data type For example, an array of Java integers is converted to a XML sequence of integers.
javax.sql.RowSet | xsd:anyType Note: You cannot convert from XML back to a RowSet.
java.util.Collection and classes that implement the interface | xsd:anySimplType* Note: You cannot convert from XML back to a Collection because java.util.Collection is only an interface. You can, however, convert back to a class that implements the Collection interface.

Note: Static member variables are not converted.

Note: Final instance member variables (constants) are not converted.

- Private fields are converted if JavaBean style get and set property methods for that field are available in the class. For example, the following private member field: testBool is converted to an XML schema type because the class that contains testBool has set and get methods for this private field as show in the following code segment:

    public class TestSimpleTypes
    {
    	private boolean testBool;
    	public boolean getTestBool(){
    		return testBool;
    	}
    	public void setTestBool(boolean b){
    		testBool = b;
    	}
    }

- Interface type fields will be converted if JavaBean style get and set property methods for the interface are available in the class. You cannot convert from XML back to an interface. You can, however, convert back to a class that implements a interface.

Related Topics

To learn more about creating Java class variables in business processes, see Creating Variables.

To lean more about using Java classes as input or output parameters in transformations, see Using Java Classes in Transformations.