public class DataStoreNode extends Object implements DebianPackageConstants
A node representing a directory or file in the DataStore
.
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 |
---|
DataStoreNode()
Creates the root node.
|
DataStoreNode(DataSource source,
String name,
FileOwner owner,
FileMode mode)
Creates a node for a file.
|
DataStoreNode(String name,
FileOwner owner,
FileMode mode)
Creates a node for a directory.
|
DataStoreNode(String name,
String target,
FileOwner owner,
FileMode mode)
Creates a node for a symbolic link.
|
Modifier and Type | Method and Description |
---|---|
void |
addChildNode(DataStoreNode childNode)
Adds a child node.
|
List<FileHash> |
createFileHashes(MessageDigest digest)
Creates the file hashes for all files within the directory and its
sub-directories (if this node represents a directory) or for the file (if
this node represents a file).
|
DataStoreNode |
getChildNodeByName(String name)
Returns the child node with the specified name.
|
String |
getName()
Returns the name.
|
DataStoreNode |
getParentNode()
Returns the parent node.
|
String |
getPath()
Returns the path.
|
long |
getSize()
Returns the size of the files under this node and its sub-nodes.
|
boolean |
isDirectory()
Returns the flag if the node is a directory node.
|
boolean |
isFile()
Returns the flag if the node is a file node.
|
boolean |
isSymbolicLink()
Returns the flag if the node is a symbolic link node.
|
void |
write(org.apache.commons.compress.archivers.tar.TarArchiveOutputStream out)
Writes the node and its child nodes into the stream.
|
public DataStoreNode()
Creates the root node.
public DataStoreNode(String name, FileOwner owner, FileMode mode)
Creates a node for a directory.
name
- The name.owner
- The owner.mode
- The mode.IllegalArgumentException
- If any of the parameters are null
.public DataStoreNode(DataSource source, String name, FileOwner owner, FileMode mode)
Creates a node for a file.
source
- The source for the content of the file.name
- The name.owner
- The owner.mode
- The mode.IllegalArgumentException
- If any of the parameters are null
.public DataStoreNode(String name, String target, FileOwner owner, FileMode mode)
Creates a node for a symbolic link.
name
- The name.target
- The target of the symbolic link.owner
- The owner.mode
- The mode.IllegalArgumentException
- If any of the parameters are null
.public String getName()
Returns the name.
public String getPath()
Returns the path.
public boolean isDirectory()
Returns the flag if the node is a directory node.
true
, if the node is a directory node,
false
otherwise.isFile()
public boolean isFile()
Returns the flag if the node is a file node.
Symbolic links are also files.
true
, if the node is a file node,
false
otherwise.isDirectory()
,
isSymbolicLink()
public boolean isSymbolicLink()
Returns the flag if the node is a symbolic link node.
true
, if the node is a symbolic link node,
false
otherwise.isFile()
public long getSize() throws IOException
Returns the size of the files under this node and its sub-nodes.
IOException
- If the size of a file can't be determined.public void addChildNode(DataStoreNode childNode)
Adds a child node.
childNode
- The child node.IllegalArgumentException
- If the child node is null
, this node is not a
directory node, the child node is already added to a node or
this node already contains a child node with the same name.public DataStoreNode getChildNodeByName(String name)
Returns the child node with the specified name.
name
- The name.null
, if this node doesn't contain such
a node.IllegalArgumentException
- If the name is null
or this node is not a
directory node.public DataStoreNode getParentNode()
Returns the parent node.
null
, if the node wasn't add to
any other node.public void write(org.apache.commons.compress.archivers.tar.TarArchiveOutputStream out) throws IOException
Writes the node and its child nodes into the stream.
out
- The stream.IOException
- If an I/O error occurs.IllegalArgumentException
- If the stream is null
.public List<FileHash> createFileHashes(MessageDigest digest) throws IOException
Creates the file hashes for all files within the directory and its sub-directories (if this node represents a directory) or for the file (if this node represents a file).
Symbolic links are ignored. No hash will be created for them.
digest
- The digest used for creating the hashes.IOException
- If an I/O error occurs.Copyright © 2015–2019. All rights reserved.