Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.gjt.sp.jedit.search
Class SearchAndReplace  view SearchAndReplace download SearchAndReplace.java

java.lang.Object
  extended byorg.gjt.sp.jedit.search.SearchAndReplace

public class SearchAndReplace
extends java.lang.Object

Class that implements regular expression and literal search within jEdit buffers.

There are two main groups of methods in this class:

The "HyperSearch" and "Keep dialog" features, as reflected in checkbox options in the search dialog, are not handled from within this class. If you wish to have these options set before the search dialog appears, make a prior call to either or both of the following:
 jEdit.setBooleanProperty("search.hypersearch.toggle",true);
 jEdit.setBooleanProperty("search.keepDialog.toggle",true);
If you are not using the dialog to undertake a search or replace, you may call any of the search and replace methods (including hyperSearch(View) 55 ) without concern for the value of these properties.

Version:
$Id: SearchAndReplace.java,v 1.57 2003/10/10 23:46:24 spestov Exp $

Field Summary
private static boolean beanshell
           
private static SearchFileSet fileset
           
private static boolean ignoreCase
           
private static SearchMatcher matcher
           
private static boolean regexp
           
private static java.lang.String replace
           
private static bsh.BshMethod replaceMethod
           
private static bsh.NameSpace replaceNS
           
private static boolean reverse
           
private static java.lang.String search
           
private static boolean wrap
           
 
Constructor Summary
SearchAndReplace()
           
 
Method Summary
private static java.lang.String _replace(SearchMatcher.Match occur, java.lang.String found)
           
private static int _replace(org.gjt.sp.jedit.View view, org.gjt.sp.jedit.Buffer buffer, SearchMatcher matcher, int start, int end, boolean smartCaseReplace)
          Replaces all occurances of the search string with the replacement string.
static boolean find(org.gjt.sp.jedit.View view)
          Finds the next occurance of the search string.
static boolean find(org.gjt.sp.jedit.View view, org.gjt.sp.jedit.Buffer buffer, int start)
          Finds the next instance of the search string in the specified buffer.
static boolean find(org.gjt.sp.jedit.View view, org.gjt.sp.jedit.Buffer buffer, int start, boolean firstTime, boolean reverse)
          Finds the next instance of the search string in the specified buffer.
static boolean getAutoWrapAround()
          Returns the state of the auto wrap around flag.
static boolean getBeanShellReplace()
          Returns the state of the BeanShell replace flag.
private static int getColumnOnOtherLine(org.gjt.sp.jedit.Buffer buffer, int line, int col)
          Should be somewhere else...
static boolean getIgnoreCase()
          Returns the state of the ignore case flag.
static boolean getRegexp()
          Returns the state of the regular expression flag.
static java.lang.String getReplaceString()
          Returns the current replacement string.
static boolean getReverseSearch()
          Returns the state of the reverse search flag.
static SearchFileSet getSearchFileSet()
          Returns the current search file set.
static SearchMatcher getSearchMatcher()
          Returns the current search string matcher.
static java.lang.String getSearchString()
          Returns the current search string.
static boolean hyperSearch(org.gjt.sp.jedit.View view)
          Performs a HyperSearch.
static boolean hyperSearch(org.gjt.sp.jedit.View view, boolean selection)
          Performs a HyperSearch.
private static void initReplace()
          Set up BeanShell replace if necessary.
static void load()
          Loads search and replace state from the properties.
private static void record(org.gjt.sp.jedit.View view, java.lang.String action, boolean replaceAction, boolean recordFileSet)
           
static boolean replace(org.gjt.sp.jedit.View view)
          Replaces the current selection with the replacement string.
static boolean replace(org.gjt.sp.jedit.View view, org.gjt.sp.jedit.Buffer buffer, int start, int end)
          Replaces text in the specified range with the replacement string.
static boolean replaceAll(org.gjt.sp.jedit.View view)
          Replaces all occurances of the search string with the replacement string.
static void save()
          Saves search and replace state to the properties.
static void setAutoWrapAround(boolean wrap)
          Sets the state of the auto wrap around flag.
static void setBeanShellReplace(boolean beanshell)
          Sets the state of the BeanShell replace flag.
static void setIgnoreCase(boolean ignoreCase)
          Sets the ignore case flag.
static void setRegexp(boolean regexp)
          Sets the state of the regular expression flag.
static void setReplaceString(java.lang.String replace)
          Sets the current replacement string.
static void setReverseSearch(boolean reverse)
          Determines whether a reverse search will conducted from the current position to the beginning of a buffer.
static void setSearchFileSet(SearchFileSet fileset)
          Sets the current search file set.
static void setSearchMatcher(SearchMatcher matcher)
          Sets a custom search string matcher.
static void setSearchString(java.lang.String search)
          Sets the current search string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

search

private static java.lang.String search

replace

private static java.lang.String replace

replaceMethod

private static bsh.BshMethod replaceMethod

replaceNS

private static bsh.NameSpace replaceNS

regexp

private static boolean regexp

ignoreCase

private static boolean ignoreCase

