net.sf.okapi.lib.xliff2.processor

## Class XLIFFProcessor

- java.lang.Object
- - net.sf.okapi.lib.xliff2.processor.XLIFFProcessor

- All Implemented Interfaces:
    java.lang.Runnable

      public class XLIFFProcessor
      extends java.lang.Object
      implements java.lang.Runnable

  High-level class implementing the low-level reading and (optionally) re-writing of a document, with the possibility to easily modify the content.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `XLIFFProcessor()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(IEventHandler handler)` Adds an event handler to this processor.
    `void` | `remove(IEventHandler handler)` Removes a given handler from this processor.
    `void` | `remove(int index)` Removes the handler at a given position.
    `void` | `removeAll()` Removes all handlers from this processor.
    `void` | `run()` Process the document.
    `void` | `run(java.io.File inputFile)` Run the processor for a given input file.
    `void` | `run(java.io.File inputFile, java.io.File outputFile)` Run the processor for a given input file, and (if specified) re-write the modified document in a given output file.
    `void` | `setHandler(IEventHandler handler)` Sets a single event handler to make modifications on a selection of events.
    `void` | `setInput(java.io.File inputFile)`
    `void` | `setInput(java.io.InputStream inputStream)`
    `void` | `setInput(java.lang.String inputText)`
    `void` | `setInput(java.net.URI inputURI)`
    `void` | `setOutput(java.io.File outputFile)` Sets the output file.
    `void` | `setOutput(java.io.Writer outputWriter)`

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

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

- - ### Constructor Detail

    - #### XLIFFProcessor

          public XLIFFProcessor()

  - ### Method Detail

    - #### setInput

          public void setInput(java.io.File inputFile)

    - #### setInput

          public void setInput(java.lang.String inputText)

    - #### setInput

          public void setInput(java.net.URI inputURI)

    - #### setInput

          public void setInput(java.io.InputStream inputStream)

    - #### setOutput

          public void setOutput(java.io.File outputFile)

      Sets the output file.
      Parameters:
        `outputFile` - the output file (Use null to specify no output).

    - #### setOutput

          public void setOutput(java.io.Writer outputWriter)

    - #### run

          public void run(java.io.File inputFile,
                 java.io.File outputFile)

      Run the processor for a given input file, and (if specified) re-write the modified document in a given output file. The two file names must be different. The input and output are closed at the end of the process. This methods is an helper method that simply calls `setInput(File)`, `setOutput(File)` and then `run()`.
      Parameters:
        `inputFile` - document to modify.
        `outputFile` - resulting document. Use null to not produce an output file.
      Throws:
        `InvalidParameterException` - if the input and output files are the same.

    - #### run

          public void run(java.io.File inputFile)

      Run the processor for a given input file.
      Parameters:
        `inputFile` - document to process.

    - #### run

          public void run()

      Process the document. You must have set the input, output and event handler before calling this method. The input and output are closed at the end of the process.
      Specified by:
        `run` in interface `java.lang.Runnable`

    - #### setHandler

          public void setHandler(IEventHandler handler)

      Sets a single event handler to make modifications on a selection of events. All existing handler are removed before setting this one.
      Parameters:
        `handler` - the handler to set.

    - #### add

          public void add(IEventHandler handler)

      Adds an event handler to this processor. Existing handlers are preserved. The handlers are executed in the order they have been added.
      Parameters:
        `handler` - the handler to add.

    - #### removeAll

          public void removeAll()

      Removes all handlers from this processor.

    - #### remove

          public void remove(IEventHandler handler)

      Removes a given handler from this processor.
      Parameters:
        `handler` - the handler to remove.

    - #### remove

          public void remove(int index)

      Removes the handler at a given position.
      Parameters:
        `index` - the index of the handler to remove.
      Throws:
        `java.lang.IndexOutOfBoundsException` - if the index in invalid.