Class PathSegment
java.lang.Object
org.odpi.openmetadata.adapters.connectors.surveyaction.surveyfolder.layout.PathSegment
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.
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddChild(PathSegment child) Add a segment that is expected inside a directory that matches this segment.Return the role of the matching file or directory.Return the segments expected inside a directory that matches this segment.Return the pattern for the name of the file or directory.Return whether this segment describes a directory or a file.booleanReturn whether this segment describes a directory.booleanReturn whether more than one file or directory in the same parent directory may match.booleanReturn whether a matching file or directory must be present.booleanReturn whether the name pattern includes a variable.booleanDoes the name of a file or directory match this segment's name pattern?setArtifactRole(String artifactRole) Set up the role of the matching file or directory.setMultiple(boolean multiple) Set up whether more than one file or directory in the same parent directory may match.setRequired(boolean required) Set up whether a matching file or directory must be present.toString()Standard toString method.
-
Field Details
-
DIRECTORY
Value of segmentType for a directory.- See Also:
-
FILE
Value of segmentType for a file.- See Also:
-
-
Constructor Details
-
PathSegment
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
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
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
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
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
Set up whether more than one file or directory in the same parent directory may match.- Parameters:
multiple- boolean- Returns:
- this segment
-
getArtifactRole
Return the role of the matching file or directory.- Returns:
- role or null
-
setArtifactRole
Set up the role of the matching file or directory.- Parameters:
artifactRole- role- Returns:
- this segment
-
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
Add a segment that is expected inside a directory that matches this segment.- Parameters:
child- nested segment- Returns:
- the nested segment
-
toString
Standard toString method.
-