public class Range extends Object
Modifier and Type | Field and Description |
---|---|
static int |
TYPE_CHARACTER
Deprecated.
POI 3.8 beta 5
|
static int |
TYPE_LISTENTRY
Deprecated.
POI 3.8 beta 5
|
static int |
TYPE_PARAGRAPH
Deprecated.
POI 3.8 beta 5
|
static int |
TYPE_SECTION
Deprecated.
POI 3.8 beta 5
|
static int |
TYPE_TABLE
Deprecated.
POI 3.8 beta 5
|
static int |
TYPE_TEXT
Deprecated.
POI 3.8 beta 5
|
static int |
TYPE_UNDEFINED
Deprecated.
POI 3.8 beta 5
|
Constructor and Description |
---|
Range(int start,
int end,
HWPFDocumentCore doc)
Used to construct a Range from a document.
|
Modifier and Type | Method and Description |
---|---|
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.
|
CharacterRun |
insertAfter(String text)
Inserts text onto the end of this range
|
CharacterRun |
insertBefore(String text)
Inserts text into the front of this range.
|
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(String newText,
boolean addAfter)
Replace range text with new one, adding it to the range and deleting
original text from document
|
void |
replaceText(String pPlaceHolder,
String pValue)
Replace (all instances of) a piece of text with another...
|
void |
replaceText(String pPlaceHolder,
String pValue,
int pOffset)
Replace (one instance of) a piece of text with another...
|
boolean |
sanityCheck()
Method for debug purposes.
|
static String |
stripFields(String text)
Removes any fields (eg macros, page markers etc) from the string.
|
String |
text()
Gets the text that this Range contains.
|
String |
toString() |
@Deprecated public static final int TYPE_PARAGRAPH
@Deprecated public static final int TYPE_CHARACTER
@Deprecated public static final int TYPE_SECTION
@Deprecated public static final int TYPE_TEXT
@Deprecated public static final int TYPE_LISTENTRY
@Deprecated public static final int TYPE_TABLE
@Deprecated public static final int TYPE_UNDEFINED
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.public String text()
public static String stripFields(String text)
public int numSections()
public int numParagraphs()
public int numCharacterRuns()
public CharacterRun insertBefore(String text)
text
- The text to insertpublic CharacterRun insertAfter(String text)
text
- The text to insertpublic void delete()
public Table insertTableBefore(short columns, int rows)
columns
- The number of columnsrows
- The number of rows.public void replaceText(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@Internal public void replaceText(String pPlaceHolder, 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(String pPlaceHolder, 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 Table getTable(Paragraph paragraph)
paragraph
- The paragraph that is the first paragraph in the table.public int getStartOffset()
public int getEndOffset()
public boolean sanityCheck()
IllegalArgumentException
if checks fail.Copyright © 2010 - 2020 Adobe. All Rights Reserved