reverse

private static boolean reverse

beanshell

private static boolean beanshell

wrap

private static boolean wrap

matcher

private static SearchMatcher matcher

fileset

private static SearchFileSet fileset
Constructor Detail

SearchAndReplace

public SearchAndReplace()
Method Detail

setSearchString

public static void setSearchString(java.lang.String search)
Sets the current search string.


getSearchString

public static java.lang.String getSearchString()
Returns the current search string.


setReplaceString

public static void setReplaceString(java.lang.String replace)
Sets the current replacement string.


getReplaceString

public static java.lang.String getReplaceString()
Returns the current replacement string.


setIgnoreCase

public static void setIgnoreCase(boolean ignoreCase)
Sets the ignore case flag.


getIgnoreCase

public static boolean getIgnoreCase()
Returns the state of the ignore case flag.


setRegexp

public static void setRegexp(boolean regexp)
Sets the state of the regular expression flag.


getRegexp

public static boolean getRegexp()
Returns the state of the regular expression flag.


setReverseSearch

public static void setReverseSearch(boolean reverse)
Determines whether a reverse search will conducted from the current position to the beginning of a buffer. Note that reverse search and regular expression search is mutually exclusive; enabling one will disable the other.


getReverseSearch

public static boolean getReverseSearch()
Returns the state of the reverse search flag.


setBeanShellReplace

public static void setBeanShellReplace(boolean beanshell)
Sets the state of the BeanShell replace flag.

Since:
jEdit 3.2pre2

getBeanShellReplace

public static boolean getBeanShellReplace()
Returns the state of the BeanShell replace flag.

Since:
jEdit 3.2pre2

setAutoWrapAround

public static void setAutoWrapAround(boolean wrap)
Sets the state of the auto wrap around flag.

Since:
jEdit 3.2pre2

getAutoWrapAround

public static boolean getAutoWrapAround()
Returns the state of the auto wrap around flag.

Since:
jEdit 3.2pre2

setSearchMatcher

public static void setSearchMatcher(SearchMatcher matcher)
Sets a custom search string matcher. Note that calling setSearchString(String) 55 , setIgnoreCase(boolean) 55 , or setRegexp(boolean) 55 will reset the matcher to the default.


getSearchMatcher

public static SearchMatcher getSearchMatcher()
                                      throws java.lang.Exception
Returns the current search string matcher.

Since:
jEdit 4.1pre7

setSearchFileSet

public static void setSearchFileSet(SearchFileSet fileset)
Sets the current search file set.


getSearchFileSet

public static SearchFileSet getSearchFileSet()
Returns the current search file set.


hyperSearch

public static boolean hyperSearch(org.gjt.sp.jedit.View view)
Performs a HyperSearch.

Since:
jEdit 2.7pre3

hyperSearch

public static boolean hyperSearch(org.gjt.sp.jedit.View view,
                                  boolean selection)
Performs a HyperSearch.

Since:
jEdit 4.0pre1

find

public static boolean find(org.gjt.sp.jedit.View view)
Finds the next occurance of the search string.


find

public static boolean find(org.gjt.sp.jedit.View view,
                           org.gjt.sp.jedit.Buffer buffer,
                           int start)
                    throws java.lang.Exception
Finds the next instance of the search string in the specified buffer.


find

public static boolean find(org.gjt.sp.jedit.View view,
                           org.gjt.sp.jedit.Buffer buffer,
                           int start,
                           boolean firstTime,
                           boolean reverse)
                    throws java.lang.Exception
Finds the next instance of the search string in the specified buffer.

Since:
jEdit 4.1pre7

replace

public static boolean replace(org.gjt.sp.jedit.View view)
Replaces the current selection with the replacement string.


replace

public static boolean replace(org.gjt.sp.jedit.View view,
                              org.gjt.sp.jedit.Buffer buffer,
                              int start,
                              int end)
Replaces text in the specified range with the replacement string.


replaceAll

public static boolean replaceAll(org.gjt.sp.jedit.View view)
Replaces all occurances of the search string with the replacement string.


load

public static void load()
Loads search and replace state from the properties.


save

public static void save()
Saves search and replace state to the properties.


initReplace

private static void initReplace()
                         throws java.lang.Exception
Set up BeanShell replace if necessary.


record

private static void record(org.gjt.sp.jedit.View view,
                           java.lang.String action,
                           boolean replaceAction,
                           boolean recordFileSet)

_replace

private static int _replace(org.gjt.sp.jedit.View view,
                            org.gjt.sp.jedit.Buffer buffer,
                            SearchMatcher matcher,
                            int start,
                            int end,
                            boolean smartCaseReplace)
                     throws java.lang.Exception
Replaces all occurances of the search string with the replacement string.


_replace

private static java.lang.String _replace(SearchMatcher.Match occur,
                                         java.lang.String found)
                                  throws java.lang.Exception

getColumnOnOtherLine

private static int getColumnOnOtherLine(org.gjt.sp.jedit.Buffer buffer,
                                        int line,
                                        int col)
Should be somewhere else...