Class PlaceholderResolver


  • public class PlaceholderResolver
    extends java.lang.Object
    This class provides a way to allow user input to make use of place holder values which will be substituted at run time with appropriate values.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String cleanPathString​(java.lang.String input)
      Helper method to strip common illegal path characters from a string
      void clear()
      Clears all currently associated place holders (keys and values)
      java.lang.String get​(java.lang.String key)
      Get the value currently associated for a given placeholder
      java.util.Map<java.lang.String,​java.lang.String> getPlaceholderData()
      Gets the Map containing all the current place holder data
      java.lang.String resolveTemplate​(java.lang.String template)
      Resolves place holders into a string based on the currently associated values
      java.util.Set<java.lang.String> resolveTemplateMultiValues​(java.lang.String template, java.util.List<NamedStringList> multiValuePlaceholders)
      Resolves place holders into a string based on the currently associated values and the multi-value place holders provided.
      java.lang.String resolveTemplatePath​(java.lang.String template)
      Resolves place holders into a path string based on the currently associated values.
      java.util.Set<java.lang.String> resolveTemplatePathMultiValues​(java.lang.String template, java.util.List<NamedStringList> multiValuePlaceholders)
      Resolves place holders into a string based on the currently associated values and the multi-value place holders provided.
      void set​(java.lang.String key, java.lang.String value)
      Set they value for a given placeholder
      void setFromItem​(nuix.Item item)
      Automatically sets various place holders based on the provided item.
      void setPath​(java.lang.String key, java.lang.String value)
      Similar to the set(java.lang.String, java.lang.String) method except this has logic to appropriately handle file paths.
      • Methods inherited from class java.lang.Object

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

      • PlaceholderResolver

        public PlaceholderResolver()
    • Method Detail

      • setFromItem

        public void setFromItem​(nuix.Item item)
        Automatically sets various place holders based on the provided item. Place holders set:

        {guid} - The item's GUID.
        {guid_prefix} Characters 0-2 of the item's GUID. Useful for creating sub-directories based on GUID.
        {guid_infix} Characters 3-5 of the item's GUID. Useful for creating sub-directories based on GUID.
        {name} - The item's name as obtained by Item.getLocalisedName
        {md5} - The item's MD5 or NO_MD5 for items without an MD5 value
        {type} - The item's type name as obtained by ItemType.getLocalisedName
        {mime_type} - The item's mime type as obtained by ItemType.getName
        {kind} - The item's kind name as obtained by ItemType.getKind.getName
        {custodian} - The item's assigned custodian or NO_CUSTODIAN for items without a custodian assigned
        {evidence_name} - The name of the evidence the item belongs to.
        {item_date_short} - The item's item date formatted YYYYMMDD or NO_DATE for items without an item date.
        {item_date_long} - The item's item date formatted YYYYMMdd-HHmmss or NO_DATE for items without an item date.
        {item_date_year} - The item's item date 4 digit year or NO_DATE for items without an item date.
        {item_date_month} - The item's item date 2 digit month or NO_DATE for items without an item date.
        {item_date_day} - The item's item date 2 digit day of the month or NO_DATE for items without an item date.
        {top_level_guid} - The GUID of the provided item's top level item or ABOVE_TOP_LEVEL for items which are above top level.
        {top_level_name} - The name (via Item.getLocalisedName) of the provided item's top level item or ABOVE_TOP_LEVEL for items which are above top level.
        {top_level_kind} - The kind (via ItemType.getKind.getName) of the provided item's top level item or ABOVE_TOP_LEVEL for items which are above top level.
        {original_extension} - The original extension as obtained from Nuix via Item.getOriginalExtension or NO_ORIGINAL_EXTENSION for items where Nuix does not have an original extension value.
        {corrected_extension} - The corrected extension as obtained from Nuix via Item.getCorrectedExtension or NO_CORRECTED_EXTENSION for items where Nuix does not have a corrected extension value.
        Parameters:
        item - The item used to set all of the item based placeholder values.
      • set

        public void set​(java.lang.String key,
                        java.lang.String value)
        Set they value for a given placeholder
        Parameters:
        key - The placeholder name without '{' or '}'
        value - The value to associate
      • setPath

        public void setPath​(java.lang.String key,
                            java.lang.String value)
        Similar to the set(java.lang.String, java.lang.String) method except this has logic to appropriately handle file paths.
        Parameters:
        key - The placeholder name without '{' or '}'
        value - The file/directory path value to associate
      • get

        public java.lang.String get​(java.lang.String key)
        Get the value currently associated for a given placeholder
        Parameters:
        key - The placeholder name without '{' or '}'
        Returns:
        The currently associated placeholder value
      • clear

        public void clear()
        Clears all currently associated place holders (keys and values)
      • getPlaceholderData

        public java.util.Map<java.lang.String,​java.lang.String> getPlaceholderData()
        Gets the Map containing all the current place holder data
        Returns:
        A Map containing all the current place holder data
      • resolveTemplate

        public java.lang.String resolveTemplate​(java.lang.String template)
        Resolves place holders into a string based on the currently associated values
        Parameters:
        template - The input string containing place holders
        Returns:
        The input string in which place holders have been replaced with associated values
      • resolveTemplateMultiValues

        public java.util.Set<java.lang.String> resolveTemplateMultiValues​(java.lang.String template,
                                                                          java.util.List<NamedStringList> multiValuePlaceholders)
        Resolves place holders into a string based on the currently associated values and the multi-value place holders provided. For example imagine you wish to render the template 1 time for each tag associated to an item that has 3 tags assigned. You can call this method, providing a NamedStringList with a name of tags and those 3 tags as values. This method will then return 3 resolutions of a template containing the placeholder {tags}. Each returned result containing 1 of the 3 tags substituted. This method allows you to provide multiple multi-value place holders like this, but it is important to note the number of resulting values is multiplied. So if I provide a placeholder animals with 3 values, a placeholder colors with 5 values and a placeholder names with 4 values, the number of possible resulting values is 3*5*4=60.
        Parameters:
        template - The template to resolve
        multiValuePlaceholders - Place holders to resolve multiple times with multiple values.
        Returns:
        The various resulting values generated from all the combinations.
      • resolveTemplatePath

        public java.lang.String resolveTemplatePath​(java.lang.String template)
        Resolves place holders into a path string based on the currently associated values. Contains logic to sterilize the resulting path string so that it does not contain common illegal path characters.
        Parameters:
        template - A file/directory path string containing place holders
        Returns:
        The input string in which place holders have been replaced with associated values
      • resolveTemplatePathMultiValues

        public java.util.Set<java.lang.String> resolveTemplatePathMultiValues​(java.lang.String template,
                                                                              java.util.List<NamedStringList> multiValuePlaceholders)
        Resolves place holders into a string based on the currently associated values and the multi-value place holders provided. For example imagine you wish to render the template 1 time for each tag associated to an item that has 3 tags assigned. You can call this method, providing a NamedStringList with a name of tags and those 3 tags as values. This method will then return 3 resolutions of a template containing the placeholder {tags}. Each returned result containing 1 of the 3 tags substituted. This method allows you to provide multiple multi-value place holders like this, but it is important to note the number of resulting values is multiplied. So if I provide a placeholder animals with 3 values, a placeholder colors with 5 values and a placeholder names with 4 values, the number of possible resulting values is 3*5*4=60. This method is similar to {resolveTemplateMultiValues(String, List) except the template is resolved using {resolveTemplatePath(String) instead of the method {resolveTemplate(String) which is used by {resolveTemplateMultiValues(String, List).
        Parameters:
        template - The template to resolve
        multiValuePlaceholders - Place holders to resolve multiple times with multiple values.
        Returns:
        The various resulting values generated from all the combinations.
      • cleanPathString

        public static java.lang.String cleanPathString​(java.lang.String input)
        Helper method to strip common illegal path characters from a string
        Parameters:
        input - The string to clean up
        Returns:
        The string with illegal path characters replaced with '_'