Package com.ibm.di.fc

Class 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 Detail

      • ParserFC

        public ParserFC()
    • 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 interface FunctionInterface
        Overrides:
        updateSchema in class Function
        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 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:
        java.lang.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 java.lang.String getVersion()
        Version information.
        Returns:
        version information.
      • terminate

        public void terminate()
                       throws java.lang.Exception
        Closes the parser
        Specified by:
        terminate in interface FunctionInterface
        Overrides:
        terminate in class Function
        Throws:
        java.lang.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