1 /* |
1 /* |
2 * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
98 throw new SerialException("MalformedURLException: " + e.getMessage()); |
98 throw new SerialException("MalformedURLException: " + e.getMessage()); |
99 } |
99 } |
100 return aURL; |
100 return aURL; |
101 } |
101 } |
102 |
102 |
|
103 /** |
|
104 * Compares this {@code SerialDatalink} to the specified object. |
|
105 * The result is {@code true} if and only if the argument is not |
|
106 * {@code null} and is a {@code SerialDatalink} object whose URL is |
|
107 * identical to this object's URL |
|
108 * |
|
109 * @param obj The object to compare this {@code SerialDatalink} against |
|
110 * |
|
111 * @return {@code true} if the given object represents a {@code SerialDatalink} |
|
112 * equivalent to this SerialDatalink, {@code false} otherwise |
|
113 * |
|
114 */ |
|
115 public boolean equals(Object obj) { |
|
116 if (this == obj) { |
|
117 return true; |
|
118 } |
|
119 if (obj instanceof SerialDatalink) { |
|
120 SerialDatalink sdl = (SerialDatalink) obj; |
|
121 return url.equals(sdl.url); |
|
122 } |
|
123 return false; |
|
124 } |
103 |
125 |
104 /** |
126 /** |
105 * The identifier that assists in the serialization of this <code>SerialDatalink</code> |
127 * Returns a hash code for this {@code SerialDatalink}. The hash code for a |
106 * object. |
128 * {@code SerialDatalink} object is taken as the hash code of |
|
129 * the {@code URL} it stores |
|
130 * |
|
131 * @return a hash code value for this object. |
|
132 */ |
|
133 public int hashCode() { |
|
134 return 31 + url.hashCode(); |
|
135 } |
|
136 |
|
137 /** |
|
138 * Returns a clone of this {@code SerialDatalink}. |
|
139 * |
|
140 * @return a clone of this SerialDatalink |
|
141 */ |
|
142 public Object clone() { |
|
143 try { |
|
144 SerialDatalink sdl = (SerialDatalink) super.clone(); |
|
145 return sdl; |
|
146 } catch (CloneNotSupportedException ex) { |
|
147 // this shouldn't happen, since we are Cloneable |
|
148 throw new InternalError(); |
|
149 } |
|
150 } |
|
151 |
|
152 /** |
|
153 * readObject and writeObject are called to restore the state |
|
154 * of the {@code SerialDatalink} |
|
155 * from a stream. Note: we leverage the default Serialized form |
|
156 */ |
|
157 |
|
158 /** |
|
159 * The identifier that assists in the serialization of this |
|
160 * {@code SerialDatalink} object. |
107 */ |
161 */ |
108 static final long serialVersionUID = 2826907821828733626L; |
162 static final long serialVersionUID = 2826907821828733626L; |
109 } |
163 } |