net.sf.okapi.lib.xliff2.document

## Class XLIFFDocument

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

-     public class XLIFFDocument
      extends java.lang.Object

  Represents a complete parsed XLIFF document in memory.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `XLIFFDocument()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.util.Iterator<Event>` | `createEventIterator()` Creates an iterator for the events of this document.
    `java.lang.Object` | `fetchReference(URIParser up)` Retrieves the object corresponding to a given URI fragment.
    `java.io.File` | `getFile()` Gets the File object associated with this document.
    `FileNode` | `getFileNode(java.lang.String id)` Gets the `FileNode` from a given file id.
    `java.util.List<java.lang.String>` | `getFileNodeIds()` Gets the IDs of all `FileNode` in this XLIFF document.
    `GroupNode` | `getGroupNode(java.lang.String fileId, java.lang.String groupId)` Gets the `GroupNode` from a given file id and a given group id.
    `StartXliffData` | `getStartXliffData()` Gets the document-level data for this document.
    `UnitNode` | `getUnitNode(java.lang.String fileId, java.lang.String unitId)` Gets the `UnitNode` from a given file id and a given unit id.
    `java.util.List<Unit>` | `getUnits()` Gets a list of all the units in this document.
    `void` | `load(java.io.File file)` Loads a document from a given file, with maximum validation.
    `void` | `load(java.io.File file, int validation)` Loads a document from a given File.
    `void` | `load(java.lang.String input, int validation)` Loads a document from a string.
    `void` | `load(java.net.URI inputURI, int validation)` Loads a document from a given URI.
    `void` | `save()` Saves this document to the current file.
    `void` | `save(java.io.Writer outputWriter)` Saves this document to a writer.
    `void` | `saveAs(java.io.File outputFile)` Saves this document to a specified file.
    `void` | `setLineBreak(java.lang.String lineBreak)` Sets the line break to use when writing out this document.

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

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

- - ### Constructor Detail

    - #### XLIFFDocument

          public XLIFFDocument()

  - ### Method Detail

    - #### load

          public void load(java.io.File file)

      Loads a document from a given file, with maximum validation.
      Parameters:
        `file` - the file to load.

    - #### load

          public void load(java.io.File file,
                  int validation)

      Loads a document from a given File.
      Parameters:
        `file` - the file to load.
        `validation` - one of the VALIDATION_* constants or a ORed combination.

    - #### load

          public void load(java.net.URI inputURI,
                  int validation)

      Loads a document from a given URI.
      Parameters:
        `inputURI` - the URI to load from.
        `validation` - one of the VALIDATION_* constants or a ORed combination.

    - #### load

          public void load(java.lang.String input,
                  int validation)

      Loads a document from a string.
      Parameters:
        `input` - the content of the document to load.
        `validation` - one of the VALIDATION_* constants or a ORed combination.

    - #### saveAs

          public void saveAs(java.io.File outputFile)

      Saves this document to a specified file. If needed directories are created.
      Parameters:
        `outputFile` - the output file.
      See Also:
        `save()`

    - #### save

          public void save()

      Saves this document to the current file. The current file is not null when you have called `load(File)`, `load(File, int)` or `saveAs(File)` before.
      See Also:
        `saveAs(File)`

    - #### save

          public void save(java.io.Writer outputWriter)

      Saves this document to a writer. The writer must use an encoding that supports all Unicode characters without escaping (e.g. UTF-8)
      Parameters:
        `outputWriter` - the output writer.

    - #### getStartXliffData

          public StartXliffData getStartXliffData()

      Gets the document-level data for this document.
      Returns:
        the document-level data of this document.

    - #### getFileNode

          public FileNode getFileNode(java.lang.String id)

      Gets the `FileNode` from a given file id.
      Parameters:
        `id` - the id of the file to lookup.
      Returns:
        the `FileNode` object or null if not found.

    - #### getFileNodeIds

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

      Gets the IDs of all `FileNode` in this XLIFF document. The order of IDs is the insertion order of files.
      Returns:
        the list of IDs.

    - #### getGroupNode

          public GroupNode getGroupNode(java.lang.String fileId,
                               java.lang.String groupId)

      Gets the `GroupNode` from a given file id and a given group id.
      Parameters:
        `fileId` - the id of the file where the group is.
        `groupId` - the id of the group to lookup.
      Returns:
        the `GroupNode` or null if not found.

    - #### getUnitNode

          public UnitNode getUnitNode(java.lang.String fileId,
                             java.lang.String unitId)

      Gets the `UnitNode` from a given file id and a given unit id.
      Parameters:
        `fileId` - the id of the file where the unit is.
        `unitId` - the id of the unit to lookup.
      Returns:
        the `UnitNode` or null if not found.

    - #### createEventIterator

          public java.util.Iterator<Event> createEventIterator()

      Creates an iterator for the events of this document.
      Returns:
        a new iterator for the events of this document.

    - #### fetchReference

          public java.lang.Object fetchReference(URIParser up)

      Retrieves the object corresponding to a given URI fragment.
      Parameters:
        `up` - the `URIParser` representing the fragment to resolve.
      Returns:
        the object found, or null if the object was not found or is external to this document.

    - #### getUnits

          public java.util.List<Unit> getUnits()

      Gets a list of all the units in this document.
      Returns:
        the list of all units in this document.

    - #### getFile

          public java.io.File getFile()

      Gets the File object associated with this document. It can be null if the document we not read from a File. This object is automatically set when you call `load(File)`, `load(File, int)` and `saveAs(File)`.
      Returns:
        the File object for this document (or null if none is associated.

    - #### setLineBreak

          public void setLineBreak(java.lang.String lineBreak)

      Sets the line break to use when writing out this document. By default the line-break used is the one of the OS.
      Parameters:
        `lineBreak` - the line break to use for this document.