Java Doc for Observable.java in  » 6.0-JDK-Core » Collections-Jar-Zip-Logging-regex » java » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
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
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » Collections Jar Zip Logging regex » java.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.util.Observable

Observable
public class Observable (Code)
This class represents an observable object, or "data" in the model-view paradigm. It can be subclassed to represent an object that the application wants to have observed.

An observable object can have one or more observers. An observer may be any object that implements interface Observer. After an observable instance changes, an application calling the Observable's notifyObservers method causes all of its observers to be notified of the change by a call to their update method.

The order in which notifications will be delivered is unspecified. The default implementation provided in the Observable class will notify Observers in the order in which they registered interest, but subclasses may change this order, use no guaranteed order, deliver notifications on separate threads, or may guarantee that their subclass follows this order, as they choose.

Note that this notification mechanism is has nothing to do with threads and is completely separate from the wait and notify mechanism of class Object.

When an observable object is newly created, its set of observers is empty. Two observers are considered the same if and only if the equals method returns true for them.
author:
   Chris Warth
version:
   1.45, 05/05/07
See Also:   java.util.Observable.notifyObservers
See Also:   java.util.Observable.notifyObservers(java.lang.Object)
See Also:   java.util.Observer
See Also:   java.util.Observer.update(java.util.Observablejava.lang.Object)
since:
   JDK1.0




Constructor Summary
public  Observable()
     Construct an Observable with zero Observers.

Method Summary
public synchronized  voidaddObserver(Observer o)
     Adds an observer to the set of observers for this object, provided that it is not the same as some observer already in the set.
protected synchronized  voidclearChanged()
     Indicates that this object has no longer changed, or that it has already notified all of its observers of its most recent change, so that the hasChanged method will now return false.
public synchronized  intcountObservers()
     Returns the number of observers of this Observable object.
public synchronized  voiddeleteObserver(Observer o)
     Deletes an observer from the set of observers of this object.
public synchronized  voiddeleteObservers()
     Clears the observer list so that this object no longer has any observers.
public synchronized  booleanhasChanged()
     Tests if this object has changed.
public  voidnotifyObservers()
     If this object has changed, as indicated by the hasChanged method, then notify all of its observers and then call the clearChanged method to indicate that this object has no longer changed.
public  voidnotifyObservers(Object arg)
     If this object has changed, as indicated by the hasChanged method, then notify all of its observers and then call the clearChanged method to indicate that this object has no longer changed.
protected synchronized  voidsetChanged()
     Marks this Observable object as having been changed; the hasChanged method will now return true.


Constructor Detail
Observable
public Observable()(Code)
Construct an Observable with zero Observers.




Method Detail
addObserver
public synchronized void addObserver(Observer o)(Code)
Adds an observer to the set of observers for this object, provided that it is not the same as some observer already in the set. The order in which notifications will be delivered to multiple observers is not specified. See the class comment.
Parameters:
  o - an observer to be added.
throws:
  NullPointerException - if the parameter o is null.



clearChanged
protected synchronized void clearChanged()(Code)
Indicates that this object has no longer changed, or that it has already notified all of its observers of its most recent change, so that the hasChanged method will now return false. This method is called automatically by the notifyObservers methods.
See Also:   java.util.Observable.notifyObservers
See Also:   java.util.Observable.notifyObservers(java.lang.Object)



countObservers
public synchronized int countObservers()(Code)
Returns the number of observers of this Observable object. the number of observers of this object.



deleteObserver
public synchronized void deleteObserver(Observer o)(Code)
Deletes an observer from the set of observers of this object. Passing null to this method will have no effect.
Parameters:
  o - the observer to be deleted.



deleteObservers
public synchronized void deleteObservers()(Code)
Clears the observer list so that this object no longer has any observers.



hasChanged
public synchronized boolean hasChanged()(Code)
Tests if this object has changed. true if and only if the setChanged method has been called more recently than the clearChanged method on this object; false otherwise.
See Also:   java.util.Observable.clearChanged
See Also:   java.util.Observable.setChanged



notifyObservers
public void notifyObservers()(Code)
If this object has changed, as indicated by the hasChanged method, then notify all of its observers and then call the clearChanged method to indicate that this object has no longer changed.

Each observer has its update method called with two arguments: this observable object and null. In other words, this method is equivalent to:

notifyObservers(null)

See Also:   java.util.Observable.clearChanged
See Also:   java.util.Observable.hasChanged
See Also:   java.util.Observer.update(java.util.Observablejava.lang.Object)



notifyObservers
public void notifyObservers(Object arg)(Code)
If this object has changed, as indicated by the hasChanged method, then notify all of its observers and then call the clearChanged method to indicate that this object has no longer changed.

Each observer has its update method called with two arguments: this observable object and the arg argument.
Parameters:
  arg - any object.
See Also:   java.util.Observable.clearChanged
See Also:   java.util.Observable.hasChanged
See Also:   java.util.Observer.update(java.util.Observablejava.lang.Object)




setChanged
protected synchronized void setChanged()(Code)
Marks this Observable object as having been changed; the hasChanged method will now return true.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(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.