@Override public String toString() { return "[SearchContext: " + "searchFor=" + getSearchFor() + ", replaceWith=" + getReplaceWith() + ", matchCase=" + getMatchCase() + ", wholeWord=" + getWholeWord() + ", regex=" + isRegularExpression() + ", markAll=" + getMarkAll() + "]"; }
String replacement = context.getReplaceWith(); if (replacement==null) { replacement = "";
String replacement = context.getReplaceWith(); textArea.replaceSelection(replacement);
@Test public void testClone() { String searchFor = "foo"; boolean matchCase = true; boolean markAll = false; boolean regex = true; String replaceWith = "bar"; boolean forward = false; boolean selectionOnly = false;//true; // "true" not yet supported boolean wholeWord = true; SearchContext sc = new SearchContext(searchFor, matchCase); sc.setMarkAll(markAll); sc.setRegularExpression(regex); sc.setReplaceWith(replaceWith); sc.setSearchForward(forward); sc.setSearchSelectionOnly(selectionOnly); sc.setWholeWord(wholeWord); SearchContext sc2 = sc.clone(); Assert.assertEquals(sc2.getSearchFor(), sc.getSearchFor()); Assert.assertEquals(sc2.getMatchCase(), sc.getMatchCase()); Assert.assertEquals(sc2.getMarkAll(), sc.getMarkAll()); Assert.assertEquals(sc2.isRegularExpression(), sc.isRegularExpression()); Assert.assertEquals(sc2.getReplaceWith(), sc.getReplaceWith()); Assert.assertEquals(sc2.getSearchForward(), sc.getSearchForward()); Assert.assertEquals(sc2.getSearchSelectionOnly(), sc.getSearchSelectionOnly()); Assert.assertEquals(sc2.getWholeWord(), sc.getWholeWord()); }
String expected = textArea.getText().replaceAll("(?i:" + context.getSearchFor() + ")", context.getReplaceWith()); int count = replaceAllImpl(context); assertEquals(4, count); expected = textArea.getText().replaceAll(context.getSearchFor(), context.getReplaceWith()); context.setMatchCase(true); context.setWholeWord(false); expected = textArea.getText().replaceAll("(?i:" + context.getSearchFor() + ")", context.getReplaceWith()); context.setMatchCase(false); context.setWholeWord(false); expected = textArea.getText().replaceAll(context.getSearchFor(), context.getReplaceWith()); context.setMatchCase(true); context.setWholeWord(false);
@Override public String toString() { return "[SearchContext: " + "searchFor=" + getSearchFor() + ", replaceWith=" + getReplaceWith() + ", matchCase=" + getMatchCase() + ", wholeWord=" + getWholeWord() + ", regex=" + isRegularExpression() + ", markAll=" + getMarkAll() + "]"; }
String expected = textArea.getText().replaceAll("(?i:" + context.getSearchFor() + ")", context.getReplaceWith()); textArea.setCaretPosition(offs); boolean found = replaceImpl(context); expected = textArea.getText().replaceAll(context.getSearchFor(), context.getReplaceWith()); context.setMatchCase(true); context.setWholeWord(false); expected = textArea.getText().replaceAll("(?i:" + context.getSearchFor() + ")", context.getReplaceWith()); context.setMatchCase(false); context.setWholeWord(false); expected = textArea.getText().replaceAll(context.getSearchFor(), context.getReplaceWith()); context.setMatchCase(true); context.setWholeWord(false);
String replacement = context.getReplaceWith(); if (replacement==null) { replacement = "";
String replacement = context.getReplaceWith(); textArea.replaceSelection(replacement);