Package com.independentsoft.office.odf
Class FindResult
java.lang.Object
com.independentsoft.office.odf.FindResult
A single match of a find operation. A result knows the collection its content
belongs to, so the matched content can be replaced or removed in place.
-
Method Summary
Modifier and TypeMethodDescriptionbooleandelete()Deletes the matched text.Gets the innermost span the match starts in or null if the matched text is not contained in a span.Gets all spans the match spans.Gets the first content element of the match, usually a Text object.Gets the heading the match belongs to or null if the match belongs to a paragraph.intGets the number of matched characters.Gets the paragraph the match belongs to or null if the match belongs to a heading.intgetStart()Gets the index of the match in the text of the paragraph.getStory()Gets the part of the document the match was found in.getText()Gets the matched text.Gets the Paragraph or the Heading the match belongs to.booleanreplace(AttributedText attributedText)Replaces the matched text with the specified span.booleanReplaces the heading containing the match with the specified heading.booleanReplaces the paragraph containing the match with the specified paragraph.booleanReplaces the matched text with the specified text.booleanreplace(List<AttributedText> attributedTexts)Replaces the matched text with the specified spans.booleanreplaceContent(List<IParagraphContent> content)Replaces the matched text with the specified paragraph content, for example an image, a tab, a line break, a field or a hyperlink.toString()Returns a string that represents the current FindResult.
-
Method Details
-
replace
Replaces the matched text with the specified text. The paragraph, its style and all other content of the paragraph, for example spans, images or notes, remain unchanged.- Parameters:
newText- the replacement text.- Returns:
- true if the text was replaced.
-
replace
Replaces the matched text with the specified span. The text before and after the match keeps its formatting.- Parameters:
attributedText- the AttributedText that replaces the matched text.- Returns:
- true if the text was replaced.
-
replace
Replaces the matched text with the specified spans.- Parameters:
attributedTexts- the AttributedText objects that replace the matched text.- Returns:
- true if the text was replaced.
-
replaceContent
Replaces the matched text with the specified paragraph content, for example an image, a tab, a line break, a field or a hyperlink.- Parameters:
content- the content that replaces the matched text.- Returns:
- true if the text was replaced.
-
replace
Replaces the paragraph containing the match with the specified paragraph. The properties of the replaced paragraph are preserved if the new paragraph has no own properties and FindOptions.isPreserveFormatting() is true.- Parameters:
paragraph- the Paragraph that replaces the paragraph containing the match.- Returns:
- true if the paragraph was replaced.
-
replace
Replaces the heading containing the match with the specified heading.- Parameters:
heading- the Heading that replaces the heading containing the match.- Returns:
- true if the heading was replaced.
-
delete
public boolean delete()Deletes the matched text.- Returns:
- true if the text was deleted.
-
toString
Returns a string that represents the current FindResult. -
getElement
Gets the first content element of the match, usually a Text object.- Returns:
- the first content element of the match.
-
getText
Gets the matched text.- Returns:
- the matched text.
-
getTextHost
Gets the Paragraph or the Heading the match belongs to.- Returns:
- the Paragraph or the Heading the match belongs to.
-
getParagraph
Gets the paragraph the match belongs to or null if the match belongs to a heading.- Returns:
- the paragraph the match belongs to.
-
getHeading
Gets the heading the match belongs to or null if the match belongs to a paragraph.- Returns:
- the heading the match belongs to.
-
getAttributedText
Gets the innermost span the match starts in or null if the matched text is not contained in a span.- Returns:
- the innermost span the match starts in.
-
getAttributedTexts
Gets all spans the match spans.- Returns:
- all spans the match spans.
-
getStart
public int getStart()Gets the index of the match in the text of the paragraph.- Returns:
- the index of the match in the text of the paragraph.
-
getLength
public int getLength()Gets the number of matched characters.- Returns:
- the number of matched characters.
-
getStory
Gets the part of the document the match was found in.- Returns:
- the part of the document the match was found in.
-