Class EnvUtils


  • public final class EnvUtils
    extends java.lang.Object
    This class is used as factory for creating default implementation of DIF environments (DFEnvironmentRO and DFEnvironmentRW) and for creating environment for subtasks.
    Author:
    Petr Hamernik
    • Method Detail

      • createDefaultEnvironmentRO

        public static DFEnvironmentRO createDefaultEnvironmentRO​(java.lang.String progressName,
                                                                 boolean cancellable)
        Creates default environment for read only operations.
        Parameters:
        progressName - The progress name
        cancellable - The cancellable flag
        Returns:
        The default environment for read only operations
      • createDefaultEnvironmentRW

        public static DFEnvironmentRW createDefaultEnvironmentRW​(DFLock lock,
                                                                 java.lang.String progressName,
                                                                 boolean cancellable)
        Creates default environment for read-write operations.
        Parameters:
        lock - The lock
        progressName - The progress name
        cancellable - The cancellable flag
        Returns:
        The default environment for read-write operations
      • createSubTaskEnvironment

        public static DFEnvironmentRO createSubTaskEnvironment​(DFEnvironmentRO env,
                                                               java.lang.String subTaskName,
                                                               int masterWorkunitFrom,
                                                               int masterWorkunitTo,
                                                               int masterWorkunitTotal)
      • createRWFromRO

        public static DFEnvironmentRW createRWFromRO​(DFEnvironmentRO env,
                                                     DFLock lock)
        Make RW environment from given RO by adding lock and delegating the rest of methods. This method can be also used for replacing the current lock in some existing DFEnvironmentRW.
        Parameters:
        env - The read-only environment
        lock - The lock
        Returns:
        The proxy for the given DFEnvironmentRO, all methods except getLock() delegate to the original environment.
      • createFeedbackWithCancel

        public static EnvUtils.DFFeedbackWithCancel createFeedbackWithCancel​(DFFeedback feedback)
        Creates a proxy implementation for given DFFeedback and returns its extension of EnvUtils.DFFeedbackWithCancel type. This adds an ability to request stop action to the original feedback instance.
        Parameters:
        feedback - The original feedback
        Returns:
        proxy an extension (ability to stop operation)
      • createSubTaskEnvironment

        public static DFEnvironmentRO createSubTaskEnvironment​(java.beans.PropertyChangeEvent evt,
                                                               java.lang.String taskName)
        Creates sub-environment. If it is possible to extract environment from evt (it is instance of PropertyChangeEventWithEnv), it is used as master for the sub-environment. Otherwise, a new cancellable environment is created.
        Parameters:
        evt - the event potentially containing environment
        taskName - name of the sub-environment
        Returns:
        sub-environment