Source Code Cross Referenced for TwoWayEvent.java in  » IDE-Netbeans » performance » threaddemo » util » 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 » IDE Netbeans » performance » threaddemo.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package threaddemo.util;
043:
044:        import java.util.EventObject;
045:
046:        /**
047:         * Event indicating something happened to a two-way support.
048:         * Always indicates a state change, not just a return to the same state.
049:         * @author Jesse Glick
050:         * @see TwoWaySupport
051:         */
052:        public abstract class TwoWayEvent<DM, UMD, DMD> extends EventObject {
053:
054:            private TwoWayEvent(TwoWaySupport<DM, UMD, DMD> s) {
055:                super (s);
056:                assert s != null;
057:            }
058:
059:            /**
060:             * Get the associated two-way support.
061:             * @return the support
062:             */
063:            public TwoWaySupport<DM, UMD, DMD> getTwoWaySupport() {
064:                @SuppressWarnings("unchecked")
065:                TwoWaySupport<DM, UMD, DMD> source = (TwoWaySupport<DM, UMD, DMD>) getSource();
066:                return source;
067:            }
068:
069:            /**
070:             * Event indicating a derived value has been produced.
071:             */
072:            public static final class Derived<DM, UMD, DMD> extends
073:                    TwoWayEvent<DM, UMD, DMD> {
074:
075:                private final DM oldValue, newValue;
076:                private final DMD derivedDelta;
077:                private final UMD underlyingDelta;
078:
079:                Derived(TwoWaySupport<DM, UMD, DMD> s, DM oldValue,
080:                        DM newValue, DMD derivedDelta, UMD underlyingDelta) {
081:                    super (s);
082:                    this .oldValue = oldValue;
083:                    assert newValue != null;
084:                    this .newValue = newValue;
085:                    assert oldValue != null ^ derivedDelta == null;
086:                    this .derivedDelta = derivedDelta;
087:                    this .underlyingDelta = underlyingDelta;
088:                }
089:
090:                /**
091:                 * Get the old value of the derived model.
092:                 * @return the old value, or null if it was never calculated
093:                 */
094:                public DM getOldValue() {
095:                    return oldValue;
096:                }
097:
098:                /**
099:                 * Get the new value of the derived model.
100:                 * @return the new value
101:                 */
102:                public DM getNewValue() {
103:                    return newValue;
104:                }
105:
106:                /**
107:                 * Get the change to the derived model.
108:                 * @return the delta, or null if the old value was null
109:                 */
110:                public DMD getDerivedDelta() {
111:                    return derivedDelta;
112:                }
113:
114:                /**
115:                 * Get the change to the underlying model that triggered this derivation.
116:                 * Only applicable in case the derived model had been invalidated and
117:                 * was stale before this derivation.
118:                 * @return the invalidating change to the underlying model, or null if
119:                 *         the derived model is simply being computed for the first time
120:                 */
121:                public UMD getUnderlyingDelta() {
122:                    return underlyingDelta;
123:                }
124:
125:                public String toString() {
126:                    return "TwoWayEvent.Derived[" + getTwoWaySupport()
127:                            + ",oldValue=" + oldValue + ",newValue=" + newValue
128:                            + ",derivedDelta=" + derivedDelta
129:                            + ",underlyingDelta=" + underlyingDelta + "]";
130:                }
131:
132:            }
133:
134:            /**
135:             * Event indicating a derived model has been invalidated.
136:             */
137:            public static final class Invalidated<DM, UMD, DMD> extends
138:                    TwoWayEvent<DM, UMD, DMD> {
139:
140:                private final DM oldValue;
141:                private final UMD underlyingDelta;
142:
143:                Invalidated(TwoWaySupport<DM, UMD, DMD> s, DM oldValue,
144:                        UMD underlyingDelta) {
145:                    super (s);
146:                    assert oldValue != null;
147:                    this .oldValue = oldValue;
148:                    assert underlyingDelta != null;
149:                    this .underlyingDelta = underlyingDelta;
150:                }
151:
152:                /**
153:                 * Get the old value of the derived model that is now invalid.
154:                 * @return the old value
155:                 */
156:                public DM getOldValue() {
157:                    return oldValue;
158:                }
159:
160:                /**
161:                 * Get the change to the underlying model that triggered this invalidation.
162:                 * @return the invalidating change to the underlying model
163:                 */
164:                public UMD getUnderlyingDelta() {
165:                    return underlyingDelta;
166:                }
167:
168:                public String toString() {
169:                    return "TwoWayEvent.Invalidated[" + getTwoWaySupport()
170:                            + ",oldValue=" + oldValue + ",underlyingDelta="
171:                            + underlyingDelta + "]";
172:                }
173:
174:            }
175:
176:            /**
177:             * Event indicating the derived model was changed and the underlying model recreated.
178:             */
179:            public static final class Recreated<DM, UMD, DMD> extends
180:                    TwoWayEvent<DM, UMD, DMD> {
181:
182:                private final DM oldValue, newValue;
183:                private final DMD derivedDelta;
184:
185:                Recreated(TwoWaySupport<DM, UMD, DMD> s, DM oldValue,
186:                        DM newValue, DMD derivedDelta) {
187:                    super (s);
188:                    assert oldValue != null;
189:                    this .oldValue = oldValue;
190:                    assert newValue != null;
191:                    this .newValue = newValue;
192:                    assert derivedDelta != null;
193:                    this .derivedDelta = derivedDelta;
194:                }
195:
196:                /**
197:                 * Get the old value of the derived model that is now invalid.
198:                 * @return the old value
199:                 */
200:                public DM getOldValue() {
201:                    return oldValue;
202:                }
203:
204:                /**
205:                 * Get the new value of the derived model.
206:                 * @return the new value
207:                 */
208:                public DM getNewValue() {
209:                    return newValue;
210:                }
211:
212:                /**
213:                 * Get the change to the derived model that should be applied to the underlying
214:                 * model as well.
215:                 * @return the delta to the derived model
216:                 */
217:                public DMD getDerivedDelta() {
218:                    return derivedDelta;
219:                }
220:
221:                public String toString() {
222:                    return "TwoWayEvent.Recreated[" + getTwoWaySupport()
223:                            + ",oldValue=" + oldValue + ",newValue=" + newValue
224:                            + ",derivedDelta=" + derivedDelta + "]";
225:                }
226:
227:            }
228:
229:            /**
230:             * Event indicating changes in the underlying model were clobbered by changes to
231:             * the derived model.
232:             */
233:            public static final class Clobbered<DM, UMD, DMD> extends
234:                    TwoWayEvent<DM, UMD, DMD> {
235:
236:                private final DM oldValue, newValue;
237:                private final DMD derivedDelta;
238:
239:                Clobbered(TwoWaySupport<DM, UMD, DMD> s, DM oldValue,
240:                        DM newValue, DMD derivedDelta) {
241:                    super (s);
242:                    this .oldValue = oldValue;
243:                    assert newValue != null;
244:                    this .newValue = newValue;
245:                    assert derivedDelta != null;
246:                    this .derivedDelta = derivedDelta;
247:                }
248:
249:                /**
250:                 * Get the old value of the derived model that is now invalid.
251:                 * @return the old value, or null if it was never calculated
252:                 */
253:                public DM getOldValue() {
254:                    return oldValue;
255:                }
256:
257:                /**
258:                 * Get the new value of the derived model.
259:                 * @return the new value
260:                 */
261:                public DM getNewValue() {
262:                    return newValue;
263:                }
264:
265:                /**
266:                 * Get the change to the derived model that should be applied to the underlying
267:                 * model as well whether it is applicable or not.
268:                 * @return the delta to the derived model
269:                 */
270:                public DMD getDerivedDelta() {
271:                    return derivedDelta;
272:                }
273:
274:                public String toString() {
275:                    return "TwoWayEvent.Clobbered[" + getTwoWaySupport()
276:                            + ",oldValue=" + oldValue + ",newValue=" + newValue
277:                            + ",derivedDelta=" + derivedDelta + "]";
278:                }
279:
280:            }
281:
282:            /**
283:             * Event indicating the reference to the derived model was garbage collected.
284:             * This does not apply if the support itself was already collected.
285:             * Also, only supports overriding {@link TwoWaySupport#createReference} will
286:             * ever fire this event, since the default implementation creates a strong
287:             * reference that cannot be collected.
288:             */
289:            public static final class Forgotten<DM, UMD, DMD> extends
290:                    TwoWayEvent<DM, UMD, DMD> {
291:
292:                Forgotten(TwoWaySupport<DM, UMD, DMD> s) {
293:                    super (s);
294:                }
295:
296:                public String toString() {
297:                    return "TwoWayEvent.Forgotten[" + getTwoWaySupport() + "]";
298:                }
299:
300:            }
301:
302:            /**
303:             * Event indicating an attempted derivation failed with an exception.
304:             * The underlying model is thus considered to be in an inconsistent state.
305:             */
306:            public static final class Broken<DM, UMD, DMD> extends
307:                    TwoWayEvent<DM, UMD, DMD> {
308:
309:                private final DM oldValue;
310:                private final UMD underlyingDelta;
311:
312:                private final Exception exception;
313:
314:                Broken(TwoWaySupport<DM, UMD, DMD> s, DM oldValue,
315:                        UMD underlyingDelta, Exception exception) {
316:                    super (s);
317:                    this .oldValue = oldValue;
318:                    this .underlyingDelta = underlyingDelta;
319:                    assert exception != null;
320:                    this .exception = exception;
321:                }
322:
323:                /**
324:                 * Get the old value of the derived model that is now invalid.
325:                 * @return the old value, or null if it was never calculated
326:                 */
327:                public DM getOldValue() {
328:                    return oldValue;
329:                }
330:
331:                /**
332:                 * Get the change to the underlying model that triggered this derivation.
333:                 * Only applicable in case the derived model had been invalidated and
334:                 * was stale before this derivation.
335:                 * @return the invalidating change to the underlying model, or null if
336:                 *         the derived model is simply being computed for the first time
337:                 */
338:                public UMD getUnderlyingDelta() {
339:                    return underlyingDelta;
340:                }
341:
342:                /**
343:                 * Get the exception encountered when trying to derive a new model.
344:                 * @return the exception that prevented a new derived model from being created
345:                 */
346:                public Exception getException() {
347:                    return exception;
348:                }
349:
350:                public String toString() {
351:                    return "TwoWayEvent.Broken[" + getTwoWaySupport()
352:                            + ",oldValue=" + oldValue + ",underlyingDelta="
353:                            + underlyingDelta + ",exception=" + exception + "]";
354:                }
355:
356:            }
357:
358:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.