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
 ParserInterface getParser()
          This method provides access to the ParserInterface implementation used internally.
 String getVersion()
          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.
 Object querySchema(Object o)
          This method queries the schema for this ParserFC.
 Entry readEntry(Object param)
          Returns the entry from the parser read operation
 void setDebug(boolean debug)
           Modify the debug mode setting of this component.
 void terminate()
          Closes the parser
 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, getDebug, getLog, getParam, getRSInterface, getUI, initialize, initialize, logmsg, setConfiguration, setContext, setLog, setParam, setRSInterface, 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
Parameters:
config - FunctionConfig
Returns:
boolean
Throws:
Exception - : never

querySchema

public Object querySchema(Object o)
                   throws Exception
This method queries the schema for this ParserFC.

Specified by:
querySchema in interface FunctionInterface
Overrides:
querySchema in class Function
Parameters:
o - Boolean.TRUE for inputschema, Boolean.FALSE for outputschema
Returns:
a Vector of Entry objects or null if no schema found
Throws:
Exception - : if the parser fails to load
See Also:
Entry, Vector

getParser

public ParserInterface getParser()
This method provides access to the ParserInterface implementation used internally.

Returns:
the parser this FC uses for handling user requests or null if the parser have not been loaded yet.

getVersion

public String getVersion()
Version information.

Returns:
version information.

terminate

public void terminate()
               throws Exception
Closes the parser

Specified by:
terminate in interface FunctionInterface
Overrides:
terminate in class Function
Throws:
Exception - An exception is thrown if this method fails.

setDebug

public void setDebug(boolean debug)

Modify the debug mode setting of this component. May be called by different threads.

This method is for internal use only. Do not call it from user code.

Overrides:
setDebug in class Function
Parameters:
debug - the debug mode setting