Class TextPieceTable

  • All Implemented Interfaces:
    CharIndexTranslator
    Direct Known Subclasses:
    OldTextPieceTable

    @Internal
    public class TextPieceTable
    extends Object
    implements CharIndexTranslator
    The piece table for matching up character positions to bits of text. This mostly works in bytes, but the TextPieces themselves work in characters. This does the icky convertion.
    • Constructor Detail

      • TextPieceTable

        public TextPieceTable()
      • TextPieceTable

        public TextPieceTable​(byte[] documentStream,
                              byte[] tableStream,
                              int offset,
                              int size,
                              int fcMin)
    • Method Detail

      • adjustForInsert

        public int adjustForInsert​(int listIndex,
                                   int length)
        Adjust all the text piece after inserting some text into one of them
        Parameters:
        listIndex - The TextPiece that had characters inserted into
        length - The number of characters inserted
      • getByteIndex

        public int getByteIndex​(int charPos)
        Description copied from interface: CharIndexTranslator
        Calculates the byte index of the given char index.
        Specified by:
        getByteIndex in interface CharIndexTranslator
        Parameters:
        charPos - The char position
        Returns:
        The byte index
      • getCharIndex

        @Deprecated
        public int getCharIndex​(int bytePos)
        Deprecated.
      • getCharIndex

        @Deprecated
        public int getCharIndex​(int startBytePos,
                                int startCP)
        Deprecated.
      • getCharIndexRanges

        public int[][] getCharIndexRanges​(int startBytePosInclusive,
                                          int endBytePosExclusive)
        Description copied from interface: CharIndexTranslator
        Finds character ranges that includes specified byte range.
        Specified by:
        getCharIndexRanges in interface CharIndexTranslator
        Parameters:
        startBytePosInclusive - start byte range
        endBytePosExclusive - end byte range
      • getCpMin

        public int getCpMin()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • lookIndexBackward

        public int lookIndexBackward​(int startBytePos)
        Description copied from interface: CharIndexTranslator
        Return last index <= bytePos that is in table
        Specified by:
        lookIndexBackward in interface CharIndexTranslator
        Returns:
        last index less of equal to bytePos that is in table
      • lookIndexForward

        public int lookIndexForward​(int startBytePos)
        Description copied from interface: CharIndexTranslator
        Return first index >= bytePos that is in table
        Specified by:
        lookIndexForward in interface CharIndexTranslator
        Returns:
        first index greater or equal to bytePos that is in table