KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > build > tasks > Config


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM - Initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.build.tasks;
12
13 public class Config {
14
15     public static String JavaDoc ANY = "*"; //$NON-NLS-1$
16
private String JavaDoc ws;
17     private String JavaDoc os;
18     private String JavaDoc arch;
19
20     private static Config genericConfig; //singleton
21

22     public Config(String JavaDoc os, String JavaDoc ws, String JavaDoc arch) {
23         this.ws = ws;
24         this.os = os;
25         this.arch = arch;
26     }
27
28     public Config(String JavaDoc[] config) {
29         this(config[0], config[1], config[2]);
30     }
31
32     public String JavaDoc getArch() {
33         return arch;
34     }
35
36     public String JavaDoc getOs() {
37         return os;
38     }
39
40     public String JavaDoc getWs() {
41         return ws;
42     }
43
44     public boolean equals(Object JavaDoc config) {
45         if (this == config)
46             return true;
47
48         if (!(config instanceof Config))
49             return false;
50
51         Config aConfig = (Config) config;
52         if (!os.equalsIgnoreCase(aConfig.os))
53             return false;
54
55         if (!ws.equalsIgnoreCase(aConfig.ws))
56             return false;
57
58         if (!arch.equalsIgnoreCase(aConfig.arch))
59             return false;
60
61         return true;
62     }
63
64     public int hashCode() {
65         return os.hashCode() + ws.hashCode() + arch.hashCode();
66     }
67
68     public String JavaDoc toString() {
69         return toString("_"); //$NON-NLS-1$
70
}
71
72     public String JavaDoc toString(String JavaDoc separator) {
73         return os + separator + ws + separator + arch;
74     }
75
76     public String JavaDoc toStringReplacingAny(String JavaDoc separator, String JavaDoc value) {
77         if (value == null) {
78             return ""; //$NON-NLS-1$
79
}
80
81         String JavaDoc newOs = os;
82         String JavaDoc newWs = ws;
83         String JavaDoc newArch = arch;
84
85         if (os == ANY)
86             newOs = value;
87         if (ws == ANY)
88             newWs = value;
89         if (arch == ANY)
90             newArch = value;
91
92         return newOs + separator + newWs + separator + newArch;
93     }
94
95     public static Config genericConfig() {
96         if (genericConfig == null)
97             genericConfig = new Config(ANY, ANY, ANY);
98
99         return genericConfig;
100     }
101
102 }
103
Popular Tags