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.event;
19:
20: import java.io.Serializable;
21:
22: import de.finix.contelligent.Type;
23:
24: public class TypeEvent extends ContelligentEvent {
25:
26: public final static EventType CREATION = new EventType(
27: TYPE_CREATION_EVENT, "type creation");
28:
29: public final static EventType CHANGED = new EventType(
30: TYPE_CHANGED_EVENT, "type changed");
31:
32: public final static EventType DELETED = new EventType(
33: TYPE_DELETED_EVENT, "type deleted");
34:
35: private final EventType eventType;
36:
37: private final String typeName;
38:
39: private final transient Type type;
40:
41: public TypeEvent(EventType eventType, String origin, String typeName) {
42: super (eventType.id, origin);
43: this .eventType = eventType;
44: this .typeName = typeName;
45: this .type = null;
46: }
47:
48: public TypeEvent(EventType eventType, String origin, Type type) {
49: super (eventType.id, origin);
50: this .eventType = eventType;
51: this .type = type;
52: this .typeName = type.getName();
53: }
54:
55: public int getType() {
56: return eventType.id;
57: }
58:
59: public String toString() {
60: StringBuffer rs = new StringBuffer("[TypeEvent(");
61: rs.append(eventType).append(") typename=").append(typeName)
62: .append(" origin=").append(getOrigin()).append("]");
63: if (getInfo() != null) {
64: rs.append(getInfo());
65: }
66: return rs.toString();
67: }
68:
69: public String getTypeName() {
70: return typeName;
71: }
72:
73: public Type getTypeInstance() {
74: return type;
75: }
76:
77: protected void additionalXML(StringBuffer buf) {
78: buf.append("<component-type>").append(typeName).append(
79: "</component-type>\n");
80: }
81:
82: static final public class EventType implements Serializable {
83: final public int id;
84:
85: final public String idString;
86:
87: private EventType(int id, String idString) {
88: this .id = id;
89: this .idString = idString;
90: }
91:
92: public String toString() {
93: return idString;
94: }
95: }
96:
97: }
|