Package org.jfree.data.general
Class AbstractDataset
- java.lang.Object
-
- org.jfree.data.general.AbstractDataset
-
- All Implemented Interfaces:
java.io.ObjectInputValidation,java.io.Serializable,java.lang.Cloneable,Dataset
- Direct Known Subclasses:
AbstractSeriesDataset,CategoryToPieDataset,DefaultBoxAndWhiskerCategoryDataset,DefaultCategoryDataset,DefaultFlowDataset,DefaultHeatMapDataset,DefaultKeyedValueDataset,DefaultMultiValueCategoryDataset,DefaultPieDataset,DefaultStatisticalCategoryDataset,DefaultValueDataset,SlidingCategoryDataset,SlidingGanttCategoryDataset,WaferMapDataset
public abstract class AbstractDataset extends java.lang.Object implements Dataset, java.lang.Cloneable, java.io.Serializable, java.io.ObjectInputValidation
An abstract implementation of theDatasetinterface, containing a mechanism for registering change listeners.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private DatasetGroupgroupThe group that the dataset belongs to.private javax.swing.event.EventListenerListlistenerListStorage for registered change listeners.private booleannotifyA flag that can be used to temporarily suppress dataset change event notifications.private static longserialVersionUIDFor serialization.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractDataset()Constructs a dataset.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChangeListener(DatasetChangeListener listener)Registers an object to receive notification of changes to the dataset.booleancanEqual(java.lang.Object other)Ensures symmetry between super/subclass implementations of equals.java.lang.Objectclone()Returns a clone of the dataset.booleanequals(java.lang.Object obj)protected voidfireDatasetChanged()Notifies all registered listeners that the dataset has changed, provided that thenotifyflag has not been set tofalse.DatasetGroupgetGroup()Returns the dataset group for the dataset.booleangetNotify()Returns the value of the notify flag.inthashCode()booleanhasListener(java.util.EventListener listener)Returnstrueif the specified object is registered with the dataset as a listener.protected voidnotifyListeners(DatasetChangeEvent event)Notifies all registered listeners that the dataset has changed.private voidreadObject(java.io.ObjectInputStream stream)Restores a serialized object.voidremoveChangeListener(DatasetChangeListener listener)Deregisters an object so that it no longer receives notification of changes to the dataset.voidsetGroup(DatasetGroup group)Sets the dataset group for the dataset.voidsetNotify(boolean notify)Sets the notify flag, which controls whether or not thefireDatasetChanged()method notifies listeners.voidvalidateObject()Validates the object.private voidwriteObject(java.io.ObjectOutputStream stream)Handles serialization.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
group
private DatasetGroup group
The group that the dataset belongs to.
-
listenerList
private transient javax.swing.event.EventListenerList listenerList
Storage for registered change listeners.
-
notify
private boolean notify
A flag that can be used to temporarily suppress dataset change event notifications.
-
-
Method Detail
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
canEqual
public boolean canEqual(java.lang.Object other)
Ensures symmetry between super/subclass implementations of equals. For more detail, see http://jqno.nl/equalsverifier/manual/inheritance.- Parameters:
other- Object- Returns:
- true ONLY if the parameter is THIS class type
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
getGroup
public DatasetGroup getGroup()
Returns the dataset group for the dataset.- Specified by:
getGroupin interfaceDataset- Returns:
- The group (never
null). - See Also:
setGroup(DatasetGroup)
-
setGroup
public void setGroup(DatasetGroup group)
Sets the dataset group for the dataset.- Specified by:
setGroupin interfaceDataset- Parameters:
group- the group (nullnot permitted).- See Also:
getGroup()
-
getNotify
public boolean getNotify()
Returns the value of the notify flag. The default value istrue. If this isfalse, calls to thefireDatasetChanged()method will NOT trigger a dataset change event.- Returns:
- A boolean.
-
setNotify
public void setNotify(boolean notify)
Sets the notify flag, which controls whether or not thefireDatasetChanged()method notifies listeners. Setting this flag totruewill trigger aDatasetChangeEventbecause there may be queued up changes.- Parameters:
notify- the new flag value.
-
addChangeListener
public void addChangeListener(DatasetChangeListener listener)
Registers an object to receive notification of changes to the dataset.- Specified by:
addChangeListenerin interfaceDataset- Parameters:
listener- the object to register.- See Also:
removeChangeListener(DatasetChangeListener)
-
removeChangeListener
public void removeChangeListener(DatasetChangeListener listener)
Deregisters an object so that it no longer receives notification of changes to the dataset.- Specified by:
removeChangeListenerin interfaceDataset- Parameters:
listener- the object to deregister.- See Also:
addChangeListener(DatasetChangeListener)
-
hasListener
public boolean hasListener(java.util.EventListener listener)
Returnstrueif the specified object is registered with the dataset as a listener. Most applications won't need to call this method, it exists mainly for use by unit testing code.- Parameters:
listener- the listener.- Returns:
- A boolean.
- See Also:
addChangeListener(DatasetChangeListener),removeChangeListener(DatasetChangeListener)
-
fireDatasetChanged
protected void fireDatasetChanged()
Notifies all registered listeners that the dataset has changed, provided that thenotifyflag has not been set tofalse.- See Also:
addChangeListener(DatasetChangeListener)
-
notifyListeners
protected void notifyListeners(DatasetChangeEvent event)
Notifies all registered listeners that the dataset has changed.- Parameters:
event- contains information about the event that triggered the notification.- See Also:
addChangeListener(DatasetChangeListener),removeChangeListener(DatasetChangeListener)
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionReturns a clone of the dataset. The cloned dataset will NOT include theDatasetChangeListenerreferences that have been registered with this dataset.- Overrides:
clonein classjava.lang.Object- Returns:
- A clone.
- Throws:
java.lang.CloneNotSupportedException- if the dataset does not support cloning.
-
writeObject
private void writeObject(java.io.ObjectOutputStream stream) throws java.io.IOExceptionHandles serialization.- Parameters:
stream- the output stream.- Throws:
java.io.IOException- if there is an I/O problem.
-
readObject
private void readObject(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundExceptionRestores a serialized object.- Parameters:
stream- the input stream.- Throws:
java.io.IOException- if there is an I/O problem.java.lang.ClassNotFoundException- if there is a problem loading a class.
-
validateObject
public void validateObject() throws java.io.InvalidObjectExceptionValidates the object. We use this opportunity to call listeners who have registered during the deserialization process, as listeners are not serialized. This method is called by the serialization system after the entire graph is read. This object has registered itself to the system with a priority of 10. Other callbacks may register with a higher priority number to be called before this object, or with a lower priority number to be called after the listeners were notified. All listeners are supposed to have register by now, either in their readObject or validateObject methods. Notify them that this dataset has changed.- Specified by:
validateObjectin interfacejava.io.ObjectInputValidation- Throws:
java.io.InvalidObjectException- If the object cannot validate itself.
-
-