org.sakaiproject.component.legacy.preference
Class BasePreferencesService.BasePreferences

java.lang.Object
  extended byorg.sakaiproject.component.legacy.preference.BasePreferencesService.BasePreferences
All Implemented Interfaces:
Comparable, Edit, Entity, EventListener, Preferences, PreferencesEdit, SessionBindingListener
Enclosing class:
BasePreferencesService

public class BasePreferencesService.BasePreferences
extends Object
implements PreferencesEdit, SessionBindingListener

Preferences implementation


Field Summary
protected  boolean m_active
          Active flag.
protected  String m_event
          The event code for this edit.
protected  String m_id
          The user id.
protected  ResourcePropertiesEdit m_properties
          The properties.
protected  Map m_props
          The sets of keyed ResourceProperties.
 
Fields inherited from interface org.sakaiproject.service.legacy.entity.Entity
SEPARATOR
 
Constructor Summary
BasePreferencesService.BasePreferences(Element el)
          Construct from information in XML.
BasePreferencesService.BasePreferences(Preferences prefs)
          Construct from another Preferences object.
BasePreferencesService.BasePreferences(String id)
          Construct.
 
Method Summary
protected  void activate()
          Enable editing.
protected  void closeEdit()
          Close the edit object - it cannot be used after this.
 int compareTo(Object obj)
          Compare this object with the specified object for order.
 boolean equals(Object obj)
          Are these objects equal?
protected  void finalize()
          Clean up.
protected  String getEvent()
          Access the event code for this edit.
 String getId()
          Access the user id.
 Collection getKeys()
          Access the keys defined in this Preferences
 ResourceProperties getProperties()
          Access the resources's properties.
 ResourceProperties getProperties(String key)
          Access the properties keyed by the specified value.
 ResourcePropertiesEdit getPropertiesEdit()
          Access the resource's properties for modification
 ResourcePropertiesEdit getPropertiesEdit(String key)
          Access the properties keyed by the specified value.
 String getReference()
          Access the internal reference which can be used to access the resource from within the system.
 String getReference(String rootProperty)
          Access the alternate internal reference which can be used to access the entity from within the system.
 String getUrl()
          Access the URL which can be used to access the resource.
 String getUrl(String rootProperty)
          Access the alternate URL which can be used to access the entity.
 int hashCode()
          Make a hash code that reflects the equals() logic as well.
 boolean isActiveEdit()
          Check to see if the edit is still active, or has already been closed.
protected  void set(Preferences prefs)
          Take all values from this object.
protected  void setAll(Preferences prefs)
          Take all values from this object.
protected  void setEvent(String event)
          Set the event code for this edit.
 Element toXml(Document doc, Stack stack)
          Serialize the resource into XML, adding an element to the doc under the top of the stack element.
 void valueBound(SessionBindingEvent event)
          SessionBindingListener implementation
 void valueUnbound(SessionBindingEvent event)
          Notifies the object that it is being unbound from a session.
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_id

protected String m_id
The user id.


m_properties

protected ResourcePropertiesEdit m_properties
The properties.


m_props

protected Map m_props
The sets of keyed ResourceProperties.


m_event

protected String m_event
The event code for this edit.


m_active

protected boolean m_active
Active flag.

Constructor Detail

BasePreferencesService.BasePreferences

public BasePreferencesService.BasePreferences(String id)
Construct.

Parameters:
id - The user id.

BasePreferencesService.BasePreferences

public BasePreferencesService.BasePreferences(Preferences prefs)
Construct from another Preferences object.


BasePreferencesService.BasePreferences

public BasePreferencesService.BasePreferences(Element el)
Construct from information in XML.

Parameters:
el - The XML DOM Element definining the user.
Method Detail

setAll

protected void setAll(Preferences prefs)
Take all values from this object.


toXml

public Element toXml(Document doc,
                     Stack stack)
Serialize the resource into XML, adding an element to the doc under the top of the stack element.

