1 11 package org.eclipse.pde.internal.build; 12 13 public class Config { 14 15 public static String ANY = "*"; private String ws; 17 private String os; 18 private String arch; 19 20 private static Config genericConfig; 22 public Config(String os, String ws, String arch) { 23 this.ws = ws; 24 this.os = os; 25 this.arch = arch; 26 } 27 28 public Config(String [] config) { 29 this(config[0], config[1], config[2]); 30 } 31 32 public Config(String config) { 33 this(Utils.getArrayFromStringWithBlank(config, ",")); } 35 36 public String getArch() { 37 return arch; 38 } 39 40 public String getOs() { 41 return os; 42 } 43 44 public String getWs() { 45 return ws; 46 } 47 48 public boolean equals(Object config) { 49 if (this == config) 50 return true; 51 52 if (!(config instanceof Config)) 53 return false; 54 55 Config aConfig = (Config) config; 56 if (!os.equalsIgnoreCase(aConfig.os)) 57 return false; 58 59 if (!ws.equalsIgnoreCase(aConfig.ws)) 60 return false; 61 62 if (!arch.equalsIgnoreCase(aConfig.arch)) 63 return false; 64 65 return true; 66 } 67 68 public int hashCode() { 69 return os.hashCode() + ws.hashCode() + arch.hashCode(); 70 } 71 72 public String toString() { 73 return toString("_"); } 75 76 public String toString(String separator) { 77 return os + separator + ws + separator + arch; 78 } 79 80 public String toStringReplacingAny(String separator, String value) { 81 if (value == null) { 82 return ""; } 84 85 String newOs = os; 86 String newWs = ws; 87 String newArch = arch; 88 89 if (os == ANY) 90 newOs = value; 91 if (ws == ANY) 92 newWs = value; 93 if (arch == ANY) 94 newArch = value; 95 96 return newOs + separator + newWs + separator + newArch; 97 } 98 99 public static Config genericConfig() { 100 if (genericConfig == null) 101 genericConfig = new Config(ANY, ANY, ANY); 102 103 return genericConfig; 104 } 105 106 } 107 | Popular Tags |