Class MCRFile


public class MCRFile extends MCRStoredNode
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 Details

  • Constructor Details

    • MCRFile

      protected MCRFile(MCRDirectory parent, Path fo, Element data)
      Returns a MCRFile object representing an existing file already stored in the store.
      Parameters:
      parent - the parent directory containing this file
      fo - the file in the local underlying filesystem storing this file
    • MCRFile

      protected MCRFile(MCRDirectory parent, String name) throws IOException
      Creates a new MCRFile that does not exist yet
      Parameters:
      parent - the parent directory
      name - the file name
      Throws:
      IOException
  • Method Details

    • buildChildNode

      protected MCRVirtualNode buildChildNode(Path fo)
      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 class MCRNode
      Parameters:
      fo - the FileObject representing the child in the underlying filesystem
      Returns:
      the child node or null, if the fo does not exists
    • getMD5

      public String getMD5()
      Returns the md5 checksum of the file's content.
      Returns:
      the md5 checksum of the file's content.
    • getExtension

      public String 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

      public String setContent(MCRContent source) throws IOException
      Sets the content of this file.
      Parameters:
      source - the content to be read
      Returns:
      the MD5 checksum of the stored content
      Throws:
      IOException
    • setMD5

      public void setMD5(String md5) throws IOException
      updates the MD5 sum of this file to the given value. Use only if you modified the content outside of setContent(MCRContent).
      Parameters:
      md5 -
      Throws:
      IOException
    • getBasicFileAttributes

      public MCRFileAttributes<String> getBasicFileAttributes() throws IOException
      Overrides:
      getBasicFileAttributes in class MCRStoredNode
      Throws:
      IOException