Class DBaseFileAttributePool


  • public final class DBaseFileAttributePool
    extends Object
    This class provides a pool of attributes obtained from a DBase file and that could be used by dedicated attribute providers.

    This class permits to syndicate the access to a single dBase file by several attribute provider, assuming that an attribute provider accesses only one record of the dBase file.

    This class uses a soft-referenced DBaseFileReader instance.

    Since:
    14.0
    Version:
    17.0 2020-01-04 14:41:52
    Author:
    Stéphane GALLAND
    See Also:
    DBaseFileAttributeProvider, DBaseFileAttributeProvider
    Maven Group Id:
    org.arakhne.afc.advanced
    Maven Artifact Id:
    dbasefile
    • Method Detail

      • getPool

        static DBaseFileAttributePool getPool​(URL dbaseFile)
        Get the attribute pool that corresponds to the specified file.
        Parameters:
        dbaseFile - is the file from which the attributes could be extracted.
        Returns:
        the pool associated to the given file.
      • getPool

        static DBaseFileAttributePool getPool​(URI dbaseFile)
        Get the attribute pool that corresponds to the specified file.
        Parameters:
        dbaseFile - is the file from which the attributes could be extracted.
        Returns:
        the pool associated to the given file.
      • getPool

        static DBaseFileAttributePool getPool​(File dbaseFile)
        Get the attribute pool that corresponds to the specified file.
        Parameters:
        dbaseFile - is the file from which the attributes could be extracted.
        Returns:
        the pool associated to the given file.
      • getContainer

        @Pure
        public static DBaseFileAttributeProvider getContainer​(URL dbaseFile,
                                                              int recordNumber)
        Get an attribute container that corresponds to the specified file.
        Parameters:
        dbaseFile - is the file to read
        recordNumber - is the index of the record inside the file (0..size-1).
        Returns:
        a container or null on error
      • getProvider

        @Pure
        public static DBaseFileAttributeProvider getProvider​(URI dbaseFile,
                                                             int recordNumber)
        Get an attribute container that corresponds to the specified file.
        Parameters:
        dbaseFile - is the file to read
        recordNumber - is the index of the record inside the file (0..size-1).
        Returns:
        a container or null on error
      • getProvider

        @Pure
        public static DBaseFileAttributeProvider getProvider​(File dbaseFile,
                                                             int recordNumber)
        Get an attribute container that corresponds to the specified file.
        Parameters:
        dbaseFile - is the file to read
        recordNumber - is the index of the record inside the file (0..size-1).
        Returns:
        a container or null on error
      • getProvider

        @Pure
        public static DBaseFileAttributeProvider getProvider​(String resource,
                                                             int recordNumber)
        Get an attribute container that corresponds to the specified file

        The resource should be located according to the Class.getResource(String) or Class.getResourceAsStream(String) functions.

        Parameters:
        resource - is the resource to read
        recordNumber - is the index of the record inside the file (0..size-1).
        Returns:
        a container or null on error
      • getCollection

        @Pure
        public static DBaseFileAttributeCollection getCollection​(URL dbaseFile,
                                                                 int recordNumber)
        Get an attribute container that corresponds to the specified file.
        Parameters:
        dbaseFile - is the file to read
        recordNumber - is the index of the record inside the file (0..size-1).
        Returns:
        a container or null on error
      • getCollection

        @Pure
        public static DBaseFileAttributeCollection getCollection​(URI dbaseFile,
                                                                 int recordNumber)
        Get an attribute container that corresponds to the specified file.
        Parameters:
        dbaseFile - is the file to read
        recordNumber - is the index of the record inside the file (0..size-1).
        Returns:
        a container or null on error
      • getCollection

        @Pure
        public static DBaseFileAttributeCollection getCollection​(File dbaseFile,
                                                                 int recordNumber)
        Get an attribute container that corresponds to the specified file.
        Parameters:
        dbaseFile - is the file to read
        recordNumber - is the index of the record inside the file (0..size-1).
        Returns:
        a container or null on error
      • getCollection

        @Pure
        public static DBaseFileAttributeCollection getCollection​(String resource,
                                                                 int recordNumber)
        Get an attribute container that corresponds to the specified file

        The resource should be located according to the Class.getResource(String) or Class.getResourceAsStream(String) functions.

        Parameters:
        resource - is the resource to read
        recordNumber - is the index of the record inside the file (0..size-1).
        Returns:
        a container or null on error
      • close

        public void close()
                   throws IOException
        Close all opened accessors.
        Throws:
        IOException - in case of error.
      • getResource

        @Pure
        public URL getResource()
        Replies the resource used by this pool.
        Returns:
        the resource used by this pool.
      • getAllAttributeNames

        @Pure
        public Collection<String> getAllAttributeNames​(int recordNumber)
        Replies the names of all the attributes that corresponds to the specified record number.

        The parameter is not used because, in a dBase file, all the record have the same attribute names.

        Parameters:
        recordNumber - the number of the record.
        Returns:
        the collection of attribute names
      • getAttributeCount

        @Pure
        public int getAttributeCount()
        Replies the count of attributes.
        Returns:
        the count of attributes
      • getRawValue

        @Pure
        public Object getRawValue​(int recordNumber,
                                  String name,
                                  OutputParameter<AttributeType> type)
                           throws AttributeException
        Replies the raw value that corresponds to the specified attribute name for the given record.
        Parameters:
        recordNumber - is the index of the record to read (0..recordCount-1).
        name - is the name of the attribute value to replies.
        type - is the type of the replied value. Tis attribute will be set by this function.
        Returns:
        the value extracted from the pool.
        Throws:
        AttributeException - if an attribute cannot be read.
      • getAccessor

        @Pure
        DBaseFileAttributeAccessor getAccessor​(int recordNumber)
        Replies the attribute accessor associated to the specified record number.
        Parameters:
        recordNumber - is the number of the record for which an accessor may be obtainable.
        Returns:
        the accessor to the record at the given position.