com.aspose.words
Class FindReplaceOptions

java.lang.Object
    extended by com.aspose.words.FindReplaceOptions

public class FindReplaceOptions 
extends java.lang.Object

Specifies options for find/replace operations.

Example:

Simple find and replace operation.
// Open the document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.writeln("Hello _CustomerName_,");

// Check the document contains what we are about to test.
System.out.println(doc.getFirstSection().getBody().getParagraphs().get(0).getText());

FindReplaceOptions options = new FindReplaceOptions();
options.setMatchCase(false);
options.setFindWholeWordsOnly(false);

// Replace the text in the document.
doc.getRange().replace("_CustomerName_", "James Bond", options);

// Save the modified document.
doc.save(getMyDir() + "\\Artifacts\\Range.ReplaceSimple.docx");

Constructor Summary
FindReplaceOptions()
          
FindReplaceOptions(int direction)
          
FindReplaceOptions(IReplacingCallback replacingCallback)
          
FindReplaceOptions(int direction, IReplacingCallback replacingCallback)
          
 
Property Getters/Setters Summary
FontgetApplyFont()
           Text formatting applied to new content.
ParagraphFormatgetApplyParagraphFormat()
           Paragraph formatting applied to new content.
intgetDirection()
voidsetDirection(int value)
           Selects direction for replace. Default value is FindReplaceDirection.FORWARD. The value of the property is FindReplaceDirection integer constant.
booleangetFindWholeWordsOnly()
voidsetFindWholeWordsOnly(boolean value)
           True indicates the oldValue must be a standalone word.
booleangetMatchCase()
voidsetMatchCase(boolean value)
           True indicates case-sensitive comparison, false indicates case-insensitive comparison.
booleangetPreserveMetaCharacters()
voidsetPreserveMetaCharacters(boolean value)
           True indicates that meta-characters beginning with "&" are preserved. Default value is false.
IReplacingCallbackgetReplacingCallback()
voidsetReplacingCallback(IReplacingCallback value)
           The user-defined method which is called before every replace occurrence.
 

Constructor Detail

FindReplaceOptions

public FindReplaceOptions()

FindReplaceOptions

public FindReplaceOptions(int direction)
Parameters:
direction - A FindReplaceDirection value.

FindReplaceOptions

public FindReplaceOptions(IReplacingCallback replacingCallback)

FindReplaceOptions

public FindReplaceOptions(int direction, IReplacingCallback replacingCallback)
Parameters:
direction - A FindReplaceDirection value.

Property Getters/Setters Detail

getApplyFont

public Font getApplyFont()
Text formatting applied to new content.

getApplyParagraphFormat

public ParagraphFormat getApplyParagraphFormat()
Paragraph formatting applied to new content.

getDirection/setDirection

public int getDirection() / public void setDirection(int value)
Selects direction for replace. Default value is FindReplaceDirection.FORWARD. The value of the property is FindReplaceDirection integer constant.

getFindWholeWordsOnly/setFindWholeWordsOnly

public boolean getFindWholeWordsOnly() / public void setFindWholeWordsOnly(boolean value)
True indicates the oldValue must be a standalone word.

Example:

Simple find and replace operation.
// Open the document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.writeln("Hello _CustomerName_,");

// Check the document contains what we are about to test.
System.out.println(doc.getFirstSection().getBody().getParagraphs().get(0).getText());

FindReplaceOptions options = new FindReplaceOptions();
options.setMatchCase(false);
options.setFindWholeWordsOnly(false);

// Replace the text in the document.
doc.getRange().replace("_CustomerName_", "James Bond", options);

// Save the modified document.
doc.save(getMyDir() + "\\Artifacts\\Range.ReplaceSimple.docx");

getMatchCase/setMatchCase

public boolean getMatchCase() / public void setMatchCase(boolean value)
True indicates case-sensitive comparison, false indicates case-insensitive comparison.

Example:

Simple find and replace operation.
// Open the document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.writeln("Hello _CustomerName_,");

// Check the document contains what we are about to test.
System.out.println(doc.getFirstSection().getBody().getParagraphs().get(0).getText());

FindReplaceOptions options = new FindReplaceOptions();
options.setMatchCase(false);
options.setFindWholeWordsOnly(false);

// Replace the text in the document.
doc.getRange().replace("_CustomerName_", "James Bond", options);

// Save the modified document.
doc.save(getMyDir() + "\\Artifacts\\Range.ReplaceSimple.docx");

getPreserveMetaCharacters/setPreserveMetaCharacters

public boolean getPreserveMetaCharacters() / public void setPreserveMetaCharacters(boolean value)
True indicates that meta-characters beginning with "&" are preserved. Default value is false.

getReplacingCallback/setReplacingCallback

public IReplacingCallback getReplacingCallback() / public void setReplacingCallback(IReplacingCallback value)
The user-defined method which is called before every replace occurrence.

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.