Package com.netrics.likeit

## Class NetricsCompoundRecord

- java.lang.Object
- - com.netrics.likeit.NetricsBaseRecord
  - - com.netrics.likeit.NetricsCompoundRecord

- All Implemented Interfaces:
    `java.io.Serializable`

      public class NetricsCompoundRecord
      extends NetricsBaseRecord

  A parent record with zero or more child records.

  A compound record is a joined set of records. It has a parent record, plus zero or more child records from zero or more child tables. Each record is associated with a table. This extends NetricsBaseRecord.

  As the child records in a compound record may themselves be compound records with child records of their own, this class supports an hierarchical structure of arbitrary depth. However ibi Patterns supports only a single depth. Hierarchies with a depth greater than two are never returned from ibi™ Patterns - Search.

  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `NetricsCompoundRecord​(java.lang.String table, NetricsRecord record)` | Create a NetricsCompoundRecord object from a NetricsRecord.
    `NetricsCompoundRecord​(java.lang.String table, java.lang.String key, java.lang.String[] fields)` | Create a NetricsCompoundRecord object.
    `NetricsCompoundRecord​(java.lang.String table, java.lang.String key, java.lang.String[] fields, java.lang.String[] attr_names, java.lang.String[] attr_values)` | Create a NetricsCompoundRecord object.
    `NetricsCompoundRecord​(java.lang.String table, java.lang.String key, java.lang.String parent_key, java.lang.String[] fields)` | Create a NetricsCompoundRecord object.
    `NetricsCompoundRecord​(java.lang.String table, java.lang.String key, java.lang.String parent_key, java.lang.String[] fields, java.lang.String[] attr_names, java.lang.String[] attr_values)` | Create a NetricsCompoundRecord object.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addChildren​(NetricsCompoundRecord... children)` | Add zero or more child records to this compound record.
    `void` | `addChildren​(java.lang.String child_table, NetricsRecord... children)` | Add zero or more standard child records to this compound record.
    `java.util.List<NetricsBaseRecord>` | `getChildren()` | Get a list of all children of this record.
    `java.util.List<NetricsBaseRecord>` | `getChildren​(java.lang.String child_table)` | Get a list of all child records for a particular table.
    `java.util.List<java.lang.String>` | `getChildTables()` | Get a list of all child tables.
    `java.lang.String` | `getTable()` | Get the table this record belongs to.
    `java.lang.String` | `toBaseString()` | Return just the base record string version.
    `NetricsRecord` | `toNetricsRecord()` | Return this record as new NetricsRecord object.
    `java.lang.String` | `toString()` | Return a human readable string version of this record.

    - ### Methods inherited from class com.netrics.likeit.NetricsBaseRecord

      `compare, getAttribute, getAttrNames, getAttrValues, getFields, getKey, getParentKey, numBytes`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### NetricsCompoundRecord

          public NetricsCompoundRecord​(java.lang.String table,
                                       java.lang.String key,
                                       java.lang.String[] fields)

      Create a NetricsCompoundRecord object.
      Parameters:
        `table` - the name of the table this record is associated with.
        `key` - A unique (user-specified) identifier for the record.
        `fields` - The actual content associated with the record, one String per field in the table. Use the empty string ("") for a field with no data in it. A field may be no longer than 2^16-3.

    - #### NetricsCompoundRecord

          public NetricsCompoundRecord​(java.lang.String table,
                                       java.lang.String key,
                                       java.lang.String parent_key,
                                       java.lang.String[] fields)

      Create a NetricsCompoundRecord object.
      Parameters:
        `table` - the name of the table this record is associated with.
        `key` - A unique (user-specified) identifier for the record.
        `parent_key` - Key of the record's parent. If this is null or empty a standard record is created instead of a child record.
        `fields` - The actual content associated with the record, one String per field in the table. Use the empty sting for a field with no data in it. A field may be no longer than 2^16-3.

    - #### NetricsCompoundRecord

          public NetricsCompoundRecord​(java.lang.String table,
                                       java.lang.String key,
                                       java.lang.String parent_key,
                                       java.lang.String[] fields,
                                       java.lang.String[] attr_names,
                                       java.lang.String[] attr_values)

      Create a NetricsCompoundRecord object.
      Parameters:
        `table` - the name of the table this record is associated with.
        `key` - A unique (user-specified) identifier for the record.
        `parent_key` - Key of the record's parent. If this is null or empty a standard record is created instead of a child record.
        `fields` - The actual content associated with the record, one String per field in the table. Use the empty sting for a field with no data in it. A field may be no longer than 2^16-3.
        `attr_names` - Names of attributes associated with this record.
        `attr_values` - Values of attributes associated with this record, in the same order as attr_names.

    - #### NetricsCompoundRecord

          public NetricsCompoundRecord​(java.lang.String table,
                                       java.lang.String key,
                                       java.lang.String[] fields,
                                       java.lang.String[] attr_names,
                                       java.lang.String[] attr_values)

      Create a NetricsCompoundRecord object.
      Parameters:
        `table` - the name of the table this record is associated with.
        `key` - A unique (user-specified) identifier for the record.
        `fields` - The actual content associated with the record, one String per field in the table. Use the empty sting for a field with no data in it. A field may be no longer than 2^16-3.
        `attr_names` - Names of attributes associated with this record.
        `attr_values` - Values of attributes associated with this record, in the same order as attr_names.

    - #### NetricsCompoundRecord

          public NetricsCompoundRecord​(java.lang.String table,
                                       NetricsRecord record)

      Create a NetricsCompoundRecord object from a NetricsRecord. This constructor is used to convert a standard record into a compound record.
      Parameters:
        `table` - the name of the table this record is associated with.
        `record` - the NetricsRecord object.

  - ### Method Detail

    - #### toNetricsRecord

          public NetricsRecord toNetricsRecord()

      Return this record as new NetricsRecord object. This is used to convert this back to a standard single table NetricsRecord. The record returned contains only the parent record data. All table and child record information is of course lost in such a conversion.
      Returns:
        a NetricsRecord object with the same keys and field values.

    - #### addChildren

          public void addChildren​(NetricsCompoundRecord... children)
                           throws java.lang.IllegalArgumentException

      Add zero or more child records to this compound record.

      This adds zero or more child records to this compound record. The child records must be children of this record (i.e. it's parent record key must be the key of this record.)

      A particular child record for a particular table can appear only once. If a child with this key already exists for the given table it is replaced.

      Parameters:
        `children` - the child records to be added.
      Throws:
        `java.lang.IllegalArgumentException` - if any child record is not a child of this record.

    - #### addChildren

          public void addChildren​(java.lang.String child_table,
                                  NetricsRecord... children)
                           throws java.lang.IllegalArgumentException

      Add zero or more standard child records to this compound record.

      This adds zero or more child records to this compound record. The child records are standard NetricsRecord objects. They are all associated with a specific named child table. The child records must be children of this record (i.e. it's parent record key must be the key of this record.)

      A particular child record for a particular table can appear only once. If a child with this key already exists for the given table it is replaced.

      Parameters:
        `child_table` - the child table for all child records.
        `children` - the child records to be added.
      Throws:
        `java.lang.IllegalArgumentException` - if any child record is not a child of this record.

    - #### getTable

          public java.lang.String getTable()

      Get the table this record belongs to.
      Returns:
        the name of the table this record belongs to.

    - #### getChildren

          public java.util.List<NetricsBaseRecord> getChildren()

      Get a list of all children of this record. This returns only the top level children, it does not recursively decend the record tree to return a flattened list of the entire tree.
      Returns:
        null if this record has no children, list of all child records otherwise.

    - #### getChildren

          public java.util.List<NetricsBaseRecord> getChildren​(java.lang.String child_table)

      Get a list of all child records for a particular table.
      Parameters:
        `child_table` - the name of the child table.
      Returns:
        null if no children exists for the given table, a list of all child records for the table otherwise.

    - #### getChildTables

          public java.util.List<java.lang.String> getChildTables()

      Get a list of all child tables.
      Returns:
        a list of all the different child tables the children of this record belong to. A zero length list if this record has no children.

    - #### toBaseString

          public java.lang.String toBaseString()

      Return just the base record string version. This returns the NetricsBaseRecord.toString output without any of the additional information.
      Returns:
        as described above.

    - #### toString

          public java.lang.String toString()

      Return a human readable string version of this record. This converts the current compound record into a human readable string. The format is the parent record table name, followed by a comma and the NetricsBaseRecord format string version of the parent record. The child records are then printed out, each proceeded by a new-line and a tab character. The format is recursive, so children of the child record are printed out after the child each with a new-line and an additional tab character.
      Overrides:
        `toString` in class `NetricsBaseRecord`
      Returns:
        the human readable string form as described above.