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
      void addCommonFieldsOfRelatedItem​(nuix.Item relatedItem, java.lang.String prefix, java.lang.String valueIfItemNull)  
      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 placeholders (keys and values)
      java.lang.String get​(java.lang.String key)
      Get the value currently associated for a given placeholder
      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 placeholders 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 placeholders 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 setFromCase​(nuix.Case nuixCase)
      Convenience method for setting various values of a Nuix case:

      {case_name} - The name assigned to the case, as obtained by calling Case.getName
      {case_guid} - The GUID assigned to the case, as obtained by calling Case.getGuid
      {investigator} - The investigator associated to the case, as obtained by calling Case.getInvestigator
      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.
      void setStandardValues​(org.joda.time.DateTime now)
      Convenience method for setting various standard values:

      {date_short} - The datetime of invocation, formatted YYYYMMDD
      {date_long} - The datetime of invocation, formatted YYYYMMdd-HHmmss
      {date_year} - The datetime of invocation, as 4 digit year
      {date_month} - The datetime of invocation, as 2 digit month
      {date_day} - The datetime of invocation, as 2 digit day of the month
      {nuix_version} - The Nuix version as defined in NUIX_VERSION
      • 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 associated top level item
        {top_level_name} - The name (via Item.getLocalisedName) of the associated top level item
        {top_level_kind} - The kind (via ItemType.getKind.getName) of the associated top level item
        {top_level_type} - The localised (human friendly) name of the mime type attributed to the associated top level item.
        {top_level_mimetype} - The mime type of the associated top level item.
        {top_level_short_date} - The short format (YYYYMMDD) item date of the associated top level item.
        {top_level_long_date} - The long format (YYYYMMDD-HHMMSS) item date of the associated top level item.
        {top_level_year} - The item date year (YYYY) of the associated top level item.
        {top_level_month} - The item date month (MM) of the associated top level item.
        {top_level_day} - The item date day (DD) of the associated top level item.
        {parent_guid} - The GUID of the associated parent item
        {parent_name} - The name (via Item.getLocalisedName) of the associated parent item
        {parent_kind} - The kind (via ItemType.getKind.getName) of the associated parent item
        {parent_type} - The localised (human friendly) name of the mime type attributed to the associated parent item.
        {parent_mimetype} - The mime type of the associated parent item.
        {parent_short_date} - The short format (YYYYMMDD) item date of the associated parent item.
        {parent_long_date} - The long format (YYYYMMDD-HHMMSS) item date of the associated parent item.
        {parent_year} - The item date year (YYYY) of the associated parent item.
        {parent_month} - The item date month (MM) of the associated parent item.
        {parent_day} - The item date day (DD) of the associated parent item.
        {container_guid} - The GUID of the associated nearest ancestor container item
        {container_name} - The name (via Item.getLocalisedName) of the associated nearest ancestor container item
        {container_kind} - The kind (via ItemType.getKind.getName) of the associated nearest ancestor container item
        {container_type} - The localised (human friendly) name of the mime type attributed to the associated nearest ancestor container item.
        {container_mimetype} - The mime type of the associated nearest ancestor container item.
        {container_short_date} - The short format (YYYYMMDD) item date of the associated nearest ancestor container item.
        {container_long_date} - The long format (YYYYMMDD-HHMMSS) item date of the associated nearest ancestor container item.
        {container_year} - The item date year (YYYY) of the associated nearest ancestor container item.
        {container_month} - The item date month (MM) of the associated nearest ancestor container item.
        {container_day} - The item date day (DD) of the associated nearest ancestor container item.
        {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 the item based placeholder values.
      • addCommonFieldsOfRelatedItem

        public void addCommonFieldsOfRelatedItem​(nuix.Item relatedItem,
                                                 java.lang.String prefix,
                                                 java.lang.String valueIfItemNull)
      • setStandardValues

        public void setStandardValues​(org.joda.time.DateTime now)
        Convenience method for setting various standard values:

        {date_short} - The datetime of invocation, formatted YYYYMMDD
        {date_long} - The datetime of invocation, formatted YYYYMMdd-HHmmss
        {date_year} - The datetime of invocation, as 4 digit year
        {date_month} - The datetime of invocation, as 2 digit month
        {date_day} - The datetime of invocation, as 2 digit day of the month
        {nuix_version} - The Nuix version as defined in NUIX_VERSION
        Parameters:
        now - DateTime instance to use for all placeholders, likely you would want to provide a moment in time such as when an export started.
      • setFromCase

        public void setFromCase​(nuix.Case nuixCase)
        Convenience method for setting various values of a Nuix case:

        {case_name} - The name assigned to the case, as obtained by calling Case.getName
        {case_guid} - The GUID assigned to the case, as obtained by calling Case.getGuid
        {investigator} - The investigator associated to the case, as obtained by calling Case.getInvestigator
        Parameters:
        nuixCase - The case to assign values from
      • 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 placeholders (keys and values)
      • 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 placeholders 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 placeholders
        Returns:
        The input string in which placeholders 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 placeholders 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 placeholders 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 - placeholders 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 '_'