Class DefaultModuleFileProvider
java.lang.Object
dev.jcputney.elearning.parser.impl.provider.DefaultModuleFileProvider
- All Implemented Interfaces:
ModuleFileProvider
Default implementation of the ModuleFileProvider interface.
This class delegates file access operations to an underlying FileAccess instance, providing a consistent interface for parsers to use without directly depending on the FileAccess interface.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultModuleFileProvider(FileAccess fileAccess) Constructs a DefaultModuleFileProvider with the specified FileAccess instance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanfileExists(String path) Checks if a file exists at the specified path.fileExistsBatch(List<String> paths) Checks if multiple files exist in a batch operation.getFileContents(String path) Gets the contents of a file as an InputStream.Gets the root path of the module.longGets the total size of all files in the module.booleanChecks if the module contains xAPI-related files.Lists all files in the specified directory.voidPrefetches common module files for faster subsequent access.
-
Field Details
-
XAPI_JS_FILE
The name of the xAPI JavaScript file.- See Also:
-
XAPI_SEND_STATEMENT_FILE
The name of the xAPI send statement file.- See Also:
-
-
Constructor Details
-
DefaultModuleFileProvider
Constructs a DefaultModuleFileProvider with the specified FileAccess instance.- Parameters:
fileAccess- An instance of FileAccess for reading files in the module package.- Throws:
IllegalArgumentException- if fileAccess is null
-
-
Method Details
-
getFileContents
Gets the contents of a file as an InputStream.- Specified by:
getFileContentsin interfaceModuleFileProvider- Parameters:
path- The path to the file.- Returns:
- An InputStream containing the file contents.
- Throws:
IOException- If an error occurs while reading the file.IllegalArgumentException- if a path is null
-
fileExists
Checks if a file exists at the specified path.- Specified by:
fileExistsin interfaceModuleFileProvider- Parameters:
path- The path to check.- Returns:
- true if the file exists, false otherwise.
- Throws:
IllegalArgumentException- if a path is null
-
getRootPath
Gets the root path of the module.- Specified by:
getRootPathin interfaceModuleFileProvider- Returns:
- The root path of the module.
-
hasXapiSupport
public boolean hasXapiSupport()Checks if the module contains xAPI-related files.- Specified by:
hasXapiSupportin interfaceModuleFileProvider- Returns:
- true if xAPI is enabled, false otherwise.
-
listFiles
Lists all files in the specified directory.- Specified by:
listFilesin interfaceModuleFileProvider- Parameters:
directory- The directory to list files from.- Returns:
- A list of file names in the directory.
- Throws:
IOException- If an error occurs while listing the files.IllegalArgumentException- if the directory is null
-
fileExistsBatch
Checks if multiple files exist in a batch operation.This implementation delegates to the underlying FileAccess implementation.
- Specified by:
fileExistsBatchin interfaceModuleFileProvider- Parameters:
paths- List of file paths to check- Returns:
- Map where keys are the file paths and values indicate whether the file exists
- Throws:
IllegalArgumentException- if paths is null or contains null elements
-
prefetchCommonFiles
public void prefetchCommonFiles()Prefetches common module files for faster subsequent access.This implementation delegates to the underlying FileAccess implementation.
- Specified by:
prefetchCommonFilesin interfaceModuleFileProvider
-
getTotalSize
Gets the total size of all files in the module.This implementation delegates to the underlying FileAccess implementation.
- Specified by:
getTotalSizein interfaceModuleFileProvider- Returns:
- Total size of all files in bytes, or -1 if not supported
- Throws:
IOException- if there's an error accessing file sizes
-