A
- The type of the attachment.public class FileSystemNodeImpl<A> extends Object implements FileSystemNode<A>, DebianPackageConstants
A FileSystemNode
implementation.
CONFFILES_ENTRY, CONFIG_ENTRY, CONTROL_ENTRY, CONTROL_NAME, CONTROL_TAR_PREFIX, DATA_NAME, DATA_TAR_PREFIX, DEBIAN_BINARY, DIRECTORY_MODE, DOC_BASE_PATH, FILE_MODE, MD5SUMS_ENTRY, POSTINST_ENTRY, POSTRM_ENTRY, PREINST_ENTRY, PRERM_ENTRY, ROOT_GROUP_ID, ROOT_GROUP_NAME, ROOT_USER_ID, ROOT_USER_NAME, SCRIPT_MODE, SHLIBS_ENTRY, SYMBOLS_ENTRY, TAR_BZIP2_SUFFIX, TAR_GZIP_SUFFIX, TAR_XZ_SUFFIX, TEMPLATES_ENTRY, TRIGGERS_ENTRY, USR_PATH, USR_SHARE_PATH
UTF_8, UTF_8_CHARSET
Constructor and Description |
---|
FileSystemNodeImpl(String name)
Creates a node representing a directory.
|
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.
|
public FileSystemNodeImpl(String name)
Creates a node representing a directory.
The node is marked as created by a dependency.
name
- The name.IllegalArgumentException
- If the name is null
.public FileSystemNode<A> getParent()
FileSystemNode
Returns the parent.
getParent
in interface FileSystemNode<A>
null
, if this node is the root node.public FileSystemNode<A> setParent(FileSystemNode<A> parent)
FileSystemNode
Sets the parent.
setParent
in interface FileSystemNode<A>
parent
- The parent or null
, if this node should be the
root node.null
, if this node wasn't a
child node before.public String getName()
FileSystemNode
Returns the name of the node.
getName
in interface FileSystemNode<A>
public Path getPath()
FileSystemNode
Returns the path of the node.
getPath
in interface FileSystemNode<A>
public Path getSymLinkTarget()
FileSystemNode
Returns the path of the target of the symbolic link.
getSymLinkTarget
in interface FileSystemNode<A>
null
, if the node doesn't represent a
symbolic link.FileSystemNode.isSymLink()
public FileOwner getOwner()
FileSystemNode
Returns the owner.
getOwner
in interface FileSystemNode<A>
public FileMode getMode()
FileSystemNode
Returns the mode.
getMode
in interface FileSystemNode<A>
public boolean isDirectory()
FileSystemNode
Returns the flag if the node represents a directory.
isDirectory
in interface FileSystemNode<A>
true
, if the node represents a directory,
false
otherwise.public boolean isFile()
FileSystemNode
Returns the flag if the node represents a file.
Symbolic links are handled as files.
isFile
in interface FileSystemNode<A>
true
, if the node represents a file,
false
otherwise.FileSystemNode.isSymLink()
public boolean isSymLink()
FileSystemNode
Returns the flag if the node represents a symbolic link.
isSymLink
in interface FileSystemNode<A>
true
, if the node represents a symbolic
link, false
otherwise.FileSystemNode.getSymLinkTarget()
public A getAttachment()
FileSystemNode
Returns the attachment.
getAttachment
in interface FileSystemNode<A>
null
, if no attachment is
set.public void setAttachment(A attachment)
FileSystemNode
Sets the attachment.
setAttachment
in interface FileSystemNode<A>
attachment
- The attachment.public FileSystemNode<A> createChildDirectory(String name, FileOwner owner, FileMode mode, A attachment)
FileSystemNode
Creates a child node within this node representing a directory.
createChildDirectory
in interface FileSystemNode<A>
name
- The name.owner
- The owner.mode
- The mode.attachment
- The attachment (optional).public FileSystemNode<A> createChildFile(String name, FileOwner owner, FileMode mode, A attachment)
FileSystemNode
Creates a child node within this node representing a file.
createChildFile
in interface FileSystemNode<A>
name
- The name.owner
- The owner.mode
- The mode.attachment
- The attachment (optional).public FileSystemNode<A> createChildSymLink(String name, Path target, FileOwner owner, FileMode mode, A attachment)
FileSystemNode
Creates a child node within this node representing a file.
createChildSymLink
in interface FileSystemNode<A>
name
- The name.target
- The path of the target.owner
- The owner.mode
- The mode.attachment
- The attachment (optional).public FileSystemNode<A> addChild(FileSystemNode<A> child)
FileSystemNode
Adds a child node to this node.
addChild
in interface FileSystemNode<A>
child
- The child node.null
, if no child node with the same name exists.public FileSystemNode<A> getChild(String name)
FileSystemNode
Returns the child node with the specified name.
getChild
in interface FileSystemNode<A>
name
- The name.null
, if no child node with the
specified name exists.public FileSystemNode<A> removeChild(String name)
FileSystemNode
Removes the child node with the specified name.
removeChild
in interface FileSystemNode<A>
name
- The name.null
, if no child node
with the specified name exists.public boolean removeChild(FileSystemNode<A> child)
FileSystemNode
Removes the specified child node.
removeChild
in interface FileSystemNode<A>
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.public List<FileSystemNode<A>> moveChildrenTo(FileSystemNode<A> node)
FileSystemNode
Moves all child nodes of this node to the specified node.
moveChildrenTo
in interface FileSystemNode<A>
node
- The node.public FileSystemNode<A> createDirectories(Path path)
FileSystemNode
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.
createDirectories
in interface FileSystemNode<A>
path
- The path.public FileSystemNode<A> getNode(Path path)
FileSystemNode
Returns the node for the specified path.
getNode
in interface FileSystemNode<A>
path
- The path.null
, if the node or any nodes on path
to it don't exist.public boolean containsOnlyCreatedByDependency()
FileSystemNode
Returns the flag if the child nodes (recursively) are all created by dependency.
This method doesn't check the flag of this node.
containsOnlyCreatedByDependency
in interface FileSystemNode<A>
true
, if all child nodes were created by a
dependency, false
otherwise.FileSystemNode.isCreatedByDependency()
public boolean isCreatedByDependency()
FileSystemNode
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.
isCreatedByDependency
in interface FileSystemNode<A>
true
, if this node was created by a
dependency, false
otherwise.FileSystemNode.containsOnlyCreatedByDependency()
public FileSystemNodeVisitResult walkNodeTree(FileSystemNodeVisitor<A> visitor) throws IOException
FileSystemNode
Walks the node tree starting at this node.
walkNodeTree
in interface FileSystemNode<A>
visitor
- The visitor to invoke for each node.IOException
- If an I/O error occurs.Copyright © 2015–2019. All rights reserved.