Java Doc for BufferedValueModel.java in  » Swing-Library » jgoodies-data-binding » com » jgoodies » binding » value » 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 » Swing Library » jgoodies data binding » com.jgoodies.binding.value 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


com.jgoodies.binding.value.AbstractValueModel
   com.jgoodies.binding.value.BufferedValueModel

BufferedValueModel
final public class BufferedValueModel extends AbstractValueModel (Code)
A ValueModel that wraps another ValueModel, the subject, and delays changes of the subject's value. Returns the subject's value until a value has been set. The buffered value is not written to the subject until the trigger channel changes to Boolean.TRUE. The buffered value can be flushed by changing the trigger channel value to Boolean.FALSE. Note that the commit and flush events are performed only if the trigger channel fires a change event. Since a plain ValueHolder fires no property change event if a value is set that has been set before, it is recommended to use a Trigger instead and invoke its #triggerCommit and triggerFlush methods.

The BufferedValueModel has been designed to behave much like its subject when accessing the value. Therefore it throws all exceptions that would arise when accessing the subject directly. Hence, attempts to read or write a value while the subject is null are always rejected with a NullPointerException.

This class provides the bound read-write properties subject and triggerChannel for the subject and trigger channel and a bound read-only property buffering for the buffering state.

The BufferedValueModel registers listeners with the subject and trigger channel. It is recommended to remove these listeners by invoking #release if the subject and trigger channel live much longer than this buffer. After #release has been called you must not use the BufferedValueModel instance any longer. As an alternative you may use event listener lists in subjects and trigger channels that are based on WeakReferences.

If the subject value changes while this model is in buffering state this change won't show through as this model's new value. If you want to update the value whenever the subject value changes, register a listener with the subject value and flush this model's trigger.

Constraints: The subject is of type Object, the trigger channel value of type Boolean.
author:
   Karsten Lentzsch
version:
   $Revision: 1.9 $
See Also:   ValueModel
See Also:   ValueModel.getValue
See Also:   ValueModel.setValue(Object)



Field Summary
final public static  StringPROPERTYNAME_BUFFERING
     The name of the bound read-only bean property that indicates whether this models is buffering or in write-through state.
final public static  StringPROPERTYNAME_SUBJECT
     The name of the bound read-write bean property for the subject.
final public static  StringPROPERTYNAME_TRIGGER_CHANNEL
     The name of the bound read-write bean property for the trigger channel.

Constructor Summary
public  BufferedValueModel(ValueModel subject, ValueModel triggerChannel)
     Constructs a BufferedValueModel on the given subject using the given trigger channel.

Method Summary
public  ValueModelgetSubject()
     Returns the subject, i.e.
public  ValueModelgetTriggerChannel()
     Returns the ValueModel that is used to trigger commit and flush events.
public  ObjectgetValue()
     Returns the subject's value if no value has been set since the last commit or flush, and returns the buffered value otherwise.
public  booleanisBuffering()
     Returns whether this model buffers a value or not, that is, whether a value has been assigned since the last commit or flush.
public  voidrelease()
     Removes the PropertyChangeListeners from the subject and trigger channel.

To avoid memory leaks it is recommended to invoke this method if the subject and trigger channel live much longer than this buffer.

public  voidsetSubject(ValueModel newSubject)
     Sets a new subject ValueModel, i.e.
public  voidsetTriggerChannel(ValueModel newTriggerChannel)
     Sets the ValueModel that triggers the commit and flush events.
public  voidsetValue(Object newBufferedValue)
     Sets a new buffered value and turns this BufferedValueModel into the buffering state.

Field Detail
PROPERTYNAME_BUFFERING
final public static String PROPERTYNAME_BUFFERING(Code)
The name of the bound read-only bean property that indicates whether this models is buffering or in write-through state.
See Also:   BufferedValueModel.isBuffering()



PROPERTYNAME_SUBJECT
final public static String PROPERTYNAME_SUBJECT(Code)
The name of the bound read-write bean property for the subject.
See Also:   BufferedValueModel.getSubject()
See Also:   BufferedValueModel.setSubject(ValueModel)



PROPERTYNAME_TRIGGER_CHANNEL
final public static String PROPERTYNAME_TRIGGER_CHANNEL(Code)
The name of the bound read-write bean property for the trigger channel.
See Also:   BufferedValueModel.getTriggerChannel()
See Also:   BufferedValueModel.setTriggerChannel(ValueModel)




Constructor Detail
BufferedValueModel
public BufferedValueModel(ValueModel subject, ValueModel triggerChannel)(Code)
Constructs a BufferedValueModel on the given subject using the given trigger channel.
Parameters:
  subject - the value model to be buffered
Parameters:
  triggerChannel - the value model that triggers the commit or flush event
