KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > orbutil > RepIdDelegator


1 /*
2  * @(#)RepIdDelegator.java 1.8 05/01/04
3  *
4  * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.corba.se.impl.orbutil;
9
10 import org.omg.CORBA.ORB JavaDoc;
11 import java.io.Serializable JavaDoc;
12 import java.util.Hashtable JavaDoc;
13 import com.sun.corba.se.impl.io.TypeMismatchException;
14 import java.net.MalformedURLException JavaDoc;
15 import com.sun.corba.se.impl.util.RepositoryId;
16
17 /**
18  * Delegates to the current RepositoryId implementation in
19  * com.sun.corba.se.impl.util. This is necessary to
20  * overcome the fact that many of RepositoryId's methods
21  * are static.
22  */

23 public final class RepIdDelegator
24     implements RepositoryIdStrings,
25                RepositoryIdUtility,
26                RepositoryIdInterface
27 {
28     // RepositoryIdFactory methods
29

30     public String JavaDoc createForAnyType(Class JavaDoc type) {
31         return RepositoryId.createForAnyType(type);
32     }
33
34     public String JavaDoc createForJavaType(Serializable JavaDoc ser)
35         throws TypeMismatchException
36     {
37         return RepositoryId.createForJavaType(ser);
38     }
39                
40     public String JavaDoc createForJavaType(Class JavaDoc clz)
41         throws TypeMismatchException
42     {
43         return RepositoryId.createForJavaType(clz);
44     }
45
46     public String JavaDoc createSequenceRepID(java.lang.Object JavaDoc ser) {
47         return RepositoryId.createSequenceRepID(ser);
48     }
49
50     public String JavaDoc createSequenceRepID(Class JavaDoc clazz) {
51         return RepositoryId.createSequenceRepID(clazz);
52     }
53
54     public RepositoryIdInterface getFromString(String JavaDoc repIdString) {
55         return new RepIdDelegator(RepositoryId.cache.getId(repIdString));
56     }
57
58     // RepositoryIdUtility methods
59

60     public boolean isChunkedEncoding(int valueTag) {
61         return RepositoryId.isChunkedEncoding(valueTag);
62     }
63
64     public boolean isCodeBasePresent(int valueTag) {
65         return RepositoryId.isCodeBasePresent(valueTag);
66     }
67
68     public String JavaDoc getClassDescValueRepId() {
69         return RepositoryId.kClassDescValueRepID;
70     }
71
72     public String JavaDoc getWStringValueRepId() {
73         return RepositoryId.kWStringValueRepID;
74     }
75
76     public int getTypeInfo(int valueTag) {
77         return RepositoryId.getTypeInfo(valueTag);
78     }
79
80     public int getStandardRMIChunkedNoRepStrId() {
81         return RepositoryId.kPreComputed_StandardRMIChunked_NoRep;
82     }
83
84     public int getCodeBaseRMIChunkedNoRepStrId() {
85         return RepositoryId.kPreComputed_CodeBaseRMIChunked_NoRep;
86     }
87
88     public int getStandardRMIChunkedId() {
89         return RepositoryId.kPreComputed_StandardRMIChunked;
90     }
91
92     public int getCodeBaseRMIChunkedId() {
93         return RepositoryId.kPreComputed_CodeBaseRMIChunked;
94     }
95
96     public int getStandardRMIUnchunkedId() {
97         return RepositoryId.kPreComputed_StandardRMIUnchunked;
98     }
99
100     public int getCodeBaseRMIUnchunkedId() {
101         return RepositoryId.kPreComputed_CodeBaseRMIUnchunked;
102     }
103
104     public int getStandardRMIUnchunkedNoRepStrId() {
105     return RepositoryId.kPreComputed_StandardRMIUnchunked_NoRep;
106     }
107
108     public int getCodeBaseRMIUnchunkedNoRepStrId() {
109         return RepositoryId.kPreComputed_CodeBaseRMIUnchunked_NoRep;
110     }
111
112     // RepositoryIdInterface methods
113

114     public Class JavaDoc getClassFromType() throws ClassNotFoundException JavaDoc {
115         return delegate.getClassFromType();
116     }
117
118     public Class JavaDoc getClassFromType(String JavaDoc codebaseURL)
119         throws ClassNotFoundException JavaDoc, MalformedURLException JavaDoc
120     {
121         return delegate.getClassFromType(codebaseURL);
122     }
123
124     public Class JavaDoc getClassFromType(Class JavaDoc expectedType,
125                                   String JavaDoc codebaseURL)
126         throws ClassNotFoundException JavaDoc, MalformedURLException JavaDoc
127     {
128         return delegate.getClassFromType(expectedType, codebaseURL);
129     }
130
131     public String JavaDoc getClassName() {
132         return delegate.getClassName();
133     }
134
135     // Constructor used for factory/utility cases
136
public RepIdDelegator() {}
137
138     // Constructor used by getIdFromString. All non-static
139
// RepositoryId methods will use the provided delegate.
140
private RepIdDelegator(RepositoryId _delegate) {
141         this.delegate = _delegate;
142     }
143
144     private RepositoryId delegate;
145
146     public String JavaDoc toString() {
147         if (delegate != null)
148             return delegate.toString();
149         else
150             return this.getClass().getName();
151     }
152
153     public boolean equals(Object JavaDoc obj) {
154         if (delegate != null)
155             return delegate.equals(obj);
156         else
157             return super.equals(obj);
158     }
159 }
160
Popular Tags