visidia.misc.property
Class PropertyTable

java.lang.Object
  extended by visidia.misc.property.PropertyTable
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
Agent, Edge, Vertex

public class PropertyTable
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

A property table stores properties under names like a Hashtable. The difference with the hashtable is given by default values which are not stored to save space.

See Also:
Serialized Form

Constructor Summary
PropertyTable()
          Using this constructor, there will be no default values.
PropertyTable(java.util.Hashtable<java.lang.Object,VisidiaProperty> defaults)
          Constructs a new property table with default values.
PropertyTable(java.util.Hashtable<java.lang.Object,VisidiaProperty> def, java.util.Hashtable<java.lang.Object,VisidiaProperty> properties)
          Constructs a new property table with default and specifics values.
 
Method Summary
 java.lang.Object clone()
           
 boolean containsElement(java.lang.Object key)
          Contains element.
 java.util.Set<java.util.Map.Entry<java.lang.Object,VisidiaProperty>> entrySet()
          Returns a Set view of mappings contained in this property table.
 java.lang.Object getLockOwner()
          Gets the lock owner.
 java.util.Set<java.lang.Object> getPropertyKeys()
          Gets the property keys.
 VisidiaProperty getVisidiaProperty(java.lang.Object key)
          Returns the property associated with the key.
 boolean isPersistentProperty(java.lang.Object key)
          Checks if the property associated with the key is persistent (it cannot be removed).
 boolean locked()
          Locked.
 void lockProperties(java.lang.Object requester)
          Lock properties.
 VisidiaProperty removeProperty(java.lang.Object key)
          Removes the property.
 void resetProperties()
          Reset properties.
 void setProperties(PropertyTable properties)
          Sets the properties.
 VisidiaProperty setVisidiaProperty(VisidiaProperty property)
          Sets a property: a value and the corresponding key.
 void unlockProperties(java.lang.Object requester)
          Unlock properties only if lockOwner has locked the properties itself.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyTable

public PropertyTable()
Using this constructor, there will be no default values. The property table will be used just like a Hashtable.


PropertyTable

public PropertyTable(java.util.Hashtable<java.lang.Object,VisidiaProperty> defaults)
Constructs a new property table with default values.

Parameters:
defaults - Default properties that will be used when nobody has modified them.

PropertyTable

public PropertyTable(java.util.Hashtable<java.lang.Object,VisidiaProperty> def,
                     java.util.Hashtable<java.lang.Object,VisidiaProperty> properties)
Constructs a new property table with default and specifics values.

Parameters:
def - Default properties that will be used when nobody has modified them.
properties - Specifics properties that will be used for this property table.
Method Detail

setProperties

public void setProperties(PropertyTable properties)
Sets the properties.

Parameters:
properties - the new properties

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

entrySet

public java.util.Set<java.util.Map.Entry<java.lang.Object,VisidiaProperty>> entrySet()
Returns a Set view of mappings contained in this property table.

Returns:
the set view of the mappings contains in this table

getVisidiaProperty

public VisidiaProperty getVisidiaProperty(java.lang.Object key)
Returns the property associated with the key. If the key can't be found, returns null.

Parameters:
key - the key
Returns:
the property

setVisidiaProperty

public VisidiaProperty setVisidiaProperty(VisidiaProperty property)
Sets a property: a value and the corresponding key.

Parameters:
property - the property
Returns:
the previous property of the specified key in this hashtable, or null if it did not have one.

isPersistentProperty

public boolean isPersistentProperty(java.lang.Object key)
Checks if the property associated with the key is persistent (it cannot be removed).

Parameters:
key - the key
Returns:
true, if persistent property (default is false)

removeProperty

public VisidiaProperty removeProperty(java.lang.Object key)
Removes the property.

Parameters:
key - the key
Returns:
the property

resetProperties

public void resetProperties()
Reset properties.


getPropertyKeys

public java.util.Set<java.lang.Object> getPropertyKeys()
Gets the property keys.

Returns:
the property keys

containsElement

public boolean containsElement(java.lang.Object key)
Contains element.

Parameters:
key - the key
Returns:
true, if successful

getLockOwner

public java.lang.Object getLockOwner()
Gets the lock owner.

Returns:
the lock owner

locked

public boolean locked()
Locked.

Returns:
true, if successful

lockProperties

public void lockProperties(java.lang.Object requester)
Lock properties. If already locked by lockOwner itself, does nothing. If already locked by anyone else, wait until the owner unlocks them.

Parameters:
requester - the requester

unlockProperties

public void unlockProperties(java.lang.Object requester)
Unlock properties only if lockOwner has locked the properties itself.

Parameters:
requester - the requester