throws:
  NullPointerException - if the triggerChannel is null




Method Detail
getSubject
public ValueModel getSubject()(Code)
Returns the subject, i.e. the underlying ValueModel that provides the unbuffered value. the ValueModel that provides the unbuffered value



getTriggerChannel
public ValueModel getTriggerChannel()(Code)
Returns the ValueModel that is used to trigger commit and flush events. the ValueModel that is used to trigger commit and flush events



getValue
public Object getValue()(Code)
Returns the subject's value if no value has been set since the last commit or flush, and returns the buffered value otherwise. Attempts to read a value when no subject is set are rejected with a NullPointerException. the buffered value
throws:
  NullPointerException - if no subject is set



isBuffering
public boolean isBuffering()(Code)
Returns whether this model buffers a value or not, that is, whether a value has been assigned since the last commit or flush. true if a value has been assigned since the last commit or flush



release
public void release()(Code)
Removes the PropertyChangeListeners from the subject and trigger channel.

To avoid memory leaks it is recommended to invoke this method if the subject and trigger channel live much longer than this buffer. Once #release has been invoked the BufferedValueModel instance must not be used any longer.

As an alternative you may use event listener lists in subjects and trigger channels that are based on WeakReferences.
See Also:   java.lang.ref.WeakReference




setSubject
public void setSubject(ValueModel newSubject)(Code)
Sets a new subject ValueModel, i.e. the model that provides the unbuffered value. Notifies all listeners that the subject property has changed.
Parameters:
  newSubject - the subject ValueModel to be set



setTriggerChannel
public void setTriggerChannel(ValueModel newTriggerChannel)(Code)
Sets the ValueModel that triggers the commit and flush events.
Parameters:
  newTriggerChannel - the ValueModel to be set as trigger channel
throws:
  NullPointerException - if the newTriggerChannel is null



setValue
public void setValue(Object newBufferedValue)(Code)
Sets a new buffered value and turns this BufferedValueModel into the buffering state. The buffered value is not provided to the underlying model until the trigger channel indicates a commit. Attempts to set a value when no subject is set are rejected with a NullPointerException.

The above semantics is easy to understand, however it is tempting to check the new value against the current subject value to avoid that the buffer unnecessary turns into the buffering state. But here's a problem. Let's say the subject value is "first" at buffer creation time, and let's say the subject value has changed in the meantime to "second". Now someone sets the value "second" to this buffer. The subject value and the value to be set are equal. Shall we buffer? Also, this decision would depend on the ability to read the subject. The semantics would depend on the subject' state and capabilities.

It is often sufficient to observe the buffering state when enabling or disabling a commit command button like "OK" or "Apply". And later check the changed state in a PresentationModel. You may want to do better and may want to observe a property like "defersTrueChange" that indicates whether flushing a buffer will actually change the subject. But note that such a state may change with subject value changes, which may be hard to understand for a user.

TODO: Consider adding an optimized execution path for the case that this model is already in buffering state. In this case the old buffered value can be used instead of invoking #readBufferedOrSubjectValue().
Parameters:
  newBufferedValue - the value to be buffered
throws:
  NullPointerException - if no subject is set




Fields inherited from com.jgoodies.binding.value.AbstractValueModel
final public static String PROPERTYNAME_VALUE(Code)(Java Doc)

Methods inherited from com.jgoodies.binding.value.AbstractValueModel
final public void addValueChangeListener(PropertyChangeListener l)(Code)(Java Doc)
final public boolean booleanValue()(Code)(Java Doc)
final public double doubleValue()(Code)(Java Doc)
final public void fireValueChange(Object oldValue, Object newValue)(Code)(Java Doc)
final public void fireValueChange(Object oldValue, Object newValue, boolean checkIdentity)(Code)(Java Doc)
final public void fireValueChange(boolean oldValue, boolean newValue)(Code)(Java Doc)
final public void fireValueChange(int oldValue, int newValue)(Code)(Java Doc)
final public void fireValueChange(long oldValue, long newValue)(Code)(Java Doc)
final public void fireValueChange(double oldValue, double newValue)(Code)(Java Doc)
final public void fireValueChange(float oldValue, float newValue)(Code)(Java Doc)
final public float floatValue()(Code)(Java Doc)
public String getString()(Code)(Java Doc)
final public int intValue()(Code)(Java Doc)
final public long longValue()(Code)(Java Doc)
final public void removeValueChangeListener(PropertyChangeListener l)(Code)(Java Doc)
final public void setValue(boolean b)(Code)(Java Doc)
final public void setValue(double d)(Code)(Java Doc)
final public void setValue(float f)(Code)(Java Doc)
final public void setValue(int i)(Code)(Java Doc)
final public void setValue(long l)(Code)(Java Doc)
public String toString()(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.