1 32 33 34 package com.mockobjects.eziba.sql;class ArgumentArray 35 { 36 37 ArgumentArray(Object [] p_args) 38 { 39 m_args = p_args; 40 } 41 42 public boolean equals(Object p_other) 43 { 44 if (! (p_other instanceof ArgumentArray) ) 45 { 46 return false; 47 } 48 return arraysEqual(m_args, ((ArgumentArray)p_other).m_args); 49 } 50 51 public int hashCode() 52 { 53 return m_args.length; 54 } 55 56 public String toString() 57 { 58 StringBuffer sb = new StringBuffer (); 59 sb.append("["); 60 for (int i = 0; i < m_args.length; ++i) 61 { 62 if (i > 0) { sb.append(','); } 63 sb.append(m_args[i]); 64 } 65 sb.append(']'); 66 return sb.toString(); 67 } 68 69 private static boolean objectsEqual(final Object p_first, 70 final Object p_second) 71 { 72 if (p_first == null && p_second == null) 73 { 74 return true; 75 } 76 else if ( p_first == Wildcard.WILDCARD 77 || p_second == Wildcard.WILDCARD) 78 { 79 return true; 80 } 81 else if (p_first == null || p_second == null) 82 { 83 return false; 84 } 85 else 86 { 87 return p_first.equals(p_second); 88 } 89 } 90 91 98 99 private static boolean arraysEqual(final Object [] p_first, 100 final Object [] p_second) 101 { 102 if ( p_first.length != p_second.length ) 105 { 106 return false; 107 } 108 for (int i = 0; i < p_first.length; i++) 109 { 110 if ( ! objectsEqual(p_first[i],p_second[i]) ) 111 { 112 return false; 113 } 114 } 115 return true; 116 } 117 118 119 private final Object [] m_args; 120 } | Popular Tags |