GraphLab Project

graphlab.platform.attribute
Class TimeLimitedNotifiableAttrSet<T extends AttributeSet>

java.lang.Object
  extended by graphlab.platform.attribute.TimeLimitedNotifiableAttrSet<T>
All Implemented Interfaces:
AttributeSet, NotifiableAttributeSet, java.lang.Runnable
Direct Known Subclasses:
EdgeNotifiableAttrSet, GraphNotifiableAttrSet, VertexNotifiableAttrSet

public class TimeLimitedNotifiableAttrSet<T extends AttributeSet>
extends java.lang.Object
implements java.lang.Runnable, NotifiableAttributeSet

A handy NotifiableSet which acts on any AttributeSet and converts it to a NotifiableAttributeSet, This is done by checking the AttributeSet for changes in each (100) mili seconds. changes on (T) input will take effect on next 100 milisecond, using this class should be done with care, this class uses a thread and checks the edge on each 100ms for any changes, so creating a lot of instances of this class (for example for all edges of graph) will take more and more cpu,

try to create as few as possible instances of this class and call stop() when you don't need it any more!


Constructor Summary
TimeLimitedNotifiableAttrSet(T input)
           
 
Method Summary
 void addAttributeListener(AttributeListener attributeListener)
          Add a listener to changes of an AttributeSet.
 void fireAttributeChange(java.util.Collection<AttributeListener> listeners, java.lang.String name, java.lang.Object oldVal, java.lang.Object newVal)
           
 java.lang.Object get(java.lang.String name)
           
 java.util.Collection<AttributeListener> getAttributeListeners()
           
 java.util.Map<java.lang.String,java.lang.Object> getAttrs()
           
 void put(java.lang.String name, java.lang.Object value)
           
 void removeAttributeListener(AttributeListener attributeListener)
          Remove a listener from list of listeners.
 void run()
          -> Thread
 void start()
          starts firinig listeners to this class
 void stop()
          stops firing listeners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeLimitedNotifiableAttrSet

public TimeLimitedNotifiableAttrSet(T input)
Method Detail

start

public void start()
starts firinig listeners to this class


stop

public void stop()
stops firing listeners


run

public void run()
-> Thread

Specified by:
run in interface java.lang.Runnable

getAttrs

public java.util.Map<java.lang.String,java.lang.Object> getAttrs()
Specified by:
getAttrs in interface AttributeSet
Returns:
a unmodifiable copy of attributes in this object

put

public void put(java.lang.String name,
                java.lang.Object value)
Specified by:
put in interface AttributeSet

get

public java.lang.Object get(java.lang.String name)
Specified by:
get in interface AttributeSet

addAttributeListener

public void addAttributeListener(AttributeListener attributeListener)
Description copied from interface: NotifiableAttributeSet
Add a listener to changes of an AttributeSet.
It's better to use a List because of getAttributeListeners() method.

Specified by:
addAttributeListener in interface NotifiableAttributeSet
Parameters:
attributeListener - the listener!

getAttributeListeners

public java.util.Collection<AttributeListener> getAttributeListeners()
Specified by:
getAttributeListeners in interface NotifiableAttributeSet
Returns:
List of listeners

removeAttributeListener

public void removeAttributeListener(AttributeListener attributeListener)
Description copied from interface: NotifiableAttributeSet
Remove a listener from list of listeners.

Specified by:
removeAttributeListener in interface NotifiableAttributeSet

fireAttributeChange

public void fireAttributeChange(java.util.Collection<AttributeListener> listeners,
                                java.lang.String name,
                                java.lang.Object oldVal,
                                java.lang.Object newVal)

GraphLab Project