Class TMXWriter2

java.lang.Object
org.omegat.util.TMXWriter2
All Implemented Interfaces:
AutoCloseable

public class TMXWriter2 extends Object implements AutoCloseable
Helper for write TMX files, using StAX. We can't use JAXB for writing because it changes spaces on formatted output.
  • Field Details

  • Constructor Details

    • TMXWriter2

      public TMXWriter2(File file, Language sourceLanguage, Language targetLanguage, boolean sentenceSegmentingEnabled, boolean levelTwo, boolean forceValidTMX) throws Exception
      Parameters:
      file - to write TMX entries.
      sourceLanguage - language of source.
      targetLanguage - language of target.
      sentenceSegmentingEnabled - true when sentence segmenting enabled, otherwise false.
      levelTwo - When true, the tmx is made compatible with level 2 (TMX version 1.4)
      Throws:
      Exception - when error occurred.
  • Method Details

    • close

      public void close() throws XMLStreamException, IOException
      Specified by:
      close in interface AutoCloseable
      Throws:
      XMLStreamException
      IOException
    • writeComment

      public void writeComment(String comment) throws Exception
      Throws:
      Exception
    • writeEntries

      public void writeEntries(Map<EntryKey,? extends ITMXEntry> entries, boolean addProp) throws Exception
      Write entries.
      Parameters:
      entries - Map of SourceTextEntry and TMXEntry to output.
      Throws:
      Exception - when i/o error or XMLStream error happened.
    • writeEntry

      public void writeEntry(@Nullable @Nullable String source, @Nullable @Nullable String translation, ITMXEntry entry, @Nullable @Nullable List<String> propValues) throws Exception
      Write one entry.
      Parameters:
      source - source text to write.
      translation - translation text to write.
      entry - that has interface ITMXEntry.
      propValues - pairs with property name and values
      Throws:
      Exception
    • writeEntry

      public void writeEntry(@Nullable @Nullable String source, @Nullable @Nullable String translation, @Nullable @Nullable String note, String creator, long creationDate, @Nullable @Nullable String changer, long changeDate, @Nullable @Nullable List<String> propValues) throws Exception
      Throws:
      Exception