Class ResourceIndexConverterStorage

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

public class ResourceIndexConverterStorage extends ConverterStorage
A specialized ConverterStorage for managing resource indexing in the conversion process.

The ResourceIndexConverterStorage class extends ConverterStorage and provides methods for accessing and managing the resource index, which associates resource paths with unique IDs.

Usage example:


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

 // Retrieve the resource index map
 Map<IPath, Long> resourceIndex = indexStorage.getResources();

 // Get the ID associated with a specific resource path
 IPath resourcePath = ...; // Specify the resource path
 Long resourceId = indexStorage.getResourceId(resourcePath);
 

Note: All resource paths and IDs used in this class are assumed to be non-null.

  • Constructor Details

    • ResourceIndexConverterStorage

      public ResourceIndexConverterStorage(File file)
      Creates a new instance of ResourceIndexConverterStorage with the specified DB file.
      Parameters:
      file - the DB file, cannot be null.
  • Method Details

    • getResources

      public Map<org.eclipse.core.runtime.IPath,Long> getResources()
      Retrieves the resource index map.
      Returns:
      a map associating resource paths with unique IDs.
    • getResourceId

      public long getResourceId(org.eclipse.core.runtime.IPath path)
      Retrieves the ID associated with the specified resource path.
      Parameters:
      path - the resource path, cannot be null or empty.
      Returns:
      the ID associated with the resource path, or -1 if the path is null or empty, or if the path is not found.
    • getResourceIdOrNew

      public long getResourceIdOrNew(org.eclipse.core.runtime.IPath path)
      Gets the stored resource id or create new ID and store it. This method always return 0 if path is empty.
      Parameters:
      path - the path, cannot be null.
      Returns:
      the resource id or new, cannot return null.
    • isEmpty

      public boolean isEmpty()
      Checks if the resource index storage is empty.
      Returns:
      true if the storage is empty, false otherwise.
    • 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