net.sf.okapi.common.resource
Class TextFragment

java.lang.Object
  extended by net.sf.okapi.common.resource.TextFragment
All Implemented Interfaces:
java.lang.Appendable, java.lang.CharSequence, java.lang.Comparable<java.lang.Object>

public class TextFragment
extends java.lang.Object
implements java.lang.Appendable, java.lang.CharSequence, java.lang.Comparable<java.lang.Object>

Implements the methods for creating and manipulating a pre-parsed flat representation of a content with in-line codes.

The model uses two objects to store the data:

The coded text string is composed of normal characters and markers.

A marker is a sequence of two special characters (in the Unicode PUA) that indicate the type of underlying code (opening, closing, isolated), and an index pointing to its corresponding Code object where more information can be found. The value of the index is encoded as a Unicode PUA character. You can use the toChar(int) and toIndex(char) methods to encoded and decode the index value.

To get the coded text of a TextFragment object use getCodedText(), and to get its list of codes use getCodes().

You can modify directly the coded text or the codes and re-apply them to the TextFragment object using setCodedText(String) and setCodedText(String, List).

Adding a code to the coded text can be done by: