Class Entry

  • Direct Known Subclasses:
    XMLIntactEntry

    public class Entry
    extends java.lang.Object
    Translatable entry. Holds a list of source tags and text, translated text and maintains correspondence between tags in source and in target.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(Element elem)
      Adds an element to this entry.
      void clear()
      Cleans up this entry.
      Element get​(int i)
      Gets an element.
      boolean isEmpty()
      Returns whether or not the elements list is empty.
      void remove​(int index)
      Removes an element from this entry.
      void resetTagDetected()  
      void setTranslation​(java.lang.String translation, XMLDialect xmlDialect, java.util.List<ProtectedPart> protectedParts)
      Sets the translation of the shortcut string returned by #toShortcut().
      int size()
      Returns the number of source elements.
      java.lang.String sourceToOriginal()
      Returns the entry source in its original form as it was in original document.
      java.lang.String sourceToShortcut​(boolean tagsAggregation, XMLDialect xmlDialect, java.util.List<ProtectedPart> protectedParts)
      Returns shortcut string representation of the entry source.
      java.lang.String sourceToTMX()
      Returns long XML-encoded representation of the source entry for storing in TMX.
      java.lang.String translationToOriginal()
      Returns the translated entry as it should be stored in translated document.
      java.lang.String translationToTMX()
      Returns long XML-encoded representation of the entry translation for storing in TMX.
      • Methods inherited from class java.lang.Object

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

      • clear

        public void clear()
        Cleans up this entry.
      • resetTagDetected

        public void resetTagDetected()
      • sourceToShortcut

        public java.lang.String sourceToShortcut​(boolean tagsAggregation,
                                                 XMLDialect xmlDialect,
                                                 java.util.List<ProtectedPart> protectedParts)
        Returns shortcut string representation of the entry source. This is what the user translates. E.g. for Here's <b>bold text</b> should return Here's <b0>bold text</b0>.
        Parameters:
        tagsAggregation - Whether tags of this entry can be aggregated.
        xmlDialect - dialect for processing shortcuts
      • sourceToTMX

        public java.lang.String sourceToTMX()
        Returns long XML-encoded representation of the source entry for storing in TMX. E.g. for Here's <b>bold text</b> should return Here's <bpt i="0">&b0&gt;</bpt>bold text<ept i="0">&lt;/b0&gt;</ept>.
      • sourceToOriginal

        public java.lang.String sourceToOriginal()
        Returns the entry source in its original form as it was in original document. E.g. for Here's <b>bold text</b> should return the same string Here's <b>bold text</b>.
      • setTranslation

        public void setTranslation​(java.lang.String translation,
                                   XMLDialect xmlDialect,
                                   java.util.List<ProtectedPart> protectedParts)
                            throws TranslationException
        Sets the translation of the shortcut string returned by #toShortcut(). Before setting translation checks whether the translation contains all the same tags in weakly correct order:
        • All the tags present in source must be present in translation. For example, It's <b>bold</b> text should not be translated as Etot tekst poluzhirnyi.
        • End tag goes after corresponding beginning tag. For example, It's <b>bold</b> text should not be translated as Etot tekst </b>poluzhirnyi<b>.
        • If standalone tag or tag pair was enclosed in another tag pair in source, it should be enclosed in translation. For example, It's <b>bold and <i>bold italic</i></b> text should not be translated as Etot tekst <b>poluzhirnyi</b> i <i>naklonnyi</i>.
        • Independent standalone tags and tag pairs may be reordered within entry. For example, It's <b>bold</b> and <i>italic</i> text can be translated as Etot tekst <i>naklonnyi</i> i <b>poluzhirnyi</b>.
        Throws:
        TranslationException - -- if any tag is missing or tags are ordered incorrectly.
      • translationToTMX

        public java.lang.String translationToTMX()
        Returns long XML-encoded representation of the entry translation for storing in TMX.
      • translationToOriginal

        public java.lang.String translationToOriginal()
        Returns the translated entry as it should be stored in translated document.
      • add

        public void add​(Element elem)
        Adds an element to this entry. Can be either a Text or a Tag.
      • remove

        public void remove​(int index)
        Removes an element from this entry.
      • get

        public Element get​(int i)
        Gets an element. Can be either a Text or a Tag.
      • size

        public int size()
        Returns the number of source elements.
      • isEmpty

        public boolean isEmpty()
        Returns whether or not the elements list is empty.