1 package org.apache.ojb.broker.accesslayer.sql; 2 3 17 18 import org.apache.ojb.broker.query.Query; 19 import org.apache.ojb.broker.metadata.ClassDescriptor; 20 21 27 class SqlCacheKey 28 { 29 public static final int TYPE_SELECT = 1; 30 public static final int TYPE_INSERT = 2; 31 public static final int TYPE_UPDATE = 3; 32 public static final int TYPE_DELETE = 4; 33 34 private final Query m_query; 35 private final ClassDescriptor m_cld; 36 private final int type; 37 38 public SqlCacheKey(final Query query, final ClassDescriptor cld, final int type) 39 { 40 m_query = query; 41 m_cld = cld; 42 this.type = type; 43 } 44 45 public int hashCode() 46 { 47 int retval = 0; 48 if (getCld() != null) 49 { 50 retval += getCld().hashCode(); 51 } 52 if (getQuery() != null) 53 { 54 retval += getQuery().hashCode(); 55 } 56 return retval+type; 57 } 58 59 public boolean equals(Object other) 60 { 61 if (other == null) 62 { 63 return false; 64 } 65 if (other instanceof SqlCacheKey) 66 { 67 SqlCacheKey temp = (SqlCacheKey) other; 68 if (temp.getCld().equals(getCld()) && (temp.getQuery().equals(getQuery())) && (temp.getType() == this.getType())) 69 { 70 return true; 71 } 72 else 73 { 74 return false; 75 } 76 } 77 else 78 { 79 return false; 80 } 81 } 82 83 public Query getQuery() 84 { 85 return m_query; 86 } 87 88 public ClassDescriptor getCld() 89 { 90 return m_cld; 91 } 92 93 public int getType() 94 { 95 return type; 96 } 97 101 102 112 } 113 | Popular Tags |