java.lang.Object
org.odpi.openmetadata.adapters.connectors.surveyaction.surveyfolder.layout.PathSegment

public class PathSegment extends Object
PathSegment describes a file or directory that is expected at one level of a directory layout. It is the in-memory form of a PathSegmentAttribute.

The name pattern is literal text with variables. {name} matches any text and {name:regex} matches text that also matches the regular expression. For example, dp={n}_pressure={p} matches dp=004_pressure=150, and run_{n:\d+}.log matches run_12.log but not run_final.log.
  • Field Details

  • Constructor Details

    • PathSegment

      public PathSegment(String segmentType, String namePattern)
      Constructor.
      Parameters:
      segmentType - directory or file (anything other than "file" is treated as a directory)
      namePattern - pattern for the name of the file or directory
      Throws:
      IllegalArgumentException - the name pattern is null, empty or not a valid pattern
  • Method Details

    • matches

      public boolean matches(String name)
      Does the name of a file or directory match this segment's name pattern?
      Parameters:
      name - name of a file or directory (not its path)
      Returns:
      boolean
    • getSegmentType

      public String getSegmentType()
      Return whether this segment describes a directory or a file.
      Returns:
      directory or file
    • isDirectory

      public boolean isDirectory()
      Return whether this segment describes a directory.
      Returns:
      boolean
    • getNamePattern

      public String getNamePattern()
      Return the pattern for the name of the file or directory.
      Returns:
      pattern
    • isVariable

      public boolean isVariable()
      Return whether the name pattern includes a variable.
      Returns:
      boolean
    • isRequired

      public boolean isRequired()
      Return whether a matching file or directory must be present.
      Returns:
      boolean
    • setRequired

      public PathSegment setRequired(boolean required)
      Set up whether a matching file or directory must be present.
      Parameters:
      required - boolean
      Returns:
      this segment
    • isMultiple

      public boolean isMultiple()
      Return whether more than one file or directory in the same parent directory may match.
      Returns:
      boolean
    • setMultiple

      public PathSegment setMultiple(boolean multiple)
      Set up whether more than one file or directory in the same parent directory may match.
      Parameters:
      multiple - boolean
      Returns:
      this segment
    • getArtifactRole

      public String getArtifactRole()
      Return the role of the matching file or directory.
      Returns:
      role or null
    • setArtifactRole

      public PathSegment setArtifactRole(String artifactRole)
      Set up the role of the matching file or directory.
      Parameters:
      artifactRole - role
      Returns:
      this segment
    • getChildren

      public List<PathSegment> getChildren()
      Return the segments expected inside a directory that matches this segment. If there are none, the contents of the directory are not checked.
      Returns:
      list of segments
    • addChild

      public PathSegment addChild(PathSegment child)
      Add a segment that is expected inside a directory that matches this segment.
      Parameters:
      child - nested segment
      Returns:
      the nested segment
    • toString

      public String toString()
      Standard toString method.
      Overrides:
      toString in class Object
      Returns:
      print out of variables in a JSON-style