Class DefaultModuleParserFactory
java.lang.Object
dev.jcputney.elearning.parser.impl.factory.DefaultModuleParserFactory
- All Implemented Interfaces:
ModuleParserFactory
Default implementation of the ModuleParserFactory interface.
This class creates appropriate parsers for different types of eLearning modules based on the detected module type. It uses a ModuleTypeDetector to determine the module type and then creates the corresponding parser.
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultModuleParserFactory(FileAccess fileAccess) Constructs a new DefaultModuleParserFactory with the specified FileAccess implementation, a default ModuleTypeDetector, and default parser options.DefaultModuleParserFactory(FileAccess fileAccess, ModuleTypeDetector moduleTypeDetector) Constructs a new DefaultModuleParserFactory with the specified FileAccess and ModuleTypeDetector implementations, using default parser options.DefaultModuleParserFactory(FileAccess fileAccess, ModuleTypeDetector moduleTypeDetector, ParserOptions options) Constructs a new DefaultModuleParserFactory with the specified FileAccess, ModuleTypeDetector, and ParserOptions.DefaultModuleParserFactory(FileAccess fileAccess, ParserOptions options) Constructs a new DefaultModuleParserFactory with the specified FileAccess implementation, a default ModuleTypeDetector, and custom parser options. -
Method Summary
Modifier and TypeMethodDescriptionModuleParser<?>Returns an appropriate parser for the module type detected at the given path.Parses the module at the specified path and returns a ModuleMetadata object containing the extracted metadata.voidregisterParser(ModuleType moduleType, Function<FileAccess, ModuleParser<?>> parserFactory) Registers a parser factory function for the specified module type.booleanunregisterParser(ModuleType moduleType) Unregisters the parser factory function for the specified module type.
-
Constructor Details
-
DefaultModuleParserFactory
public DefaultModuleParserFactory(FileAccess fileAccess, ModuleTypeDetector moduleTypeDetector, ParserOptions options) Constructs a new DefaultModuleParserFactory with the specified FileAccess, ModuleTypeDetector, and ParserOptions.- Parameters:
fileAccess- the FileAccess implementation to use for accessing module filesmoduleTypeDetector- the ModuleTypeDetector implementation to use for detecting module typesoptions- the parser options to control validation and calculation behavior- Throws:
IllegalArgumentException- if fileAccess or moduleTypeDetector is null
-
DefaultModuleParserFactory
Constructs a new DefaultModuleParserFactory with the specified FileAccess and ModuleTypeDetector implementations, using default parser options.- Parameters:
fileAccess- the FileAccess implementation to use for accessing module filesmoduleTypeDetector- the ModuleTypeDetector implementation to use for detecting module types- Throws:
IllegalArgumentException- if fileAccess or moduleTypeDetector is null
-
DefaultModuleParserFactory
Constructs a new DefaultModuleParserFactory with the specified FileAccess implementation, a default ModuleTypeDetector, and custom parser options.- Parameters:
fileAccess- the FileAccess implementation to use for accessing module filesoptions- the parser options to control validation and calculation behavior- Throws:
IllegalArgumentException- if fileAccess is null
-
DefaultModuleParserFactory
Constructs a new DefaultModuleParserFactory with the specified FileAccess implementation, a default ModuleTypeDetector, and default parser options.- Parameters:
fileAccess- the FileAccess implementation to use for accessing module files- Throws:
IllegalArgumentException- if fileAccess is null
-
-
Method Details
-
registerParser
public void registerParser(ModuleType moduleType, Function<FileAccess, ModuleParser<?>> parserFactory) Registers a parser factory function for the specified module type.- Parameters:
moduleType- the module type to register the parser forparserFactory- the factory function that creates a parser for the specified module type- Throws:
IllegalArgumentException- if moduleType or parserFactory is null
-
unregisterParser
Unregisters the parser factory function for the specified module type.- Parameters:
moduleType- the module type to unregister the parser for- Returns:
- true if a parser was unregistered, false if no parser was registered for the specified module type
- Throws:
IllegalArgumentException- if moduleType is null
-
getParser
Returns an appropriate parser for the module type detected at the given path.- Specified by:
getParserin interfaceModuleParserFactory- Returns:
- A ModuleParser instance for the detected module type.
- Throws:
ModuleDetectionException- if the module type cannot be determined.
-
parseModule
Parses the module at the specified path and returns a ModuleMetadata object containing the extracted metadata.- Specified by:
parseModulein interfaceModuleParserFactory- Returns:
- A ModuleMetadata object containing the extracted metadata.
- Throws:
ModuleDetectionException- if the module type cannot be determined.ModuleParsingException- if an error occurs during parsing.ModuleDetectionException- if the module type cannot be determined.ModuleParsingException- if an error occurs during parsing.ModuleException
-