Class XLIFFProcessor

  • All Implemented Interfaces:
    Runnable

    public class XLIFFProcessor
    extends Object
    implements 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 Detail

      • XLIFFProcessor

        public XLIFFProcessor()
    • Method Detail

      • setInput

        public void setInput​(File inputFile)
      • setInput

        public void setInput​(String inputText)
      • setInput

        public void setInput​(URI inputURI)
      • setInput

        public void setInput​(InputStream inputStream)
      • setOutput

        public void setOutput​(File outputFile)
        Sets the output file.
        Parameters:
        outputFile - the output file (Use null to specify no output).
      • setOutput

        public void setOutput​(Writer outputWriter)
      • run

        public void run​(File inputFile,
                        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​(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 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:
        IndexOutOfBoundsException - if the index in invalid.