com.ibm.di.fc
Class ParserFC

java.lang.Object
  extended by com.ibm.di.fc.Function
      extended by com.ibm.di.fc.ParserFC
All Implemented Interfaces:
FunctionInterface, VersionInfoInterface

public class ParserFC
extends Function

This is a function component that wraps parser operations. The configured parser is used in read/write mode depending on the type of object passed to this FC. If the passed type is an com.ibm.di.entry.Entry object, the write operation is used, otherwise the function will try to coerce the input param to an input stream in order to use the parser read operation. system.getFC("ibmdi.ParserFC").perform (new Entry()); // Returns the encoded string/byte array system.getFC("ibmdi.ParserFC").perform (file|string|inputstream|reader); // Returns the parsed entry


Field Summary
 
Fields inherited from class com.ibm.di.fc.Function
logger
 
Constructor Summary
ParserFC()
           
 
Method Summary
 String getVersion()
          Return version information
 Object perform(Object obj)
          If this method is called with an object of type java.lang.String, java.io.File, java.io.InputStream or java.io.Reader the configured parser is provided that object as input and the returned value is an Entry object resulting from the parsing.
 Entry readEntry(Object param)
          Returns the entry from the parser read operation
 boolean updateSchema(FunctionConfig config)
          This method modifies the schema in the provided configuration.
 Object writeEntry(Object obj)
          Returns the string or byte array from the parser write operation
 
Methods inherited from class com.ibm.di.fc.Function
debug, getConfiguration, getContext, getLog, getParam, getUI, initialize, initialize, logmsg, setConfiguration, setContext, setLog, setParam, terminate, verifyInitialized
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParserFC

public ParserFC()
Method Detail

perform

public Object perform(Object obj)
               throws Exception
If this method is called with an object of type java.lang.String, java.io.File, java.io.InputStream or java.io.Reader the configured parser is provided that object as input and the returned value is an Entry object resulting from the parsing. If this method is called with an Entry object, the parser is used to generate a byte stream that is returned either as a byte array or java.lang.String object. The latter depends on the configuration switch "returnString" setting. Depending on the value of the "mode" configuration parameter this method calls either readEntry or writeEntry method of the Parser.

Parameters:
obj - the input object for the function
Returns:
the output object for the function
Throws:
Exception - An exception is thrown if this method fails.

writeEntry

public Object writeEntry(Object obj)
                  throws Exception
Returns the string or byte array from the parser write operation

Parameters:
obj - The entry object to encode
Returns:
The string or byte array value resulting from the operation
Throws:
Exception - Any exception thrown by the parser

readEntry

public Entry readEntry(Object param)
                throws Exception
Returns the entry from the parser read operation

Parameters:
param - The parser input object
Returns:
The entry resulting from the parser read operation
Throws:
Exception - Any exception thrown by the parser

updateSchema

public boolean updateSchema(FunctionConfig config)
                     throws Exception
This method modifies the schema in the provided configuration. The intent is to allow the FC to provide a schema definition dynamically based on a given configuration.

Specified by:
updateSchema in interface FunctionInterface
Overrides:
updateSchema in class Function
Throws:
Exception

getVersion

public String getVersion()
Return version information

Returns:
The version value