Class JDB2Manager

java.lang.Object
com.pnfsoftware.jeb.core.dao.impl.JDB2Manager
All Implemented Interfaces:
IFileDatabase

public class JDB2Manager extends Object implements IFileDatabase
JEB database file ("*.jdb2") manager.
  • Field Details

    • EXTENSION

      public static final String EXTENSION
      JEB database file extension with the Leading dot. The case matters.
      See Also:
    • MARKER

      public static final int MARKER
      File header marker, little-endian: JDB2
      See Also:
    • TYPE_PROJECT

      public static final int TYPE_PROJECT
      Project block marker, little-endian: PRJ
      See Also:
    • TYPE_QSTATES

      public static final int TYPE_QSTATES
      Quick-states block marker, little-endian: QCK
      See Also:
    • TYPE_ARTIFACTS

      public static final int TYPE_ARTIFACTS
      Artifacts collections, little-endian: ART
      See Also:
    • TYPE_PROJECT_CONFIGURATION

      public static final int TYPE_PROJECT_CONFIGURATION
      Persisted Project Configuration: PPC
      See Also:
    • TYPE_PROJECT_METADATA

      public static final int TYPE_PROJECT_METADATA
      Persisted Project Metadata: PPM
      See Also:
    • FLAG_NONE

      public static final int FLAG_NONE
      No flag
      See Also:
    • FLAG_COMPRESS

      public static final int FLAG_COMPRESS
      This flags is used to specify that the record should be compressed
      See Also:
    • FLAG_ENCRYPT

      public static final int FLAG_ENCRYPT
      This flags is used to specify that the record should be encrypted
      See Also:
    • FLAG_CRCCHECK

      public static final int FLAG_CRCCHECK
      The record should be accompanied by a CRC32 value to verify its basic integrity
      See Also:
  • Constructor Details

    • JDB2Manager

      public JDB2Manager(String basedir)
      Create a JDB2 manager rooted at a base directory.
      Parameters:
      basedir - base directory where JDB2 files are stored
  • Method Details

    • saveFile

      public boolean saveFile(String key, byte[] data)
      DO NOT USE! PROJECT record only, old format!
      Specified by:
      saveFile in interface IFileDatabase
      Parameters:
      key - file key
      data - file data
      Returns:
      success indicator
    • loadFile

      public byte[] loadFile(String key)
      DO NOT USE! PROJECT record only, old format!
      Specified by:
      loadFile in interface IFileDatabase
      Parameters:
      key - file key
      Returns:
      file data, null on error
    • hasFile

      public boolean hasFile(String key)
      Description copied from interface: IFileDatabase
      Determine if the database contains the given file (the file must exist).
      Specified by:
      hasFile in interface IFileDatabase
      Parameters:
      key - file key
      Returns:
      presence indicator
    • getFileObject

      public File getFileObject(String key)
      Description copied from interface: IFileDatabase
      Attempt to get the filesystem object backing this db file entry.

      This method may not be implemented (e.g. if this database is not backed by on-disk files), in which case the implementation may throw an UnsupportedOperationException.

      Specified by:
      getFileObject in interface IFileDatabase
      Parameters:
      key - file key
      Returns:
      the backing file object for the entry
    • deleteFile

      public boolean deleteFile(String key)
      Description copied from interface: IFileDatabase
      Delete a file.
      Specified by:
      deleteFile in interface IFileDatabase
      Parameters:
      key - file key
      Returns:
      success indicator
    • getFileReader

      public InputStream getFileReader(String key) throws FileNotFoundException
      Description copied from interface: IFileDatabase
      Get an input stream reader for low-level reading from a file. The client is responsible for closing the stream after usage.

      This method may not be implemented, in which case the implementation may throw an UnsupportedOperationException.

      Specified by:
      getFileReader in interface IFileDatabase
      Parameters:
      key - file key
      Returns:
      an input stream reading the entry contents
      Throws:
      FileNotFoundException
    • getFileWriter

      public OutputStream getFileWriter(String key) throws FileNotFoundException
      Description copied from interface: IFileDatabase
      Get an output stream reader for low-level writing to a file. The client is responsible for closing the stream after usage.

      This method may not be implemented, in which case the implementation may throw an UnsupportedOperationException.

      Specified by:
      getFileWriter in interface IFileDatabase
      Parameters:
      key - file key
      Returns:
      an output stream writing to the entry contents
      Throws:
      FileNotFoundException
    • getDatabaseWriter

      public IFileDatabaseWriter getDatabaseWriter(String key) throws IOException
      Description copied from interface: IFileDatabase
      Get a database record writer.

      This method may not be implemented, in which case the implementation may throw an UnsupportedOperationException.

      Specified by:
      getDatabaseWriter in interface IFileDatabase
      Parameters:
      key - file key
      Returns:
      a structured database writer for the entry
      Throws:
      IOException - if the writer could not be created
    • getDatabaseReader

      public IFileDatabaseReader getDatabaseReader(String key) throws IOException
      Description copied from interface: IFileDatabase
      Get a database record reader.

      This method may not be implemented, in which case the implementation may throw an UnsupportedOperationException.

      Specified by:
      getDatabaseReader in interface IFileDatabase
      Parameters:
      key - file key
      Returns:
      a structured database reader for the entry
      Throws:
      IOException - if the reader could not be created
    • projectTypeToName

      public static String projectTypeToName(int type)
      Convert a well-known JDB2 record type to a readable symbolic name.
      Parameters:
      type - record type
      Returns:
      a symbolic name for known record types, or a hexadecimal representation otherwise