Class SettableDataContext

    • Field Detail

      • CLEANUP_NAME

        protected static final String CLEANUP_NAME
        The object descriptor for the clean-up registered for SettableDataContext instances.
        See Also:
        Constant Field Values
      • cleanup

        protected transient Cleanup<RuntimeException> cleanup
        The clean-up for closing the Closeable parameter values.
      • valueLock

        protected transient ReadWriteLock valueLock
        The lock for synchronising access to the values of this data context.
      • values

        protected final HashMap<String,​Serializable> values
        The value of the input and output parameters. If a parameter is not in the list its value is expected to be null.
      • inputParams

        protected final HashMap<String,​ProcessModelParameter> inputParams
        A map of all input parameters, mapping the name of a parameter to the corresponding parameter object.
      • outputParams

        protected final HashMap<String,​ProcessModelParameter> outputParams
        A map of all output parameters, mapping the name of a parameter to the corresponding parameter object.
    • Constructor Detail

      • SettableDataContext

        @Deprecated(since="15.0.0",
                    forRemoval=true)
        public SettableDataContext()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Creates a new SettableDataContext with no parameters and no values.
      • SettableDataContext

        public SettableDataContext​(Logger logger)
        Creates a new SettableDataContext with no parameters and no values.
        Parameters:
        logger - The logger of the using service-instance specific for this class.
      • SettableDataContext

        @Deprecated(since="15.0.0",
                    forRemoval=true)
        public SettableDataContext​(Map<String,​Serializable> values,
                                   Map<String,​ProcessModelParameter> inputParams,
                                   Map<String,​ProcessModelParameter> outputParams)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Creates a new SettableDataContext with the designated parameters and values. Please ensure that the maps are consistent, that is the value-map contains only parameters that are either in the input or in the output parameter map. Additionally, all mandatory input parameter need to have a value in the value map.
        Parameters:
        values - The values of the parameters, mapping the parameter names to the corresponding values.
        The caller is responsible for closing the values if appropriate.
        inputParams - The input parameters for the data context mapping the parameter name to the corresponding parameter object.
        outputParams - The output parameters for the data context mapping the parameter name to the corresponding parameter object.
      • SettableDataContext

        public SettableDataContext​(Map<String,​Serializable> values,
                                   Map<String,​ProcessModelParameter> inputParams,
                                   Map<String,​ProcessModelParameter> outputParams,
                                   Logger logger)
        Creates a new SettableDataContext with the designated parameters and values. Please ensure that the maps are consistent, that is the value-map contains only parameters that are either in the input or in the output parameter map. Additionally, all mandatory input parameter need to have a value in the value map.
        Parameters:
        values - The values of the parameters, mapping the parameter names to the corresponding values.
        The caller is responsible for closing the values if appropriate.
        inputParams - The input parameters for the data context mapping the parameter name to the corresponding parameter object.
        outputParams - The output parameters for the data context mapping the parameter name to the corresponding parameter object.
        logger - The logger of the using service-instance specific for this class.
    • Method Detail

      • addInputParameter

        public void addInputParameter​(ProcessModelParameter param,
                                      Serializable value)
        Adds the designated parameter as input parameter to this data context having the designated value. If you need to have it as output parameter as well, also add it as output parameter. If the value is not set yet, use null as value. But do not provide null for a mandatory input parameter!
        Parameters:
        param - The parameter to add as input parameter to this data context.
        value - The value of the input parameter (may be null). The caller is responsible for closing if appropriate.
        Throws:
        ClassCastException - If the designated value is not of the Java-type corresponding to the ADEPT-data type of the designated parameter, a ClassCastException will be thrown.
      • addOutputParameter

        public void addOutputParameter​(ProcessModelParameter param)
        Adds the designated parameter as output parameter to this data context. If you need to have it as input parameter as well, also add it as input parameter.
        Parameters:
        param - The parameter to add as output parameter to this data context.
      • getValues

        public Map<String,​Serializable> getValues()
        Returns the values set for the data context, that is a mapping from parameter names to the corresponding values as Java-objects.
        Returns:
        All values as mapping from parameter names to the values as Java-objects.
        The values will be coupled to this DataContext, so do not close them; clone them if required longer than this DataContext.
      • checkType

        protected void checkType​(Object value,
                                 ProcessConstants.AdeptDataType expectedType)
        Checks whether the designated value is of the Java-type corresponding to the designated ADEPT-data type.
        Parameters:
        value - The value to check the type of.
        expectedType - The ADEPT-data type that the value is expected to be.
        Throws:
        ClassCastException - If the designated value is not of an appropriate type, a ClassCastException will be thrown.
      • isNull

        public boolean isNull​(String parameterName)
                       throws NoSuchParameterException
        Description copied from interface: InputDataContext
        Returns whether the value of the designated parameter is NULL which means the data element has not been written or has been consumed yet or has been explicitly set to NULL by a previous application. This method has to be called before retrieving a value.
        Specified by:
        isNull in interface InputDataContext
        Parameters:
        parameterName - The name of the parameter to check on NULL.
        Returns:
        true if the value of the designated parameter is NULL and therefore has not been written or has been consumed yet.
        Throws:
        NoSuchParameterException - If the parameter of the designated name does not exist, a NoSuchParameterException will be thrown.
      • checkInputExistence

        protected void checkInputExistence​(String parameterName)
                                    throws NoSuchParameterException
        Checks whether the designated parameter is an input parameter (exists in the input parameter map).
        Parameters:
        parameterName - The name of the input parameter to check for its existence.
        Throws:
        NoSuchParameterException - If the designated parameter name is not known as input parameter, a NoSuchParameterException will be thrown.
      • checkInputExistenceAndType

        protected void checkInputExistenceAndType​(String parameterName,
                                                  ProcessConstants.AdeptDataType expectedType)
                                           throws NoSuchParameterException,
                                                  InvalidDataTypeException
        Checks whether the designated parameter is an input parameter (exists in the input parameter map) and whether it is of the Java-type corresponding to the designated expected ADEPT-data type. If the value of the input parameter is NULL an IllegalStateException is thrown.
        Parameters:
        parameterName - The name of the input parameter to check for its existence and type.
        expectedType - The type that is expected for the designated parameter.
        Throws:
        NoSuchParameterException - If the designated parameter name is not known as input parameter, a NoSuchParameterException will be thrown.
        InvalidDataTypeException - If the designated parameter is known but its value is not of the Java-type corresponding to the designated expected type.
        IllegalStateException - If the value of the designated parameter is null an IllegalStateException will be thrown.
      • isReadOnly

        public boolean isReadOnly()
        Description copied from interface: DataContext
        Returns whether this data container is read only and therefore does not allow to store values (and throws an UnsupportedOperationException at the corresponding methods).
        Specified by:
        isReadOnly in interface DataContext
        Returns:
        Whether this data container is read only and therefore does not allow to store values.
      • ignoreValue

        public void ignoreValue​(String parameterName)
                         throws NoSuchParameterException
        Description copied from interface: DataContext
        Ignores the value of the designated parameter that is the value has not been written.
        An InvalidExecutorThreadException will be thrown if the method is not called by the main thread of the corresponding component.
        Specified by:
        ignoreValue in interface DataContext
        Parameters:
        parameterName - The name of the parameter to be ignored.
        Throws:
        NoSuchParameterException - If the parameter of the designated name does not exist, a NoSuchParameterException will be thrown.
      • ignoredValue

        public boolean ignoredValue​(String parameterName)
                             throws NoSuchParameterException
        Description copied from interface: DataContext
        Returns whether the value of the designated output parameter is not or has not been set (ignored) by the application.
        An InvalidExecutorThreadException will be thrown if the method is not called by the main thread of the corresponding component.
        Specified by:
        ignoredValue in interface DataContext
        Parameters:
        parameterName - The name of the output parameter to check for being unset.
        Returns:
        true if the value of the designated output parameter is or has not been written.
        Throws:
        NoSuchParameterException - If the output parameter of the designated name does not exist, a NoSuchParameterException will be thrown.
      • storeIntegerParameterValue

        public void storeIntegerParameterValue​(String parameterName,
                                               long value)
                                        throws NoSuchParameterException,
                                               InvalidDataTypeException
        Description copied from interface: DataContext
        Writes an output parameter of the type integer (in java: long) to the data context of the process management system. The RuntimeEnvironment executes some management routines, e. g. access control, and delegates the function call to the DataContainer object.
        An InvalidExecutorThreadException will be thrown if the method is not called by the main thread of the corresponding component.
        Specified by:
        storeIntegerParameterValue in interface DataContext
        Parameters:
        parameterName - The name of the output parameter to be written.
        value - The value that is written for the designated output parameter.
        Throws:
        NoSuchParameterException - If the parameter of the designated name does not exist, a NoSuchParameterException will be thrown.
        InvalidDataTypeException - If the designated parameter is not of type INTEGER, an InvalidDataTypeException will be raised.
        See Also:
        DataContainer
      • storeFloatParameterValue

        public void storeFloatParameterValue​(String parameterName,
                                             double value)
                                      throws NoSuchParameterException,
                                             InvalidDataTypeException
        Description copied from interface: DataContext
        Writes an output parameter of the type float to the data container of the process management system. The RuntimeEnvironment executes some management routines, e. g. access control, and delegates the function call to the DataContainer object.
        An InvalidExecutorThreadException will be thrown if the method is not called by the main thread of the corresponding component.
        Specified by:
        storeFloatParameterValue in interface DataContext
        Parameters:
        parameterName - The name of the output parameter to be written.
        value - The value that is written for the designated output parameter.
        Throws:
        NoSuchParameterException - If the parameter of the designated name does not exist, a NoSuchParameterException will be thrown.
        InvalidDataTypeException - If the designated parameter is not of type FLOAT, an InvalidDataTypeException will be raised.
        See Also:
        DataContainer
      • storedFloatParameterValue

        public double storedFloatParameterValue​(String parameterName)
                                         throws NoSuchParameterException,
                                                InvalidDataTypeException
        Description copied from interface: DataContext
        Reads the double value of the designated output parameter.
        An InvalidExecutorThreadException will be thrown if the method is not called by the main thread of the corresponding component.
        Callers should first check whether the value is null by calling DataContext.ignoredValue(String). Otherwise in case of NULL an IllegalStateException is thrown.
        Specified by:
        storedFloatParameterValue in interface DataContext
        Parameters:
        parameterName - The name of the output parameter to be read.
        Returns:
        The value of the output parameter of ADEPT2-type FLOAT and of Java-type double.
        Throws:
        NoSuchParameterException - If the output parameter of the designated name does not exist, a NoSuchParameterException will be thrown.
        InvalidDataTypeException - If the designated output parameter is not of type FLOAT, an InvalidDataTypeException will be raised.
        See Also:
        ProcessConstants.AdeptDataType.FLOAT
      • storeBooleanParameterValue

        public void storeBooleanParameterValue​(String parameterName,
                                               boolean value)
                                        throws NoSuchParameterException,
                                               InvalidDataTypeException
        Description copied from interface: DataContext
        Writes an output parameter of the type boolean to the data container of the process management system. The RuntimeEnvironment executes some management routines, e. g. access control, and delegates the function call to the DataContainer object.
        An InvalidExecutorThreadException will be thrown if the method is not called by the main thread of the corresponding component.
        Specified by:
        storeBooleanParameterValue in interface DataContext
        Parameters:
        parameterName - The name of the output parameter to be written.
        value - The value that is written for the designated output parameter.
        Throws:
        NoSuchParameterException - If the parameter of the designated name does not exist, a NoSuchParameterException will be thrown.
        InvalidDataTypeException - If the designated parameter is not of type BOOLEAN, an InvalidDataTypeException will be raised.
        See Also:
        DataContainer
      • storedBooleanParameterValue

        public boolean storedBooleanParameterValue​(String parameterName)
                                            throws NoSuchParameterException,
                                                   InvalidDataTypeException
        Description copied from interface: DataContext
        Reads the boolean value of the designated output parameter.
        An InvalidExecutorThreadException will be thrown if the method is not called by the main thread of the corresponding component.
        Callers should first check whether the value is null by calling DataContext.ignoredValue(String). Otherwise in case of NULL an IllegalStateException is thrown.
        Specified by:
        storedBooleanParameterValue in interface DataContext
        Parameters:
        parameterName - The name of the output parameter to be read.
        Returns:
        The value of the output parameter of ADEPT2-type BOOLEAN and of Java-type boolean.
        Throws:
        NoSuchParameterException - If the output parameter of the designated name does not exist, a NoSuchParameterException will be thrown.
        InvalidDataTypeException - If the designated output parameter is not of type BOOLEAN, an InvalidDataTypeException will be raised.
        See Also:
        ProcessConstants.AdeptDataType.BOOLEAN
      • storeStringParameterValue

        public void storeStringParameterValue​(String parameterName,
                                              String value)
                                       throws NoSuchParameterException,
                                              InvalidDataTypeException
        Description copied from interface: DataContext
        Writes an output parameter of type String to the data container of the process management system. The RuntimeEnvironment executes some management routines, e. g. access control, and delegates the function call to the DataContainer object.
        An InvalidExecutorThreadException will be thrown if the method is not called by the main thread of the corresponding component.
        Specified by:
        storeStringParameterValue in interface DataContext
        Parameters:
        parameterName - The name of the output parameter to be written.
        value - The value that is written for the designated output parameter.
        Throws:
        NoSuchParameterException - If the parameter of the designated name does not exist, a NoSuchParameterException will be thrown.
        InvalidDataTypeException - If the designated parameter is not of type STRING, an InvalidDataTypeException will be raised.
        See Also:
        DataContainer
      • storeDateParameterValue

        public void storeDateParameterValue​(String parameterName,
                                            Date value)
                                     throws NoSuchParameterException,
                                            InvalidDataTypeException
        Description copied from interface: DataContext
        Writes an output parameter of the type date to the data context of the process management system. The RuntimeEnvironment executes some management routines, e. g. access control, and delegates the function call to the DataContainer object.
        An InvalidExecutorThreadException will be thrown if the method is not called by the main thread of the corresponding component.
        Specified by:
        storeDateParameterValue in interface DataContext
        Parameters:
        parameterName - The name of the output parameter to be written.
        value - The value that is written for the designated output parameter.
        Throws:
        NoSuchParameterException - If the parameter of the designated name does not exist, a NoSuchParameterException will be thrown.
        InvalidDataTypeException - If the designated parameter is not of type DATE, an InvalidDataTypeException will be raised.
        See Also:
        DataContainer
      • storeURIParameterValue

        public void storeURIParameterValue​(String parameterName,
                                           URI value)
                                    throws NoSuchParameterException,
                                           InvalidDataTypeException
        Description copied from interface: DataContext
        Writes an output parameter of type URI to the data container of the process management system. The RuntimeEnvironment executes some management routines, e. g. access control, and delegates the function call to the DataContainer object.
        An InvalidExecutorThreadException will be thrown if the method is not called by the main thread of the corresponding component.
        Specified by:
        storeURIParameterValue in interface DataContext
        Parameters:
        parameterName - The name of the output parameter to be written.
        value - The value that is written for the designated output parameter.
        Throws:
        NoSuchParameterException - If the parameter of the designated name does not exist, a NoSuchParameterException will be thrown.
        InvalidDataTypeException - If the designated parameter is not of type URI, an InvalidDataTypeException will be raised.
        See Also:
        DataContainer
      • storeUDTParameterValue

        public void storeUDTParameterValue​(String parameterName,
                                           UDTValue value)
                                    throws NoSuchParameterException,
                                           InvalidDataTypeException
        Description copied from interface: DataContext
        Writes an output parameter of an user defined type to the data container of the process management system. The RuntimeEnvironment executes some management routines, e. g. access control, and delegates the function call to the DataContainer object.
        An InvalidExecutorThreadException will be thrown if the method is not called by the main thread of the corresponding component.
        Specified by:
        storeUDTParameterValue in interface DataContext
        Parameters:
        parameterName - The name of the output parameter to be written.
        value - The value that is written for the designated output parameter. The caller is responsible for closing.
        Throws:
        NoSuchParameterException - If the parameter of the designated name does not exist, a NoSuchParameterException will be thrown.
        InvalidDataTypeException - If the designated parameter is not of type UDT, an InvalidDataTypeException will be raised.
        See Also:
        DataContainer
      • storedUDTParameterValue

        public UDTValue storedUDTParameterValue​(String parameterName)
                                         throws NoSuchParameterException,
                                                InvalidDataTypeException
        Description copied from interface: DataContext
        Reads the value of the designated output parameter of user-defined type.
        An InvalidExecutorThreadException will be thrown if the method is not called by the main thread of the corresponding component.
        Callers should first check whether the value is null by calling DataContext.ignoredValue(String). Otherwise in case of NULL an IllegalStateException is thrown.
        Specified by:
        storedUDTParameterValue in interface DataContext
        Parameters:
        parameterName - The name of the output parameter to be read.
        Returns:
        The value of the output parameter of ADEPT2-type USERDEFINED and of Java-type UDTValue. The UDTValue will be coupled to this DataContext, so do not close it; clone it if required longer than this DataContext.
        Throws:
        NoSuchParameterException - If the output parameter of the designated name does not exist, a NoSuchParameterException will be thrown.
        InvalidDataTypeException - If the designated output parameter is not of type USERDEFINED, an InvalidDataTypeException will be raised.
        See Also:
        ProcessConstants.AdeptDataType.USERDEFINED
      • checkOutputExistence

        protected void checkOutputExistence​(String parameterName)
                                     throws NoSuchParameterException
        Checks whether the designated parameter is an output parameter (exists in the output parameter map).
        Parameters:
        parameterName - The name of the output parameter to check for its existence.
        Throws:
        NoSuchParameterException - If the designated parameter name is not known as output parameter, a NoSuchParameterException will be thrown.
      • checkOutputExistenceAndType

        protected void checkOutputExistenceAndType​(String parameterName,
                                                   ProcessConstants.AdeptDataType expectedType)
                                            throws NoSuchParameterException,
                                                   InvalidDataTypeException
        Checks whether the designated parameter is an output parameter (exists in the output parameter map) and whether it is of the Java-type corresponding to the designated expected ADEPT-data type.
        Parameters:
        parameterName - The name of the output parameter to check for its existence and type.
        expectedType - The type that is expected for the designated parameter.
        Throws:
        NoSuchParameterException - If the designated parameter name is not known as output parameter, a NoSuchParameterException will be thrown.
        InvalidDataTypeException - If the designated parameter is known but its value is not of the Java-type corresponding to the designated expected type.
      • checkOutputIgnored

        protected void checkOutputIgnored​(String parameterName)
                                   throws NoSuchParameterException
        Check whether the actual output parameter is null. In case of NULL an IllegalStateException will thrown.
        Parameters:
        parameterName - The name of the output parameter to check.
        Throws:
        NoSuchParameterException - If the designated parameter name is not known as output parameter, a NoSuchParameterException will be thrown.
        IllegalStateException - If the value of the designated parameter is NULL an IllegalStateException will be thrown.
      • subEquals

        public boolean subEquals​(Object obj)
        An implementation of Object.equals(Object) for various purpose. Due to several reasons we do not want actually override Object.equals(Object).
        Overrides:
        subEquals in class de.aristaflow.adept2.model.common.defaultimplementation.DefaultPluginDataContainer
        Parameters:
        obj - The object with which to compare.
        Returns:
        Whether this is the same object as the designated one.
      • subHashCode

        public int subHashCode()
        An implementation of Object.hashCode() for various purpose. Due to several reasons we do not want actually override Object.hashCode().
        The implementation conforms to the implementation of subEquals(Object) with respect to Object.equals(Object).
        Overrides:
        subHashCode in class de.aristaflow.adept2.model.common.defaultimplementation.DefaultPluginDataContainer
        Returns:
        A hash code value for this object.