net.sf.okapi.lib.xliff2.document

## Class WithGroupOrUnitNode

- java.lang.Object
- - net.sf.okapi.lib.xliff2.document.WithGroupOrUnitNode

- All Implemented Interfaces:
    IWithGroupOrUnitNode
  Direct Known Subclasses:
    FileNode, GroupNode

      public abstract class WithGroupOrUnitNode
      extends java.lang.Object
      implements IWithGroupOrUnitNode

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `WithGroupOrUnitNode()` Creates a new `WithGroupOrUnitNode` object.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `GroupNode` | `add(GroupNode node)` Adds a `GroupNode` to this object.
    `UnitNode` | `add(UnitNode node)` Adds a `UnitNode` to this object.
    `GroupNode` | `addGroupNode(java.lang.String id)` Adds a `GroupNode` to this object.
    `UnitNode` | `addUnitNode(java.lang.String id)` Adds a `UnitNode` to this object.
    `java.util.Iterator<IGroupOrUnitNode>` | `createGroupOrUnitIterator()` Creates an iterator for the group nodes and unit nodes in this object.
    `GroupNode` | `getGroupNode(java.lang.String id)` Gets a `GroupNode` for a given id.
    `UnitNode` | `getUnitNode(java.lang.String id)` Gets the `UnitNode` for a given unit id.
    `java.util.List<UnitNode>` | `getUnitNodes()` Gets all the `UnitNode` elements of this object.

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### WithGroupOrUnitNode

          public WithGroupOrUnitNode()

      Creates a new `WithGroupOrUnitNode` object.

  - ### Method Detail

    - #### add

          public UnitNode add(UnitNode node)

      Description copied from interface: `IWithGroupOrUnitNode`
      Adds a `UnitNode` to this object.
      Specified by:
        `add` in interface `IWithGroupOrUnitNode`
      Parameters:
        `node` - the unit node to add.
      Returns:
        the added unit node.
      See Also:
        `IWithGroupOrUnitNode.addUnitNode(String)`

    - #### addUnitNode

          public UnitNode addUnitNode(java.lang.String id)

      Description copied from interface: `IWithGroupOrUnitNode`
      Adds a `UnitNode` to this object.
      Specified by:
        `addUnitNode` in interface `IWithGroupOrUnitNode`
      Parameters:
        `id` - the ID of the new unit.
      Returns:
        the added unit node.

    - #### add

          public GroupNode add(GroupNode node)

      Description copied from interface: `IWithGroupOrUnitNode`
      Adds a `GroupNode` to this object. If the group ID is null, it is automatically set to a UUID.
      Specified by:
        `add` in interface `IWithGroupOrUnitNode`
      Parameters:
        `node` - the group node to add.
      Returns:
        the added group node.
      See Also:
        `IWithGroupOrUnitNode.addGroupNode(String)`

    - #### addGroupNode

          public GroupNode addGroupNode(java.lang.String id)

      Description copied from interface: `IWithGroupOrUnitNode`
      Adds a `GroupNode` to this object.
      Specified by:
        `addGroupNode` in interface `IWithGroupOrUnitNode`
      Parameters:
        `id` - the ID of the group (can be null). If the ID is null it is automatically set to a UUID.
      Returns:
        the added group node.

    - #### getUnitNodes

          public java.util.List<UnitNode> getUnitNodes()

      Description copied from interface: `IWithGroupOrUnitNode`
      Gets all the `UnitNode` elements of this object. All units at any level in this object are returned.
      Specified by:
        `getUnitNodes` in interface `IWithGroupOrUnitNode`
      Returns:
        all the unit nodes for the object. The list will be empty (but never null), if no unit nodes were found.

    - #### getUnitNode

          public UnitNode getUnitNode(java.lang.String id)

      Description copied from interface: `IWithGroupOrUnitNode`
      Gets the `UnitNode` for a given unit id. The unit can be at any level in this object.
      Specified by:
        `getUnitNode` in interface `IWithGroupOrUnitNode`
      Parameters:
        `id` - the id to look for.
      Returns:
        the unit node for the given id, or null if none is found.

    - #### getGroupNode

          public GroupNode getGroupNode(java.lang.String id)

      Description copied from interface: `IWithGroupOrUnitNode`
      Gets a `GroupNode` for a given id. The group can be at any level in this object.
      Specified by:
        `getGroupNode` in interface `IWithGroupOrUnitNode`
      Parameters:
        `id` - the id to look for.
      Returns:
        the group node for the given id, or null if none is found.

    - #### createGroupOrUnitIterator

          public java.util.Iterator<IGroupOrUnitNode> createGroupOrUnitIterator()

      Description copied from interface: `IWithGroupOrUnitNode`
      Creates an iterator for the group nodes and unit nodes in this object.
      Specified by:
        `createGroupOrUnitIterator` in interface `IWithGroupOrUnitNode`
      Returns:
        a new iterator for the nodes in this object.