Class Text

java.lang.Object
org.omegat.filters3.Text
All Implemented Interfaces:
Element
Direct Known Subclasses:
XMLEntityText, XMLText

public abstract class Text extends Object implements Element
Abstract piece of text.

P.S. The most important method is createInstance(String).

  • Constructor Details

    • Text

      public Text(String text)
      Creates a new instance of Text initialized with some text.
  • Method Details

    • getText

      public String getText()
      Returns the piece of text stored.
    • isMeaningful

      public boolean isMeaningful()
      Whether the text is meaningful, i.e. contains anything but space.
    • append

      public void append(String newText)
    • createInstance

      public abstract Text createInstance(String newText)
      Creates a new instance of the same class as this one. This method is used while translating to create pieces of translated text.

      For example, the following HTML sentence <i>Friday</i> I'm in love. (Tag[<i>], Text[Friday], Tag[</i>], Text[ I'm in love.]) can be translated as V <i>pyatnitzu</i> ya vlyublyon. (Text[V ], Tag[<i>], Text[pyatnitzu], Tag[</i>], Text[ ya vlyublyon.]). Tags are the same, but text is translated. Even the number of text elements might change! So OmegaT must be able to create Text classes with appropriate toOriginal() methods for storing translated text, so it would pick any of the original Text instances, e.g. Text[Friday], and call createInstance("V "), createInstance("pyatnitzu"), and createInstance(" ya vlyublyon.").

    • toShortcut

      public String toShortcut()
      Returns shortcut string representation of the element. Basically, the text itself.
      Specified by:
      toShortcut in interface Element
    • toSafeCalcShortcut

      public String toSafeCalcShortcut()
      Description copied from interface: Element
      Returns shorcuts like '\b_i0_\b' for statistics calculation
      Specified by:
      toSafeCalcShortcut in interface Element
    • toTMX

      public String toTMX()
      Returns long XML-encoded representation of the element. Basically, the XML-encoded text (< -> &lt; etc). E.g. for Rock&Roll should return Rock&Roll.
      Specified by:
      toTMX in interface Element
    • toOriginal

      public abstract String toOriginal()
      Returns the text in its original form as it was in original document. E.g. for Rock&Roll should return Rock&Roll for XML and Rock&Roll for text files.
      Specified by:
      toOriginal in interface Element