Package com.independentsoft.office.odf

# Class FindResult

java.lang.Object
com.independentsoft.office.odf.FindResult

public class FindResult extends Object
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 Type
  Method
  Description
  `boolean`
  `delete()`
  Deletes the matched text.
  `AttributedText`
  `getAttributedText()`
  Gets the innermost span the match starts in or null if the matched text is not contained in a span.
  `List<AttributedText>`
  `getAttributedTexts()`
  Gets all spans the match spans.
  `IContentElement`
  `getElement()`
  Gets the first content element of the match, usually a Text object.
  `Heading`
  `getHeading()`
  Gets the heading the match belongs to or null if the match belongs to a paragraph.
  `int`
  `getLength()`
  Gets the number of matched characters.
  `Paragraph`
  `getParagraph()`
  Gets the paragraph the match belongs to or null if the match belongs to a heading.
  `int`
  `getStart()`
  Gets the index of the match in the text of the paragraph.
  `ContentStory`
  `getStory()`
  Gets the part of the document the match was found in.
  `String`
  `getText()`
  Gets the matched text.
  `IContentElement`
  `getTextHost()`
  Gets the Paragraph or the Heading the match belongs to.
  `boolean`
  `replace​(AttributedText attributedText)`
  Replaces the matched text with the specified span.
  `boolean`
  `replace​(Heading heading)`
  Replaces the heading containing the match with the specified heading.
  `boolean`
  `replace​(Paragraph paragraph)`
  Replaces the paragraph containing the match with the specified paragraph.
  `boolean`
  `replace​(String newText)`
  Replaces the matched text with the specified text.
  `boolean`
  `replace​(List<AttributedText> attributedTexts)`
  Replaces the matched text with the specified spans.
  `boolean`
  `replaceContent​(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.
  `String`
  `toString()`
  Returns a string that represents the current FindResult.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Method Details

  - ### replace

    public boolean replace​(String newText)
    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

    public boolean replace​(AttributedText attributedText)
    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

    public boolean replace​(List<AttributedText> attributedTexts)
    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

    public boolean replaceContent​(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.
    Parameters:
      `content` - the content that replaces the matched text.
    Returns:
      true if the text was replaced.

  - ### replace

    public boolean replace​(Paragraph paragraph)
    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

    public boolean replace​(Heading heading)
    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

    public String toString()
    Returns a string that represents the current FindResult.
    Overrides:
      `toString` in class `Object`
    Returns:
      A string that represents the current FindResult.

  - ### getElement

    public IContentElement getElement()
    Gets the first content element of the match, usually a Text object.
    Returns:
      the first content element of the match.

  - ### getText

    public String getText()
    Gets the matched text.
    Returns:
      the matched text.

  - ### getTextHost

    public IContentElement getTextHost()
    Gets the Paragraph or the Heading the match belongs to.
    Returns:
      the Paragraph or the Heading the match belongs to.

  - ### getParagraph

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

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

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

    public List<AttributedText> 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

    public ContentStory getStory()
    Gets the part of the document the match was found in.
    Returns:
      the part of the document the match was found in.