KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > common > domains > registry > DomainEntry


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.admin.common.domains.registry;
25 import java.io.File JavaDoc;
26 import java.io.Serializable JavaDoc;
27 import java.io.IOException JavaDoc;
28
29
30 /**
31    This class represents the data required to be registered for each
32    domain so that invariants between domains can be maintained, and
33    communication to domains established.
34    <p>
35    Instances of this class are immutable - they are simply data carriers.
36  *
37  * @author <a HREF="mailto:toby.h.ferguson@sun.com">Toby H Ferguson</a>
38  * @version $Revision: 1.3 $
39  */

40
41
42 public class DomainEntry implements Cloneable JavaDoc, Serializable JavaDoc
43 {
44
45       /**
46          Construct an immutable instance
47          @param name the name of the domain
48          @param root the root of the domain
49          @param contactData the data used to contact the domain
50          @throws NullPointerException if any argument is null
51       */

52   public DomainEntry(String JavaDoc name, File JavaDoc root, ContactDataSet contactData) throws NullPointerException JavaDoc {
53     if (name == null || root == null || contactData == null) {
54       throw new NullPointerException JavaDoc();
55     }
56     this.name = name;
57     this.root = root;
58         try
59         {
60         this.path = root.getCanonicalPath();
61         }
62         catch(IOException JavaDoc ioe)
63         {
64         this.path = root.getAbsolutePath();
65         }
66     this.contactData = contactData;
67   }
68
69       /**
70          Get the name of the receiver
71          @return the name of the receiver
72       */

73   public String JavaDoc getName(){
74     return this.name;
75   }
76
77       /**
78          Get the root of the receiver
79          @return the root of the receiver
80       */

81   public File JavaDoc getRoot(){
82     return this.root;
83   }
84
85       /**
86          Get the path of the receiver
87          @return the path of the receiver
88       */

89   public String JavaDoc getPath(){
90     return this.path;
91   }
92
93       /**
94          Get the contact data of the receiver
95          @return the contact data of the receiver
96       */

97   public ContactDataSet getContactData(){
98     return this.contactData;
99   }
100
101   public Object JavaDoc clone() {
102     try {
103       return super.clone();
104     }
105     catch (CloneNotSupportedException JavaDoc c){
106       return null;
107     }
108   }
109
110   public int hashcode(){
111     final String JavaDoc s = this.name+this.root.toString();
112     return s.hashCode();
113   }
114
115   public boolean equals(Object JavaDoc rhs){
116     return rhs != null && rhs instanceof DomainEntry && this.equals((DomainEntry) rhs);
117   }
118
119   private boolean equals(DomainEntry rhs){
120     return rhs != null && this == rhs ||
121     (this.name.equals(rhs.name) && this.root.equals(rhs.root));
122   }
123
124   private String JavaDoc name;
125   private File JavaDoc root;
126   private String JavaDoc path;
127   private ContactDataSet contactData;
128   
129 }
130
Popular Tags