org.apache.poi.hwpf.model
Class TextPieceTable

java.lang.Object
  extended by org.apache.poi.hwpf.model.TextPieceTable
All Implemented Interfaces:
CharIndexTranslator

public final 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

Field Summary
protected  java.util.ArrayList _textPieces
           
 
Constructor Summary
TextPieceTable()
           
TextPieceTable(byte[] documentStream, byte[] tableStream, int offset, int size, int fcMin)
           
 
Method Summary
 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 getCharIndex(int bytePos)
          Calculates the char index of the given byte index.
 int getCpMin()
           
 java.util.List getTextPieces()
           
 boolean isUnicodeAtByteOffset(int bytePos)
          Is the text at the given byte offset unicode, or plain old ascii? In a very evil fashion, you have to actually know this to make sense of character and paragraph properties :(
 boolean isUnicodeAtCharOffset(int cp)
          Is the text at the given Character offset unicode, or plain old ascii? In a very evil fashion, you have to actually know this to make sense of character and paragraph properties :(
 byte[] writeTo(HWPFOutputStream docStream)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_textPieces

protected java.util.ArrayList _textPieces
Constructor Detail

TextPieceTable

public TextPieceTable()

TextPieceTable

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

getCpMin

public int getCpMin()

getTextPieces

public java.util.List getTextPieces()

isUnicodeAtCharOffset

public boolean isUnicodeAtCharOffset(int cp)
Is the text at the given Character offset unicode, or plain old ascii? In a very evil fashion, you have to actually know this to make sense of character and paragraph properties :(

Parameters:
cp - The character offset to check about

isUnicodeAtByteOffset

public boolean isUnicodeAtByteOffset(int bytePos)
Description copied from interface: CharIndexTranslator
Is the text at the given byte offset unicode, or plain old ascii? In a very evil fashion, you have to actually know this to make sense of character and paragraph properties :(

Specified by:
isUnicodeAtByteOffset in interface CharIndexTranslator
Parameters:
bytePos - The character offset to check about
Returns:
true if the text at the given byte offset is unicode

writeTo

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

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

getCharIndex

public int getCharIndex(int bytePos)
Description copied from interface: CharIndexTranslator
Calculates the char index of the given byte index.

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


Copyright 2011 The Apache Software Foundation or its licensors, as applicable.