| java.lang.Object org.apache.poi.hwpf.usermodel.Range
All known Subclasses: org.apache.poi.hwpf.usermodel.TableCell, org.apache.poi.hwpf.usermodel.Section, org.apache.poi.hwpf.usermodel.DocumentPosition, org.apache.poi.hwpf.usermodel.Paragraph, org.apache.poi.hwpf.usermodel.CharacterRun, org.apache.poi.hwpf.usermodel.Table,
Range | public class Range (Code) | | 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.
author: Ryan Ackley |
Constructor Summary | |
public | Range(int start, int end, HWPFDocument doc) Used to construct a Range from a document. | protected | Range(int start, int end, Range parent) Used to create Ranges that are children of other Ranges. | protected | Range(int startIdx, int endIdx, int idxType, Range parent) Constructor used to build a Range from indexes in one of its internal
lists. |
Method Summary | |
public void | delete() | public CharacterRun | getCharacterRun(int index) Gets the character run at index. | public Paragraph | getParagraph(int index) Gets the paragraph at index. | public Section | getSection(int index) Gets the section at index. | public Table | getTable(Paragraph paragraph) Gets the table that starts with paragraph. | protected void | initAll() loads all of the list indexes. | public CharacterRun | insertAfter(String text) | public CharacterRun | insertAfter(String text, CharacterProperties props) Inserts text onto the end of this range and gives that text the
CharacterProperties specified in props.
Parameters: text - The text to insert. Parameters: props - The CharacterProperties to give the text. | public Paragraph | insertAfter(ParagraphProperties props, int styleIndex) Inserts and empty paragraph into the end of this range.
Parameters: props - The properties that the new paragraph will have. Parameters: styleIndex - The index into the stylesheet for the new paragraph. | protected Paragraph | insertAfter(ParagraphProperties props, int styleIndex, String text) Inserts a paragraph into the end of this range. | public ListEntry | insertAfter(ParagraphProperties props, int listID, int level, int styleIndex) Inserts a list into the beginning of this range.
Parameters: props - The properties of the list entry. | public CharacterRun | insertBefore(String text) Inserts text into the front of this range. | public CharacterRun | insertBefore(String text, CharacterProperties props) Inserts text into the front of this range and it gives that text the
CharacterProperties specified in props.
Parameters: text - The text to insert. Parameters: props - The CharacterProperties to give the text. | public Paragraph | insertBefore(ParagraphProperties props, int styleIndex) Inserts and empty paragraph into the front of this range.
Parameters: props - The properties that the new paragraph will have. Parameters: styleIndex - The index into the stylesheet for the new paragraph. | protected Paragraph | insertBefore(ParagraphProperties props, int styleIndex, String text) Inserts a paragraph into the front of this range. | public Table | insertBefore(TableProperties props, int rows) Inserts a simple table into the beginning of this range. | public ListEntry | insertBefore(ParagraphProperties props, int listID, int level, int styleIndex) Inserts a list into the beginning of this range.
Parameters: props - The properties of the list entry. | public int | numCharacterRuns() | public int | numParagraphs() Used to get the number of paragraphs in a range. | public int | numSections() Used to get the number of sections in a range. | public String | text() Gets the text that this Range contains. | public int | type() This method is used to determine the type. |
TYPE_CHARACTER | final public static int TYPE_CHARACTER(Code) | | |
TYPE_LISTENTRY | final public static int TYPE_LISTENTRY(Code) | | |
TYPE_PARAGRAPH | final public static int TYPE_PARAGRAPH(Code) | | |
TYPE_SECTION | final public static int TYPE_SECTION(Code) | | |
TYPE_TABLE | final public static int TYPE_TABLE(Code) | | |
TYPE_TEXT | final public static int TYPE_TEXT(Code) | | |
TYPE_UNDEFINED | final public static int TYPE_UNDEFINED(Code) | | |
_charEnd | protected int _charEnd(Code) | | The end index in the characterRuns list for this Range.
|
_charRangeFound | protected boolean _charRangeFound(Code) | | Have we loaded the characterRun indexes yet.
|
_charStart | protected int _charStart(Code) | | The start index in the characterRuns list for this Range
|
_characters | protected List _characters(Code) | | All CharacterRuns that belong to the document this Range belongs to.
|
_end | protected int _end(Code) | | The ending character offset of this range.
|
_parEnd | protected int _parEnd(Code) | | The end index in the paragraphs list for this Range.
|
_parRangeFound | protected boolean _parRangeFound(Code) | | Have we loaded the paragraph indexes yet.
|
_parStart | protected int _parStart(Code) | | The start index in the paragraphs list for this Range
|
_paragraphs | protected List _paragraphs(Code) | | All paragraphs that belong to the document this Range belongs to.
|
_sectionEnd | protected int _sectionEnd(Code) | | The end index in the sections list for this Range.
|
_sectionRangeFound | boolean _sectionRangeFound(Code) | | Have we loaded the section indexes yet
|
_sectionStart | protected int _sectionStart(Code) | | The start index in the sections list for this Range
|
_sections | protected List _sections(Code) | | All sections that belong to the document this Range belongs to.
|
_start | protected int _start(Code) | | The starting character offset of this range.
|
_text | protected List _text(Code) | | All text pieces that belong to the document this Range belongs to.
|
_textEnd | protected int _textEnd(Code) | | The end index in the text list for this Range.
|
_textRangeFound | protected boolean _textRangeFound(Code) | | Have we loaded the Text indexes yet
|
_textStart | protected int _textStart(Code) | | The start index in the text list for this Range.
|
Range | public Range(int start, int end, HWPFDocument doc)(Code) | | Used to construct a Range from a document. This is generally used to
create a Range that spans the whole document.
Parameters: start - Starting character offset of the range. Parameters: end - Ending character offset of the range. Parameters: doc - The HWPFDocument the range is based on. |
Range | protected Range(int start, int end, Range parent)(Code) | | Used to create Ranges that are children of other Ranges.
Parameters: start - Starting character offset of the range. Parameters: end - Ending character offset of the range. Parameters: parent - The parent this range belongs to. |
Range | protected Range(int startIdx, int endIdx, int idxType, Range parent)(Code) | | Constructor used to build a Range from indexes in one of its internal
lists.
Parameters: startIdx - The starting index in the list. Parameters: endIdx - The ending index in the list. Parameters: idxType - The list type. Parameters: parent - The parent Range this range belongs to. |
delete | public void delete()(Code) | | |
getCharacterRun | public CharacterRun getCharacterRun(int index)(Code) | | Gets the character run at index. The index is relative to this range.
Parameters: index - The index of the character run to get. The character run at the specified index in this range. |
getParagraph | public Paragraph getParagraph(int index)(Code) | | Gets the paragraph at index. The index is relative to this range.
Parameters: index - The index of the paragraph to get. The paragraph at the specified index in this range. |
getSection | public Section getSection(int index)(Code) | | Gets the section at index. The index is relative to this range.
Parameters: index - The index of the section to get. The section at the specified index in this range. |
getTable | public Table getTable(Paragraph paragraph)(Code) | | Gets the table that starts with paragraph. In a Word file, a table consists
of a group of paragraphs with certain flags set.
Parameters: paragraph - The paragraph that is the first paragraph in the table. The table that starts with paragraph |
initAll | protected void initAll()(Code) | | loads all of the list indexes.
|
insertAfter | public CharacterRun insertAfter(String text)(Code) | | Inserts text onto the end of this range
Parameters: text - The text to insert The character run the text was inserted into. |
insertAfter | public CharacterRun insertAfter(String text, CharacterProperties props)(Code) | | Inserts text onto the end of this range and gives that text the
CharacterProperties specified in props.
Parameters: text - The text to insert. Parameters: props - The CharacterProperties to give the text. A new CharacterRun that has the given text and properties and is now a part of the document. |
insertAfter | public Paragraph insertAfter(ParagraphProperties props, int styleIndex)(Code) | | Inserts and empty paragraph into the end of this range.
Parameters: props - The properties that the new paragraph will have. Parameters: styleIndex - The index into the stylesheet for the new paragraph. The newly inserted paragraph. |
insertAfter | protected Paragraph insertAfter(ParagraphProperties props, int styleIndex, String text)(Code) | | Inserts a paragraph into the end of this range. The paragraph will
contain one character run that has the default properties for the
paragraph's style.
It is necessary for the text to end with the character '\r'
Parameters: props - The paragraph's properties. Parameters: styleIndex - The index of the paragraph's style in the style sheet. Parameters: text - The text to insert. A newly inserted paragraph. |
insertAfter | public ListEntry insertAfter(ParagraphProperties props, int listID, int level, int styleIndex)(Code) | | Inserts a list into the beginning of this range.
Parameters: props - The properties of the list entry. All list entries areparagraphs. Parameters: listID - The id of the list that contains the properties. Parameters: level - The indentation level of the list. Parameters: styleIndex - The base style's index in the stylesheet. The empty ListEntry that is now part of the document. |
insertBefore | public CharacterRun insertBefore(String text)(Code) | | Inserts text into the front of this range.
Parameters: text - The text to insert The character run that text was inserted into. |
insertBefore | public CharacterRun insertBefore(String text, CharacterProperties props)(Code) | | Inserts text into the front of this range and it gives that text the
CharacterProperties specified in props.
Parameters: text - The text to insert. Parameters: props - The CharacterProperties to give the text. A new CharacterRun that has the given text and properties and is now a part of the document. |
insertBefore | public Paragraph insertBefore(ParagraphProperties props, int styleIndex)(Code) | | Inserts and empty paragraph into the front of this range.
Parameters: props - The properties that the new paragraph will have. Parameters: styleIndex - The index into the stylesheet for the new paragraph. The newly inserted paragraph. |
insertBefore | protected Paragraph insertBefore(ParagraphProperties props, int styleIndex, String text)(Code) | | Inserts a paragraph into the front of this range. The paragraph will
contain one character run that has the default properties for the
paragraph's style.
It is necessary for the text to end with the character '\r'
Parameters: props - The paragraph's properties. Parameters: styleIndex - The index of the paragraph's style in the style sheet. Parameters: text - The text to insert. A newly inserted paragraph. |
insertBefore | public Table insertBefore(TableProperties props, int rows)(Code) | | Inserts a simple table into the beginning of this range. The number of
columns is determined by the TableProperties passed into this function.
Parameters: props - The table properties for the table. Parameters: rows - The number of rows. The empty Table that is now part of the document. |
insertBefore | public ListEntry insertBefore(ParagraphProperties props, int listID, int level, int styleIndex)(Code) | | Inserts a list into the beginning of this range.
Parameters: props - The properties of the list entry. All list entries areparagraphs. Parameters: listID - The id of the list that contains the properties. Parameters: level - The indentation level of the list. Parameters: styleIndex - The base style's index in the stylesheet. The empty ListEntry that is now part of the document. |
numCharacterRuns | public int numCharacterRuns()(Code) | | The number of characterRuns in this range. |
numParagraphs | public int numParagraphs()(Code) | | Used to get the number of paragraphs in a range. If this range is smaller
than a paragraph, it will return 1 for its containing paragraph.
The number of paragraphs in this range. |
numSections | public int numSections()(Code) | | Used to get the number of sections in a range. If this range is smaller
than a section, it will return 1 for its containing section.
The number of sections in this range. |
text | public String text()(Code) | | Gets the text that this Range contains.
The text for this range. |
type | public int type()(Code) | | This method is used to determine the type. Handy for switch statements
compared to the instanceof operator.
A TYPE constant. |
|
|