1 20 21 package org.jdesktop.jdic.filetypes; 22 23 24 36 public class Action { 37 38 45 private String description; 46 47 50 private String verb; 51 52 55 private String command; 56 57 60 private int hashcode = 0; 61 62 72 public Action(String verb, String command) { 73 this.verb = verb; 74 this.command = command; 75 } 76 77 84 public Action(String verb, String command, String desc) { 85 this.verb = verb; 86 this.command = command; 87 this.description = desc; 88 } 89 90 95 public String getDescription() { 96 return description; 97 } 98 99 107 public void setDescription(String description) { 108 this.description = description; 109 } 110 111 116 public String getVerb() { 117 return verb; 118 } 119 120 125 public void setVerb(String verb) { 126 this.verb = verb; 127 } 128 129 134 public String getCommand() { 135 return command; 136 } 137 138 143 public void setCommand(String command) { 144 this.command = command; 145 } 146 147 159 public boolean equals(Object otherObj) { 160 if (otherObj instanceof Action) { 161 Action otherAction = (Action) otherObj; 162 String otherDescription = otherAction.getDescription(); 163 String otherVerb = otherAction.getVerb(); 164 String otherCommand = otherAction.getCommand(); 165 166 if ((description == null 167 ? otherDescription == null 168 : description.equals(otherDescription)) 169 && (verb == null 170 ? otherVerb == null 171 : verb.equals(otherVerb)) 172 && (command == null 173 ? otherCommand == null 174 : command.equals(otherCommand))) { 175 return true; 176 } 177 } 178 return false; 179 } 180 181 188 public int hashCode() { 189 if (hashcode != 0) { 190 int result = 17; 191 if (this.description != null) { 192 result = 37 * result + this.description.hashCode(); 193 } 194 if (this.verb != null) { 195 result = 37 * result + this.verb.hashCode(); 196 } 197 if (this.command != null) { 198 result = 37 * result + this.command.hashCode(); 199 } 200 hashcode = result; 201 } 202 return hashcode; 203 } 204 205 213 public String toString() { 214 String crlfString = "\r\n"; 215 String content = ""; 216 String tabString = "\t"; 217 218 content = content.concat(tabString); 219 content = content.concat("Description: "); 220 if (this.description != null) { 221 content = content.concat(description); 222 } 223 content = content.concat(crlfString); 224 225 content = content.concat(tabString); 226 content = content.concat("Verb: "); 227 if (this.verb != null) { 228 content = content.concat(verb); 229 } 230 content = content.concat(crlfString); 231 232 content = content.concat(tabString); 233 content = content.concat("Command: "); 234 if (this.command != null) { 235 content = content.concat(command); 236 } 237 content = content.concat(crlfString); 238 239 return content; 240 } 241 } 242 | Popular Tags |