/*
 * Author: 
 * Inception Date: 
 *
 * This software is copyrighted by 		and the Regents of
 * the University of California.  The following terms apply to all
 * files associated with the software unless explicitly disclaimed in
 * individual files.
 * 
 * The authors hereby grant permission to use this software without
 * fee or royalty for any non-commercial purpose.  The authors also
 * grant permission to redistribute this software, provided this
 * copyright and a copy of this license (for reference) are retained
 * in all distributed copies.
 *
 * For commercial use of this software, contact the authors.
 * 
 * IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
 * ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
 * DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 * THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
 * IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
 * NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
 * MODIFICATIONS.
 */

package ninja2.core.sn_btree.bufcache;

import ninja2.core.io_core.interfaces.*;
import ninja2.core.io_core.interfaces.disk.*;
import ninja2.core.io_core.core.*;
import ninja2.core.io_core.util.*;
import java.util.Vector;

/**
 * A BufCacheElement is one of the primitive entries in the buffer
 * cache.  It stores a MemRegionIF, as well as the name of the segment
 * from which it is read, the block number within that segment, the
 * block size, and whether or not this block is dirty.
 * 
 * @author
 * @see ninja2.core.io_core.interfaces.MemRegionIF 
 */

public class BufCacheElement extends ninja2.core.io_core.interfaces.GenericQueueElement {

  public String      segment_name;
  public int         block_size;
  public int         block_num;
  public boolean     dirty;
  public MemRegionIF region;
  public Vector 	 uniqueID;	/* MARK: request ID */

  BufCacheElement() {
	uniqueID = new Vector();
  }
  public String toString() {
	Integer ID;	
	ID = uniqueID.isEmpty() ? new Integer(-1):(Integer)uniqueID.firstElement();
    String newStr = new String(segment_name + ": block size " + block_size +
		      ", block #" + block_num + ", dirty: " + dirty +", fsmID: "+ID);
/*    String bytesStr = new String("");
    int size = region.getSize();

    for (int i=0; i<size; i+=4) {
      if (i+4 <= size) {
	int nextInt = region.getInt(i);
	bytesStr = new String(bytesStr + Integer.toHexString(nextInt) + " ");
	if (i % 16 == 15)
	  bytesStr = new String(bytesStr + "\n");
      }
    }
    newStr = new String(newStr + "\n" + bytesStr);*/
    return newStr;
  }

}

