Class SSSOMTransformApplication<T>
- Type Parameters:
T
- The type of object that this application produces when the SSSOM/Transform ruleset is applied to mappings.
- All Implemented Interfaces:
ISSSOMTransformApplication<T>
- Direct Known Subclasses:
SSSOMTOwlApplication
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the mapping formatter used by this application.Gets the prefix manager used by this application.Gets the variable manager used by this application.Processes a callback action.boolean
Processes a directive action.Processes an application-specific filter.Processes a generating action.void
onInit
(PrefixManager prefixManager) Initialises the application.Processes a preprocessing action.void
Registers a new SSSOM/T callback function.void
registerDirective
(ISSSOMTFunction<Void> function) Registers a new SSSOM/T directive function.void
registerFilter
(ISSSOMTFunction<IMappingFilter> function) Registers a new SSSOM/T filter function.void
registerGenerator
(ISSSOMTFunction<IMappingTransformer<T>> function) Registers a new SSSOM/T generator function.void
Registers a new SSSOM/T preprocessor function.
-
Constructor Details
-
SSSOMTransformApplication
public SSSOMTransformApplication()
-
-
Method Details
-
getPrefixManager
Gets the prefix manager used by this application. It will have been provided by the SSSOM/Transform parser and will know of all the prefixes declared in the header of the ruleset.- Returns:
- The prefix manager.
-
getVariableManager
Gets the variable manager used by this application. Functions may use this object to declare mapping-dependent variables and get their value for a given mapping.- Returns:
- The variable manager.
-
getFormatter
Gets the mapping formatter used by this application. Functions may use this object to expand placeholders found in their arguments. It may also be used to define more substitutions.The formatter is already configured to recognise placeholders corresponding to the standard SSSOM metadata fields. For example,
%{subject_id}
will be recognised and replaced by the subject ID of the current mapping.The formatter is also pre-configured with a
short
modifier to substitute IRI fields into CURIEs. For example,%{subject_id|short}
will be replaced by the short form of the mapping’s subject ID.- Returns:
- The mapping formatter.
-
registerFilter
Registers a new SSSOM/T filter function.The function will be called when its name is found in the filter part of a SSSOM/T rule. It should return a mapping filter.
- Parameters:
function
- The function to register.
-
registerDirective
Registers a new SSSOM/T directive function.The function will be called when its name is found as the sole element of a SSSOM/T rule (no filters).
- Parameters:
function
- The function to register.
-
registerCallback
Registers a new SSSOM/T callback function.The function will be called when its name is found in the action part of a SSSOM/T rule, before looking up for a preprocessor or generator function. It should return a processor callback.
- Parameters:
function
- The function to register.
-
registerPreprocessor
Registers a new SSSOM/T preprocessor function.The function will be called when its name is found in the action part of a SSSOM/T rule, if no callback function with that name exists, before looking up for a generator function. It should return a preprocessor, that is, a transformer that produces mappings out of mappings.
- Parameters:
function
- The function to register.
-
registerGenerator
Registers a new SSSOM/T generator function.The function will be called when its name is found in the action part of a SSSOM/T rule, if no callback function and no preprocessor function with that name exist. It should return a transformer that produces the desired type of objects from mappings.
- Parameters:
function
- The function to register.
-
onInit
Description copied from interface:ISSSOMTransformApplication
Initialises the application. This method is called by the SSSOM/Transform parser when all rules have been syntaxically parsed, before the parser attempts to process the action part of each rule.- Specified by:
onInit
in interfaceISSSOMTransformApplication<T>
- Parameters:
prefixManager
- A prefix manager initialised with all the prefix declarations found in the SSSOM/Transform file.
-
onFilter
public IMappingFilter onFilter(String name, List<String> arguments, Map<String, String> keyedArguments) throws SSSOMTransformErrorDescription copied from interface:ISSSOMTransformApplication
Processes an application-specific filter. This method is called when the parser finds a function call within the filter part of a rule. If the application recognises the function, it must return a mapping filter; otherwise, it must returnnull
or throw aSSSOMTransformError
.- Specified by:
onFilter
in interfaceISSSOMTransformApplication<T>
- Parameters:
name
- The name of the function.arguments
- The list of arguments passed to the function.keyedArguments
- The map of keyed arguments (/key=...
) passed to the function.- Returns:
- A mapping filter that filters mappings according to the application’s
needs, or
null
if the name is not a valid filter name for this application. - Throws:
SSSOMTransformError
- If the application cannot process the filer (e.g., the arguments are invalid).
-
onDirectiveAction
public boolean onDirectiveAction(String name, List<String> arguments, Map<String, String> keyedArguments) throws SSSOMTransformErrorDescription copied from interface:ISSSOMTransformApplication
Processes a directive action. This method is called when the parser finds a function call that is not associated with any filter. Such calls (which can only happen at the beginning of a SSSOM/T file, after the prefix declarations but before any other rule) cannot produce mapping processing rules but may otherwise influence the behaviour of the application. They are executed as soon as they are encountered when parsing the abstract tree.- Specified by:
onDirectiveAction
in interfaceISSSOMTransformApplication<T>
- Parameters:
name
- The name of the function.arguments
- The list of arguments passed to the function.keyedArguments
- The map of keyed arguments (/key=...
) passed to the function.- Returns:
true
if the name is a valid directive for this application, otherwisefalse
/- Throws:
SSSOMTransformError
- If the application cannot process the action (e.g. the arguments are invalid).
-
onCallback
public IMappingProcessorCallback onCallback(String name, List<String> arguments, Map<String, String> keyedArguments) throws SSSOMTransformErrorDescription copied from interface:ISSSOMTransformApplication
Processes a callback action. This method is the first one called when the parser finds a normal action (any action associated with a filter). If the application recognises the function as a callback function, it must return the corresponding callback object; otherwise, it must returnnull
.- Specified by:
onCallback
in interfaceISSSOMTransformApplication<T>
- Parameters:
name
- The name of the function.arguments
- The list of arguments passed to the function.keyedArguments
- The map of keyed arguments (/key=...
) passed to the function.- Returns:
- A callback object implementing the action according to the
application’s needs, or
null
if the name is not a valid callback function name for this application. - Throws:
SSSOMTransformError
- If the application cannot process the action (e.g., the arguments are invalid).
-
onPreprocessingAction
public IMappingTransformer<Mapping> onPreprocessingAction(String name, List<String> arguments, Map<String, String> keyedArguments) throws SSSOMTransformErrorDescription copied from interface:ISSSOMTransformApplication
Processes a preprocessing action. This method is called when the parser finds a normal action that is not recognised as a callback action (i.e.ISSSOMTransformApplication.onCallback(String, List, Map)
returnednull
). It the application recognises the function, it must return a mapping preprocessor; otherwise, it must returnnull
.- Specified by:
onPreprocessingAction
in interfaceISSSOMTransformApplication<T>
- Parameters:
name
- The name of the function.arguments
- The list of arguments passed to the function.keyedArguments
- The map of keyed arguments (/key=...
) passed to the function.- Returns:
- A mapping preprocessor implementing the action according to the
application’s needs, or
null
if the name is not a valid preprocessing function name for this application. - Throws:
SSSOMTransformError
- If the application cannot process the action (e.g., the arguments are invalid).
-
onGeneratingAction
public IMappingTransformer<T> onGeneratingAction(String name, List<String> arguments, Map<String, String> keyedArguments) throws SSSOMTransformErrorDescription copied from interface:ISSSOMTransformApplication
Processes a generating action. This method is called when the parser finds a normal action that is not recognised as a callback action nor as a preprocessing action (i.e. bothISSSOMTransformApplication.onCallback(String, List, Map)
andISSSOMTransformApplication.onPreprocessingAction(String, List, Map)
returnednull
). If the application recognises the function, it must return a mapping transformer that produces the kind of objects desired by the application.- Specified by:
onGeneratingAction
in interfaceISSSOMTransformApplication<T>
- Parameters:
name
- The name of the function.arguments
- The list of arguments passed to the function.keyedArguments
- The map of keyed arguments (/key=...
) passed to the function.- Returns:
- A mapping transformer implementing the action according to the application’s needs.
- Throws:
SSSOMTransformError
- If the application cannot process the action (e.g. the name is not recognised or the arguments are invalid).
-