com.aspose.words
Class ReplaceAction

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

public class ReplaceAction 
extends java.lang.Object

Utility class containing constants. Allows the user to specify what happens to the current match during a replace operation.

Example:

Shows how to insert content of one document into another during a customized find and replace operation.
public void insertDocumentAtReplace() throws Exception
{
    Document mainDoc = new Document(getMyDir() + "InsertDocument1.doc");
    mainDoc.getRange().replace(Pattern.compile("\\[MY_DOCUMENT\\]"), new InsertDocumentAtReplaceHandler(), false);
    mainDoc.save(getMyDir() + "InsertDocumentAtReplace Out.doc");
}

private class InsertDocumentAtReplaceHandler implements IReplacingCallback
{
    public int replacing(ReplacingArgs e) throws Exception
    {
        Document subDoc = new Document(getMyDir() + "InsertDocument2.doc");

        // Insert a document after the paragraph, containing the match text.
        Paragraph para = (Paragraph)e.getMatchNode().getParentNode();
        insertDocument(para, subDoc);

        // Remove the paragraph with the match text.
        para.remove();

        return ReplaceAction.SKIP;
    }
}
See Also:
IReplacingCallback, Range, Range.replace(java.lang.String,java.lang.String,boolean,boolean)

Field Summary
static final intREPLACE = 0
           Replace the current match.
static final intSKIP = 1
           Skip the current match.
static final intSTOP = 2
           Terminate the replace operation.
 

Field Detail

REPLACE = 0

public static final int REPLACE
Replace the current match.

SKIP = 1

public static final int SKIP
Skip the current match.

STOP = 2

public static final int STOP
Terminate the replace operation.

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