net.sf.okapi.lib.xliff2.walker

## Class XliffWalker

- java.lang.Object
- - net.sf.okapi.lib.xliff2.walker.XliffWalker

-     public class XliffWalker
      extends java.lang.Object

  Allows for traversal of the tree structure of an XLIFF document, in a fashion similar to visitor pattern. Three types of visitor can be added to the XliffWalker: File visitors, Unit visitors, and Segment visitors. The exact order in which the visit() method of those visitors is called is determined by the `IXliffWalkerStrategy`, for which a default implementation, flexible implementation and ordered pipeline implementations are provided.
  Author:
    Martin Wunderlich, Vladyslav Mykhalets

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `XliffWalker.VisitPlaceAwareXliffVisitor<T>` Xliff visitor `IXliffVisitor` decorator class aware of visit place defined by path selector `XliffWalkerPathSelector`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XliffWalker()`
    `XliffWalker(IXliffWalkerStrategy strategy)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `addFileVisitor(IXliffVisitor<FileNode> visitor, XliffWalkerPathSelector... pathSelectors)`
    `java.lang.String` | `addFileVisitor(XliffWalker.VisitPlaceAwareXliffVisitor<FileNode> visitor)`
    `java.lang.String` | `addSegmentVisitor(IXliffVisitor<Segment> visitor, XliffWalkerPathSelector... pathSelectors)`
    `java.lang.String` | `addSegmentVisitor(XliffWalker.VisitPlaceAwareXliffVisitor<Segment> visitor)`
    `java.lang.String` | `addUnitVisitor(IXliffVisitor<UnitNode> visitor, XliffWalkerPathSelector... pathSelectors)`
    `java.lang.String` | `addUnitVisitor(XliffWalker.VisitPlaceAwareXliffVisitor<UnitNode> visitor)`
    `void` | `doWalk(XLIFFDocument xlf)` Main method for running the traversal.
    `java.util.List<IXliffVisitor<FileNode>>` | `getAllFileNodeVisitors()`
    `java.util.List<IXliffVisitor<Segment>>` | `getAllSegmentVisitors()`
    `java.util.List<IXliffVisitor<UnitNode>>` | `getAllUnitNodeVisitors()`
    `java.util.List<IXliffVisitor<FileNode>>` | `getFileNodeVisitors(java.lang.String fileId)` Method returns visitors which are configured to be executed on specific file id.
    `XliffWalker.VisitPlaceAwareXliffVisitor<FileNode>` | `getFileVisitor(java.lang.String id)` Method returns `XliffWalker.VisitPlaceAwareXliffVisitor` for `FileNode` by its id.
    `XliffWalker.VisitPlaceAwareXliffVisitor<Segment>` | `getSegmentVisitor(java.lang.String id)` Method returns `XliffWalker.VisitPlaceAwareXliffVisitor` for `Segment` by its id.
    `java.util.List<IXliffVisitor<Segment>>` | `getSegmentVisitors(java.lang.String fileId, java.lang.String unitId, int segmentIndex)` Method returns visitors which are configured to be executed on specific file id, unit id and segment index.
    `java.util.List<IXliffVisitor<UnitNode>>` | `getUnitNodeVisitors(java.lang.String fileId, java.lang.String unitId)` Method returns visitors which are configured to be executed on specific file id and unit id.
    `XliffWalker.VisitPlaceAwareXliffVisitor<UnitNode>` | `getUnitVisitor(java.lang.String id)` Method returns `XliffWalker.VisitPlaceAwareXliffVisitor` for `UnitNode` by its id.
    `int` | `getVisitorCount()`
    `void` | `removeFileVisitor(java.lang.String id)`
    `void` | `removeSegmentVisitor(java.lang.String id)`
    `void` | `removeUnitVisitor(java.lang.String id)`
    `void` | `removeVisitors()`
    `void` | `setVisitors(java.util.List<IXliffVisitor<FileNode>> fileVisitors, java.util.List<IXliffVisitor<UnitNode>> unitVisitors, java.util.List<IXliffVisitor<Segment>> segmentVisitors)`
    `java.util.Iterator<java.lang.String>` | `visitorsIterator()`

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

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

