Class PathResolver
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.extraction.execution.PathResolver
-
- All Implemented Interfaces:
LogEnabled,Component,Serviceable
public class PathResolver extends AbstractLogEnabled implements Component, Serviceable
The resolver for string paths which can contain variables (format isfoo/a_${meta1/meta2/meta3}_m_${meta4}_z/bar\qux/${meta5}) and need to be resolved against some given contents.
-
-
Constructor Summary
Constructors Constructor Description PathResolver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanhasVariable(String path)Returnstrueif the path contains variables to be resolved.booleanisFolder(String path)Returnstrueif the unresolved path represents a folder, i.e.Map<Path,List<Content>>resolvePath(String path, List<Content> contents, Extraction extraction, Path basePath)Resolve the given path, which can contain variables, with the values for the given contents.voidservice(ServiceManager manager)-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Constructor Detail
-
PathResolver
public PathResolver()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
hasVariable
public boolean hasVariable(String path)
Returnstrueif the path contains variables to be resolved.
If it returnsfalse, thenresolvePath(String, List, Extraction, Path)can be called withnullparameters for contents and extraction.- Parameters:
path- The relative path to resolve- Returns:
trueif the path contains variables to be resolved
-
isFolder
public boolean isFolder(String path)
Returnstrueif the unresolved path represents a folder, i.e. its last element does not contain a '.' character.- Parameters:
path- The relative path to resolve- Returns:
trueif the unresolved path represents a folder
-
resolvePath
public Map<Path,List<Content>> resolvePath(String path, List<Content> contents, Extraction extraction, Path basePath)
Resolve the given path, which can contain variables, with the values for the given contents.
Thus, the result is aMapof resolvedPaths, each value containg the list of contents for its associated resolved path key.
If a variable is multivalued, a content can be in several paths at the same time in the result.
For instance,foo/a_${meta1/meta2/meta3}_m_${meta4}_z/bar\qux/${meta5}could be resolved to the pathfoo / a_val1_m_val2_z / bar / qux / val3for some contents.- Parameters:
path- The relative path to resolve. It must not start, nor end with a '/' or a '\' charactercontents- The contents. Can be null ifhasVariable(String)was called before and returned false.extraction- The extraction. Can be null ifhasVariable(String)was called before and returned false.basePath- The base absolute path- Returns:
- The absolute resolved paths mapped with their matching contents.
If the returned map contains only one path with a null list, it means that all contents match for that given single path.
-
-