View Javadoc
1   /*
2    *
3    * The DbUnit Database Testing Framework
4    * Copyright (C)2002-2008, DbUnit.org
5    *
6    * This library is free software; you can redistribute it and/or
7    * modify it under the terms of the GNU Lesser General Public
8    * License as published by the Free Software Foundation; either
9    * version 2.1 of the License, or (at your option) any later version.
10   *
11   * This library is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   * Lesser General Public License for more details.
15   *
16   * You should have received a copy of the GNU Lesser General Public
17   * License along with this library; if not, write to the Free Software
18   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19   *
20   */
21  
22  package org.dbunit.ext.oracle;
23  
24  import java.math.BigDecimal;
25  
26  /**
27   * This class provides some basic functionality shared among the OracleSdo*
28   * objects.
29   *
30   * @author clucas@e-miles.com
31   * @author Last changed by: $Author$
32   * @version $Revision$ $Date$
33   * @since ?
34   */
35  class OracleSdoHelper
36  {
37      public static boolean objectsEqual(Object object1, Object object2)
38      {
39          return
40              (object1 != null && object1.equals(object2)) ||
41              (object1 == null && object2 == null) ||
42              // special case for BigDecimal support
43              (object1 != null && object2 != null &&
44              object1 instanceof BigDecimal && object2 instanceof BigDecimal &&
45              ((BigDecimal)object1).compareTo((BigDecimal)object2) == 0);
46      }
47  
48      public static boolean objectArraysEquals(Object [] objects1, Object [] objects2)
49      {
50          if (objects1 == objects2)
51          {
52              return true;
53          }
54  
55          if (objects1 == null || objects2 == null || objects1.length != objects2.length)
56          {
57              return false;
58          }
59  
60          for (int index = 0; index<objects1.length; index++)
61          {
62              if (! objectsEqual(objects1[index], objects2[index]))
63              {
64                  return false;
65              }
66          }
67  
68          return true;
69      }
70  
71      public static int objectArrayHashCode(Object [] objects)
72      {
73          int hash = 7;
74          if (objects != null)
75          {
76              for (int index = 0; index<objects.length; index++)
77              {
78                  hash = 31 * hash + (null == objects[index] ? 0 : objects[index].hashCode());
79              }
80          }
81          return hash;
82      }
83  }