2-APL UPC project.
1package blockworld.lib;
2
3/*
4
5 This file is part of the Bushfire project.
6
7 Copyright 2003, M. Albers, H Boros, R Burema, N. Goh, J. Herold, B.
8 Maassen, R. Peek, J. Priem, Bas Steunebrink, P. van der Werken.
9
10 The Bushfire project is free software; you can redistribute it
11 and/or modify it under the terms of the GNU General Public License
12 as published by the Free Software Foundation; either version 2 of
13 the License, or (at your option) any later version.
14
15 The Bushfire project is distributed in the hope that it will be
16 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
17 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with the Bushfire project; if not, write to the Free Software Foundation,
22 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
24 $Id: ROIntegerAttr.java,v 1.3 2004/09/14 10:58:06 cvs-3apl Exp $
25
26 */
27
28import java.util.Observable;
29
30public class ROIntegerAttr extends Observable implements Cloneable {
31 String _name;
32
33 Integer _value;
34
35 public ROIntegerAttr( String name, Integer value ) {
36 _name = name;
37 _value = value;
38 }
39
40 public void addAttributeListener( IntegerAttrListener listener ) {
41 addObserver( new IntegerAttrAdapter( listener ) );
42 }
43
44 public void removeAttributeListener( IntegerAttrListener listener ) {
45 deleteObserver( new IntegerAttrAdapter( listener ) );
46 }
47
48 public int getValue() {
49 return _value.intValue();
50 }
51
52 /**
53 * Similar to getValue, except that this method returns an Integer instead
54 * of an int
55 */
56 public Integer getIntegerValue() {
57 return _value;
58 }
59
60 public String getName() {
61 return _name;
62 }
63
64 /**
65 * Returns a copy of this object. The clone has no observers.
66 *
67 * @return A copy of this object.
68 */
69 public Object clone() throws CloneNotSupportedException {
70 ROIntegerAttr a = (ROIntegerAttr) super.clone();
71 a._name = new String( _name );
72 a._value = new Integer( _value.intValue() );
73 a.deleteObservers();
74 return a;
75 }
76}