1 26 27 package org.objectweb.ccm.IDL3; 28 29 37 38 public class ConstantDeclImpl 39 extends AnyValueDeclImpl 40 implements ConstantDecl 41 { 42 48 51 private org.omg.CORBA.ConstantDef constant_def_; 52 53 56 private TypeRef type_; 57 58 64 69 protected 70 ConstantDeclImpl(Repository rep, ScopeImpl parent) 71 { 72 super(rep, parent); 74 75 constant_def_ = null; 77 type_ = null; 78 the_declaration_kind_ = DeclarationKind._dk_constant; 79 } 80 81 87 92 protected void 93 load(org.omg.CORBA.Contained contained) 94 { 95 constant_def_ = org.omg.CORBA.ConstantDefHelper.narrow(contained); 96 setType(getRepository().getAsTypeRef(constant_def_.type_def())); 97 AnyValue any = new AnyValue(); 98 any.loadAny(constant_def_.value()); 99 setAnyValue(any); 100 101 super.load(contained); 102 } 103 104 109 protected void 110 loadAsMapping(org.omg.CORBA.Contained contained) 111 { 112 constant_def_ = org.omg.CORBA.ConstantDefHelper.narrow(contained); 113 setType(getRepository().getAsMappedTypeRef(constant_def_.type_def())); 114 AnyValue any = new AnyValue(); 115 any.loadAny(constant_def_.value()); 116 setAnyValue(any); 117 118 super.loadAsMapping(contained); 119 } 120 121 127 130 public void 131 create() 132 { 133 constant_def_ = the_parent_.getContainer().create_constant(getId(), 134 getName(), 135 getVersion(), 136 type_.getIDLType(), 137 getAnyValue().computeAny(type_.getIDLType().type())); 138 139 super.create(); 140 } 141 142 149 public Declaration[] 150 getDependencies() 151 { 152 if (dependencies_!=null) 153 return dependencies_; 154 155 org.objectweb.ccm.util.Vector constant_depend = new org.objectweb.ccm.util.Vector(); 156 157 if (getType().isDeclaration()) 159 constant_depend.add(getType()); 160 161 Declaration[] depend = getType().getDependencies(); 162 for (int i=0;i<depend.length;i++) 163 constant_depend.add(depend[i]); 164 165 dependencies_ = (Declaration[])constant_depend.toArray(new Declaration[0]); 166 return dependencies_; 167 } 168 169 170 176 181 public void 182 setType(TypeRef type) 183 { 184 if(type != null) 185 { 186 type_ = type; 187 type_.addRef(); 188 } 189 } 190 191 194 public TypeRef 195 getType() 196 { 197 return type_; 198 } 199 200 206 209 public void 210 destroy() 211 { 212 if (type_!=null) 213 type_.removeRef(); 214 215 super.destroy(); 216 } 217 218 223 protected org.omg.CORBA.Contained 224 getContained() 225 { 226 return constant_def_; 227 } 228 } 229 | Popular Tags |