/*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * (the "License"); you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
 * 
 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
 * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
 * language governing rights and limitations under the License.
 * 
 * The Original Code is the Venice Web Communities System.
 * 
 * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
 * for Silverwrist Design Studios.  Portions created by Eric J. Bowersox are
 * Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios.  All Rights Reserved.
 * 
 * Contributor(s): 
 */
package com.silverwrist.dynamo.event;

import com.silverwrist.dynamo.iface.*;

/**
 * Events of this type are sent to an object that implements
 * {@link com.silverwrist.dynamo.event.SessionValueBindListener SessionValueBindListener} when it is bound
 * or unbound from a {@link com.silverwrist.dynamo.iface.SessionInfo SessionInfo} object.
 *
 * @author Eric J. Bowersox &lt;erbo@silcom.com&gt;
 * @version X
 */
public class SessionValueBindEvent extends DynamoEventObject
{
  /*--------------------------------------------------------------------------------
   * Attributes
   *--------------------------------------------------------------------------------
   */

  private transient String m_namespace;   // namespace for this value
  private transient String m_name;        // name for this value
  private transient Object m_value;       // value for event

  /*--------------------------------------------------------------------------------
   * Constructor
   *--------------------------------------------------------------------------------
   */

  /**
   * Constructs a new instance of <CODE>SessionValueBindEvent</CODE>.
   *
   * @param session The {@link com.silverwrist.dynamo.iface.SessionInfo SessionInfo} associated with the event.
   * @param namespace The namespace URI associated with the object.
   * @param name The name associated with the object.
   */
  public SessionValueBindEvent(SessionInfo session, String namespace, String name)
  {
    super(session);
    m_namespace = namespace;
    m_name = name;
    m_value = null;

  } // end consructor

  /**
   * Constructs a new instance of <CODE>SessionValueBindEvent</CODE>.
   *
   * @param session The {@link com.silverwrist.dynamo.iface.SessionInfo SessionInfo} associated with the event.
   * @param namespace The namespace URI associated with the object.
   * @param name The name associated with the object.
   * @param value The object value associated with the event.
   */
  public SessionValueBindEvent(SessionInfo session, String namespace, String name, Object value)
  {
    super(session);
    m_namespace = namespace;
    m_name = name;
    m_value = value;

  } // end consructor

  /*--------------------------------------------------------------------------------
   * Overrides from class DynamoEventObject
   *--------------------------------------------------------------------------------
   */

  /**
   * Returns a string representation of the object. In general, the <CODE>toString</CODE> method returns a string
   * that "textually represents" this object. 
   *
   * @return A string representation of the object.
   */
  public String toString()
  {
    return "SessionValueBindEvent: session = " + source + ", namespace = " + m_namespace + ", name = "
           + m_name + ", value = " + m_value;

  } // end toString

  /*--------------------------------------------------------------------------------
   * External operations
   *--------------------------------------------------------------------------------
   */

  /**
   * Returns the {@link com.silverwrist.dynamo.iface.SessionInfo SessionInfo} associated with this event.
   *
   * @return The <CODE>SessionInfo</CODE> associated with this event.
   */
  public SessionInfo getSession()
  {
    return (SessionInfo)getSource();

  } // end getSession

  /**
   * Returns the namespace URI that the value is/was stored under.
   *
   * @return The namespace URI that the value is/was stored under.
   */
  public String getNamespace()
  {
    return m_namespace;

  } // end getNamespace

  /**
   * Returns the name that the value is/was stored under.
   *
   * @return The name that the value is/was stored under.
   */
  public String getName()
  {
    return m_name;

  } // end getName

  /**
   * Returns the value associated with the event.  For
   * {@link com.silverwrist.dynamo.event.SessionValueBindListener#valueAdded(com.silverwrist.dynamo.event.SessionValueBindEvent) valueAdded()}
   * events, this value is the target value itself.  For
   * {@link com.silverwrist.dynamo.event.SessionValueBindListener#valueReplaced(com.silverwrist.dynamo.event.SessionValueBindEvent) valueReplaced()}
   * events, this value is the value that the target value was replaced with in the session.  For
   * {@link com.silverwrist.dynamo.event.SessionValueBindListener#valueRemoved(com.silverwrist.dynamo.event.SessionValueBindEvent) valueRemoved()}
   * events, this value is <CODE>null</CODE>.
   *
   * @return The value associated with the event.
   */
  public Object getValue()
  {
    return m_value;

  } // end getValue

} // end class SessionValueBindEvent
