KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > dmi > DmiClassSpec


1 /*
2  * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
3  * notice. All rights reserved.
4  */

5 package com.tc.object.dmi;
6
7 import com.tc.util.Assert;
8
9 public class DmiClassSpec {
10
11   private final String JavaDoc classLoaderDesc;
12   private final String JavaDoc className;
13   private final String JavaDoc spec;
14
15   public DmiClassSpec(final String JavaDoc classLoaderDesc, final String JavaDoc className) {
16     Assert.pre(classLoaderDesc != null);
17     Assert.pre(className != null);
18     this.classLoaderDesc = classLoaderDesc;
19     this.className = className;
20     this.spec = classLoaderDesc + "-" + className;
21   }
22
23   public String JavaDoc getClassLoaderDesc() {
24     return classLoaderDesc;
25   }
26
27   public String JavaDoc getClassName() {
28     return className;
29   }
30
31   public int hashCode() {
32     return spec.hashCode();
33   }
34
35   public boolean equals(Object JavaDoc obj) {
36     if (!(obj instanceof DmiClassSpec)) return false;
37     DmiClassSpec that = (DmiClassSpec) obj;
38     return this.spec.equals(that.spec);
39   }
40   
41   public String JavaDoc toString() {
42     return "DmiClassSpec{loader=" + classLoaderDesc + ", className=" + className + "}";
43   }
44   
45   public static String JavaDoc toString(DmiClassSpec[] specs) {
46     StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
47     sb.append("[");
48     for (int i = 0; i < specs.length; i++) {
49       sb.append(specs[i].toString()).append(",");
50     }
51     sb.append("]");
52     return sb.toString();
53   }
54 }
55
Popular Tags