347 * The hash code is the sum of the hash code of its addresses.
348 *
349 * @return A hash code of this reference as an int.
350 */
351 public int hashCode() {
352 int hash = className.hashCode();
353 for (Enumeration<RefAddr> e = getAll(); e.hasMoreElements();)
354 hash += e.nextElement().hashCode();
355 return hash;
356 }
357
358 /**
359 * Generates the string representation of this reference.
360 * The string consists of the class name to which this reference refers,
361 * and the string representation of each of its addresses.
362 * This representation is intended for display only and not to be parsed.
363 *
364 * @return The non-null string representation of this reference.
365 */
366 public String toString() {
367 StringBuilder sb = new StringBuilder("Reference Class Name: " +
368 className + "\n");
369 int len = addrs.size();
370 for (int i = 0; i < len; i++)
371 sb.append(get(i).toString());
372
373 return sb.toString();
374 }
375
376 /**
377 * Makes a copy of this reference using its class name
378 * list of addresses, class factory name and class factory location.
379 * Changes to the newly created copy does not affect this Reference
380 * and vice versa.
381 */
382 public Object clone() {
383 Reference r = new Reference(className, classFactory, classFactoryLocation);
384 Enumeration<RefAddr> a = getAll();
385 r.addrs = new Vector<>();
386
387 while (a.hasMoreElements())
388 r.addrs.addElement(a.nextElement());
|
347 * The hash code is the sum of the hash code of its addresses.
348 *
349 * @return A hash code of this reference as an int.
350 */
351 public int hashCode() {
352 int hash = className.hashCode();
353 for (Enumeration<RefAddr> e = getAll(); e.hasMoreElements();)
354 hash += e.nextElement().hashCode();
355 return hash;
356 }
357
358 /**
359 * Generates the string representation of this reference.
360 * The string consists of the class name to which this reference refers,
361 * and the string representation of each of its addresses.
362 * This representation is intended for display only and not to be parsed.
363 *
364 * @return The non-null string representation of this reference.
365 */
366 public String toString() {
367 StringBuilder sb = new StringBuilder();
368 sb.append("Reference Class Name: ");
369 sb.append(className).append('\n');
370 int len = addrs.size();
371 for (int i = 0; i < len; i++)
372 sb.append(get(i).toString());
373
374 return sb.toString();
375 }
376
377 /**
378 * Makes a copy of this reference using its class name
379 * list of addresses, class factory name and class factory location.
380 * Changes to the newly created copy does not affect this Reference
381 * and vice versa.
382 */
383 public Object clone() {
384 Reference r = new Reference(className, classFactory, classFactoryLocation);
385 Enumeration<RefAddr> a = getAll();
386 r.addrs = new Vector<>();
387
388 while (a.hasMoreElements())
389 r.addrs.addElement(a.nextElement());
|