CleanerRegistry class
Registry for managing custom cleaner functions by name.
This class provides a centralized registry for cleaner functions that can be referenced by name in parser configurations. This allows cleaner functions to be serialized and deserialized using string names rather than function references, which is useful for configuration-based scraping setups.
The registry supports:
- Registering cleaner functions with unique names
- Retrieving cleaner functions by name
- Checking if a cleaner is registered
- Listing all registered cleaner names
- Clearing all registered cleaners
Example usage:
// Register a cleaner function
CleanerRegistry.register('trimText', (data, extractedData, debug) {
if (data.obj is String) {
return (data.obj as String).trim();
}
return null;
});
// Use in parser configuration
Parser(
id: 'title',
parents: ['_root'],
type: ParserType.text,
selectors: ['.title'],
cleanerName: 'trimText', // Reference by name
);
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
Static Methods
-
clear(
) → void - Removes all registered cleaner functions from the registry.
-
has(
String name) → bool - Checks if a cleaner function is registered with the given name.
-
register(
String name, CleanerFunction cleaner) → void - Registers a cleaner function with a unique name.
-
resolve(
String? name) → CleanerFunction? - Retrieves a cleaner function by name.