Specified by:
toXml in interface Entity
Parameters:
doc - The DOM doc to contain the XML (or null for a string return).
stack - The DOM elements, the top of which is the containing element of the new "resource" element.
Returns:
The newly added element.

getId

public String getId()
Access the user id.

Specified by:
getId in interface Preferences
Returns:
The preferences id.

getUrl

public String getUrl()
Access the URL which can be used to access the resource.

Specified by:
getUrl in interface Entity
Returns:
The URL which can be used to access the resource.

getReference

public String getReference()
Access the internal reference which can be used to access the resource from within the system.

Specified by:
getReference in interface Entity
Returns:
The the internal reference which can be used to access the resource from within the system.

getReference

public String getReference(String rootProperty)
Description copied from interface: Entity
Access the alternate internal reference which can be used to access the entity from within the system.

Specified by:
getReference in interface Entity
Parameters:
rootProperty - The name of the entity property whose value controls which alternate reference is requested. If null, the native 'raw' reference is requested.
Returns:
The the alternate internal reference which can be used to access the entity from within the system.

getUrl

public String getUrl(String rootProperty)
Description copied from interface: Entity
Access the alternate URL which can be used to access the entity.

Specified by:
getUrl in interface Entity
Parameters:
rootProperty - The name of the entity property whose value controls which alternate reference URL is requested. If null, the native 'raw' URL is requested.
Returns:
The alternate URL which can be used to access the entity.

getProperties

public ResourceProperties getProperties()
Access the resources's properties.

Specified by:
getProperties in interface Entity
Returns:
The resources's properties.

getProperties

public ResourceProperties getProperties(String key)
Access the properties keyed by the specified value.

Specified by:
getProperties in interface Preferences
Parameters:
key - The key to the properties.
Returns:
The properties keyed by the specified value (possibly empty)

getKeys

public Collection getKeys()
Description copied from interface: Preferences
Access the keys defined in this Preferences

Specified by:
getKeys in interface Preferences
Returns:
A Collection of the keys (String) defined in this Preferences.

equals

public boolean equals(Object obj)
Are these objects equal? If they are both User objects, and they have matching id's, they are.

Returns:
true if they are equal, false if not.

hashCode

public int hashCode()
Make a hash code that reflects the equals() logic as well. We want two objects, even if different instances, if they have the same id to hash the same.


compareTo

public int compareTo(Object obj)
Compare this object with the specified object for order.

Specified by:
compareTo in interface Comparable
Returns:
A negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

getPropertiesEdit

public ResourcePropertiesEdit getPropertiesEdit(String key)
Access the properties keyed by the specified value. If the key does not yet exist, create it.

Specified by:
getPropertiesEdit in interface PreferencesEdit
Parameters:
key - The key to the properties.
Returns:
The properties keyed by the specified value (possibly empty)

finalize

protected void finalize()
Clean up.


set

protected void set(Preferences prefs)
Take all values from this object.


getEvent

protected String getEvent()
Access the event code for this edit.

Returns:
The event code for this edit.

setEvent

protected void setEvent(String event)
Set the event code for this edit.

Parameters:
event - The event code for this edit.

getPropertiesEdit

public ResourcePropertiesEdit getPropertiesEdit()
Access the resource's properties for modification

Specified by:
getPropertiesEdit in interface Edit
Returns:
The resource's properties.

activate

protected void activate()
Enable editing.


isActiveEdit

public boolean isActiveEdit()
Check to see if the edit is still active, or has already been closed.

Specified by:
isActiveEdit in interface Edit
Returns:
true if the edit is active, false if it's been closed.

closeEdit

protected void closeEdit()
Close the edit object - it cannot be used after this.


valueBound

public void valueBound(SessionBindingEvent event)
SessionBindingListener implementation

Specified by:
valueBound in interface SessionBindingListener
Parameters:
event - the event that identifies the session

valueUnbound

public void valueUnbound(SessionBindingEvent event)
Description copied from interface: SessionBindingListener
Notifies the object that it is being unbound from a session.

Specified by:
valueUnbound in interface SessionBindingListener
Parameters:
event - the event that identifies the session