|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.poi.hwpf.usermodel.Range
public class Range
This class is the central class of the HWPF object model. All properties that apply to a range of characters in a Word document extend this class. It is possible to insert text and/or properties at the beginning or end of a range. Ranges are only valid if there hasn't been an insert in a prior Range since the Range's creation. Once an element (text, paragraph, etc.) has been inserted into a Range, subsequent Ranges become unstable.
| Field Summary | |
|---|---|
static int |
TYPE_CHARACTER
|
static int |
TYPE_LISTENTRY
|
static int |
TYPE_PARAGRAPH
|
static int |
TYPE_SECTION
|
static int |
TYPE_TABLE
|
static int |
TYPE_TEXT
|
static int |
TYPE_UNDEFINED
|
| Constructor Summary | |
|---|---|
Range(int start,
int end,
HWPFDocumentCore doc)
Used to construct a Range from a document. |
|
| Method Summary | |
|---|---|
void |
delete()
|
CharacterRun |
getCharacterRun(int index)
Gets the character run at index. |
int |
getEndOffset()
|
Paragraph |
getParagraph(int index)
Gets the paragraph at index. |
Section |
getSection(int index)
Gets the section at index. |
int |
getStartOffset()
|
Table |
getTable(Paragraph paragraph)
Gets the table that starts with paragraph. |
Paragraph |
insertAfter(ParagraphProperties props,
int styleIndex)
Deprecated. Use code shall not work with ParagraphProperties |
ListEntry |
insertAfter(ParagraphProperties props,
int listID,
int level,
int styleIndex)
Deprecated. Use code shall not work with ParagraphProperties |
CharacterRun |
insertAfter(java.lang.String text)
Inserts text onto the end of this range |
CharacterRun |
insertAfter(java.lang.String text,
CharacterProperties props)
Deprecated. User code should not work with CharacterProperties |
Paragraph |
insertBefore(ParagraphProperties props,
int styleIndex)
Deprecated. Use code shall not work with ParagraphProperties |
ListEntry |
insertBefore(ParagraphProperties props,
int listID,
int level,
int styleIndex)
Deprecated. Use code shall not work with ParagraphProperties |
CharacterRun |
insertBefore(java.lang.String text)
Inserts text into the front of this range. |
CharacterRun |
insertBefore(java.lang.String text,
CharacterProperties props)
Deprecated. User code should not work with CharacterProperties |
Table |
insertBefore(TableProperties props,
int rows)
Deprecated. Use code shall not work with TableProperties. Use
insertTableBefore(short, int) instead |
Table |
insertTableBefore(short columns,
int rows)
Inserts a simple table into the beginning of this range. |
int |
numCharacterRuns()
|
int |
numParagraphs()
Used to get the number of paragraphs in a range. |
int |
numSections()
Used to get the number of sections in a range. |
void |
replaceText(java.lang.String newText,
boolean addAfter)
Replace range text with new one, adding it to the range and deleting original text from document |
void |
replaceText(java.lang.String pPlaceHolder,
java.lang.String pValue)
Replace (all instances of) a piece of text with another... |
void |
replaceText(java.lang.String pPlaceHolder,
java.lang.String pValue,
int pOffset)
Replace (one instance of) a piece of text with another... |
boolean |
sanityCheck()
Method for debug purposes. |
static java.lang.String |
stripFields(java.lang.String text)
Removes any fields (eg macros, page markers etc) from the string. |
java.lang.String |
text()
Gets the text that this Range contains. |
java.lang.String |
toString()
|
int |
type()
This method is used to determine the type. |
boolean |
usesUnicode()
Deprecated. Range is not linked to any text piece anymore, so to check if unicode is used please access TextPieceTable during
document load time |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int TYPE_PARAGRAPH
public static final int TYPE_CHARACTER
public static final int TYPE_SECTION
public static final int TYPE_TEXT
public static final int TYPE_LISTENTRY
public static final int TYPE_TABLE
public static final int TYPE_UNDEFINED
| Constructor Detail |
|---|
public Range(int start,
int end,
HWPFDocumentCore doc)
start - Starting character offset of the range.end - Ending character offset of the range.doc - The HWPFDocument the range is based on.| Method Detail |
|---|
public boolean usesUnicode()
TextPieceTable during
document load time
public java.lang.String text()
public static java.lang.String stripFields(java.lang.String text)
public int numSections()
public int numParagraphs()
public int numCharacterRuns()
public CharacterRun insertBefore(java.lang.String text)
text - The text to insert
public CharacterRun insertAfter(java.lang.String text)
text - The text to insert
public CharacterRun insertBefore(java.lang.String text,
CharacterProperties props)
CharacterProperties
text - The text to insert.props - The CharacterProperties to give the text.
public CharacterRun insertAfter(java.lang.String text,
CharacterProperties props)
CharacterProperties
text - The text to insert.props - The CharacterProperties to give the text.
public Paragraph insertBefore(ParagraphProperties props,
int styleIndex)
ParagraphProperties
props - The properties that the new paragraph will have.styleIndex - The index into the stylesheet for the new paragraph.
public Paragraph insertAfter(ParagraphProperties props,
int styleIndex)
ParagraphProperties
props - The properties that the new paragraph will have.styleIndex - The index into the stylesheet for the new paragraph.
public void delete()
public Table insertBefore(TableProperties props,
int rows)
TableProperties. Use
insertTableBefore(short, int) instead
props - The table properties for the table.rows - The number of rows.
public Table insertTableBefore(short columns,
int rows)
columns - The number of columnsrows - The number of rows.
public ListEntry insertBefore(ParagraphProperties props,
int listID,
int level,
int styleIndex)
ParagraphProperties
props - The properties of the list entry. All list entries are
paragraphs.listID - The id of the list that contains the properties.level - The indentation level of the list.styleIndex - The base style's index in the stylesheet.
public ListEntry insertAfter(ParagraphProperties props,
int listID,
int level,
int styleIndex)
ParagraphProperties
props - The properties of the list entry. All list entries are
paragraphs.listID - The id of the list that contains the properties.level - The indentation level of the list.styleIndex - The base style's index in the stylesheet.
public void replaceText(java.lang.String newText,
boolean addAfter)
newText - The text to be replaced withaddAfter - if true the text will be added at the end of current
range, otherwise to the beginning
public void replaceText(java.lang.String pPlaceHolder,
java.lang.String pValue,
int pOffset)
pPlaceHolder - The text to be replaced (e.g., "${organization}")pValue - The replacement text (e.g., "Apache Software Foundation")pOffset - The offset or index where the text to be replaced begins
(relative to/within this Range)
public void replaceText(java.lang.String pPlaceHolder,
java.lang.String pValue)
pPlaceHolder - The text to be replaced (e.g., "${organization}")pValue - The replacement text (e.g., "Apache Software Foundation")public CharacterRun getCharacterRun(int index)
index - The index of the character run to get.
public Section getSection(int index)
index - The index of the section to get.
public Paragraph getParagraph(int index)
index - The index of the paragraph to get.
public int type()
public Table getTable(Paragraph paragraph)
paragraph - The paragraph that is the first paragraph in the table.
public int getStartOffset()
public int getEndOffset()
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean sanityCheck()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||