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.xwork2.field;
23  
24  import java.beans.PropertyChangeListener;
25  import java.beans.PropertyChangeSupport;
26  
27  /**
28   * @author Tony Chemit - chemit@codelutin.com
29   */
30  public class FieldExpressionBean {
31  
32      protected final PropertyChangeSupport p;
33  
34      protected boolean booleanValue;
35  
36      protected short shortValue;
37  
38      protected int intValue;
39  
40      protected long longValue;
41  
42      protected double doubleValue;
43  
44      protected String stringValue;
45  
46      public FieldExpressionBean() {
47          p = new PropertyChangeSupport(this);
48      }
49  
50      public boolean isBooleanValue() {
51          return booleanValue;
52      }
53  
54      public double getDoubleValue() {
55          return doubleValue;
56      }
57  
58      public int getIntValue() {
59          return intValue;
60      }
61  
62      public long getLongValue() {
63          return longValue;
64      }
65  
66      public short getShortValue() {
67          return shortValue;
68      }
69  
70      public String getStringValue() {
71          return stringValue;
72      }
73  
74      public void setBooleanValue(boolean newValue) {
75          Object oldValue = booleanValue;
76          booleanValue = newValue;
77          firePropertyChange("booleanValue", oldValue, newValue);
78      }
79  
80      public void setDoubleValue(double newValue) {
81          Object oldValue = doubleValue;
82          doubleValue = newValue;
83          firePropertyChange("doubleValue", oldValue, newValue);
84      }
85  
86      public void setIntValue(int newValue) {
87          Object oldValue = stringValue;
88          intValue = newValue;
89          firePropertyChange("intValue", oldValue, newValue);
90      }
91  
92      public void setLongValue(long newValue) {
93          Object oldValue = longValue;
94          longValue = newValue;
95          firePropertyChange("longValue", oldValue, newValue);
96      }
97  
98      public void setShortValue(short newValue) {
99          Object oldValue = shortValue;
100         shortValue = newValue;
101         firePropertyChange("shortValue", oldValue, newValue);
102     }
103 
104     public void setStringValue(String newValue) {
105         Object oldValue = stringValue;
106         stringValue = newValue;
107         firePropertyChange("stringValue", oldValue, newValue);
108     }
109 
110     protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
111         p.firePropertyChange(propertyName, oldValue, newValue);
112     }
113 
114     public void addPropertyChangeListener(PropertyChangeListener listener) {
115         p.addPropertyChangeListener(listener);
116     }
117 
118     public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
119         p.addPropertyChangeListener(propertyName, listener);
120     }
121 
122     public void removePropertyChangeListener(PropertyChangeListener listener) {
123         p.removePropertyChangeListener(listener);
124     }
125 
126     public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
127         p.removePropertyChangeListener(propertyName, listener);
128     }
129 }