Package org.apache.poi.hwpf.model
Class TextPieceTable
java.lang.Object
org.apache.poi.hwpf.model.TextPieceTable
- All Implemented Interfaces:
CharIndexTranslator
- Direct Known Subclasses:
OldTextPieceTable
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
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
ConstructorsConstructorDescriptionTextPieceTable
(byte[] documentStream, byte[] tableStream, int offset, int size, int fcMin) -
Method Summary
Modifier and TypeMethodDescriptionvoid
int
adjustForInsert
(int listIndex, int length) Adjust all the text piece after inserting some text into one of themboolean
int
getByteIndex
(int charPos) Calculates the byte index of the given char index.int
getCharIndex
(int bytePos) Deprecated.int
getCharIndex
(int startBytePos, int startCP) Deprecated.int[][]
getCharIndexRanges
(int startBytePosInclusive, int endBytePosExclusive) Finds character ranges that includes specified byte range.int
getCpMin()
protected int
getEncodingMultiplier
(TextPiece textPiece) getText()
int
hashCode()
boolean
isIndexInTable
(int bytePos) Check if index is in tableint
lookIndexBackward
(int startBytePos) Return last index invalid input: '<'= bytePos that is in tableint
lookIndexForward
(int startBytePos) Return first index >= bytePos that is in tableprotected TextPiece
newTextPiece
(int nodeStartChars, int nodeEndChars, byte[] buf, PieceDescriptor pd) byte[]
writeTo
(ByteArrayOutputStream docStream)
-
Field Details
-
_textPieces
-
_textPiecesFCOrder
-
-
Constructor Details
-
TextPieceTable
public TextPieceTable() -
TextPieceTable
public TextPieceTable(byte[] documentStream, byte[] tableStream, int offset, int size, int fcMin)
-
-
Method Details
-
newTextPiece
protected TextPiece newTextPiece(int nodeStartChars, int nodeEndChars, byte[] buf, PieceDescriptor pd) -
add
-
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 intolength
- The number of characters inserted
-
equals
-
getByteIndex
public int getByteIndex(int charPos) Description copied from interface:CharIndexTranslator
Calculates the byte index of the given char index.- Specified by:
getByteIndex
in interfaceCharIndexTranslator
- Parameters:
charPos
- The char position- Returns:
- The byte index
-
getCharIndex
Deprecated. -
getCharIndex
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 interfaceCharIndexTranslator
- Parameters:
startBytePosInclusive
- start byte rangeendBytePosExclusive
- end byte range
-
getEncodingMultiplier
-
getCpMin
public int getCpMin() -
getText
-
getTextPieces
-
hashCode
public int hashCode() -
isIndexInTable
public boolean isIndexInTable(int bytePos) Description copied from interface:CharIndexTranslator
Check if index is in table- Specified by:
isIndexInTable
in interfaceCharIndexTranslator
- Parameters:
bytePos
-- Returns:
- true if index in table, false if not
-
lookIndexBackward
public int lookIndexBackward(int startBytePos) Description copied from interface:CharIndexTranslator
Return last index invalid input: '<'= bytePos that is in table- Specified by:
lookIndexBackward
in interfaceCharIndexTranslator
- Parameters:
startBytePos
-- 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 interfaceCharIndexTranslator
- Parameters:
startBytePos
-- Returns:
- first index greater or equal to bytePos that is in table
-
writeTo
- Throws:
IOException
-