01: /**
02: * $Id: Compare.java,v 1.1 2004/01/20 21:51:28 mjain Exp $
03: * Copyright 2003 Sun Microsystems, Inc. All
04: * rights reserved. Use of this product is subject
05: * to license terms. Federal Acquisitions:
06: * Commercial Software -- Government Users
07: * Subject to Standard License Terms and
08: * Conditions.
09: *
10: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
11: * are trademarks or registered trademarks of Sun Microsystems,
12: * Inc. in the United States and other countries.
13: */package com.sun.portal.wsrp.consumer.common;
14:
15: import java.util.Set;
16: import java.util.Map;
17: import java.util.List;
18: import java.util.Iterator;
19:
20: /**
21: * Common utility static methods.
22: *
23: */
24: public class Compare {
25:
26: public static boolean isStrSame(String a, String b) {
27: if (a == null && b == null) {
28: return true;
29: }
30: if (a != null && a.equals(b)) {
31: return true;
32: }
33: return false;
34: }
35:
36: public static boolean isArraySame(String[] a, String[] b) {
37:
38: if (a == null && b == null) {
39: return true;
40: }
41:
42: if (a != null && b != null) {
43: if (a.length == b.length) {
44: for (int i = 0; i < a.length; i++) {
45: if (!isStrSame(a[i], b[i])) {
46: // element not same
47: return false;
48: }
49: }
50: // all elements same
51: return true;
52: } else {
53: // length is not same
54: return false;
55: }
56: } else {
57: // only one of them is null
58: return false;
59: }
60: }
61:
62: public static boolean isMapSame(Map a, Map b) {
63:
64: if (a == null && b == null) {
65: return true;
66: }
67:
68: if (a != null) {
69: return a.equals(b);
70: } else {
71: return b.equals(a);
72: }
73:
74: }
75:
76: public static boolean isListSame(List a, List b) {
77: if (a == null && b == null) {
78: return true;
79: }
80:
81: if (a != null) {
82: return a.equals(b);
83: } else {
84: return b.equals(a);
85: }
86: }
87: }
|