org.omus.core
Class PropertySet

java.lang.Object
  |
  +--org.omus.core.PropertySet
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
PropertyUpdate

public class PropertySet
extends java.lang.Object
implements java.io.Serializable

Represents a collection of properties. The PropertySet class is similar to the ActionScript PropertySet object in the Client API. Each group and each user have a set of properties associated with them. The datatype as well as persistence and synchronization settings for each property must be defined in the XML configuration file on the server. See the Configuration chapter for details. The PropertySet object can be used to read individual property values, to load properties from the database or to synchronize them. The actual modification of the value of a property is carried out through methods of the DataField instance that represents the property. Please note that modified values will not be written to the database and not be reflected in the clients before you commit all changes with a call to synchronize. Example code to change some properties of a user and synchronize them might look as follows:

     PropertySet ps = group.getProperties();
     IntField age = (IntField)ps.getValue("age");
     age.setInt(27);
     BooleanField married = (BooleanField)ps.getValue("married");
     married.setBoolean(false);
     try {
         ps.synchronize();
     } catch (org.omus.db.DbException dbe) {
         System.out.println("ERROR: " + dbe);
     }
 

See Also:
Serialized Form

Method Summary
 boolean contains(java.lang.String name)
          Returns true if this PropertySet object contains a property with the specified name
 java.lang.Object getOwner()
          Returns the owner of this PropertySet object.
 IntField getPrimaryKey()
          Returns the primary key for this PropertySet object corresponding to the usrID and grpID fields in the userprops and groupprops tables in the database.
 java.lang.Class getType(java.lang.String name)
          Returns the type of the property with the specified name.
 DataField getValue(java.lang.String name)
          Returns the value of the property with the specified name or null if the property was not loaded yet.
 boolean isLoaded(java.lang.String name)
          Returns true if the value of the property with the specified name has been loaded from the database.
 boolean isModified(java.lang.String name)
          Returns true if the property with the specified name was modified since the last synchronization.
 void load(java.lang.String[] propNames)
          Loads all values of the properties with the specified names into the client.
 void loadAll()
          Loads the values of all properties that are not loaded automatically.
 int size()
          Returns the number of properties in this set.
 void synchronize()
          Synchronizes all modified properties in this set according to the synchronization settings in the XML configuration file on the server.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getOwner

public java.lang.Object getOwner()
Returns the owner of this PropertySet object. The returned object is either an instance of Group or an instance of User.

getPrimaryKey

public IntField getPrimaryKey()
Returns the primary key for this PropertySet object corresponding to the usrID and grpID fields in the userprops and groupprops tables in the database.

contains

public boolean contains(java.lang.String name)
Returns true if this PropertySet object contains a property with the specified name

isModified

public boolean isModified(java.lang.String name)
Returns true if the property with the specified name was modified since the last synchronization.

isLoaded

public boolean isLoaded(java.lang.String name)
Returns true if the value of the property with the specified name has been loaded from the database.

getType

public java.lang.Class getType(java.lang.String name)
Returns the type of the property with the specified name.

getValue

public DataField getValue(java.lang.String name)
Returns the value of the property with the specified name or null if the property was not loaded yet. To modify the value use one of the methods of the returned DataField.

size

public int size()
Returns the number of properties in this set.

synchronize

public void synchronize()
                 throws DbException
Synchronizes all modified properties in this set according to the synchronization settings in the XML configuration file on the server. This may include writing the new values to the database or updating them in one or all clients of the current group depending on the configuration.

load

public void load(java.lang.String[] propNames)
          throws DbException
Loads all values of the properties with the specified names into the client. Note that the values of all properties except for those with a cacheLevel attribute set to "off" will be loaded automatically. See the Configuration chapter for more details.

loadAll

public void loadAll()
             throws DbException
Loads the values of all properties that are not loaded automatically.