- - ### Constructor Detail

    - #### XliffWalker

          public XliffWalker()

    - #### XliffWalker

          public XliffWalker(IXliffWalkerStrategy strategy)

  - ### Method Detail

    - #### doWalk

          public void doWalk(XLIFFDocument xlf)

      Main method for running the traversal. Should only be called after some visitors have been added to the Walker. Otherwise, an exception will be thrown.

    - #### visitorsIterator

          public java.util.Iterator<java.lang.String> visitorsIterator()

    - #### setVisitors

          public void setVisitors(java.util.List<IXliffVisitor<FileNode>> fileVisitors,
                         java.util.List<IXliffVisitor<UnitNode>> unitVisitors,
                         java.util.List<IXliffVisitor<Segment>> segmentVisitors)

    - #### removeFileVisitor

          public void removeFileVisitor(java.lang.String id)

    - #### removeUnitVisitor

          public void removeUnitVisitor(java.lang.String id)

    - #### removeSegmentVisitor

          public void removeSegmentVisitor(java.lang.String id)

    - #### getVisitorCount

          public int getVisitorCount()

    - #### getFileVisitor

          public XliffWalker.VisitPlaceAwareXliffVisitor<FileNode> getFileVisitor(java.lang.String id)

      Method returns `XliffWalker.VisitPlaceAwareXliffVisitor` for `FileNode` by its id.
      Parameters:
        `id` - id of the visitor
      Returns:
        instance of `XliffWalker.VisitPlaceAwareXliffVisitor` for `FileNode`

    - #### getUnitVisitor

          public XliffWalker.VisitPlaceAwareXliffVisitor<UnitNode> getUnitVisitor(java.lang.String id)

      Method returns `XliffWalker.VisitPlaceAwareXliffVisitor` for `UnitNode` by its id.
      Parameters:
        `id` - id of the visitor
      Returns:
        instance of `XliffWalker.VisitPlaceAwareXliffVisitor` for `UnitNode`

    - #### getSegmentVisitor

          public XliffWalker.VisitPlaceAwareXliffVisitor<Segment> getSegmentVisitor(java.lang.String id)

      Method returns `XliffWalker.VisitPlaceAwareXliffVisitor` for `Segment` by its id.
      Parameters:
        `id` - id of the visitor
      Returns:
        instance of `XliffWalker.VisitPlaceAwareXliffVisitor` for `Segment`

    - #### getFileNodeVisitors

          public java.util.List<IXliffVisitor<FileNode>> getFileNodeVisitors(java.lang.String fileId)

      Method returns visitors which are configured to be executed on specific file id.
      Parameters:
        `fileId` - file node id
      Returns:
        list of `IXliffVisitor` for `FileNode`

    - #### getUnitNodeVisitors

          public java.util.List<IXliffVisitor<UnitNode>> getUnitNodeVisitors(java.lang.String fileId,
                                                                    java.lang.String unitId)

      Method returns visitors which are configured to be executed on specific file id and unit id.
      Parameters:
        `fileId` - file node id
        `unitId` - unit node id
      Returns:
        list of `IXliffVisitor` for `UnitNode`

    - #### getSegmentVisitors

          public java.util.List<IXliffVisitor<Segment>> getSegmentVisitors(java.lang.String fileId,
                                                                  java.lang.String unitId,
                                                                  int segmentIndex)

      Method returns visitors which are configured to be executed on specific file id, unit id and segment index.
      Parameters:
        `fileId` - file node id
        `unitId` - unit node id
        `segmentIndex` - segment index
      Returns:
        list of `IXliffVisitor` for `Segment`

    - #### getAllFileNodeVisitors

          public java.util.List<IXliffVisitor<FileNode>> getAllFileNodeVisitors()

    - #### getAllUnitNodeVisitors

          public java.util.List<IXliffVisitor<UnitNode>> getAllUnitNodeVisitors()

    - #### getAllSegmentVisitors

          public java.util.List<IXliffVisitor<Segment>> getAllSegmentVisitors()

    - #### addFileVisitor

          public java.lang.String addFileVisitor(XliffWalker.VisitPlaceAwareXliffVisitor<FileNode> visitor)

    - #### addFileVisitor

          public java.lang.String addFileVisitor(IXliffVisitor<FileNode> visitor,
                                        XliffWalkerPathSelector... pathSelectors)

    - #### addUnitVisitor

          public java.lang.String addUnitVisitor(XliffWalker.VisitPlaceAwareXliffVisitor<UnitNode> visitor)

    - #### addUnitVisitor

          public java.lang.String addUnitVisitor(IXliffVisitor<UnitNode> visitor,
                                        XliffWalkerPathSelector... pathSelectors)

    - #### addSegmentVisitor

          public java.lang.String addSegmentVisitor(XliffWalker.VisitPlaceAwareXliffVisitor<Segment> visitor)

    - #### addSegmentVisitor

          public java.lang.String addSegmentVisitor(IXliffVisitor<Segment> visitor,
                                           XliffWalkerPathSelector... pathSelectors)

    - #### removeVisitors

          public void removeVisitors()