Class TMXWriter2

  • All Implemented Interfaces:
    java.lang.AutoCloseable

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

      Fields 
      Modifier and Type Field Description
      static java.lang.String PROP_ID  
    • Constructor Summary

      Constructors 
      Constructor Description
      TMXWriter2​(java.io.File file, Language sourceLanguage, Language targetLanguage, boolean sentenceSegmentingEnabled, boolean levelTwo, boolean forceValidTMX)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      void writeComment​(java.lang.String comment)  
      void writeEntries​(java.util.Map<EntryKey,​? extends ITMXEntry> entries, boolean addProp)
      Write entries.
      void writeEntry​(java.lang.String source, java.lang.String translation, java.lang.String note, java.lang.String creator, long creationDate, java.lang.String changer, long changeDate, java.util.List<java.lang.String> propValues)  
      void writeEntry​(java.lang.String source, java.lang.String translation, ITMXEntry entry, java.util.List<java.lang.String> propValues)
      Write one entry.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TMXWriter2

        public TMXWriter2​(java.io.File file,
                          Language sourceLanguage,
                          Language targetLanguage,
                          boolean sentenceSegmentingEnabled,
                          boolean levelTwo,
                          boolean forceValidTMX)
                   throws java.lang.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:
        java.lang.Exception - when error occurred.
    • Method Detail

      • close

        public void close()
                   throws javax.xml.stream.XMLStreamException,
                          java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        javax.xml.stream.XMLStreamException
        java.io.IOException
      • writeComment

        public void writeComment​(java.lang.String comment)
                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • writeEntries

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

        public void writeEntry​(java.lang.String source,
                               java.lang.String translation,
                               ITMXEntry entry,
                               java.util.List<java.lang.String> propValues)
                        throws java.lang.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:
        java.lang.Exception
      • writeEntry

        public void writeEntry​(java.lang.String source,
                               java.lang.String translation,
                               java.lang.String note,
                               java.lang.String creator,
                               long creationDate,
                               java.lang.String changer,
                               long changeDate,
                               java.util.List<java.lang.String> propValues)
                        throws java.lang.Exception
        Throws:
        java.lang.Exception