1 /*
2 * Scope: a generic MVC framework.
3 * Copyright (c) 2000-2002, The Scope team
4 * All rights reserved.
5 *
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 *
14 * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * Neither the name "Scope" nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *
35 *
36 * $Id: BasicModelChangeEvent.java,v 1.4 2002/09/05 15:41:46 ludovicc Exp $
37 */
38 package org.scopemvc.model.basic;
39
40
41 import org.scopemvc.core.ModelChangeEvent;
42 import org.scopemvc.core.ModelChangeEventSource;
43 import org.scopemvc.core.Selector;
44
45 /***
46 * <P>
47 *
48 * Concrete implementation of {@link org.scopemvc.core.ModelChangeEvent
49 * ModelChangeEvent}. </P>
50 *
51 * @author <A HREF="mailto:smeyfroi@users.sourceforge.net">Steve Meyfroidt</A>
52 * @created 05 August 2002
53 * @version $Revision: 1.4 $ $Date: 2002/09/05 15:41:46 $
54 */
55 public final class BasicModelChangeEvent implements ModelChangeEvent {
56
57 /***
58 * The type of change. Initialised to VALUE_CHANGED.
59 *
60 * @see org.scopemvc.core.ModelChangeTypes
61 */
62 private int type = VALUE_CHANGED;
63
64 /***
65 * Source Model of this event.
66 */
67 private ModelChangeEventSource model;
68
69 /***
70 * Property of the source Model that caused this event.
71 */
72 private Selector propertySelector;
73
74
75 /***
76 * Constructor for the BasicModelChangeEvent object
77 */
78 public BasicModelChangeEvent() { }
79
80
81 /***
82 * Gets the type
83 *
84 * @return The type value
85 */
86 public int getType() {
87 return type;
88 }
89
90
91 /***
92 * Gets the model
93 *
94 * @return The model value
95 */
96 public ModelChangeEventSource getModel() {
97 return model;
98 }
99
100
101 /***
102 * Gets the selector
103 *
104 * @return The selector value
105 */
106 public Selector getSelector() {
107 return propertySelector;
108 }
109
110
111 /***
112 * Sets the type
113 *
114 * @param inType The new type value
115 */
116 public void setType(int inType) {
117 if (!(type == VALUE_CHANGED
118 || type == VALUE_ADDED
119 || type == VALUE_REMOVED
120 || type == ACCESS_CHANGED)) {
121 throw new IllegalArgumentException("Illegal ModelChangeEvent type: " + inType);
122 }
123
124 type = inType;
125 }
126
127
128 /***
129 * Sets the model
130 *
131 * @param inModel The new model value
132 */
133 public void setModel(ModelChangeEventSource inModel) {
134 if (inModel == null) {
135 throw new IllegalArgumentException("Can't set a null model source for a BasicModelChangeEvent.");
136 }
137
138 model = inModel;
139 }
140
141
142 /***
143 * Sets the selector
144 *
145 * @param inSelector The new selector value
146 */
147 public void setSelector(Selector inSelector) {
148 propertySelector = inSelector;
149 }
150
151
152 /***
153 * Returns a string representation of this object
154 *
155 * @return a string representation of this object
156 */
157 public String toString() {
158 StringBuffer result = new StringBuffer("BasicModelChangeEvent(type:");
159 if (type == VALUE_CHANGED) {
160 result.append("VALUE_CHANGED");
161 } else if (type == VALUE_ADDED) {
162 result.append("VALUE_ADDED");
163 } else if (type == VALUE_REMOVED) {
164 result.append("VALUE_REMOVED");
165 } else if (type == ACCESS_CHANGED) {
166 result.append("ACCESS_CHANGED");
167 }
168 result.append(")(Model:" + model + ")(" + propertySelector + ")");
169 return result.toString();
170 }
171 }
172
This page was automatically generated by Maven