KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > core > windows > persistence > GroupConfig


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20
21 package org.netbeans.core.windows.persistence;
22
23
24
25
26
27 /**
28  * Class of group config properties for communication with persistence management.
29  * It keeps data which are read/written from/in .wsgrp xml file.
30  *
31  * @author Peter Zavadsky
32  */

33 public class GroupConfig {
34
35     /** Unique name of group. */
36     public String JavaDoc name;
37
38     /** Is group opened or not. */
39     public boolean opened;
40
41
42     /** Array of TCGroupConfigs */
43     public TCGroupConfig[] tcGroupConfigs;
44
45     /** Creates a new instance of GroupConfig */
46     public GroupConfig() {
47         name = ""; // NOI18N
48
tcGroupConfigs = new TCGroupConfig[0];
49     }
50     
51     public boolean equals (Object JavaDoc obj) {
52         if (this == obj) {
53             return true;
54         }
55         if (!(obj instanceof GroupConfig)) {
56             return false;
57         }
58         GroupConfig groupCfg = (GroupConfig) obj;
59         if (!name.equals(groupCfg.name)) {
60             return false;
61         }
62         if (opened != groupCfg.opened) {
63             return false;
64         }
65         //Order of tcGroupConfigs array is NOT defined
66
if (tcGroupConfigs.length != groupCfg.tcGroupConfigs.length) {
67             return false;
68         }
69         for (int i = 0; i < tcGroupConfigs.length; i++) {
70             TCGroupConfig tcGroupCfg = null;
71             for (int j = 0; j < groupCfg.tcGroupConfigs.length; j++) {
72                 if (tcGroupConfigs[i].tc_id.equals(groupCfg.tcGroupConfigs[j].tc_id)) {
73                     tcGroupCfg = groupCfg.tcGroupConfigs[j];
74                     break;
75                 }
76             }
77             if (tcGroupCfg == null) {
78                 return false;
79             }
80             if (!tcGroupConfigs[i].equals(tcGroupCfg)) {
81                 return false;
82             }
83         }
84         return true;
85     }
86     
87     public int hashCode() {
88         int hash = 17;
89         hash = 37 * hash + name.hashCode();
90         hash = 37 * hash + (opened ? 0 : 1);
91         for (int i = 0; i < tcGroupConfigs.length; i++) {
92             hash = 37 * hash + tcGroupConfigs[i].hashCode();
93         }
94         return hash;
95     }
96     
97 }
98
Popular Tags