Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.poi.hwpf.model
Class TextPieceTable

    java.lang.Object
      org.apache.poi.hwpf.model.TextPieceTable

All Implemented Interfaces:
  CharIndexTranslator

    public class TextPieceTable

extends java.lang.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.

Author:
  Ryan Ackley

Constructor Summary
`TextPieceTable()`
`TextPieceTable(byte[] documentStream, byte[] tableStream, int offset, int size, int fcMin)`

Method Summary
`void` | `add(TextPiece piece)`
`int` | `adjustForInsert(int listIndex, int length)` Adjust all the text piece after inserting some text into one of them
`boolean` | `equals(java.lang.Object o)`
`int` | `getByteIndex(int charPos)` Calculates the byte index of the given char index.
`int` | `getCharIndex(int bytePos)` Calculates the char index of the given byte index.
`int` | `getCharIndex(int startBytePos, int startCP)` Calculates the char index of the given byte index.
`int[][]` | `getCharIndexRanges(int startBytePosInclusive, int endBytePosExclusive)` Finds character ranges that includes specified byte range.
`int` | `getCpMin()`
`java.lang.StringBuffer` | `getText()`
`java.util.List` | `getTextPieces()`
`int` | `hashCode()`
`boolean` | `isIndexInTable(int bytePos)` Check if index is in table
`int` | `lookIndexBackward(int startBytePos)` Return last index <= bytePos that is in table
`int` | `lookIndexForward(int startBytePos)` Return first index >= bytePos that is in table
`byte[]` | `writeTo(HWPFOutputStream docStream)`

Methods inherited from class java.lang.Object
`getClass, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### TextPieceTable

    public TextPieceTable()

### TextPieceTable

    public TextPieceTable(byte[] documentStream,
                          byte[] tableStream,
                          int offset,
                          int size,
                          int fcMin)

Method Detail

### add

    public void add(TextPiece piece)

### 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

### equals

    public boolean equals(java.lang.Object o)

  Overrides:
    `equals` in class `java.lang.Object`

### 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

    public int getCharIndex(int bytePos)

  Description copied from interface: `CharIndexTranslator`
  Calculates the char index of the given byte index. Look forward if index is not in table

  Specified by:
    `getCharIndex` in interface `CharIndexTranslator`
  Parameters:
    `bytePos` - The character offset to check
  Returns:
    the char index

### getCharIndex

    public int getCharIndex(int startBytePos,
                            int startCP)

  Description copied from interface: `CharIndexTranslator`
  Calculates the char index of the given byte index. Look forward if index is not in table

  Specified by:
    `getCharIndex` in interface `CharIndexTranslator`
  Parameters:
    `startBytePos` - The character offset to check
    `startCP` - look from this characted position
  Returns:
    the char index

### 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()

### getText

    public java.lang.StringBuffer getText()

### getTextPieces

    public java.util.List getTextPieces()

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `java.lang.Object`

### isIndexInTable

    public boolean isIndexInTable(int bytePos)

  Description copied from interface: `CharIndexTranslator`
  Check if index is in table

  Specified by:
    `isIndexInTable` in interface `CharIndexTranslator`
  Returns:
    true if index in table, false if not

### 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

### writeTo

    public byte[] writeTo(HWPFOutputStream docStream)
                   throws java.io.IOException

  Throws:
    `java.io.IOException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD