Class HashPlugin

java.lang.Object
com.basis.plugin.HashPlugin
All Implemented Interfaces:
com.basis.startup.type.plugin.BBjFilePlugin

public class HashPlugin extends Object implements com.basis.startup.type.plugin.BBjFilePlugin
This is the interface used to read, write, and get information about open file plugins. Instances are created by the open method of the FileOpenPlugin interface.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor.
    HashPlugin(int p_initialCapacity)
    Constructor taking initial capacity.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Close the file position.
    int
    extract(byte[] p_buffer, int p_size, byte[] p_key, int p_keylen, int p_keyNumber, int p_timeout)
    Extract from the key given.
    int
    extract(byte[] p_buffer, int p_size, int p_timeout)
    Extract from the current position.
    int
    extract(byte[] p_buffer, int p_size, int p_keyNumber, int p_timeout)
    Extract from the current position.
    int
    extract(byte[] p_buffer, int p_size, long p_index, int p_timeout)
    Extract from the index given.
    byte[]
    getFIN(int p_index)
    Base FIN function used by the interpreter to get the FIN byte array.
    getFINTemplate(int p_index)
    Get template string for base FIN function.
    int
    getFirstKey(byte[] p_buffer, int p_keylen)
    Get first key in current key number.
    long
    Get current index -- this is not guaranteed to be useful for all file types.
    int
    getKey(byte[] p_buffer, int p_keylen)
    Get key at the current position.
    int
    getKey(byte[] p_buffer, int p_keylen, int p_keyNumber)
    Get key at the current position.
    int
    Get logical key size (if applicable).
    int
    getLastKey(byte[] p_buffer, int p_keylen)
    Get last key in current key number.
    long
    Get length of the file -- not valid for all file types.
    int
    Maximum number of bytes that a user is able to read from the file in a single read.
    int
    getNextKey(byte[] p_buffer, int p_keylen)
    Get next key at the current position.
    long
    Get maximum number of records (if applicable).
    int
    getPreviousKey(byte[] p_buffer, int p_keylen)
    Get previous key at the current position.
    long
    Get the number of records actually in the file.
    int
    Get record size (if applicable).
    byte[]
    getXFIN(int p_index)
    Base XFIN function used by the interpreter to get the XFIN byte array.
    getXFINTemplate(int p_index)
    Get template string for base XFIN function.
    boolean
    Is the plugin file record oriented (i.e.
    void
    Lock the file.
    int
    read(byte[] p_buffer, int p_size, byte[] p_key, int p_keylen, int p_keyNumber, boolean p_find, long p_move, int p_timeout)
    Read from the key given and change the position either forwards or backwards.
    int
    read(byte[] p_buffer, int p_size, int p_keyNumber, long p_move, int p_timeout)
    Read from the current position and change the position either forwards or backwards.
    int
    read(byte[] p_buffer, int p_size, long p_move, int p_timeout)
    Read from the current position and change the position either forwards or backwards.
    int
    read(byte[] p_buffer, int p_size, long p_index, long p_move, int p_timeout)
    Read from the index given and change the position either forwards or backwards.
    void
    remove(byte[] p_key, int p_keylen, boolean p_dom)
    Remove the record indicated by a key.
    void
    remove(long p_index)
    Remove the record indicated by an index.
    void
    Unlock the file.
    void
    write(byte[] p_buffer, int p_size, byte[] p_key, int p_keylen, long p_move, boolean p_dom, int p_timeout)
    Write a record at the position given by a key.
    void
    write(byte[] p_buffer, int p_size, long p_move, boolean p_dom, int p_timeout)
    Write a record at the current position except for multi keyed MKEYED files where the key will be derived from the record.
    void
    write(byte[] p_buffer, int p_size, long p_index, long p_move, boolean p_dom, int p_timeout)
    Write a record at the position given by an index.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • HashPlugin

      public HashPlugin()
      Constructor.
    • HashPlugin

      public HashPlugin(int p_initialCapacity)
      Constructor taking initial capacity.
      Parameters:
      p_initialCapacity - Initial capacity of the HashMap.
  • Method Details

    • isRecordOriented

      public boolean isRecordOriented()
      Is the plugin file record oriented (i.e. records are read)?
      Specified by:
      isRecordOriented in interface com.basis.startup.type.plugin.BBjFilePlugin
      Returns:
      true if the file is read as records.
    • read

      public int read(byte[] p_buffer, int p_size, long p_move, int p_timeout) throws com.basis.startup.type.BBjException
      Read from the current position and change the position either forwards or backwards.
      Specified by:
      read in interface com.basis.startup.type.plugin.BBjFilePlugin
      Parameters:
      p_buffer - Buffer to fill with the bytes read.
      p_size - Maximum number of bytes to read into the buffer.
      p_move - Number of records (or bytes in STRING file) to move the position after the read. If this is negative the position will be moved backwards.
      p_timeout - Timeout value in seconds for the read operation.
      Returns:
      Number of bytes actually read.
      Throws:
      com.basis.startup.type.BBjException
    • read

      public int read(byte[] p_buffer, int p_size, int p_keyNumber, long p_move, int p_timeout) throws com.basis.startup.type.BBjException
      Read from the current position and change the position either forwards or backwards. If the key number given is not the current key number then the current position will be the first key of the specified key number.
      Specified by:
      read in interface com.basis.startup.type.plugin.BBjFilePlugin
      Parameters:
      p_buffer - Buffer to fill with the bytes read.
      p_size - Maximum number of bytes to read into the buffer.
      p_keyNumber - Key number to use for iteration. If the key number is different than the one currently being used the iteration will start at the beginning of the key specified.
      p_move - Number of records (or bytes in STRING file) to move the position after the read. If this is negative the position will be moved backwards.
      p_timeout - Timeout value in seconds for the read operation.
      Returns:
      Number of bytes actually read.
      Throws:
      com.basis.startup.type.BBjException
    • read

      public int read(byte[] p_buffer, int p_size, byte[] p_key, int p_keylen, int p_keyNumber, boolean p_find, long p_move, int p_timeout) throws com.basis.startup.type.BBjException
      Read from the key given and change the position either forwards or backwards. File types without keys will give an error.
      Specified by:
      read in interface com.basis.startup.type.plugin.BBjFilePlugin
      Parameters:
      p_buffer - Buffer to fill with the bytes read.
      p_size - Maximum number of bytes to read into the buffer.
      p_key - Key value to search for on the read.
      p_keylen - Length of the actual key in the key byte array.
      p_keyNumber - Number of the key chain to search.
      p_find - true if the position should not be changed if the key is not found.
      p_move - Number of records (or bytes in STRING file) to move the position after the read. If this is negative the position will be moved backwards.
      p_timeout - Timeout value in seconds for the read operation.
      Returns:
      Number of bytes actually read.
      Throws:
      com.basis.startup.type.BBjException
    • read

      public int read(byte[] p_buffer, int p_size, long p_index, long p_move, int p_timeout) throws com.basis.startup.type.BBjException
      Read from the index given and change the position either forwards or backwards. File types without indexes will give an error.
      Specified by:
      read in interface com.basis.startup.type.plugin.BBjFilePlugin
      Parameters:
      p_buffer - Buffer to fill with the bytes read.
      p_size - Maximum number of bytes to read into the buffer.
      p_index - Index to jump to for the read.
      p_move - Number of records (or bytes in STRING file) to move the position after the read. If this is negative the position will be moved backwards.
      p_timeout - Timeout value in seconds for the read operation.
      Returns:
      Number of bytes actually read.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • extract

      public int extract(byte[] p_buffer, int p_size, int p_timeout) throws com.basis.startup.type.BBjException
      Extract from the current position.
      Specified by:
      extract in interface com.basis.startup.type.plugin.BBjFilePlugin
      Parameters:
      p_buffer - Buffer to fill with the bytes read.
      p_size - Maximum number of bytes to read into the buffer.
      p_timeout - Timeout value in seconds for the read operation.
      Returns:
      Number of bytes actually read.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • extract

      public int extract(byte[] p_buffer, int p_size, int p_keyNumber, int p_timeout) throws com.basis.startup.type.BBjException
      Extract from the current position. If the key number given is not the current key number then the current position will be the first key of the specified key number.
      Specified by:
      extract in interface com.basis.startup.type.plugin.BBjFilePlugin
      Parameters:
      p_buffer - Buffer to fill with the bytes read.
      p_size - Maximum number of bytes to read into the buffer.
      p_keyNumber - Key number to use for iteration. If the key number is different than the one currently being used the iteration will start at the beginning of the key specified.
      p_timeout - Timeout value in seconds for the read operation.
      Returns:
      Number of bytes actually read.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • extract

      public int extract(byte[] p_buffer, int p_size, byte[] p_key, int p_keylen, int p_keyNumber, int p_timeout) throws com.basis.startup.type.BBjException
      Extract from the key given. File types without keys will give an error.
      Specified by:
      extract in interface com.basis.startup.type.plugin.BBjFilePlugin
      Parameters:
      p_buffer - Buffer to fill with the bytes read.
      p_size - Maximum number of bytes to read into the buffer.
      p_key - Key value to search for on the read.
      p_keylen - Length of the actual key in the key byte array.
      p_keyNumber - Number of the key chain to search.
      p_timeout - Timeout value in seconds for the read operation.
      Returns:
      Number of bytes actually read.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • extract

      public int extract(byte[] p_buffer, int p_size, long p_index, int p_timeout) throws com.basis.startup.type.BBjException
      Extract from the index given. File types without indexes will give an error.
      Specified by:
      extract in interface com.basis.startup.type.plugin.BBjFilePlugin
      Parameters:
      p_buffer - Buffer to fill with the bytes read.
      p_size - Maximum number of bytes to read into the buffer.
      p_index - Index to jump to for the read.
      p_timeout - Timeout value in seconds for the read operation.
      Returns:
      Number of bytes actually read.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • write

      public void write(byte[] p_buffer, int p_size, long p_move, boolean p_dom, int p_timeout) throws com.basis.startup.type.BBjException
      Write a record at the current position except for multi keyed MKEYED files where the key will be derived from the record.
      Specified by:
      write in interface com.basis.startup.type.plugin.BBjFilePlugin
      Parameters:
      p_buffer - Record bytes.
      p_size - Number of bytes to write from the buffer.
      p_move - Number of records (or bytes in STRING file) to move the position after the write. If this is negative the position will be moved backwards. The move is relative to the location of the record written.
      p_dom - true if an error should be given for a duplicate key.
      p_timeout - Timeout value in seconds for the write operation.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • write

      public void write(byte[] p_buffer, int p_size, byte[] p_key, int p_keylen, long p_move, boolean p_dom, int p_timeout) throws com.basis.startup.type.BBjException
      Write a record at the position given by a key. File types without keys and multi-keyed MKEYED and XKEYED files will give an error.
      Specified by:
      write in interface com.basis.startup.type.plugin.BBjFilePlugin
      Parameters:
      p_buffer - Record bytes.
      p_size - Number of bytes to write from the buffer.
      p_key - Key to use in writing the record.
      p_keylen - Length of the actual key in the key byte array.
      p_move - Number of records (or bytes in STRING file) to move the position after the write. If this is negative the position will be moved backwards. The move is relative to the location of the record written.
      p_dom - true if an error should be given for a duplicate key.
      p_timeout - Timeout value in seconds for the write operation.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • write

      public void write(byte[] p_buffer, int p_size, long p_index, long p_move, boolean p_dom, int p_timeout) throws com.basis.startup.type.BBjException
      Write a record at the position given by an index. File types without indexes will give an error.
      Specified by:
      write in interface com.basis.startup.type.plugin.BBjFilePlugin
      Parameters:
      p_buffer - Record bytes.
      p_size - Number of bytes to write from the buffer.
      p_index - Index to use in writing the record.
      p_move - Number of records (or bytes in STRING file) to move the position after the write. If this is negative the position will be moved backwards. The move is relative to the location of the record written.
      p_dom - true if an error should be given for a duplicate key.
      p_timeout - Timeout value in seconds for the write operation.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • remove

      public void remove(byte[] p_key, int p_keylen, boolean p_dom) throws com.basis.startup.type.BBjException
      Remove the record indicated by a key. File types without keys will give an error.
      Specified by:
      remove in interface com.basis.startup.type.plugin.BBjFilePlugin
      Parameters:
      p_key - Key of the record to remove.
      p_keylen - Length of the actual key in the key byte array.
      p_dom - true if an error should be given for a missing key.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • lock

      public void lock() throws com.basis.startup.type.BBjException
      Lock the file.
      Specified by:
      lock in interface com.basis.startup.type.plugin.BBjFilePlugin
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • unlock

      public void unlock() throws com.basis.startup.type.BBjException
      Unlock the file.
      Specified by:
      unlock in interface com.basis.startup.type.plugin.BBjFilePlugin
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • close

      public void close() throws com.basis.startup.type.BBjException
      Close the file position.
      Specified by:
      close in interface com.basis.startup.type.plugin.BBjFilePlugin
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • getKey

      public int getKey(byte[] p_buffer, int p_keylen) throws com.basis.startup.type.BBjException
      Get key at the current position.
      Specified by:
      getKey in interface com.basis.startup.type.plugin.BBjFilePlugin
      Parameters:
      p_buffer - Buffer in which to place the key.
      p_keylen - Length of the key buffer provided.
      Returns:
      Number of bytes in the key.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • getKey

      public int getKey(byte[] p_buffer, int p_keylen, int p_keyNumber) throws com.basis.startup.type.BBjException
      Get key at the current position.
      Specified by:
      getKey in interface com.basis.startup.type.plugin.BBjFilePlugin
      Parameters:
      p_buffer - Buffer in which to place the key.
      p_keylen - Length of the key buffer provided.
      p_keyNumber - Which key number to get the key for.
      Returns:
      Number of bytes in the key.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • getFirstKey

      public int getFirstKey(byte[] p_buffer, int p_keylen) throws com.basis.startup.type.BBjException
      Get first key in current key number.
      Specified by:
      getFirstKey in interface com.basis.startup.type.plugin.BBjFilePlugin
      Parameters:
      p_buffer - Buffer in which to place the key.
      p_keylen - Length of key buffer provided.
      Returns:
      Number of bytes in the key.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • getLastKey

      public int getLastKey(byte[] p_buffer, int p_keylen) throws com.basis.startup.type.BBjException
      Get last key in current key number.
      Specified by:
      getLastKey in interface com.basis.startup.type.plugin.BBjFilePlugin
      Parameters:
      p_buffer - Buffer in which to place the key.
      p_keylen - Length of key buffer provided.
      Returns:
      Number of bytes in the key.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • getNextKey

      public int getNextKey(byte[] p_buffer, int p_keylen) throws com.basis.startup.type.BBjException
      Get next key at the current position.
      Specified by:
      getNextKey in interface com.basis.startup.type.plugin.BBjFilePlugin
      Parameters:
      p_buffer - Buffer in which to place the key.
      p_keylen - Length of key buffer provided.
      Returns:
      Number of bytes in the key.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • getPreviousKey

      public int getPreviousKey(byte[] p_buffer, int p_keylen) throws com.basis.startup.type.BBjException
      Get previous key at the current position.
      Specified by:
      getPreviousKey in interface com.basis.startup.type.plugin.BBjFilePlugin
      Parameters:
      p_buffer - Buffer in which to place the key.
      p_keylen - Length of key buffer provided.
      Returns:
      Number of bytes in the key.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • getKeySize

      public int getKeySize() throws com.basis.startup.type.BBjException
      Get logical key size (if applicable).
      Specified by:
      getKeySize in interface com.basis.startup.type.plugin.BBjFilePlugin
      Returns:
      Logical key size for this file -- multi keyed MKEYED files return 0.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • getNumberOfRecords

      public long getNumberOfRecords() throws com.basis.startup.type.BBjException
      Get maximum number of records (if applicable).
      Specified by:
      getNumberOfRecords in interface com.basis.startup.type.plugin.BBjFilePlugin
      Returns:
      Number of records or -1.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • getRecordSize

      public int getRecordSize() throws com.basis.startup.type.BBjException
      Get record size (if applicable).
      Specified by:
      getRecordSize in interface com.basis.startup.type.plugin.BBjFilePlugin
      Returns:
      Record size.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • getFIN

      public byte[] getFIN(int p_index) throws com.basis.startup.type.BBjException
      Base FIN function used by the interpreter to get the FIN byte array.
      Specified by:
      getFIN in interface com.basis.startup.type.plugin.BBjFilePlugin
      Parameters:
      p_index - Index of FIN to retrieve.
      Returns:
      FIN byte array as expected by BBx.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • getFINTemplate

      public String getFINTemplate(int p_index) throws com.basis.startup.type.BBjException
      Get template string for base FIN function.
      Specified by:
      getFINTemplate in interface com.basis.startup.type.plugin.BBjFilePlugin
      Parameters:
      p_index - Index of FIN to get template for.
      Returns:
      Template for FIN index requested.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • getXFIN

      public byte[] getXFIN(int p_index) throws com.basis.startup.type.BBjException
      Base XFIN function used by the interpreter to get the XFIN byte array.
      Specified by:
      getXFIN in interface com.basis.startup.type.plugin.BBjFilePlugin
      Parameters:
      p_index - Index of FIN to retrieve.
      Returns:
      XFIN byte array as expected by BBj.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • getXFINTemplate

      public String getXFINTemplate(int p_index) throws com.basis.startup.type.BBjException
      Get template string for base XFIN function.
      Specified by:
      getXFINTemplate in interface com.basis.startup.type.plugin.BBjFilePlugin
      Parameters:
      p_index - Index of XFIN to get template for.
      Returns:
      Template for XFIN index requested.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • getLength

      public long getLength() throws com.basis.startup.type.BBjException
      Get length of the file -- not valid for all file types.
      Specified by:
      getLength in interface com.basis.startup.type.plugin.BBjFilePlugin
      Returns:
      Length of the file.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • getIndex

      public long getIndex() throws com.basis.startup.type.BBjException
      Get current index -- this is not guaranteed to be useful for all file types.
      Specified by:
      getIndex in interface com.basis.startup.type.plugin.BBjFilePlugin
      Returns:
      Current index.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • getMaxReadSize

      public int getMaxReadSize() throws com.basis.startup.type.BBjException
      Maximum number of bytes that a user is able to read from the file in a single read. For record files this is the record size (or maximum record size).
      Specified by:
      getMaxReadSize in interface com.basis.startup.type.plugin.BBjFilePlugin
      Returns:
      Maximum number of bytes that can possibly be read at one time.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • getRecordCount

      public long getRecordCount() throws com.basis.startup.type.BBjException
      Get the number of records actually in the file.
      Specified by:
      getRecordCount in interface com.basis.startup.type.plugin.BBjFilePlugin
      Returns:
      The number of records actually in the file if available.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.
    • remove

      public void remove(long p_index) throws com.basis.startup.type.BBjException
      Remove the record indicated by an index.
      Specified by:
      remove in interface com.basis.startup.type.plugin.BBjFilePlugin
      Parameters:
      p_index - Index of the record to remove.
      Throws:
      com.basis.startup.type.BBjException - If a problem occurs.