Class FileComponent

java.lang.Object
org.cdlib.mrt.core.FileComponent
All Implemented Interfaces:
Serializable, StateInf

public class FileComponent extends Object implements Serializable, StateInf
Author:
dloy
See Also:
  • Field Details

  • Constructor Details

    • FileComponent

      protected FileComponent(FileComponent fileComponent)
    • FileComponent

      public FileComponent()
      Generic constructor
  • Method Details

    • getComponentFile

      public File getComponentFile()
      Get a file for this Component
      Returns:
      file for this Component
    • setComponentFile

      public void setComponentFile(File componentFile)
      Set file for this Component
      Parameters:
      file - for this Component
    • getMimeType

      public String getMimeType()
      File Mime type
      Returns:
      file Mime Type
    • setMimeType

      public void setMimeType(String MimeType)
      Set MimeType
      Parameters:
      MimeType - set using this value
    • setCreated

      public void setCreated(DateState created)
      set date/time of last modification
      Parameters:
      lastModifiedDate -
    • setCreated

      public void setCreated()
      set date/time of last modification using current Date
    • getCreated

      public DateState getCreated()
      Last modified Date
      Returns:
      last modified date
    • setLastModifiedDate

      public void setLastModifiedDate(String lastModifiedDate)
      set date/time of last modification using the Iso date format as String
      Parameters:
      lastModifiedDate -
    • addMessageDigest

      public void addMessageDigest(String digest, String algorithmS) throws TException
      Save a new MessageDigest for this file
      Parameters:
      digest - character hex form of digest (checksum)
      algorithmS - Digest type (checksumtype)
      Throws:
      TException
    • setFirstMessageDigest

      public void setFirstMessageDigest(String digest, String algorithmS) throws TException
      Save a new MessageDigest for this file as only digest
      Parameters:
      digest - character hex form of digest (checksum)
      algorithmS - Digest type (checksumtype)
      Throws:
      TException
    • getMessageDigest

      public MessageDigest getMessageDigest(String algorithmS)
      Return a specific digest based on algorithm e.g. return a checksum based on checksum type
      Parameters:
      algorithmS - checksum type
      Returns:
      hex character checksum
    • getMessageDigest

      public MessageDigest getMessageDigest(MessageDigestType algorithm)
      Return a specific digest based on an algorithm enum
      Parameters:
      algorithm - enum form of checksum
      Returns:
      hex character checksum
    • getIdentifier

      public String getIdentifier()
      Name of file including relative path values
      Returns:
      File name
    • setIdentifier

      public void setIdentifier(String name)
      Set file Name
      Parameters:
      name - file Name
    • getURL

      public URL getURL()
      URL reference to file
      Returns:
      file reference
    • getURLNorm

      public URL getURLNorm()
    • setURL

      public void setURL(URL link)
      Set link to file
      Parameters:
      link - file link
    • setURL

      public void setURL(String linkS) throws TException
      Set link to file passed as string
      Parameters:
      linkS - String form of link to file
      Throws:
      TException - argument not URL
    • getSize

      public long getSize()
      Size of file in bytes
      Returns:
      file size
    • setSize

      public void setSize(long size)
      File size
      Parameters:
      size - file Size
    • setSize

      public void setSize(String sizeS) throws TException
      File size as string
      Parameters:
      sizeS - file size as String
      Throws:
      TException - non-numeric file size string
    • setMessageDigests

      public void setMessageDigests(HashSet<MessageDigest> messageDigests)
    • getMessageDigests

      public HashSet<MessageDigest> getMessageDigests()
      set of MessageDigest - each containing a unique MessageDigest type (e.g. checksum type)
      Returns:
      Set of message digests for this specific file
    • getMessageDigest

      public MessageDigest getMessageDigest()
      Return the first Message digest in digest set Typically there will only be one as saved in manifest
      Returns:
      first (or only) message digest
    • getLocalID

      public String getLocalID()
      get LocalID value
      Returns:
      LocalID value
    • setLocalID

      public void setLocalID(String localID)
      set localID value
      Parameters:
      localID - LocalID value
    • getPrimaryID

      public String getPrimaryID()
      get primaryID value
      Returns:
      primary ID
    • setPrimaryID

      public void setPrimaryID(String primaryID)
      set primaryID value
      Parameters:
      primaryID - primary ID
    • copy

      public void copy(FileComponent fileState)
      copy "Constructor" Copy another FileState to this FileState
      Parameters:
      fileState - copy from
    • matchFixity

      public boolean matchFixity(FileComponent test)
      Match this FileState to another FileState on MessageDigest
      Parameters:
      test - comparison FileState
      Returns:
      true=FileStates match, false=FileStates do not match
    • equals

      public boolean equals(FileComponent test)
      See if this FileState is equal to another FileState
      Parameters:
      test - comparison FileState
      Returns:
      true=FileStates match, false=FileStates do not match
    • matchString

      protected boolean matchString(String val1, String val2)
      local definition of string comparison
      Parameters:
      val1 - match String1
      val2 - match String2
      Returns:
      true=Strings match, false=Strings do not match
    • matchURL

      protected boolean matchURL(URL val1, URL val2)
      local definition of URL comparison
      Parameters:
      val1 - match URL 1
      val2 - match URL 2
      Returns:
      true=URLs match, false=URLs do not match
    • matchDigests

      protected boolean matchDigests(FileComponent test)
      Match available digests - a successful match completes test
      Parameters:
      test - FileState to match
      Returns:
      true=a MessageDigest matches, false=a MessageDigest does not match OR no match was found
    • dump

      public String dump(String header)
      Dump FileState information
      Parameters:
      header - header for dump display
      Returns:
      String containing dump information
    • getDigestDisplay

      protected String getDigestDisplay()
      Dump Set of Digest values
      Returns:
      String containing Digest values
    • getDateDisplay

      protected String getDateDisplay()
      Display LastModifiedDate as Iso Date
      Returns:
      String containing Iso Date
    • getCreator

      public String getCreator()
    • setCreator

      public void setCreator(String creator)
    • getTitle

      public String getTitle()
    • setTitle

      public void setTitle(String title)
    • getDate

      public String getDate()
    • setDate

      public void setDate(String date)
    • normBox

      public static URL normBox(URL inURL)