Class TargetKeyStorage

java.lang.Object
com.e1c.langtool.internal.converter.db.ConverterStorage
com.e1c.langtool.internal.converter.db.TargetKeyStorage

public class TargetKeyStorage extends ConverterStorage
A specialized ConverterStorage for managing target keys in the conversion process.

The TargetKeyStorage class extends ConverterStorage and provides methods for accessing and managing target keys associated with unique IDs.

Usage example:


 // Create an instance of TargetKeyStorage with a specified DB file
 File dbFile = ...; // Specify the DB file
 TargetKeyStorage targetKeyStorage = new TargetKeyStorage(dbFile);

 // Get the target key associated with a specific ID
 long id = ...; // Specify the ID
 String targetKey = targetKeyStorage.getTargetKey(id);

 // Put or update a target key for a specific ID
 String newTargetKey = ...; // Specify the new target key
 String previousTargetKey = targetKeyStorage.putTargetKey(id, newTargetKey);

 // Remove a target key associated with a specific ID
 String removedTargetKey = targetKeyStorage.removeTargetKey(id);
 

Note: All IDs, target keys, and DB file used in this class are assumed to be non-null.

  • Constructor Details

    • TargetKeyStorage

      public TargetKeyStorage(File dbFile)
      Creates a new instance of TargetKeyStorage with the specified DB file.
      Parameters:
      dbFile - the DB file, cannot be null.
      Throws:
      IllegalArgumentException - if the provided file is null.
  • Method Details

    • getTargetKey

      public String getTargetKey(long id)
      Retrieves the target key associated with the specified ID.
      Parameters:
      id - the unique ID.
      Returns:
      the target key associated with the ID, or null if the ID is not found or invalid.
    • putTargetKey

      public String putTargetKey(long id, String data)
      Puts or updates a target key for the specified ID.
      Parameters:
      id - the unique ID.
      data - the target key to put or update, cannot be null.
      Returns:
      the previous target key associated with the ID, or null if there was none.
    • removeTargetKey

      public String removeTargetKey(long id)
      Removes the target key associated with the specified ID.
      Parameters:
      id - the unique ID.
      Returns:
      the removed target key, or null if the ID is not found or invalid.
    • afterOpenDb

      protected void afterOpenDb(org.mapdb.DB db)
      Description copied from class: ConverterStorage
      After open db.
      Overrides:
      afterOpenDb in class ConverterStorage
      Parameters:
      db - the db
    • beforeClose

      protected void beforeClose()
      Description copied from class: ConverterStorage
      Performs tasks before closing the converter storage.
      Overrides:
      beforeClose in class ConverterStorage