001: /*******************************************************************************
002: * Copyright (c) 2000, 2007 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM - Initial API and implementation
010: *******************************************************************************/package org.eclipse.pde.internal.build.tasks;
011:
012: public class Config {
013:
014: public static String ANY = "*"; //$NON-NLS-1$
015: private String ws;
016: private String os;
017: private String arch;
018:
019: private static Config genericConfig; //singleton
020:
021: public Config(String os, String ws, String arch) {
022: this .ws = ws;
023: this .os = os;
024: this .arch = arch;
025: }
026:
027: public Config(String[] config) {
028: this (config[0], config[1], config[2]);
029: }
030:
031: public String getArch() {
032: return arch;
033: }
034:
035: public String getOs() {
036: return os;
037: }
038:
039: public String getWs() {
040: return ws;
041: }
042:
043: public boolean equals(Object config) {
044: if (this == config)
045: return true;
046:
047: if (!(config instanceof Config))
048: return false;
049:
050: Config aConfig = (Config) config;
051: if (!os.equalsIgnoreCase(aConfig.os))
052: return false;
053:
054: if (!ws.equalsIgnoreCase(aConfig.ws))
055: return false;
056:
057: if (!arch.equalsIgnoreCase(aConfig.arch))
058: return false;
059:
060: return true;
061: }
062:
063: public int hashCode() {
064: return os.hashCode() + ws.hashCode() + arch.hashCode();
065: }
066:
067: public String toString() {
068: return toString("_"); //$NON-NLS-1$
069: }
070:
071: public String toString(String separator) {
072: return os + separator + ws + separator + arch;
073: }
074:
075: public String toStringReplacingAny(String separator, String value) {
076: if (value == null) {
077: return ""; //$NON-NLS-1$
078: }
079:
080: String newOs = os;
081: String newWs = ws;
082: String newArch = arch;
083:
084: if (os == ANY)
085: newOs = value;
086: if (ws == ANY)
087: newWs = value;
088: if (arch == ANY)
089: newArch = value;
090:
091: return newOs + separator + newWs + separator + newArch;
092: }
093:
094: public static Config genericConfig() {
095: if (genericConfig == null)
096: genericConfig = new Config(ANY, ANY, ANY);
097:
098: return genericConfig;
099: }
100:
101: }
|