1 19 20 21 package com.sslexplorer.language; 22 23 24 25 import java.io.IOException ; 26 27 import java.io.InputStream ; 28 29 import java.net.URL ; 30 31 import java.util.Properties ; 32 33 34 35 90 91 public class LanguageCategory { 92 93 94 95 100 101 public final static String NAME_KEY = "sslexplorer.resourceBundle.name"; 102 103 104 105 110 111 public final static String DESCRIPTION_KEY = "sslexplorer.resourceBundle.description"; 112 113 114 115 120 121 public final static String LOCATION_KEY = "sslexplorer.resourceBundle.location"; 122 123 124 125 130 131 public final static String EXTENSION_ID_KEY = "sslexplorer.resourceBundle.extensionId"; 132 133 134 135 140 141 public final static String EXTENSION_CORE = "core"; 142 143 144 145 150 151 public final static int LOCATION_CORE = 0; 152 153 154 155 160 161 public final static int LOCATION_AGENT = 1; 162 163 164 165 170 171 public final static int LOCATION_LAUNCHER = 2; 172 173 174 175 177 private String id; 178 179 private String name; 180 181 private String description; 182 183 private String extensionId; 184 185 private URL base; 186 187 private String path; 188 189 private int location; 190 191 192 193 212 213 public LanguageCategory(InputStream in, URL base, String path, String id) throws IOException { 214 215 Properties resources = new Properties (); 216 217 resources.load(in); 218 219 name = resources.getProperty(LanguageCategory.NAME_KEY, id); 220 221 description = resources.getProperty(LanguageCategory.DESCRIPTION_KEY, id); 222 223 extensionId = resources.getProperty(LanguageCategory.EXTENSION_ID_KEY, EXTENSION_CORE); 224 225 try { 226 227 location = Integer.parseInt(resources.getProperty(LanguageCategory.LOCATION_KEY, String.valueOf(LanguageCategory.LOCATION_CORE))); 228 229 } 230 231 catch(NumberFormatException nfe) { 232 233 location = LanguageCategory.LOCATION_CORE; 234 235 } 236 237 this.base = base; 238 239 this.path = path; 240 241 this.id = id; 242 243 } 244 245 246 247 268 269 public LanguageCategory(URL base, String path, String id, String name, String description, String extensionId, int location) { 270 271 super(); 272 273 this.base = base; 274 275 this.path = path; 276 277 this.id = id; 278 279 this.name = name; 280 281 this.description = description; 282 283 this.extensionId = extensionId; 284 285 this.location = location; 286 287 } 288 289 290 291 302 303 public int getLocation() { 304 305 return location; 306 307 } 308 309 310 311 324 325 public void setLocation(int location) { 326 327 if(location == LOCATION_CORE || location == LOCATION_AGENT || location == LOCATION_LAUNCHER) { 328 329 this.location = location; 330 331 } 332 333 else { 334 335 throw new IllegalArgumentException ("Illegal location: "+ location); 336 337 } 338 339 } 340 341 342 343 352 353 public String getDescription() { 354 355 return description; 356 357 } 358 359 360 361 370 371 public void setDescription(String description) { 372 373 this.description = description; 374 375 } 376 377 378 379 390 391 public String getId() { 392 393 return id; 394 395 } 396 397 398 399 410 411 public void setId(String id) { 412 413 this.id = id; 414 415 } 416 417 418 419 428 429 public String getName() { 430 431 return name; 432 433 } 434 435 436 437 446 447 public void setName(String name) { 448 449 this.name = name; 450 451 } 452 453 454 455 468 469 public URL getBase() { 470 471 return base; 472 473 } 474 475 476 477 490 491 public void setBase(URL base) { 492 493 this.base = base; 494 495 } 496 497 498 499 514 515 public String getPath() { 516 517 return path; 518 519 } 520 521 522 523 524 525 540 541 public void setPath(String path) { 542 543 this.path = path; 544 545 } 546 547 548 549 550 551 566 567 public String getExtensionId() { 568 569 return extensionId; 570 571 } 572 573 574 575 576 577 592 593 public void setExtensionId(String extensionId) { 594 595 this.extensionId = extensionId; 596 597 } 598 599 600 601 602 603 } 604 605 | Popular Tags |