Source Code Cross Referenced for JdbcPropertyChangeSupport.java in  » Web-Server » Jigsaw » org » w3c » tools » jdbc » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Server » Jigsaw » org.w3c.tools.jdbc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // JdbcPropertyChangeSupport.java
002:        // $Id: JdbcPropertyChangeSupport.java,v 1.1 2000/09/06 11:57:43 bmahe Exp $
003:        // (c) COPYRIGHT MIT, INRIA and Keio, 2000.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:
006:        package org.w3c.tools.jdbc;
007:
008:        import java.beans.PropertyChangeEvent;
009:        import java.beans.PropertyChangeListener;
010:        import java.beans.PropertyChangeSupport;
011:        import java.util.Hashtable;
012:        import java.util.Vector;
013:
014:        /**
015:         * This subclass of java.beans.PropertyChangeSupport is identical
016:         * in functionality except that it fire a PropertyChangeEvent even if the
017:         * old value and the new value are identicals.
018:         * @version $Revision: 1.1 $
019:         * @author  Benoît Mahé (bmahe@w3.org)
020:         */
021:        public class JdbcPropertyChangeSupport extends PropertyChangeSupport {
022:
023:            /**
024:             * Our listeners
025:             */
026:            private Vector listeners = null;
027:
028:            /**
029:             * Our listeners for specific properties
030:             */
031:            private Hashtable children = null;
032:
033:            /**
034:             * Our Bean
035:             */
036:            private Object source = null;
037:
038:            /**
039:             * Add a PropertyChangeListener to the listener list.
040:             * The listener is registered for all properties.
041:             * @param listener  The PropertyChangeListener to be added
042:             */
043:            public synchronized void addPropertyChangeListener(
044:                    PropertyChangeListener listener) {
045:                if (listeners == null) {
046:                    listeners = new Vector();
047:                }
048:                listeners.addElement(listener);
049:            }
050:
051:            /**
052:             * Remove a PropertyChangeListener from the listener list.
053:             * This removes a PropertyChangeListener that was registered
054:             * for all properties.
055:             * @param listener  The PropertyChangeListener to be removed
056:             */
057:            public synchronized void removePropertyChangeListener(
058:                    PropertyChangeListener listener) {
059:                if (listeners == null) {
060:                    return;
061:                }
062:                listeners.removeElement(listener);
063:            }
064:
065:            /**
066:             * Add a PropertyChangeListener for a specific property.  The listener
067:             * will be invoked only when a call on firePropertyChange names that
068:             * specific property.
069:             * @param propertyName  The name of the property to listen on.
070:             * @param listener  The PropertyChangeListener to be added
071:             */
072:            public synchronized void addPropertyChangeListener(
073:                    String propertyName, PropertyChangeListener listener) {
074:                if (children == null) {
075:                    children = new Hashtable();
076:                }
077:                JdbcPropertyChangeSupport child = (JdbcPropertyChangeSupport) children
078:                        .get(propertyName);
079:                if (child == null) {
080:                    child = new JdbcPropertyChangeSupport(source);
081:                    children.put(propertyName, child);
082:                }
083:                child.addPropertyChangeListener(listener);
084:            }
085:
086:            /**
087:             * Remove a PropertyChangeListener for a specific property.
088:             * @param propertyName  The name of the property that was listened on.
089:             * @param listener  The PropertyChangeListener to be removed
090:             */
091:            public synchronized void removePropertyChangeListener(
092:                    String propertyName, PropertyChangeListener listener) {
093:                if (children == null) {
094:                    return;
095:                }
096:                JdbcPropertyChangeSupport child = (JdbcPropertyChangeSupport) children
097:                        .get(propertyName);
098:                if (child == null) {
099:                    return;
100:                }
101:                child.removePropertyChangeListener(listener);
102:            }
103:
104:            /**
105:             * Report a bound property update to any registered listeners.
106:             * No event is fired if old and new are equal and non-null.
107:             * @param propertyName  The programmatic name of the property
108:             *		that was changed.
109:             * @param oldValue  The old value of the property.
110:             * @param newValue  The new value of the property.
111:             */
112:            public void firePropertyChange(String propertyName,
113:                    Object oldValue, Object newValue) {
114:                Vector targets = null;
115:                JdbcPropertyChangeSupport child = null;
116:                synchronized (this ) {
117:                    if (listeners != null) {
118:                        targets = (Vector) listeners.clone();
119:                    }
120:                    if (children != null && propertyName != null) {
121:                        child = (JdbcPropertyChangeSupport) children
122:                                .get(propertyName);
123:                    }
124:                }
125:
126:                PropertyChangeEvent evt = new PropertyChangeEvent(source,
127:                        propertyName, oldValue, newValue);
128:
129:                if (targets != null) {
130:                    for (int i = 0; i < targets.size(); i++) {
131:                        PropertyChangeListener target = (PropertyChangeListener) targets
132:                                .elementAt(i);
133:                        target.propertyChange(evt);
134:                    }
135:                }
136:
137:                if (child != null) {
138:                    child.firePropertyChange(evt);
139:                }
140:            }
141:
142:            /**
143:             * Report an int bound property update to any registered listeners.
144:             * No event is fired if old and new are equal and non-null.
145:             * <p>
146:             * This is merely a convenience wrapper around the more general
147:             * firePropertyChange method that takes Object values.
148:             * @param propertyName  The programmatic name of the property
149:             *		that was changed.
150:             * @param oldValue  The old value of the property.
151:             * @param newValue  The new value of the property.
152:             */
153:            public void firePropertyChange(String propertyName, int oldValue,
154:                    int newValue) {
155:                firePropertyChange(propertyName, new Integer(oldValue),
156:                        new Integer(newValue));
157:            }
158:
159:            /**
160:             * Report a boolean bound property update to any registered listeners.
161:             * No event is fired if old and new are equal and non-null.
162:             * <p>
163:             * This is merely a convenience wrapper around the more general
164:             * firePropertyChange method that takes Object values.
165:             * @param propertyName  The programmatic name of the property
166:             *		that was changed.
167:             * @param oldValue  The old value of the property.
168:             * @param newValue  The new value of the property.
169:             */
170:            public void firePropertyChange(String propertyName,
171:                    boolean oldValue, boolean newValue) {
172:                firePropertyChange(propertyName, new Boolean(oldValue),
173:                        new Boolean(newValue));
174:            }
175:
176:            /**
177:             * Fire an existing PropertyChangeEvent to any registered listeners.
178:             * No event is fired if the given event's old and new values are
179:             * equal and non-null.
180:             * @param evt  The PropertyChangeEvent object.
181:             */
182:            public void firePropertyChange(PropertyChangeEvent evt) {
183:                String propertyName = evt.getPropertyName();
184:                Vector targets = null;
185:                JdbcPropertyChangeSupport child = null;
186:                synchronized (this ) {
187:                    if (listeners != null) {
188:                        targets = (Vector) listeners.clone();
189:                    }
190:                    if (children != null && propertyName != null) {
191:                        child = (JdbcPropertyChangeSupport) children
192:                                .get(propertyName);
193:                    }
194:                }
195:
196:                if (targets != null) {
197:                    for (int i = 0; i < targets.size(); i++) {
198:                        PropertyChangeListener target = (PropertyChangeListener) targets
199:                                .elementAt(i);
200:                        target.propertyChange(evt);
201:                    }
202:                }
203:                if (child != null) {
204:                    child.firePropertyChange(evt);
205:                }
206:            }
207:
208:            /**
209:             * Check if there are any listeners for a specific property.
210:             * @param propertyName  the property name.
211:             * @return true if there are ore or more listeners for the given property
212:             */
213:            public synchronized boolean hasListeners(String propertyName) {
214:                if (listeners != null && !listeners.isEmpty()) {
215:                    return true;
216:                }
217:                if (children != null) {
218:                    JdbcPropertyChangeSupport child = (JdbcPropertyChangeSupport) children
219:                            .get(propertyName);
220:                    if (child != null && child.listeners != null) {
221:                        return !child.listeners.isEmpty();
222:                    }
223:                }
224:                return false;
225:            }
226:
227:            /**
228:             * Constructor
229:             * @param sourceBean our bean
230:             */
231:            public JdbcPropertyChangeSupport(Object sourceBean) {
232:                super(sourceBean);
233:                this.source = sourceBean;
234:            }
235:
236:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.