View Javadoc
1   /*
2    * #%L
3    * Nuiton Validator
4    * %%
5    * Copyright (C) 2013 - 2014 Code Lutin, Tony Chemit
6    * %%
7    * This program is free software: you can redistribute it and/or modify
8    * it under the terms of the GNU Lesser General Public License as 
9    * published by the Free Software Foundation, either version 3 of the 
10   * License, or (at your option) any later version.
11   * 
12   * This program is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Lesser Public License for more details.
16   * 
17   * You should have received a copy of the GNU General Lesser Public 
18   * License along with this program.  If not, see
19   * <http://www.gnu.org/licenses/lgpl-3.0.html>.
20   * #L%
21   */
22  package org.nuiton.validator.bean;
23  
24  import java.beans.PropertyChangeListener;
25  import java.beans.PropertyChangeSupport;
26  
27  public class SimpleBean {
28  
29      protected int intValue;
30  
31      protected String stringValue;
32  
33      final PropertyChangeSupport p;
34  
35      public SimpleBean() {
36          p = new PropertyChangeSupport(this);
37      }
38  
39      public int getIntValue() {
40          return intValue;
41      }
42  
43      public String getStringValue() {
44          return stringValue;
45      }
46  
47      public void setStringValue(String stringValue) {
48          String old = this.stringValue;
49          this.stringValue = stringValue;
50          p.firePropertyChange("stringValue", old, stringValue);
51      }
52  
53      public void setIntValue(int intValue) {
54          int old = this.intValue;
55          this.intValue = intValue;
56          p.firePropertyChange("intValue", old, intValue);
57      }
58  
59      public void addPropertyChangeListener(PropertyChangeListener listener) {
60          p.addPropertyChangeListener(listener);
61      }
62  
63      public void addPropertyChangeListener(String propertyName,
64                                            PropertyChangeListener listener) {
65          p.addPropertyChangeListener(propertyName, listener);
66      }
67  
68      public void removePropertyChangeListener(PropertyChangeListener listener) {
69          p.removePropertyChangeListener(listener);
70      }
71  
72      public void removePropertyChangeListener(String propertyName,
73                                               PropertyChangeListener listener) {
74          p.removePropertyChangeListener(propertyName, listener);
75      }
76  }