Class DigestHelper


  • public class DigestHelper
    extends java.lang.Object
    This class assists in the manipulation of Nuix digest lists.
    • Constructor Summary

      Constructors 
      Constructor Description
      DigestHelper()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addAllItems​(java.util.Collection<nuix.Item> items)
      Add a collection of items, using each item's MD5 value.
      void addAllMd5ByteArrays​(java.util.Collection<byte[]> md5DigestByteArrays)
      Add a collection of MD5 values where each MD5 is represented as its equivalent byte array.
      void addAllMd5Strings​(java.util.Collection<java.lang.String> md5DigestStrings)
      Add a collection of MD5 values where MD5 is represented as a hexadecimal string.
      static java.lang.String bytesToHex​(byte[] bytes)
      Convenience method for converting a byte array to a hex string.
      void clear()
      Clears out all digests currently being tracked by this instance.
      static DigestHelper createFromExistingDigestLists​(java.util.Collection<java.io.File> digestFiles)
      Creates an instance of DigestHelper containing the digests from all specified digest lists.
      static DigestHelper createFromExistingDigestListsByName​(java.util.Collection<java.lang.String> existingDigestNames)
      Creates an instance of DigestHelper containing the digests from all specified digest lists.
      boolean currentlyContains​(byte[] md5)
      Whether this instance currently contains the specific digest.
      boolean currentlyContains​(java.lang.String md5)
      Whether this instance currently contains the specific digest.
      boolean currentlyContains​(nuix.Item item)
      Whether this instance currently contains the specific digest for the provided item.
      static java.io.File getDigestListDirectory()
      Returns the assumed directory containing digest lists.
      static java.io.File getDigestListLocation​(java.lang.String name)
      Returns the assumed location of a particular named digest list.
      int getDistinctDigestCount()
      Returns the counts of distinct digests currently stored in this instance.
      static byte[] hexToBytes​(java.lang.String hex)
      Convenience method for converting hex string to byte array.
      int loadDigestList​(java.io.File location)
      Includes all entries from an existing Nuix digest list file.
      int loadDigestList​(java.lang.String location)
      Includes all entries from an existing Nuix digest list file.
      int loadDigestListByName​(java.lang.String name)
      Includes all entries from an the appropriate existing Nuix digest list file based on the provided name.
      int saveDigestList​(java.io.File location)
      Saves a Nuix digest list based on data which has been added so far using methods addAllItems(Collection) or addAllMd5Strings(Collection) or addAllMd5ByteArrays(Collection).
      int saveDigestList​(java.lang.String location)
      Saves a Nuix digest list based on data which has been added so far using methods addAllItems(Collection) or addAllMd5Strings(Collection) or addAllMd5ByteArrays(Collection).
      int saveDigestListByName​(java.lang.String name)
      Saves a digest list to the appropriate location with provided name.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DigestHelper

        public DigestHelper()
    • Method Detail

      • getDigestListDirectory

        public static java.io.File getDigestListDirectory()
        Returns the assumed directory containing digest lists.
        Returns:
        File representing the digest lists directory.
      • getDigestListLocation

        public static java.io.File getDigestListLocation​(java.lang.String name)
        Returns the assumed location of a particular named digest list.
        Parameters:
        name - The named of the digest list.
        Returns:
        File represent the digest list location.
      • hexToBytes

        public static byte[] hexToBytes​(java.lang.String hex)
        Convenience method for converting hex string to byte array.
        Parameters:
        hex - String of hexadecimal.
        Returns:
        Byte array equivalent.
      • bytesToHex

        public static java.lang.String bytesToHex​(byte[] bytes)
        Convenience method for converting a byte array to a hex string.
        Parameters:
        bytes - The bytes to convert.
        Returns:
        A string representation of the byte array as hexadecimal.
      • createFromExistingDigestLists

        public static DigestHelper createFromExistingDigestLists​(java.util.Collection<java.io.File> digestFiles)
                                                          throws java.io.IOException
        Creates an instance of DigestHelper containing the digests from all specified digest lists.
        Parameters:
        digestFiles - Collection of digest files to load into the resulting instance.
        Returns:
        A DigestHelper instance containing all the digests from the provided existing digest lists.
        Throws:
        java.io.IOException - Thrown if there is an issue with the file stream.
      • createFromExistingDigestListsByName

        public static DigestHelper createFromExistingDigestListsByName​(java.util.Collection<java.lang.String> existingDigestNames)
                                                                throws java.io.IOException
        Creates an instance of DigestHelper containing the digests from all specified digest lists. Assumes digest lists are stored in "%appdata%\Nuix\Digest Lists"
        Parameters:
        existingDigestNames - A collection of digest list names.
        Returns:
        A DigestHelper instance containing all the digests from the provided existing digest lists.
        Throws:
        java.io.IOException - Thrown if there is an issue with the file stream.
      • addAllMd5ByteArrays

        public void addAllMd5ByteArrays​(java.util.Collection<byte[]> md5DigestByteArrays)
        Add a collection of MD5 values where each MD5 is represented as its equivalent byte array.
        Parameters:
        md5DigestByteArrays - A collection of MD5 byte arrays.
      • addAllMd5Strings

        public void addAllMd5Strings​(java.util.Collection<java.lang.String> md5DigestStrings)
        Add a collection of MD5 values where MD5 is represented as a hexadecimal string.
        Parameters:
        md5DigestStrings - A collection of MD5 hexadecimal strings. Null or empty values are ignored.
      • addAllItems

        public void addAllItems​(java.util.Collection<nuix.Item> items)
        Add a collection of items, using each item's MD5 value.
        Parameters:
        items - Collection of items to add to this instance. Items which return a null or empty MD5 string will be ignored.
      • saveDigestList

        public int saveDigestList​(java.io.File location)
                           throws java.io.IOException
        Saves a Nuix digest list based on data which has been added so far using methods addAllItems(Collection) or addAllMd5Strings(Collection) or addAllMd5ByteArrays(Collection).
        Parameters:
        location - The location in which to save the Nuix formatted digest list file.
        Returns:
        The number of digests saved. Should match the count returned by getDistinctDigestCount() before this call was made.
        Throws:
        java.io.IOException - If there is an issue with the output stream.
      • saveDigestListByName

        public int saveDigestListByName​(java.lang.String name)
                                 throws java.io.IOException
        Saves a digest list to the appropriate location with provided name. Assumes digest lists are stored in "%appdata%\Nuix\Digest Lists"
        Parameters:
        name - The name of the digest list to save.
        Returns:
        The number of digests saved. Should match the count returned by getDistinctDigestCount() before this call was made.
        Throws:
        java.io.IOException - If there is an issue with the output stream.
      • saveDigestList

        public int saveDigestList​(java.lang.String location)
                           throws java.io.IOException
        Saves a Nuix digest list based on data which has been added so far using methods addAllItems(Collection) or addAllMd5Strings(Collection) or addAllMd5ByteArrays(Collection).
        Parameters:
        location - The location in which to save the Nuix formatted digest list file.
        Returns:
        The number of digests saved. Should match the count returned by getDistinctDigestCount() before this call was made.
        Throws:
        java.io.IOException - Caused by an issue with the output stream.
      • loadDigestList

        public int loadDigestList​(java.io.File location)
                           throws java.io.IOException
        Includes all entries from an existing Nuix digest list file.
        Parameters:
        location - The location of the existing digest list file.
        Returns:
        The count of digests loaded from the file.
        Throws:
        java.io.IOException - Caused by an issue with the input stream.
      • loadDigestListByName

        public int loadDigestListByName​(java.lang.String name)
                                 throws java.io.IOException
        Includes all entries from an the appropriate existing Nuix digest list file based on the provided name. Assumes digest lists are stored in "%appdata%\Nuix\Digest Lists"
        Parameters:
        name - The name of the existing Nuix digest list to load.
        Returns:
        The count of digests loaded from the file.
        Throws:
        java.io.IOException - Caused by an issue with the input stream.
      • loadDigestList

        public int loadDigestList​(java.lang.String location)
                           throws java.io.IOException
        Includes all entries from an existing Nuix digest list file.
        Parameters:
        location - The location of the existing digest list file.
        Returns:
        The count of digests loaded from the file.
        Throws:
        java.io.IOException - Caused by an issue with the input stream.
      • getDistinctDigestCount

        public int getDistinctDigestCount()
        Returns the counts of distinct digests currently stored in this instance.
        Returns:
        Count of distinct digests stored.
      • clear

        public void clear()
        Clears out all digests currently being tracked by this instance.
      • currentlyContains

        public boolean currentlyContains​(byte[] md5)
        Whether this instance currently contains the specific digest.
        Parameters:
        md5 - MD5 as byte array.
        Returns:
        True if this instance contains this digest.
      • currentlyContains

        public boolean currentlyContains​(java.lang.String md5)
        Whether this instance currently contains the specific digest.
        Parameters:
        md5 - MD5 as hexadecimal string.
        Returns:
        True if this instance contains this digest.
      • currentlyContains

        public boolean currentlyContains​(nuix.Item item)
        Whether this instance currently contains the specific digest for the provided item.
        Parameters:
        item - The item which will have it's MD5 checked for.
        Returns:
        True if this instance contains the digest for this item.