net.sf.okapi.lib.xliff2.reader

## Class XLIFFReader

- java.lang.Object
- - net.sf.okapi.lib.xliff2.reader.XLIFFReader

- All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

      public class XLIFFReader
      extends java.lang.Object
      implements java.io.Closeable

  Implements a stream-based and event-driven XLIFF reader.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `VALIDATION_INCLUDE_FRAGIDPREFIX` Includes validation of the fragment identification values.
    `static int` | `VALIDATION_INCLUDE_SCHEMAS` Includes schemas-based validation.
    `static int` | `VALIDATION_MAXIMAL` Performs as much validation as possible with the reader (which may not be a full validation for the modules, depending on the modules supported).
    `static int` | `VALIDATION_MINIMAL` Performs as little validation as possible.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XLIFFReader()` Creates a new XLIFFReader object with full validation.
    `XLIFFReader(int validation)` Creates a new XLIFFReader object.
    `XLIFFReader(int validation, URIParser uriParserToUse)` Creates a new XLIFFReader object.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Closes the document.
    `int` | `getWarningCount()` Gets the number of warnings.
    `boolean` | `hasNext()` Indicates if there is another event.
    `Event` | `next()` Gets the next filter event.
    `void` | `open(java.io.File file)` Opens an XLIFF document by its File object.
    `void` | `open(java.io.InputStream inputStream)` Opens an XLIFF document by its stream.
    `void` | `open(java.lang.String input)` Opens an XLIFF document passed as a string.
    `void` | `open(java.net.URI inputURI)` Opens an XLIFF document by its URI.
    `protected void` | `processMatches()`
    `void` | `setReportUnsingnificantParts(boolean reportUnsingnificantParts)` Sets the flag to report or not parts of the documents that are not significant.
    `static void` | `validate(java.io.File file)` Validates an XLIFF document passed as a File object.
    `static void` | `validate(java.io.File file, URIParser uriParser)` Validates an XLIFF document passed as a File object.
    `static void` | `validate(java.io.InputStream inputStream, URIParser uriParser)` Validates an XLIFF document passed as a stream.
    `static void` | `validate(java.lang.String input, URIParser uriParser)` Validates an XLIFF document passed as a string.
    `static void` | `validate(java.net.URI inputURI, URIParser uriParser)` Validates an XLIFF document passed as a URI.

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

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

- - ### Field Detail

    - #### VALIDATION_MINIMAL

          public static final int VALIDATION_MINIMAL

      Performs as little validation as possible.
      See Also:
        Constant Field Values

    - #### VALIDATION_MAXIMAL

          public static final int VALIDATION_MAXIMAL

      Performs as much validation as possible with the reader (which may not be a full validation for the modules, depending on the modules supported).
      See Also:
        Constant Field Values

    - #### VALIDATION_INCLUDE_SCHEMAS

          public static final int VALIDATION_INCLUDE_SCHEMAS

      Includes schemas-based validation.
      See Also:
        Constant Field Values

    - #### VALIDATION_INCLUDE_FRAGIDPREFIX

          public static final int VALIDATION_INCLUDE_FRAGIDPREFIX

      Includes validation of the fragment identification values.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### XLIFFReader

          public XLIFFReader()

      Creates a new XLIFFReader object with full validation.

    - #### XLIFFReader

          public XLIFFReader(int validation)

      Creates a new XLIFFReader object. You can choose the type of validation to perform.
      Parameters:
        `validation` - one of the VALIDATION_* constants or a ORed combination.

    - #### XLIFFReader

          public XLIFFReader(int validation,
                     URIParser uriParserToUse)

      Creates a new XLIFFReader object.
      Parameters:
        `validation` - one of the VALIDATION_* constants or a ORed combination.
        `uriParserToUse` - URI parser to use when processing references (e.g. value of ref in an <mrk> element). If it is set to null, a URIParser object that handles default prefixes will be used.

  - ### Method Detail

    - #### validate

          public static void validate(java.io.File file)

      Validates an XLIFF document passed as a File object.
      Parameters:
        `file` - the XLIFF document to validate.

    - #### validate

          public static void validate(java.io.File file,
                      URIParser uriParser)

      Validates an XLIFF document passed as a File object.
      Parameters:
        `file` - the XLIFF document to validate.
        `uriParser` - the URI parser to use when processing references (can be null).

    - #### validate

          public static void validate(java.net.URI inputURI,
                      URIParser uriParser)

      Validates an XLIFF document passed as a URI.
      Parameters:
        `inputURI` - the URI to process.
        `uriParser` - the URI parser to use when processing references (can be null).

    - #### validate

          public static void validate(java.lang.String input,
                      URIParser uriParser)

      Validates an XLIFF document passed as a string.
      Parameters:
        `input` - the content to process.
        `uriParser` - the URI parser to use when processing references (can be null).

    - #### validate

          public static void validate(java.io.InputStream inputStream,
                      URIParser uriParser)

      Validates an XLIFF document passed as a stream.
      Parameters:
        `inputStream` - the stream to process.
        `uriParser` - the URI parser to use when processing references (can be null).

    - #### open

          public void open(java.io.File file)

      Opens an XLIFF document by its File object.
      Parameters:
        `file` - the file to process.

    - #### open

          public void open(java.net.URI inputURI)

      Opens an XLIFF document by its URI.
      Parameters:
        `inputURI` - the URI to process.

    - #### open

          public void open(java.lang.String input)

      Opens an XLIFF document passed as a string.
      Parameters:
        `input` - the string containing the document to process.

    - #### open

          public void open(java.io.InputStream inputStream)

      Opens an XLIFF document by its stream. Note that if a schema validation is done, this call will create a temporary copy of the content. If you can use `open(File)`, `open(URI)` or `open(String)`.
      Parameters:
        `inputStream` - the input stream to process.

    - #### close

          public void close()

      Closes the document.
      Specified by:
        `close` in interface `java.io.Closeable`
      Specified by:
        `close` in interface `java.lang.AutoCloseable`

    - #### hasNext

          public boolean hasNext()

      Indicates if there is another event.
      Returns:
        true if there is another event, false otherwise.

    - #### next

          public Event next()

      Gets the next filter event.
      Returns:
        the next filter event.

    - #### setReportUnsingnificantParts

          public void setReportUnsingnificantParts(boolean reportUnsingnificantParts)

      Sets the flag to report or not parts of the documents that are not significant. For example white space between structural elements.

      By default those parts are not reported.

      Parameters:
        `reportUnsingnificantParts` - true to report those parts, false to not report them.

    - #### getWarningCount

          public int getWarningCount()

      Gets the number of warnings.
      Returns:
        the number of warnings.

    - #### processMatches

          protected void processMatches()
                                 throws javax.xml.stream.XMLStreamException

      Throws:
        `javax.xml.stream.XMLStreamException`