01: /*
02: * Copyright 2001-2006 C:1 Financial Services GmbH
03: *
04: * This software is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License Version 2.1, as published by the Free Software Foundation.
07: *
08: * This software is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11: * Lesser General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public
14: * License along with this library; if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16: */
17:
18: package de.finix.contelligent.client.gui;
19:
20: import java.util.ArrayList;
21: import java.util.List;
22: import java.util.StringTokenizer;
23:
24: public class GUIDescription {
25: private String guiImpl;
26:
27: private String configuration;
28:
29: public GUIDescription(String guiImpl) {
30: this .guiImpl = guiImpl;
31: }
32:
33: public GUIDescription(String guiImpl, String configuration) {
34: this .guiImpl = guiImpl;
35: this .configuration = configuration;
36: }
37:
38: public String getGuiImpl() {
39: return guiImpl;
40: }
41:
42: public String getConfiguration() {
43: return configuration;
44: }
45:
46: // For backward-compatibility
47: public static GUIModification[] convertEnumerationToModifications(
48: String enumeration) {
49: List<GUIModification> modifications = new ArrayList<GUIModification>();
50: StringTokenizer tokenizer = new StringTokenizer(enumeration,
51: ",");
52: int tokens = tokenizer.countTokens();
53: for (int i = 0; i < tokens; i++) {
54: String gui = tokenizer.nextToken().trim();
55: int command;
56: if (gui.startsWith("-")) {
57: command = GUIModification.REMOVE;
58: String guiImpl = gui.substring(1);
59: modifications.add(new GUIModification(command,
60: new GUIDescription(guiImpl)));
61: } else if (gui.startsWith("+")) {
62: command = GUIModification.ADD;
63: String guiImpl = gui.substring(1);
64: modifications.add(new GUIModification(command,
65: new GUIDescription(guiImpl)));
66: } else {
67: command = GUIModification.REPLACE;
68: modifications.add(new GUIModification(command,
69: new GUIDescription(gui)));
70: }
71: }
72: return (GUIModification[]) modifications
73: .toArray(new GUIModification[0]);
74: }
75:
76: public boolean equals(Object o) {
77: if (o instanceof GUIDescription) {
78: String oGuiImpl = ((GUIDescription) o).getGuiImpl();
79: if (oGuiImpl != null) {
80: return (oGuiImpl.equals(this .getGuiImpl()));
81: } else {
82: return false;
83: }
84: } else {
85: return false;
86: }
87: }
88:
89: public int hashCode() {
90: return -1;
91: }
92:
93: }
|