View Javadoc

1   /*
2    * Fsgrep is a simple Java application which allows a user to
3    * search all files in a directory structure for lines matching
4    * a given pattern.  Its functionality is a combination of the
5    * Unix 'find' and 'grep' utilities.
6    * Visit [http://fsgrep.sourceforge.net/] for more information.
7    * 
8    * Copyright (C) 2003-2006 Murali Krishnan [murali_ca_us@users.sourceforge.net]
9    * 
10   * Fsgrep is free software; you can redistribute it and/or modify
11   * it under the terms of version 2 of the GNU General Public
12   * License as published by the Free Software Foundation.
13   * 
14   * Fsgrep is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Public License for more details.
18   * 
19   * You should have received a copy of the GNU General Public License
20   * along with Fsgrep (see the file named LICENSE.txt); if not, write
21   * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22   * Boston, MA  02111-1307  USA
23   */
24  
25  package mk.fsgrep;
26  
27  
28  
29  
30  /***
31   * 
32   * 
33   * @author  Murali Krishnan
34   *
35   */
36  abstract class Action {
37  
38      //------------------------------------------------------------
39      //- Class Variables
40  
41  
42  
43      //------------------------------------------------------------
44      //- Class Functions
45  
46  
47  
48      //------------------------------------------------------------
49      //- Instance Variables
50  
51      private Fsgrep _model = null;
52  
53  
54      //------------------------------------------------------------
55      //- Constructors
56  
57  
58  
59      //------------------------------------------------------------
60      //- Accessors
61  
62      protected Fsgrep getModel() {return _model;}
63  
64  
65      //------------------------------------------------------------
66      //- Settors
67  
68      protected void setModel(Fsgrep val) {_model=val;}
69  
70  
71      //------------------------------------------------------------
72      //- Private/Protected Utility Functions
73  
74  
75  
76      //------------------------------------------------------------
77      //- Public Interface Functions
78  
79  
80  
81      //------------------------------------------------------------
82      //- Class Interface Functions
83  
84      protected abstract void execute();
85  
86  
87      public boolean isSearch() {return false;}
88  
89  
90  
91      //------------------------------------------------------------
92      //- Inner Classes
93  
94      static class Undefined extends Action {
95          protected void execute() {
96              System.out.println("No action defined.");
97          }
98      }
99  
100 
101     static class Search extends Action {
102         protected void execute() {
103             getModel().searchForPattern();
104         }
105 
106 
107         public boolean isSearch() {return true;}
108     }
109 
110 
111     static class Replace extends Action {
112         protected void execute() {
113             getModel().replacePattern();
114         }
115     }
116 
117 
118     static class ListFiles extends Action {
119         protected void execute() {
120             getModel().listFiles();
121         }
122     }
123 
124 
125     static class Rescan extends Action {
126         protected void execute() {
127             getModel().getFinder().reset();
128             getModel().prepare();
129         }
130     }
131 
132 
133     //------------------------------------------------------------
134     //- Main
135 
136 
137 
138 }