Class BaseNPLProgram

java.lang.Object
com.nt.udc.npl.BaseNPLProgram
All Implemented Interfaces:
NPLProgramIfc

public abstract class BaseNPLProgram extends Object implements NPLProgramIfc
  • Field Details

  • Constructor Details

    • BaseNPLProgram

      public BaseNPLProgram()
      Initializes this NPL program's built-in function table.
    • BaseNPLProgram

      public BaseNPLProgram(Class outputType, DataReceiverIfc ireceiver, LoggerIfc logIfc)
      Sets the the output type, Data Receiver and Logger with the given values for this NPLProgram and then initializes this NPL program's built-in function table.
  • Method Details

    • getLogger

      public LoggerIfc getLogger()
      Returns the LoggerIfc being used to log messages generated by this NPLProgram during data processing
      Specified by:
      getLogger in interface NPLProgramIfc
    • setLogger

      public void setLogger(LoggerIfc logIfc)
      Sets the LoggerIfc to be used for logging messages generated by this NPLProgram during data processing
      Specified by:
      setLogger in interface NPLProgramIfc
    • getOutputType

      public Class getOutputType()
      Returns the Class for the DCFieldContainer object that this NPLProgram will produce.
    • setOutputType

      public void setOutputType(Class out_type) throws ClassCastException
      Returns the Class for the DCFieldContainer object that this NPLProgram will produce.
      Throws:
      ClassCastException
    • getDataReceiver

      public DataReceiverIfc getDataReceiver()
      Specified by:
      getDataReceiver in interface NPLProgramIfc
    • setDataReceiver

      public void setDataReceiver(DataReceiverIfc ireceiver)
      Specified by:
      setDataReceiver in interface NPLProgramIfc
    • processData

      public DCFieldContainer[] processData(DCFieldContainer input, Class out_type) throws NPLException
      Description copied from interface: NPLProgramIfc
      Process the given input fields with this NPL program. If this NPL program is creating any output records, the specified output type is used.
      Specified by:
      processData in interface NPLProgramIfc
      Parameters:
      input - input fields to process
      out_type - type of any output records created by this NPL program (must implement DCFieldContainer interface)
      Throws:
      NPLException - if error while processing data
    • setMethodHandler

      public void setMethodHandler(IDCMethodHandler mh) throws NPLException
      Description copied from interface: NPLProgramIfc
      Set the method handler object of the NPL program corresponding to the method handler imported by the NPL program.
      Specified by:
      setMethodHandler in interface NPLProgramIfc
      Parameters:
      mh - object that implements sub-interface of IDCMethodHandler
      Throws:
      NPLException - if object passed to this method does not implement interface imported in NPL file
    • getMethodHandler

      public IDCMethodHandler getMethodHandler()
      Description copied from interface: NPLProgramIfc
      Returns the method handler imported by the NPL program and set using setMethodHandler(IDCMethodHandler mh).
      Specified by:
      getMethodHandler in interface NPLProgramIfc
    • getMethodHandler

      public IDCMethodHandler getMethodHandler(String name)
      Description copied from interface: NPLProgramIfc
      Returns the method handler with the specified name. Use IMPORTED_JAVA_HANDLER_NAME to retrieve the imported method handler. For method handlers declared using the JavaHook declaration, use the name given to identify the method handler in the JavaHook declaration.
      Specified by:
      getMethodHandler in interface NPLProgramIfc
      Parameters:
      name - name of method handler to get
      Returns:
      method handler with given name or null if no method handler with given name
    • getInputFields

      public ArrayList getInputFields()
      Description copied from interface: NPLProgramIfc
      Gets a list of the input fields defined in the input records.
      Specified by:
      getInputFields in interface NPLProgramIfc
      Returns:
      List of input fields. The elements in this ArrayList are actually other ArrayLists, one for each input record. The elements of these ArrayLists are FieldDescriptor objects, one for each field in the input record.
    • getOutputFields

      public ArrayList getOutputFields()
      Description copied from interface: NPLProgramIfc
      Gets a list of the output fields defined in the output records.
      Specified by:
      getOutputFields in interface NPLProgramIfc
      Returns:
      List of output fields. The elements in this ArrayList are actually other ArrayLists, one for each output record. The elements of these ArrayLists are FieldDescriptor objects, one for each field in the output record.
    • getExposedFields

      public ArrayList getExposedFields(String reason)
      Description copied from interface: NPLProgramIfc
      Gets a list of the fields defined in the expose clause for the reason provided.
      Specified by:
      getExposedFields in interface NPLProgramIfc
      Parameters:
      reason - Reason the fields are being exposed.
      Returns:
      List of exposed fields. The elements in the ArrayList are FieldDescriptor objects, one for each field in the expose clause matching the reason provided.
    • getConfigValue

      public String getConfigValue(String key)
      Description copied from interface: NPLProgramIfc
      Gets the value of a configuration attribute.
      Specified by:
      getConfigValue in interface NPLProgramIfc
      Parameters:
      key - Configuration attribute to get the value of.
      Returns:
      Value of the attribute. Returns null if the attribute does not exist.
    • handleException

      public void handleException(String msg, Exception e)
      Exception handler for exceptions that occur during NPL program execution. The purpose is to log a message and not throw exceptions while processing.
      Parameters:
      msg - a text message that is prepended to the standard message of the exception handler
      e - the exception that occurred
    • getOutputRecInstance

      protected DCFieldContainer getOutputRecInstance() throws NPLException
      Throws:
      NPLException
    • initBuiltInFunctionTable

      protected void initBuiltInFunctionTable()
    • builtInFunctionTable

      protected NPLFunctionTable builtInFunctionTable()
    • getFieldValue

      protected static byte[] getFieldValue(DCFieldContainer dcfc, String attr_id) throws NonExistentAttributeException
      Throws:
      NonExistentAttributeException
    • getFieldValue

      protected static byte[] getFieldValue(DCFieldContainer dcfc, FieldKey attr_id) throws NonExistentAttributeException
      Throws:
      NonExistentAttributeException
    • getFieldValueAsString

      protected static byte[] getFieldValueAsString(DCFieldContainer dcfc, FieldKey attr_id) throws NonExistentAttributeException
      Throws:
      NonExistentAttributeException
    • byte2bytes

      protected static byte[] byte2bytes(byte b)
    • bytes2byte

      protected static byte bytes2byte(byte[] barr) throws RuntimeException
      Throws:
      RuntimeException
    • short2bytes

      protected static byte[] short2bytes(short s)
    • bytes2short

      protected static short bytes2short(byte[] barr) throws RuntimeException
      Throws:
      RuntimeException
    • int2bytes

      protected static byte[] int2bytes(int i)
    • bytes2int

      protected static int bytes2int(byte[] barr) throws RuntimeException
      Throws:
      RuntimeException
    • long2bytes

      protected static byte[] long2bytes(long l)
    • bytes2long

      protected static long bytes2long(byte[] barr) throws RuntimeException
      Throws:
      RuntimeException
    • float2bytes

      protected static byte[] float2bytes(float f)
    • bytes2float

      protected static float bytes2float(byte[] barr) throws RuntimeException
      Throws:
      RuntimeException
    • double2bytes

      protected static byte[] double2bytes(double d)
    • bytes2double

      protected static double bytes2double(byte[] barr) throws RuntimeException
      Throws:
      RuntimeException
    • processRecord

      protected abstract DCFieldContainer[] processRecord(DCFieldContainer input) throws NPLException
      Throws:
      NPLException