Class ClasspathFileAccess
java.lang.Object
dev.jcputney.elearning.parser.impl.ClasspathFileAccess
- All Implemented Interfaces:
FileAccess
Implementation of
FileAccess that reads files from the classpath, allowing testing of
modules stored in the resources directory without needing actual filesystem access.-
Constructor Summary
ConstructorsConstructorDescriptionClasspathFileAccess(String rootPath) Constructs a ClasspathFileAccess instance with the specified root path. -
Method Summary
Modifier and TypeMethodDescriptionbooleanfileExistsInternal(String path) Checks if a file exists on the classpath at the given path.Retrieves the contents of a file as an InputStream from the classpath.listFilesInternal(String directoryPath) Lists all files within a specified directory path on the classpath.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.jcputney.elearning.parser.api.FileAccess
fileExists, fullPath, getFileContents, getRootPath, listFiles
-
Constructor Details
-
ClasspathFileAccess
Constructs a ClasspathFileAccess instance with the specified root path.- Parameters:
rootPath- The root path for file access.
-
-
Method Details
-
fileExistsInternal
Checks if a file exists on the classpath at the given path.- Specified by:
fileExistsInternalin interfaceFileAccess- Parameters:
path- The path to check (guaranteed to be non-null).- Returns:
- True if the file exists on the classpath, false otherwise.
-
listFilesInternal
Lists all files within a specified directory path on the classpath.- Specified by:
listFilesInternalin interfaceFileAccess- Parameters:
directoryPath- The directory to list files from (guaranteed to be non-null).- Returns:
- A list of file paths within the specified directory.
- Throws:
IOException- If there's an issue accessing the files.
-
getFileContentsInternal
Retrieves the contents of a file as an InputStream from the classpath.- Specified by:
getFileContentsInternalin interfaceFileAccess- Parameters:
path- The path to retrieve contents from (guaranteed to be non-null).- Returns:
- An InputStream of the file contents.
- Throws:
IOException- if the file can't be read.
-