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.util; 26 27 28 29 30 /*** 31 * 32 * 33 * @author Murali Krishnan 34 * 35 */ 36 public class ReplaceQueryResult { 37 38 //------------------------------------------------------------ 39 //- Class Variables 40 41 private static final int RESPONSE_YES = 0; 42 private static final int RESPONSE_YES_ALL = 1; 43 private static final int RESPONSE_NO = 2; 44 private static final int RESPONSE_NO_ALL = 3; 45 46 47 48 //------------------------------------------------------------ 49 //- Class Functions 50 51 public static ReplaceQueryResult yesThis() { 52 return new ReplaceQueryResult(RESPONSE_YES); 53 } 54 55 public static ReplaceQueryResult yesAll() { 56 return new ReplaceQueryResult(RESPONSE_YES_ALL); 57 } 58 59 public static ReplaceQueryResult noThis() { 60 return new ReplaceQueryResult(RESPONSE_NO); 61 } 62 63 public static ReplaceQueryResult noAll() { 64 return new ReplaceQueryResult(RESPONSE_NO_ALL); 65 } 66 67 68 //------------------------------------------------------------ 69 //- Instance Variables 70 71 private int vValue = RESPONSE_YES; 72 73 74 //------------------------------------------------------------ 75 //- Constructors 76 77 public ReplaceQueryResult(int pValue) { 78 vValue = pValue; 79 } 80 81 82 83 //------------------------------------------------------------ 84 //- Accessors 85 86 protected int getValue() { 87 return vValue; 88 } 89 90 91 92 //------------------------------------------------------------ 93 //- Settors 94 95 96 97 //------------------------------------------------------------ 98 //- Private/Protected Utility Functions 99 100 101 102 //------------------------------------------------------------ 103 //- Public Interface Functions 104 105 public boolean doFixThis() { 106 boolean result = (getValue() == RESPONSE_YES) || 107 (getValue() == RESPONSE_YES_ALL); 108 return result; 109 } 110 111 public boolean doFixAll() { 112 boolean result = (getValue() == RESPONSE_YES_ALL); 113 return result; 114 } 115 116 public boolean doSkipThis() { 117 boolean result = (getValue() == RESPONSE_NO) || 118 (getValue() == RESPONSE_NO_ALL); 119 return result; 120 } 121 122 public boolean doSkipAll() { 123 boolean result = (getValue() == RESPONSE_NO_ALL); 124 return result; 125 } 126 127 128 public String toString() { 129 String result = "Response[" + getValue() + "]"; 130 return result; 131 } 132 133 134 135 //------------------------------------------------------------ 136 //- Class Interface Functions 137 138 139 140 //------------------------------------------------------------ 141 //- Inner Classes 142 143 144 145 //------------------------------------------------------------ 146 //- Main 147 148 149 150 }