com.mindtree.techworks.insight.preferences.model
Class Preference

java.lang.Object
  extended by com.mindtree.techworks.insight.preferences.model.Preference
All Implemented Interfaces:
java.io.Serializable

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

This class stores a list of Preference attributes. It has a unique identifier and name. No preference attribute can exist without a preference.

Version:
$Revision: 27 $ $Date: 2007-12-16 04:58:03 -0700 (Sun, 16 Dec 2007) $
Author:
Bindul Bhowmik
See Also:
PreferenceAttribute, Serialized Form

Field Summary
static java.lang.String ID_SEPERATOR
          Seperator between the IDs of parent and child Preferences
 
Constructor Summary
Preference(java.lang.String id, boolean isUserModifiable, boolean isAggregated)
          Constructor which sets the fields.
Preference(java.lang.String id, boolean isUserModifiable, boolean isAggregated, java.lang.String name)
          Utility constructor which sets the display name also
 
Method Summary
 boolean addChildPreference(Preference preference)
          Adds a child preference to this preference
 boolean addPreferenceAttribute(PreferenceAttribute preferenceAttribute)
          Adds a preferenceAttribute to the Preference.
 boolean deregisterPreferenceModelManager(PreferenceModelManager manager)
          Deregisters the manager from this preference.
 java.lang.String getCompleteId()
          Returns the complete Id of the preference, including the parent's id.
 java.lang.String getDisplayClass()
           
 java.lang.String getId()
           
 java.lang.String getName()
           
 PreferenceAttribute getPreferenceAttributeById(java.lang.String attributeId)
          Returns a PreferenceAttribute for the id specified.
 Preference getPreferenceById(java.lang.String preferenceId)
          Returns a child preference for the Id passed
 PreferenceInfo getPreferenceInfo()
          Constructs and returns a PreferenceInfo object for this instance.
 boolean isAggregated()
           
 boolean isPreferenceAttributePresent(java.lang.String attributeId)
          Checks if the preference has an attribute with the attribute id.
 boolean isPreferencePresent(java.lang.String preferenceId)
          Checks if the Preference with the id specified is a child of this preference.
 boolean isUserModifiable()
           
 java.util.Iterator iterateChildPreferenceIds()
          Returns an iterator to the child Preference ids.
 java.util.Iterator iterateChildPreferences()
          Returns an iterator to the child Preferences.
 java.util.Iterator iteratePreferenceAttributeIds()
          Returns an iterator for the ids of all the Preference Attribtues in this Preference.
 java.util.Iterator iteratePreferenceAttributes()
          Returns an iterator for all the Preference Attributes.
 boolean registerPreferenceModelManager(PreferenceModelManager manager)
          Registers the manager for this preference.
 boolean removePreference(Preference preference)
          Removes a child preference
 boolean removePreferenceAttribute(PreferenceAttribute preferenceAttribute)
          Removes a preference attribute from this preference
 void setDisplayClass(java.lang.String displayClass)
           
 void setName(java.lang.String name)
           
protected  void setParent(Preference parentPreference)
          Sets the parent preference of this preference
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID_SEPERATOR

public static final java.lang.String ID_SEPERATOR
Seperator between the IDs of parent and child Preferences

See Also:
Constant Field Values
Constructor Detail

Preference

public Preference(java.lang.String id,
                  boolean isUserModifiable,
                  boolean isAggregated)
Constructor which sets the fields.

Parameters:
id - The unique identifier for the Preference
isUserModifiable - s the preference user modifiable
isAggregated - If this is an aggregated preference.

Preference

public Preference(java.lang.String id,
                  boolean isUserModifiable,
                  boolean isAggregated,
                  java.lang.String name)
Utility constructor which sets the display name also

Parameters:
id - The unique identifier for the Preference
isUserModifiable - s the preference user modifiable
isAggregated - If this is an aggregated preference.
name - The display name of the Preference
Method Detail

isAggregated

public boolean isAggregated()
Returns:
Returns the isAggregated.

getId

public java.lang.String getId()
Returns:
Returns the id.

getCompleteId

public java.lang.String getCompleteId()
Returns the complete Id of the preference, including the parent's id. The id is of the form:
 PARENTID_CHILDID
 

Returns:
The complete id of the Preference
See Also:
Seperator between two IDs

isUserModifiable

