Package com.ibm.di.fc
Class ParserFC
- java.lang.Object
-
- com.ibm.di.fc.Function
-
- 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
-
-
Constructor Summary
Constructors Constructor Description ParserFC()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ParserInterface
getParser()
This method provides access to theParserInterface
implementation used internally.java.lang.String
getVersion()
Version information.java.lang.Object
perform(java.lang.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.java.lang.Object
querySchema(java.lang.Object o)
This method queries the schema for this ParserFC.Entry
readEntry(java.lang.Object param)
Returns the entry from the parser read operationvoid
setDebug(boolean debug)
Modify the debug mode setting of this component.void
terminate()
Closes the parserboolean
updateSchema(FunctionConfig config)
This method modifies the schema in the provided configuration.java.lang.Object
writeEntry(java.lang.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
-
-
-
-
Method Detail
-
perform
public java.lang.Object perform(java.lang.Object obj) throws java.lang.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:
java.lang.Exception
- An exception is thrown if this method fails.
-
writeEntry
public java.lang.Object writeEntry(java.lang.Object obj) throws java.lang.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:
java.lang.Exception
- Any exception thrown by the parser
-
readEntry
public Entry readEntry(java.lang.Object param) throws java.lang.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:
java.lang.Exception
- Any exception thrown by the parser
-
updateSchema
public boolean updateSchema(FunctionConfig config) throws java.lang.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 interfaceFunctionInterface
- Overrides:
updateSchema
in classFunction
- Parameters:
config
-FunctionConfig
- Returns:
- boolean
- Throws:
java.lang.Exception
- : never
-
querySchema
public java.lang.Object querySchema(java.lang.Object o) throws java.lang.Exception
This method queries the schema for this ParserFC.- Specified by:
querySchema
in interfaceFunctionInterface
- Overrides:
querySchema
in classFunction
- Parameters:
o
- Boolean.TRUE for inputschema, Boolean.FALSE for outputschema- Returns:
- a Vector of Entry objects or null if no schema found
- Throws:
java.lang.Exception
- : if the parser fails to load- See Also:
Entry
,Vector
-
getParser
public ParserInterface getParser()
This method provides access to theParserInterface
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 java.lang.String getVersion()
Version information.- Returns:
- version information.
-
terminate
public void terminate() throws java.lang.Exception
Closes the parser- Specified by:
terminate
in interfaceFunctionInterface
- Overrides:
terminate
in classFunction
- Throws:
java.lang.Exception
- An exception is thrown if this method fails.
-
-