1 26 27 package org.objectweb.ccm.IDL3; 28 29 37 38 public class TypeRefImpl 39 implements TypeRef 40 { 41 47 50 private org.omg.CORBA.IDLType type_; 51 52 55 private int kind_; 56 57 60 private int length_; 61 private int scale_; 62 private TypeRef content_; 63 64 67 private Declaration[] dependencies_; 68 69 75 80 protected 81 TypeRefImpl(org.omg.CORBA.IDLType type, 82 int kind) 83 { 84 type_ = type; 86 kind_ = kind; 87 length_ = 0; 88 scale_ = 0; 89 content_ = null; 90 dependencies_ = null; 91 } 92 93 99 100 106 111 public org.omg.CORBA.IDLType 112 getIDLType() 113 { 114 return type_; 115 } 116 117 120 public void 121 addRef() 122 { 123 } 125 126 129 public void 130 removeRef() 131 { 132 } 134 135 138 public int 139 getTypeKind() 140 { 141 return kind_; 142 } 143 144 149 public Declaration[] 150 getDependencies() 151 { 152 if (dependencies_!=null) 153 return dependencies_; 154 155 if ((kind_!=TypeKind._tk_sequence) && 156 (kind_!=TypeKind._tk_array)) 157 dependencies_ = new Declaration[0]; 158 else if (content_.isDeclaration()) 159 { 160 Declaration[] depend = content_.getDependencies(); 161 Declaration[] depend2 = new Declaration[1+depend.length]; 162 for (int i=0;i<depend.length;i++) 163 depend2[i] = depend[i]; 164 165 depend2[depend.length] = (Declaration)content_; 166 dependencies_ = depend2; 167 } 168 else 169 dependencies_ = content_.getDependencies(); 170 171 return dependencies_; 172 } 173 174 177 public boolean 178 isDeclaration() 179 { 180 return false; 181 } 182 183 189 192 public void 193 setLength(int length) 194 { 195 length_ = length; 196 } 197 198 201 public void 202 setDigits(int digits) 203 { 204 length_ = digits; 205 } 206 207 210 public void 211 setScale(int scale) 212 { 213 scale_ = scale; 214 } 215 216 219 public void 220 setContentType(TypeRef content) 221 { 222 content_ = content; 223 } 224 225 228 public int 229 getLength() 230 { 231 if ((kind_==TypeKind._tk_string) || 232 (kind_==TypeKind._tk_sequence) || 233 (kind_==TypeKind._tk_array) || 234 (kind_==TypeKind._tk_wstring)) 235 return length_; 236 else 237 throw new Error ("Bad TypeKind !"); 238 } 239 240 243 public int 244 getDigits() 245 { 246 if (kind_==TypeKind._tk_fixed) 247 return length_; 248 else 249 throw new Error ("Bad TypeKind !"); 250 } 251 252 255 public int 256 getScale() 257 { 258 if (kind_==TypeKind._tk_fixed) 259 return scale_; 260 else 261 throw new Error ("Bad TypeKind !"); 262 } 263 264 267 public TypeRef 268 getContentType() 269 { 270 if ((kind_==TypeKind._tk_sequence) || 271 (kind_==TypeKind._tk_array)) 272 return content_; 273 else 274 throw new Error ("Bad TypeKind !"); 275 } 276 277 280 public String 281 getId() 282 { 283 if (kind_==TypeKind._tk_objref) 284 return "IDL:omg.org/CORBA/Object:1.0"; 285 286 throw new Error ("Bad TypeKind !"); 287 } 288 } 289 | Popular Tags |