com.rational.test.ft.datapool

Class DatapoolFactory

  • java.lang.Object
    • com.rational.test.ft.datapool.DatapoolFactory
  • All Implemented Interfaces:
    IDatapoolFactory


    public class DatapoolFactory
    extends java.lang.Object
    implements IDatapoolFactory, IDatapoolFactory
    The DatapoolFactory is a singleton object so that IDatapool and IDatapoolIterator instances can be shared. Being a singleton object means that only gets constructed and everyone uses the same factory instance to construct the shared objects. Test scripts by default use managed datapools that share the datapool and iterator instance across multiple scripts.

    Refer to the datapool package documentation for a discussion on how to iterate over datapool contents manually.

    Since:
    RFT2.0
    • Field Detail

      • DEFAULT_ITERATOR_CLASS

        public static final java.lang.String DEFAULT_ITERATOR_CLASS
        See Also:
        Constant Field Values
    • Constructor Detail

      • DatapoolFactory

        protected DatapoolFactory()
        The constructor is intentionally protected so that only once instance of the DatapoolFactory can be constructed. Refer to the get method for access to the singleton.
    • Method Detail

      • get

        public static DatapoolFactory get()
        The DatapoolFactory is a singleton object and only one should get constructed. This method returns the one and only DatapoolFactory instance for the process.
        Returns:
        Returns the one and only DatapoolFactory instance for the process.
      • load

        public IDatapool load(java.io.File dpFile,
                              boolean sharedInstance)
        Description copied from interface: IDatapoolFactory
        Load the datapool from the specified file. If a sharedInstance is requested then the cache of other datapools that have been opened is checked for an existing copy of the datapool. Note that modifying a shared instance of the datapool may effect other uses of the datapool and should only be done in a confined execution environment.
        Specified by:
        load in interface IDatapoolFactory
        Parameters:
        dpFile - The datapool file name.
        sharedInstance - Available for sharing instances of the datapool, which can save significantly on datapool loading overhead.
        See Also:
        IDatapoolFactory.unload(IDatapool)
      • unload

        public void unload(IDatapool datapool)
        Description copied from interface: IDatapoolFactory
        Removes a reference to an instance of a datapool. If the datapool is shared the reference count is reduced. Once all references to a datapool have been unloaded the datapool instance may be made available to garbage collection.
        Specified by:
        unload in interface IDatapoolFactory
        Parameters:
        datapool - The datapool instance being unloaded.
        See Also:
        IDatapoolFactory.load(java.io.File,boolean)
      • getLoadFileName

        public java.lang.String getLoadFileName(IDatapool datapool)
        Returns the file name for the datapool as it was loaded or null if the supplied datapool was not loaded from a file.
      • setLoadFileName

        public void setLoadFileName(IDatapool datapool,
                                    java.lang.String fileName)
        Update the file name for the datapool should be stored to by default. Updating this value allows the datapool to be stored without explicitly specifying the target file name.
      • open

        public IDatapoolIterator open(IDatapool datapool,
                                      java.lang.String iteratorClassName)
        Description copied from interface: IDatapoolFactory
        Return an iterator instance of the supplied iterator class. Depending on attributes associated with the iterator class it may be shared. The attributes of an iterator are negotiated between the factory implementation and the iterator base class.
        Specified by:
        open in interface IDatapoolFactory
        Parameters:
        datapool - The datapool instance being iterated over.
        See Also:
        IDatapoolFactory.close(IDatapoolIterator)
      • open

        public IDatapoolIterator open(IDatapool datapool,
                                      java.lang.String iteratorClassName,
                                      boolean shareDatapoolIterator)
        Construct a datapool iterator based on the supplied datapool and iterator class name. If a shared instance of the datapool is requested the the datapool will be queried for an associated iterator and it will be returned.
      • iteratorExists

        public boolean iteratorExists(IDatapool datapool)
      • constructDatapool

        public IDatapool constructDatapool()
        Description copied from interface: IDatapoolFactory
        Constructs and returns an empty IDataPool
      • loadForEdit

        public IDatapool loadForEdit(java.io.File dpFile,
                                     boolean sharedInstance)
        Description copied from interface: IDatapoolFactory
        Load the datapool from the specified file. If a sharedInstance is requested then the cache of other datapools that have been opened is checked for an existing copy of the datapool. Note that modifying a shared instance of the datapool may effect other uses of the datapool and should only be done in a confined execution environment.
        Parameters:
        dpFile - The datapool file name.
        sharedInstance - Available for sharing instances of the datapool, which can save significantly on datapool loading overhead.
        See Also:
        IDatapoolFactory.unload(IDatapool)
      • updateSharedDatapoolCache

        public void updateSharedDatapoolCache(com.rational.test.ft.datapool.impl.Datapool dp)
      • unload

        public void unload(IDatapool datapool)
        Description copied from interface: IDatapoolFactory
        Removes a reference to an instance of a datapool. If the datapool is shared the reference count is reduced. Once all references to a datapool have been unloaded the datapool instance will be made available to garbage collection.
        Parameters:
        datapool - The datapool instance being unloaded.
        See Also:
        #load(java.io.File,boolean)
      • getIteratorClassNames

        public DatapoolFactory.IteratorClassName[] getIteratorClassNames()
        Return the default iterator classes for display in the UI.
        Since:
        RFT2.0
      • addVariable

        public IDatapoolVariable addVariable(IDatapool datapool,
                                             java.lang.String variableName,
                                             java.lang.Object initialValue)
        Since:
        RFT2.0
      • addVariable

        public IDatapoolVariable addVariable(IDatapool datapool,
                                             java.lang.String variableName,
                                             java.lang.Object initialValue,
                                             java.lang.String[] enumLiterals)
        Since:
        RFT2.0
      • isDatapoolInCache

        public boolean isDatapoolInCache(java.lang.String datapoolFileName)