A
- The type of the attachment.public interface FileSystemNode<A>
A node representing a file or directory in the file system.
Modifier and Type | Method and Description |
---|---|
FileSystemNode<A> |
addChild(FileSystemNode<A> child)
Adds a child node to this node.
|
boolean |
containsOnlyCreatedByDependency()
Returns the flag if the child nodes (recursively) are all created by
dependency.
|
FileSystemNode<A> |
createChildDirectory(String name,
FileOwner owner,
FileMode mode,
A attachment)
Creates a child node within this node representing a directory.
|
FileSystemNode<A> |
createChildFile(String name,
FileOwner owner,
FileMode mode,
A attachment)
Creates a child node within this node representing a file.
|
FileSystemNode<A> |
createChildSymLink(String name,
Path target,
FileOwner owner,
FileMode mode,
A attachment)
Creates a child node within this node representing a file.
|
FileSystemNode<A> |
createDirectories(Path path)
Creates a node for the directory specified by the path and all
directories on the path there.
|
A |
getAttachment()
Returns the attachment.
|
FileSystemNode<A> |
getChild(String name)
Returns the child node with the specified name.
|
FileMode |
getMode()
Returns the mode.
|
String |
getName()
Returns the name of the node.
|
FileSystemNode<A> |
getNode(Path path)
Returns the node for the specified path.
|
FileOwner |
getOwner()
Returns the owner.
|
FileSystemNode<A> |
getParent()
Returns the parent.
|
Path |
getPath()
Returns the path of the node.
|
Path |
getSymLinkTarget()
Returns the path of the target of the symbolic link.
|
boolean |
isCreatedByDependency()
Returns the flag if this node was created by a dependency.
|
boolean |
isDirectory()
Returns the flag if the node represents a directory.
|
boolean |
isFile()
Returns the flag if the node represents a file.
|
boolean |
isSymLink()
Returns the flag if the node represents a symbolic link.
|
List<FileSystemNode<A>> |
moveChildrenTo(FileSystemNode<A> node)
Moves all child nodes of this node to the specified node.
|
boolean |
removeChild(FileSystemNode<A> child)
Removes the specified child node.
|
FileSystemNode<A> |
removeChild(String name)
Removes the child node with the specified name.
|
void |
setAttachment(A attachment)
Sets the attachment.
|
FileSystemNode<A> |
setParent(FileSystemNode<A> parent)
Sets the parent.
|
FileSystemNodeVisitResult |
walkNodeTree(FileSystemNodeVisitor<A> visitor)
Walks the node tree starting at this node.
|
FileSystemNode<A> getParent()
Returns the parent.
null
, if this node is the root node.FileSystemNode<A> setParent(FileSystemNode<A> parent)
Sets the parent.
parent
- The parent or null
, if this node should be the
root node.null
, if this node wasn't a
child node before.String getName()
Returns the name of the node.
Path getPath()
Returns the path of the node.
Path getSymLinkTarget()
Returns the path of the target of the symbolic link.
null
, if the node doesn't represent a
symbolic link.isSymLink()
FileOwner getOwner()
Returns the owner.
FileMode getMode()
Returns the mode.
boolean isDirectory()
Returns the flag if the node represents a directory.
true
, if the node represents a directory,
false
otherwise.boolean isFile()
Returns the flag if the node represents a file.
Symbolic links are handled as files.
true
, if the node represents a file,
false
otherwise.isSymLink()
boolean isSymLink()
Returns the flag if the node represents a symbolic link.
true
, if the node represents a symbolic
link, false
otherwise.getSymLinkTarget()
A getAttachment()
Returns the attachment.
null
, if no attachment is
set.void setAttachment(A attachment)
Sets the attachment.
attachment
- The attachment.FileSystemNode<A> createChildDirectory(String name, FileOwner owner, FileMode mode, A attachment)
Creates a child node within this node representing a directory.
name
- The name.owner
- The owner.mode
- The mode.attachment
- The attachment (optional).IllegalArgumentException
- If any of the non-optional parameters are null
.IllegalStateException
- If this node does not represents a directory or if a child
node with the specified name already exists.FileSystemNode<A> createChildFile(String name, FileOwner owner, FileMode mode, A attachment)
Creates a child node within this node representing a file.
name
- The name.owner
- The owner.mode
- The mode.attachment
- The attachment (optional).IllegalArgumentException
- If any of the non-optional parameters are null
.IllegalStateException
- If this node does not represents a directory or if a child
node with the specified name already exists.FileSystemNode<A> createChildSymLink(String name, Path target, FileOwner owner, FileMode mode, A attachment)
Creates a child node within this node representing a file.
name
- The name.target
- The path of the target.owner
- The owner.mode
- The mode.attachment
- The attachment (optional).IllegalArgumentException
- If any of the non-optional parameters are null
.IllegalStateException
- If this node does not represents a directory or if a child
node with the specified name already exists.FileSystemNode<A> addChild(FileSystemNode<A> child)
Adds a child node to this node.
child
- The child node.null
, if no child node with the same name exists.IllegalArgumentException
- If the child node is null
.IllegalStateException
- If this node does not represent a directory.FileSystemNode<A> getChild(String name)
Returns the child node with the specified name.
name
- The name.null
, if no child node with the
specified name exists.IllegalArgumentException
- If the name is null
.IllegalStateException
- If this node does not represent a directory.FileSystemNode<A> removeChild(String name)
Removes the child node with the specified name.
name
- The name.null
, if no child node
with the specified name exists.IllegalArgumentException
- If the name is null
.IllegalStateException
- If this node does not represent a directory.boolean removeChild(FileSystemNode<A> child)
Removes the specified child node.
child
- The child node.true
, if the child node was successfully removed,
false
, if the specified node is not a child node of
this node.IllegalArgumentException
- If the child node is null
.IllegalStateException
- If this node does not represent a directory.List<FileSystemNode<A>> moveChildrenTo(FileSystemNode<A> node)
Moves all child nodes of this node to the specified node.
node
- The node.IllegalArgumentException
- If the node is null
.IllegalStateException
- If this node or the specified node do not represent a
directory.FileSystemNode<A> createDirectories(Path path)
Creates a node for the directory specified by the path and all directories on the path there.
All created directories are marked as created by a dependency.
path
- The path.IllegalArgumentException
- If the path is null
.IllegalStateException
- If this node does not represent a directory or any of the
already existing nodes along the path.FileSystemNode<A> getNode(Path path)
Returns the node for the specified path.
path
- The path.null
, if the node or any nodes on path
to it don't exist.IllegalArgumentException
- If the path is null
.IllegalStateException
- If any node along the path - except the node of the last part
- does not represent a directory.boolean isCreatedByDependency()
Returns the flag if this node was created by a dependency.
This is the case if a sub-folder was added, but the parent weren't added before and created automatically.
true
, if this node was created by a
dependency, false
otherwise.containsOnlyCreatedByDependency()
boolean containsOnlyCreatedByDependency()
Returns the flag if the child nodes (recursively) are all created by dependency.
This method doesn't check the flag of this node.
true
, if all child nodes were created by a
dependency, false
otherwise.isCreatedByDependency()
FileSystemNodeVisitResult walkNodeTree(FileSystemNodeVisitor<A> visitor) throws IOException
Walks the node tree starting at this node.
visitor
- The visitor to invoke for each node.IllegalArgumentException
- If the visitor is null
.IOException
- If an I/O error occurs.Copyright © 2015–2019. All rights reserved.