Class DirectoryLayout
java.lang.Object
org.odpi.openmetadata.adapters.connectors.surveyaction.surveyfolder.layout.DirectoryLayout
DirectoryLayout describes the files and directories expected beneath a directory. It is the in-memory form
of a DirectorySchemaType and its PathSegmentAttributes.
A layout can be written as a template: one path pattern per line, where a line that ends in / is a directory. A line may be followed by [optional], [multiple] and [role=...] to describe the last segment of the path.
A layout can be written as a template: one path pattern per line, where a line that ends in / is a directory. A line may be followed by [optional], [multiple] and [role=...] to describe the last segment of the path.
campaign={id}/ [multiple]
campaign={id}/dp={n}_pressure={p}/ [multiple]
campaign={id}/dp={n}_pressure={p}/deck.inp [role=input deck]
campaign={id}/dp={n}_pressure={p}/solver.log
campaign={id}/dp={n}_pressure={p}/kpis.json [role=results summary]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddSegment(PathSegment segment) Add a segment that is expected directly inside the directory.static DirectoryLayoutfromTemplate(String template) Build a layout from a template.Return the segments expected directly inside the directory.booleanisEmpty()Return whether the layout describes anything.Write the layout as a template.Check a directory tree against this layout.
-
Constructor Details
-
DirectoryLayout
public DirectoryLayout()Default constructor
-
-
Method Details
-
getSegments
Return the segments expected directly inside the directory.- Returns:
- list of segments
-
addSegment
Add a segment that is expected directly inside the directory.- Parameters:
segment- top-level segment- Returns:
- the segment
-
isEmpty
public boolean isEmpty()Return whether the layout describes anything.- Returns:
- boolean
-
fromTemplate
Build a layout from a template. Blank lines and lines that start with # are ignored.- Parameters:
template- one path pattern per line- Returns:
- layout
- Throws:
IllegalArgumentException- a line of the template is not valid
-
toTemplate
Write the layout as a template.- Returns:
- one path pattern per line
-
validate
Check a directory tree against this layout.- Every file and directory must match one of the segments expected in its parent directory.
- A required segment must be matched at least once.
- A segment that is not multiple must be matched at most once.
- The contents of a directory are checked only if its segment has nested segments.
- A directory that is not expected is reported once - its contents are not checked.
- Files and directories whose names start with a dot are ignored.
- Parameters:
rootDirectory- directory to check- Returns:
- the violations found and the conformance score
-