/*
 * 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.security;

import java.util.*;
import com.silverwrist.dynamo.iface.*;

class ReadAuditRecord implements AuditRecord
{
  /*--------------------------------------------------------------------------------
   * Attributes
   *--------------------------------------------------------------------------------
   */

  private long m_record;
  private java.util.Date m_timestamp;
  private String m_namespace;
  private String m_name;
  private DynamoUser m_user;
  private int m_subid;
  private String m_ip;
  private Object[] m_props;

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

  ReadAuditRecord(long rec_id, Map data)
  {
    m_record = rec_id;
    m_timestamp = (java.util.Date)(data.get(AuditReadOps.HMKEY_DATE));
    m_namespace = (String)(data.get(AuditReadOps.HMKEY_NAMESPACE));
    m_name = (String)(data.get(AuditReadOps.HMKEY_NAME));
    m_user = (DynamoUser)(data.get(AuditReadOps.HMKEY_USER));
    m_subid = ((Integer)(data.get(AuditReadOps.HMKEY_SUBID))).intValue();
    m_ip = (String)(data.get(AuditReadOps.HMKEY_IP));
    m_props = (Object[])(data.get(AuditReadOps.HMKEY_PROPERTIES));

  } // end constructor

  /*--------------------------------------------------------------------------------
   * Implementations from interface AuditRecord
   *--------------------------------------------------------------------------------
   */

  public long getRecordNum()
  {
    return m_record;

  } // end getRecordNum

  public java.util.Date getTimestamp()
  {
    return m_timestamp;

  } // end getTimestamp

  public String getEventNamespace()
  {
    return m_namespace;

  } // end getEventNamespace

  public String getEventName()
  {
    return m_name;

  } // end getEventName

  public DynamoUser getUser()
  {
    return m_user;

  } // end getUser

  public int getSubID()
  {
    return m_subid;

  } // end getSubID

  public String getIPAddress()
  {
    return m_ip;

  } // end getIPAddress

  public Object getProperty(int index)
  {
    if ((index<0) || (index>=m_props.length))
      throw new IndexOutOfBoundsException("property index out of range");
    return m_props[index];

  } // end getProperty
  
} // end class ReadAuditRecord
