Package com.ibm.di.fc.castorbind
Class CastorJavaToXML
- java.lang.Object
-
- com.ibm.di.fc.Function
-
- com.ibm.di.fc.castorbind.CastorJavaToXML
-
- All Implemented Interfaces:
FunctionInterface
,VersionInfoInterface
public class CastorJavaToXML extends Function
This is the CastorJavaToXML class. This is the main class of the CastorJavaToXML function component. The CastorJavaToXML Function Component creates an XML document from a Java object or an Entry object.
-
-
Constructor Summary
Constructors Constructor Description CastorJavaToXML()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getVersion()
Version information.void
initialize(java.lang.Object obj)
In the initialize method the FC initializes its parameters.Entry
marshal(Entry aEntry, java.lang.String aMappingFile, java.lang.String aRootElementName, boolean aUseAttrNames)
This method is called when the CastorJavaToXML FC is passed an Entry object.java.lang.Object
marshal(java.lang.Object aObject, java.lang.String aMappingFile)
This method is called when the CastorJavaToXML FC is passed a Java object which is not an Entry object, the metho will serialize the object passed using Castor serialization and this will be the result XML.java.lang.Object
perform(java.lang.Object obj)
The CastorJavaToXML Function Component can operate both with Entry objects and with custom Java objects.-
Methods inherited from class com.ibm.di.fc.Function
debug, getConfiguration, getContext, getDebug, getLog, getParam, getRSInterface, getUI, initialize, logmsg, querySchema, setConfiguration, setContext, setDebug, setLog, setParam, setRSInterface, terminate, updateSchema, verifyInitialized
-
-
-
-
Method Detail
-
initialize
public void initialize(java.lang.Object obj) throws java.lang.Exception
In the initialize method the FC initializes its parameters.- Specified by:
initialize
in interfaceFunctionInterface
- Overrides:
initialize
in classFunction
- Parameters:
obj
- not used.- Throws:
java.lang.Exception
- If the mapping file parameter is missing or the return type is not valid.
-
perform
public java.lang.Object perform(java.lang.Object obj) throws java.lang.Exception
The CastorJavaToXML Function Component can operate both with Entry objects and with custom Java objects. When the Function Component is passed an Entry object on input, it will return an Entry object. This mode of operation is called Entry mode. In Entry mode each Attribute of the Entry passed on input is marshaled and placed under the root of the resulting XML element. If the "returnXMLType" parameter is set to "DOMElement" the resulting Entry contains one attribute named "xmlDOMElement" and its value is the marshaled XML element as an "org.w3c.dom.Element" object. If the "returnXMLType" parameter is set to "String" the resulting Entry contains one attribute named "xmlString" and its value is the marshaled XML element as a "java.lang.String" object. When passed a Java object which is not an Entry object, the Function Component will serialize the object passed using Castor serialization and this will be the result XML. This mode of operation is called non-Entry mode. If the "returnXMLType" parameter is set to "DOMElement" the resulting XML element is returned as a "org.w3c.dom.Element" object. If the "returnXMLType" parameter is set to "String" the XML element is returned as a "java.lang.String" object.- Parameters:
obj
- this is the input object passed to the FC.- Returns:
- Returns DOMElement or String object depending on the returnXMLType specified by the FC.
- Throws:
java.lang.Exception
- If initialization is not performed or if an Exception occur during the marshaling process.
-
marshal
public Entry marshal(Entry aEntry, java.lang.String aMappingFile, java.lang.String aRootElementName, boolean aUseAttrNames) throws java.lang.Exception
This method is called when the CastorJavaToXML FC is passed an Entry object. Each Attribute of the Entry passed on input is marshaled and placed under the root of the resulting XML element.- Parameters:
aEntry
- the input data as an Entry object.aMappingFile
- the path to the Castor XML Mapping File that defines mapping rules.aRootElementName
- This parameter specifies the name of the root element of the generated XML.aUseAttrNames
- When set to "true" the names of the Entry Attributes are used as XML element names, otherwise the XML elements are named as specified in the mapping file.- Returns:
- Returns DOMElement or String object depending on the returnXMLType specified by the FC.
- Throws:
java.lang.Exception
- If an Exception occurs during the object marshaling.
-
marshal
public java.lang.Object marshal(java.lang.Object aObject, java.lang.String aMappingFile) throws java.lang.Exception
This method is called when the CastorJavaToXML FC is passed a Java object which is not an Entry object, the metho will serialize the object passed using Castor serialization and this will be the result XML.- Parameters:
aObject
- the input data as a java.lang.Object.aMappingFile
- the path to the Castor XML Mapping File that defines mapping rules.- Returns:
- Returns DOMElement or String object depending on the returnXMLType specified by the FC.
- Throws:
java.lang.Exception
- If an Exception occurs during the object marshaling.
-
getVersion
public java.lang.String getVersion()
Version information.- Returns:
- version information.
-
-