public boolean isUserModifiable()
Returns:
Returns the isUserModifiable.

getName

public java.lang.String getName()
Returns:
Returns the name.

addPreferenceAttribute

public boolean addPreferenceAttribute(PreferenceAttribute preferenceAttribute)
Adds a preferenceAttribute to the Preference. If a preference already exists with the id of the PreferenceAttribute passed, the addition will fail. Also if the parent of the preference is not this object, then also addition fails.

Parameters:
preferenceAttribute - The PreferenceAttribute to add.
Returns:
true if the addition is succesfull or false

registerPreferenceModelManager

public boolean registerPreferenceModelManager(PreferenceModelManager manager)
Registers the manager for this preference. Checks if any other manager is already registered with the instance.

Parameters:
manager - The preferenceModelManager to set.
Returns:
true if the registration succeeds or false

deregisterPreferenceModelManager

public boolean deregisterPreferenceModelManager(PreferenceModelManager manager)
Deregisters the manager from this preference. Does a check to see if the manager being asked to be deregistered is the one registered for notifications.

Parameters:
manager - The manager to deregister
Returns:
true if the deregistration succeeds or false

getPreferenceAttributeById

public PreferenceAttribute getPreferenceAttributeById(java.lang.String attributeId)
Returns a PreferenceAttribute for the id specified. Searches also the parent preferences for the attribute.

Parameters:
attributeId - The id of the attribute
Returns:
PreferenceAttribute for the id supplied.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the id is not found.

isPreferenceAttributePresent

public boolean isPreferenceAttributePresent(java.lang.String attributeId)
Checks if the preference has an attribute with the attribute id. Checks the parent preference also for the attribute.

Parameters:
attributeId - The id to check
Returns:
true if the attribute is present or false

iteratePreferenceAttributes

public java.util.Iterator iteratePreferenceAttributes()
Returns an iterator for all the Preference Attributes.

Returns:
Iterator for all the Preference Attribtues.

iteratePreferenceAttributeIds

public java.util.Iterator iteratePreferenceAttributeIds()
Returns an iterator for the ids of all the Preference Attribtues in this Preference.

Returns:
Iterator for all the Preference Attribute Keys.

getPreferenceById

public Preference getPreferenceById(java.lang.String preferenceId)
Returns a child preference for the Id passed

Parameters:
preferenceId - The id of the preference required.
Returns:
Preference for the id passed.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the Preference for the id passed is not present.

isPreferencePresent

public boolean isPreferencePresent(java.lang.String preferenceId)
Checks if the Preference with the id specified is a child of this preference.

Parameters:
preferenceId - The id of the child preference to check.
Returns:
true if the preference is present or false

iterateChildPreferences

public java.util.Iterator iterateChildPreferences()
Returns an iterator to the child Preferences.

Returns:
An iterator of the child preferences or null if none are present.

iterateChildPreferenceIds

public java.util.Iterator iterateChildPreferenceIds()
Returns an iterator to the child Preference ids.

Returns:
An iterator of the child preference ids or null if none are present.

getPreferenceInfo

public PreferenceInfo getPreferenceInfo()
Constructs and returns a PreferenceInfo object for this instance.

Returns:
PreferenceInfo for this object.
See Also:
PreferenceInfo

getDisplayClass

public java.lang.String getDisplayClass()
Returns:
Returns the displayClass.

setDisplayClass

public void setDisplayClass(java.lang.String displayClass)
Parameters:
displayClass - The displayClass to set.

setParent

protected void setParent(Preference parentPreference)
Sets the parent preference of this preference

Parameters:
parentPreference - Parent preference

addChildPreference

public boolean addChildPreference(Preference preference)
Adds a child preference to this preference

Parameters:
preference - The preference to add
Returns:
true If preference is added successfully or false

removePreference

public boolean removePreference(Preference preference)
Removes a child preference

Parameters:
preference - The preference to remove
Returns:
true if remove succeeds or false.

removePreferenceAttribute

public boolean removePreferenceAttribute(PreferenceAttribute preferenceAttribute)
Removes a preference attribute from this preference

Parameters:
preferenceAttribute - The preferenceAttribute to remove
Returns:
true if the removal succeeds or false.

setName

public void setName(java.lang.String name)
Parameters:
name - The name to set.


Copyright © 2003-2008 MindTree Consulting Ltd.. All Rights Reserved.