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 is foo/a_${meta1/meta2/meta3}_m_${meta4}_z/bar\qux/${meta5}) and need to be resolved against some given contents.
  • Field Details

    • ROLE

      public static final String ROLE
      The Avalon role.
  • Constructor Details

  • Method Details

    • service

      public void service(ServiceManager manager) throws ServiceException
      Specified by:
      service in interface Serviceable
      Throws:
      ServiceException
    • hasVariable

      public boolean hasVariable(String path)
      Returns true if the path contains variables to be resolved.
      If it returns false, then resolvePath(String, List, Extraction, Path) can be called with null parameters for contents and extraction.
      Parameters:
      path - The relative path to resolve
      Returns:
      true if the path contains variables to be resolved
    • isFolder

      public boolean isFolder(String path)
      Returns true if the unresolved path represents a folder, i.e. its last element does not contain a '.' character.
      Parameters:
      path - The relative path to resolve
      Returns:
      true if 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 a Map of resolved Paths, 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 path foo / a_val1_m_val2_z / bar / qux / val3 for some contents.
      Parameters:
      path - The relative path to resolve. It must not start, nor end with a '/' or a '\' character
      contents - The contents. Can be null if hasVariable(String) was called before and returned false.
      extraction - The extraction. Can be null if hasVariable(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.