Class ResourceIndexConverterStorage
java.lang.Object
com.e1c.langtool.internal.converter.db.ConverterStorage
com.e1c.langtool.internal.converter.db.ResourceIndexConverterStorage
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 Summary
ConstructorsConstructorDescriptionCreates a new instance ofResourceIndexConverterStoragewith the specified DB file. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidafterOpenDb(org.mapdb.DB db) After open db.protected voidPerforms tasks before closing the converter storage.longgetResourceId(org.eclipse.core.runtime.IPath path) Retrieves the ID associated with the specified resource path.longgetResourceIdOrNew(org.eclipse.core.runtime.IPath path) Gets the stored resource id or create new ID and store it.Retrieves the resource index map.booleanisEmpty()Checks if the resource index storage is empty.Methods inherited from class com.e1c.langtool.internal.converter.db.ConverterStorage
checkOrOpen, close, delete, getValues, open, putValues, removeValues
-
Constructor Details
-
ResourceIndexConverterStorage
Creates a new instance ofResourceIndexConverterStoragewith the specified DB file.- Parameters:
file- the DB file, cannot benull.
-
-
Method Details
-
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 benullor empty.- Returns:
- the ID associated with the resource path, or
-1if the path isnullor 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 benull.- Returns:
- the resource id or new, cannot return
null.
-
isEmpty
public boolean isEmpty()Checks if the resource index storage is empty.- Returns:
trueif the storage is empty,falseotherwise.
-
afterOpenDb
protected void afterOpenDb(org.mapdb.DB db) Description copied from class:ConverterStorageAfter open db.- Overrides:
afterOpenDbin classConverterStorage- Parameters:
db- the db
-
beforeClose
protected void beforeClose()Description copied from class:ConverterStoragePerforms tasks before closing the converter storage.- Overrides:
beforeClosein classConverterStorage
-