38 |
|
|
39 |
package org.omg.CosNaming; |
package org.omg.CosNaming; |
40 |
|
|
41 |
|
import gnu.CORBA.Minor; |
42 |
|
|
43 |
import org.omg.CORBA.Any; |
import org.omg.CORBA.Any; |
44 |
import org.omg.CORBA.BAD_OPERATION; |
import org.omg.CORBA.BAD_OPERATION; |
45 |
import org.omg.CORBA.BAD_PARAM; |
import org.omg.CORBA.BAD_PARAM; |
80 |
{ |
{ |
81 |
BAD_OPERATION bad = new BAD_OPERATION("Naming context expected"); |
BAD_OPERATION bad = new BAD_OPERATION("Naming context expected"); |
82 |
bad.initCause(ex); |
bad.initCause(ex); |
83 |
|
bad.minor = Minor.Any; |
84 |
throw bad; |
throw bad; |
85 |
} |
} |
86 |
} |
} |
133 |
else |
else |
134 |
throw new BAD_PARAM(); |
throw new BAD_PARAM(); |
135 |
} |
} |
136 |
|
|
137 |
|
/** |
138 |
|
* Narrow the given object to the NamingContext. No type-checking is performed |
139 |
|
* to verify that the object actually supports the requested type. The |
140 |
|
* {@link BAD_OPERATION} will be thrown if unsupported operations are invoked |
141 |
|
* on the new returned reference, but no failure is expected at the time of |
142 |
|
* the unchecked_narrow. |
143 |
|
* |
144 |
|
* @param obj the object to cast. |
145 |
|
* |
146 |
|
* @return the casted NamingContext. |
147 |
|
* |
148 |
|
* @since 1.5 |
149 |
|
* |
150 |
|
* @see OMG issue 4158. |
151 |
|
*/ |
152 |
|
public static NamingContext unchecked_narrow(org.omg.CORBA.Object obj) |
153 |
|
{ |
154 |
|
if (obj == null) |
155 |
|
return null; |
156 |
|
else if (obj instanceof NamingContext) |
157 |
|
return (NamingContext) obj; |
158 |
|
else |
159 |
|
{ |
160 |
|
// Do not call the _is_a(..). |
161 |
|
Delegate delegate = ((ObjectImpl) obj)._get_delegate(); |
162 |
|
return new _NamingContextStub(delegate); |
163 |
|
} |
164 |
|
} |
165 |
|
|
166 |
/** |
/** |
167 |
* Read the naming context from the given CDR input stream. |
* Read the naming context from the given CDR input stream. |