Package org.mycore.datamodel.ifs2
Class MCRFile
java.lang.Object
org.mycore.datamodel.ifs2.MCRNode
org.mycore.datamodel.ifs2.MCRStoredNode
org.mycore.datamodel.ifs2.MCRFile
Represents a file stored in a file collection. This is a file that is
imported from outside the system, and may be updated and modified afterwards.
- Author:
- Frank Lützenkirchen
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
MCRFile
(MCRDirectory parent, String name) Creates a new MCRFile that does not exist yetprotected
MCRFile
(MCRDirectory parent, Path fo, Element data) Returns a MCRFile object representing an existing file already stored in the store. -
Method Summary
Modifier and TypeMethodDescriptionprotected MCRVirtualNode
buildChildNode
(Path fo) Returns a MCRVirtualNode contained in this file as a child.Returns the file name extension, which is the part after the last dot in the filename.getMD5()
Returns the md5 checksum of the file's content.setContent
(MCRContent source) Sets the content of this file.void
updates the MD5 sum of this file to the given value.Methods inherited from class org.mycore.datamodel.ifs2.MCRStoredNode
clearLabels, delete, getCurrentLabel, getLabel, getLabels, getLocalFile, getLocalPath, readData, renameTo, setLabel, setLastModified, writeData
Methods inherited from class org.mycore.datamodel.ifs2.MCRNode
getChild, getChildren, getContent, getLastModified, getName, getNodeByPath, getNumChildren, getParent, getPath, getRandomAccessContent, getRoot, getSize, hasChildren, isDirectory, isFile
-
Field Details
-
MD5_OF_EMPTY_FILE
The md5 checksum of the empty file- See Also:
-
-
Constructor Details
-
MCRFile
Returns a MCRFile object representing an existing file already stored in the store.- Parameters:
parent
- the parent directory containing this filefo
- the file in the local underlying filesystem storing this file
-
MCRFile
Creates a new MCRFile that does not exist yet- Parameters:
parent
- the parent directoryname
- the file name- Throws:
IOException
-
-
Method Details
-
buildChildNode
Returns a MCRVirtualNode contained in this file as a child. A file that is a container, like zip or tar, may contain other files as children.- Specified by:
buildChildNode
in classMCRNode
- Parameters:
fo
- the FileObject representing the child in the underlying filesystem- Returns:
- the child node or null, if the fo does not exists
-
getMD5
Returns the md5 checksum of the file's content.- Returns:
- the md5 checksum of the file's content.
-
getExtension
Returns the file name extension, which is the part after the last dot in the filename.- Returns:
- the file extension, or the empty string if the file name does not have an extension
-
setContent
Sets the content of this file.- Parameters:
source
- the content to be read- Returns:
- the MD5 checksum of the stored content
- Throws:
IOException
-
setMD5
updates the MD5 sum of this file to the given value. Use only if you modified the content outside ofsetContent(MCRContent)
.- Parameters:
md5
-- Throws:
IOException
-
getBasicFileAttributes
- Overrides:
getBasicFileAttributes
in classMCRStoredNode
- Throws:
IOException
-