|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--org.openide.util.SharedClassObject
Shared object that allows different instances of the same class to share common data.
The data are shared only between instances of the same class (not subclasses). Thus, such "variables" have neither instance nor static behavior.
| Constructor Summary | |
protected |
SharedClassObject()
Create a shared object. |
| Method Summary | |
protected void |
addNotify()
Notify subclasses that the first listener has been added to this action. |
void |
addPropertyChangeListener(PropertyChangeListener l)
|
protected boolean |
clearSharedData()
Indicate whether the shared data of the last existing instance of this class should be cleared when that instance is finalized. |
boolean |
equals(Object obj)
Test whether the classes of the compared objects are the same. |
protected void |
finalize()
|
static SharedClassObject |
findObject(Class clazz)
Obtain an instance of the desired class, if there is one. |
static SharedClassObject |
findObject(Class clazz,
boolean create)
Find an existing object, possibly creating a new one as needed. |
protected void |
firePropertyChange(String name,
Object oldValue,
Object newValue)
Fire a property change event to all listeners. |
protected Object |
getLock()
Obtain lock for synchronization on manipulation with this class. |
protected Object |
getProperty(Object key)
Get a shared variable. |
int |
hashCode()
Get a hashcode of the shared class. |
protected void |
initialize()
Initialize shared state. |
protected Object |
putProperty(Object key,
Object value)
Set a shared variable. |
protected Object |
putProperty(String key,
Object value,
boolean notify)
Set a shared variable available only for string names. |
void |
readExternal(ObjectInput oi)
Reads nothing from the stream. |
protected void |
removeNotify()
Notify subclasses that the last listener has been removed from this action. |
void |
removePropertyChangeListener(PropertyChangeListener l)
|
void |
writeExternal(ObjectOutput oo)
Writes nothing to the stream. |
protected Object |
writeReplace()
This method provides correct handling of serialization and deserialization. |
| Methods inherited from class java.lang.Object |
clone, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
protected SharedClassObject()
initialize()| Method Detail |
protected final void finalize()
throws Throwable
finalize in class Objectprotected boolean clearSharedData()
finalize().
The default implementation returns true.
Classes which have precious shared data may want to return false, so that
all instances may be finalized, after which new instances will pick up the same shared variables
without requiring a recalculation.
true if all shared data should be cleared,
false if it should stay in memorypublic final boolean equals(Object obj)
equals in class Objectobj - the object to compare totrue if the classes are equalpublic final int hashCode()
hashCode in class Objectprotected final Object getLock()
protected final Object putProperty(Object key,
Object value)
locks.key - name of the propertyvalue - value for that property (may be null)null if none
protected final Object putProperty(String key,
Object value,
boolean notify)
locks.key - name of the propertyvalue - value for that property (may be null)notify - should all listeners be notified about property change?null if noneprotected final Object getProperty(Object key)
locks.key - name of the propertynull if noneprotected void initialize()
putProperty(java.lang.Object, java.lang.Object) to set up variables.
Subclasses should always call the super method.
This method need not be called explicitly; it will be called once the first time a given shared class is used (not for each instance!).
public final void addPropertyChangeListener(PropertyChangeListener l)
public final void removePropertyChangeListener(PropertyChangeListener l)
protected void addNotify()
protected void removeNotify()
protected void firePropertyChange(String name,
Object oldValue,
Object newValue)
name - the name of the propertyoldValue - the old valuenewValue - the new value
public void writeExternal(ObjectOutput oo)
throws IOException
writeExternal in interface Externalizableoo - ignored
public void readExternal(ObjectInput oi)
throws IOException,
ClassNotFoundException
readExternal in interface Externalizableoi - ignoredprotected Object writeReplace()
This allows to have only one instance of the class in the system and work only with it.
public static SharedClassObject findObject(Class clazz)
clazz - the shared class to look fornull if such does not exists
public static SharedClassObject findObject(Class clazz,
boolean create)
clazz - the class of the object to find (must extend SharedClassObject)create - true if the object should be created if it does not yet existnull if there was none and create was falseIllegalArgumentException - if a new instance could not be created for some reason
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||