001 package org.wdssii.webindex.servlet; 002 003 /** 004 * A single index record in the list returned by WebIndexController 005 * 006 * @author Lakshman 007 * @version $Id: IndexRecordBean.java,v 1.1 2007/09/20 19:31:29 lakshman Exp $ 008 */ 009 public class IndexRecordBean implements Comparable<IndexRecordBean> { 010 private long number; 011 private String xml; 012 private String name; 013 014 public IndexRecordBean(String name, String xmldata, long no) { 015 this.name = name; 016 this.xml = xmldata; 017 this.number = no; 018 } 019 020 public long getNumber() { 021 return number; 022 } 023 024 public String getXML() { 025 return xml; 026 } 027 028 public String getName() { 029 return name; 030 } 031 032 /** compare by number (order of creation) */ 033 public int compareTo(IndexRecordBean other) { 034 if (number < other.getNumber()) 035 return -1; 036 else if (number == other.getNumber()) 037 return 0; 038 else 039 return 1; 040 } 041 042 /** The creation number will serve as our hashcode */ 043 @Override 044 public int hashCode() { 045 return (int) number; 046 } 047 048 /** The equality check is based purely on number */ 049 @Override 050 public boolean equals(Object o) { 051 if ( o instanceof IndexRecordBean ){ 052 IndexRecordBean other = (IndexRecordBean) o; 053 return (number == other.getNumber()); 054 } else { 055 return false; 056 } 057 } 058 }