KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > IntModel


1 /*******************************************************************************
2  * Copyright (c) 2004, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal;
12
13 /**
14  * Represents a single integer that can send notifications when it changes.
15  * IChangeListeners can be attached which will receive notifications whenever
16  * the integer changes.
17  */

18 public class IntModel extends Model {
19     public IntModel(int initialValue) {
20         super(new Integer JavaDoc(initialValue));
21     }
22
23     /**
24      * Sets the value of the integer and notifies all
25      * change listeners except for the one that caused the change.
26      *
27      * @param newValue the new value of the integer
28      */

29     public void set(int newValue, IChangeListener source) {
30         setState(new Integer JavaDoc(newValue), source);
31     }
32
33     /**
34      * Sets the value of the integer and notifies all change listeners
35      * of the change.
36      *
37      * @param newValue the new value of the integer
38      */

39     public void set(int newValue) {
40         setState(new Integer JavaDoc(newValue), null);
41     }
42
43     /**
44      * Returns the value of the integer.
45      *
46      * @return the value of the integer
47      */

48     public int get() {
49         return ((Integer JavaDoc) getState()).intValue();
50     }
51 }
52
Popular Tags