Package org.mycore.datamodel.ifs2
Class MCRNode
java.lang.Object
org.mycore.datamodel.ifs2.MCRNode
- Direct Known Subclasses:
MCRStoredNode
,MCRVirtualNode
Represents a file, directory or file collection within a file store. Files
and directories can be either really stored, or virtually existing as a child
node contained within a stored container file like zip or tar.
- Author:
- Frank Lützenkirchen
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract MCRNode
buildChildNode
(Path fo) Creates a node instance for the given FileObject, which represents the childReturns the child node with the given filename, or nullReturns the children of this node.Returns the content of this node for output.Returns the time this node was last modified.getName()
Returns the file or directory namegetNodeByPath
(String path) Returns the node with the given relative or absolute path in the file collection this node belongs to.int
Returns the number of child nodes of this node.Returns the parent node containing this nodegetPath()
Returns the complete path of this node up to the root file collection.Returns the content of this node for random access read.getRoot()
Returns the root file collection this node belongs tolong
getSize()
For file nodes, returns the file content size in bytes, otherwise returns 0.boolean
Returns true if this node has child nodes.boolean
Returns true if this node is a directoryboolean
isFile()
Returns true if this node is a file
-
Field Details
-
path
The path object representing this node in the underlying filesystem. -
parent
The parent node owning this file, a directory or container file
-
-
Constructor Details
-
MCRNode
Creates a new node representing a child of the given parent- Parameters:
parent
- the parent nodepath
- the file object representing this node in the underlying filesystem
-
-
Method Details
-
getName
Returns the file or directory name- Returns:
- the node's filename
-
getPath
Returns the complete path of this node up to the root file collection. Path always start with a slash, slash is used as directory delimiter.- Returns:
- the absolute path of this node
-
getParent
Returns the parent node containing this node- Returns:
- the parent directory or container file
-
getRoot
Returns the root file collection this node belongs to- Returns:
- the root file collection
-
isFile
Returns true if this node is a file- Returns:
- true if this node is a file
- Throws:
IOException
-
isDirectory
Returns true if this node is a directory- Returns:
- true if this node is a directory
- Throws:
IOException
-
getSize
For file nodes, returns the file content size in bytes, otherwise returns 0.- Returns:
- the file size in bytes
- Throws:
IOException
-
getLastModified
Returns the time this node was last modified.- Returns:
- the time this node was last modified
- Throws:
IOException
-
hasChildren
Returns true if this node has child nodes. Directories and container files like zip or tar may have child nodes.- Returns:
- true if children exist
- Throws:
IOException
-
getNumChildren
Returns the number of child nodes of this node.- Returns:
- the number of child nodes of this node.
- Throws:
IOException
-
getChildren
Returns the children of this node.- Returns:
- a List of child nodes, which may be empty, in undefined order
- Throws:
IOException
-
buildChildNode
Creates a node instance for the given FileObject, which represents the child- Parameters:
fo
- the FileObject representing the child in the underlying filesystem- Returns:
- the child node or null, if the fo does not exists
- Throws:
IllegalArgumentException
- if fo is not valid path for a child of this
-
getChild
Returns the child node with the given filename, or null- Parameters:
name
- the name of the child node- Returns:
- the child node with that name, or null when no such file exists
-
getNodeByPath
Returns the node with the given relative or absolute path in the file collection this node belongs to. Slash is used as directory delimiter. When the path starts with a slash, it is an absolute path and resolving is startet at the root file collection. When the path is relative, resolving starts with the current node. One dot represents the current node, Two dots represent the parent node, like in paths used by typical real filesystems.- Parameters:
path
- the absolute or relative path of the node to find, may contain . or ..- Returns:
- the node at the given path, or null
- Throws:
IOException
-
getContent
Returns the content of this node for output. For a directory, it will return null.- Returns:
- the content of the file
- Throws:
IOException
-
getRandomAccessContent
Returns the content of this node for random access read. Be sure not to write to the node using the returned object, use just for reading! For a directory, it will return null.- Returns:
- the content of this file, for random access
- Throws:
IOException
-