Class JsonExporter


  • public class JsonExporter
    extends java.lang.Object
    • Field Detail

      • itemTypeMapCache

        protected static java.util.Map<nuix.ItemType,​java.util.Map<java.lang.String,​java.lang.String>> itemTypeMapCache
      • encounteredPropertyNameCounts

        protected static java.util.Map<java.lang.String,​java.lang.Integer> encounteredPropertyNameCounts
      • booleanCategory

        protected static java.lang.String booleanCategory
      • integerCategory

        protected static java.lang.String integerCategory
      • longCategory

        protected static java.lang.String longCategory
      • floatCategory

        protected static java.lang.String floatCategory
      • stringCategory

        protected static java.lang.String stringCategory
      • dateTimeCategory

        protected static java.lang.String dateTimeCategory
      • durationCategory

        protected static java.lang.String durationCategory
      • binaryCategory

        protected static java.lang.String binaryCategory
      • otherCategory

        protected static java.lang.String otherCategory
    • Constructor Detail

      • JsonExporter

        public JsonExporter()
    • Method Detail

      • beforeSerialization

        public void beforeSerialization​(java.util.function.Consumer<java.util.Map<java.lang.String,​java.lang.Object>> callback)
        Allows you to provide a callback which can inspect or modify the nested series of Maps before they are serialized by GSON to JSON by exportItemAsJson(Item, File) or convertItemToJsonString(Item).
        Parameters:
        callback - A callback which may inspect or modify the nested Map form of an item before it is serialized to JSON
      • getIncludeText

        public boolean getIncludeText()
        Gets whether item content text will be included in generated JSON
        Returns:
        True if content text will be included
      • setIncludeText

        public void setIncludeText​(boolean includeText)
        Sets whether item content text will be included in generated JSON
        Parameters:
        includeText - True if content text should be included
      • getIncludeProperties

        public boolean getIncludeProperties()
        Gets whether item metadata properties will be included in generated JSON
        Returns:
        True if item metadata properties will be included in generated JSON
      • setIncludeProperties

        public void setIncludeProperties​(boolean includeProperties)
        Sets whether item metadata properties will be included in generated JSON
        Parameters:
        includeProperties - True if item metadata properties should be included in generated JSON
      • getIncludeCustomMetadata

        public boolean getIncludeCustomMetadata()
        Gets whether item custom metadata will be included in generated JSON
        Returns:
        True if item custom metadata will be included in generated JSON
      • setIncludeCustomMetadata

        public void setIncludeCustomMetadata​(boolean includeCustomMetadata)
        Sets whether item custom metadata will be included in generated JSON
        Parameters:
        includeCustomMetadata - True if item custom metadata should be included in JSON
      • getIncludeTags

        public boolean getIncludeTags()
        Gets whether items' tags will be included in generated JSON
        Returns:
        True if items' tags will be included in generated JSON
      • setIncludeTags

        public void setIncludeTags​(boolean includeTags)
        Sets whether items' tags will be included in generated JSON
        Parameters:
        includeTags - True if items' tags should be included in generated JSON
      • getSerializeNulls

        public boolean getSerializeNulls()
        Gets whether entries with a null value are included in the generated JSON
        Returns:
        True if entries with a null value will be included in generated JSON
      • setSerializeNulls

        public void setSerializeNulls​(boolean serializeNulls)
        Sets whether entries with null value are included in the generated JSON
        Parameters:
        serializeNulls - True if entries with null value should be included in generated JSON
      • getPrettyPrint

        public boolean getPrettyPrint()
        Gets whether JSON will be "pretty printed". Makes file more human readable, but can also make the file larger with all the extra white space characters for formatting.
        Returns:
        True if JSON will be "pretty printed"
      • setPrettyPrint

        public void setPrettyPrint​(boolean prettyPrint)
        Sets whether JSON will be "pretty printed". Makes file more human readable, but can also make the file larger with all the extra white space characters for formatting.
        Parameters:
        prettyPrint - True if the output should be "pretty printed"
      • mapWorkerItem

        public java.util.Map<java.lang.String,​java.lang.Object> mapWorkerItem​(nuix.WorkerItem workerItem)
        This method take a provided WorkerItem and generates a series of nested Map instances representing the WorkerItem and its data. The resulting Map is later used as input to GSON for serializing to JSON. Internally this gets the SourceItem for the given WorkerItem and provides that to mapSourceItem(SourceItem) to build most of the Map. After that it adds a few additional entries based on what is available from the WorkerItem.
        Parameters:
        workerItem - WorkerItem to serialize into a map
        Returns:
        Map representing the WorkerItem and its SourceItem
      • mapSourceItem

        public java.util.Map<java.lang.String,​java.lang.Object> mapSourceItem​(nuix.SourceItem sourceItem)
        This method takes a provided SourceItem and generates a series of nested Map instances representing the SourceItem and its data. The resulting Map is later used as input to GSON for serializing to JSON. In turn the following methods are called by this one: mapItemType(ItemType), mapProperties(Map), mapCommunication(Communication)
        Parameters:
        sourceItem - Source item to serialize into a Map
        Returns:
        Map representation of the source item
      • mapItem

        public java.util.Map<java.lang.String,​java.lang.Object> mapItem​(nuix.Item item)
        Converts a Nuix item into a series of nested Map objects, which later can be easily serialized into JSON.
        Parameters:
        item - The item to serialize into a Map
        Returns:
        Map representation of the item
      • exportItemAsJson

        public void exportItemAsJson​(nuix.Item item,
                                     java.io.File exportFilePath)
        Exports an item as a JSON representation. Items information is first converted into a series of Map objects by calling mapItem(Item), the result of which is then converted into JSON.
        Parameters:
        item - The item to serialize into JSON
        exportFilePath - File path to write the JSON result to.
      • exportSourceItemAsJson

        public void exportSourceItemAsJson​(nuix.SourceItem sourceItem,
                                           java.io.File exportFilePath)
        Exports an source item as a JSON representation. The SourceItem's information is first converted into a series of Map objects by calling mapSourceItem(SourceItem), the result of which is then converted into JSON.
        Parameters:
        sourceItem - The SourceItem to serialize into JSON
        exportFilePath - File path to write the JSON result to.
      • exportWorkerItemAsJson

        public void exportWorkerItemAsJson​(nuix.WorkerItem workerItem,
                                           java.io.File exportFilePath)
        Exports a worker item as a JSON representation. The WorkerItem's information is first converted into a series of Map objects by calling mapWorkerItem(WorkerItem), the result of which is then converted into JSON.
        Parameters:
        workerItem - The WorkerItem to serialize into JSON
        exportFilePath - File path to write the JSON result to.
      • convertItemToJsonString

        public java.lang.String convertItemToJsonString​(nuix.Item item)
        Converts an item to a JSON String representation. The Item's information is first converted into a series of Map objects by calling mapItem(Item), result of which is then serialized into a JSON String and returned.
        Parameters:
        item - The item to serialize into JSON
        Returns:
        A JSON String representation of the given item.
      • convertSourceItemToJsonString

        public java.lang.String convertSourceItemToJsonString​(nuix.SourceItem sourceItem)
        Converts a SourceItem to a JSON String representation. The SourceItem's information is first converted into a series of Map objects by calling mapSourceItem(SourceItem), result of which is then serialized into a JSON String and returned.
        Parameters:
        sourceItem - The SourceItem to serialize into JSON
        Returns:
        A JSON String representation of the given SourceItem.
      • convertWorkerItemToJsonString

        public java.lang.String convertWorkerItemToJsonString​(nuix.WorkerItem workerItem)
        Converts a WorkerItem to a JSON String representation. The WorkerItem's information is first converted into a series of Map objects by calling mapWorkerItem(WorkerItem), result of which is then serialized into a JSON String and returned.
        Parameters:
        workerItem - The WorkerItem to serialize into JSON
        Returns:
        A JSON String representation of the given WorkerItem.
      • mapProperties

        public static java.util.Map<java.lang.String,​java.lang.Object> mapProperties​(java.util.Map<java.lang.String,​java.lang.Object> properties)
        This method generates a Map of the properties for an item, organizing properties into sub-categories based on the data type of their values.
        Parameters:
        properties - A Nuix item properties map to convert
        Returns:
        A nested series of Map instances with properties categorized by value data type
      • mapItemType

        public static java.util.Map<java.lang.String,​java.lang.String> mapItemType​(nuix.ItemType itemType)
        Converts a Nuix ItemType object to a HashMap<String,String> for JSON serialization. This method first checks a local cache to see if the value has already been converted and returns that if so.
        Parameters:
        itemType - The Nuix ItemType object to Map-ify
        Returns:
        The resulting Map
      • mapCommunication

        public static java.util.Map<java.lang.String,​java.lang.Object> mapCommunication​(nuix.Communication comm)
        Converts a Nuix Communication object to a HashMap<String,Object> for JSON serialization. This method in turn calls mapAddresses(List).
        Parameters:
        comm - The Nuix Communication object to Map-ify
        Returns:
        The resulting Map
      • mapAddress

        public static java.util.Map<java.lang.String,​java.lang.Object> mapAddress​(nuix.Address address)
        Converts a Nuix Address object to a HashMap<String,Object> for JSON serialization.
        Parameters:
        address - The Nuix Address object to Map-ify
        Returns:
        The resulting Map
      • mapAddresses

        public static java.util.List<java.util.Map<java.lang.String,​java.lang.Object>> mapAddresses​(java.util.List<nuix.Address> addresses)
        Converts a List of Nuix Address objects to a list of HashMap<String,Object> for JSON serialization. This method calls mapAddress(Address) for each Address object provided.
        Parameters:
        addresses - The list of Nuix Address objects to Mapify
        Returns:
        The resulting Map