1 26 27 package org.objectweb.openccm.ast.lib; 28 29 30 import org.objectweb.openccm.ast.api.AnyValue; 31 32 33 import org.objectweb.openccm.ast.api.DeclarationKind; 34 35 36 import org.objectweb.openccm.ast.api.Declaration; 37 38 39 import org.omg.CORBA.ConstantDef ; 40 import org.omg.CORBA.ConstantDefHelper; 41 42 55 56 public class ConstantDeclImpl 57 extends DeclarationWithTypeRefImpl 58 implements org.objectweb.openccm.ast.api.ConstantDecl 59 { 60 66 67 private ConstantDef constant_def_; 68 69 70 private AnyValueImpl any_; 71 72 78 84 protected 85 ConstantDeclImpl(Repository rep, 86 ScopeImpl parent) 87 { 88 super(rep, parent); 90 91 constant_def_ = null; 93 any_ = new AnyValueImpl(); 94 } 95 96 102 108 113 protected void 114 load(org.omg.CORBA.Contained contained) 115 { 116 constant_def_ = ConstantDefHelper.narrow(contained); 117 setType(getRepository().getAsTypeRef(constant_def_.type_def())); 118 any_ = new AnyValueImpl(); 119 any_.loadAny(constant_def_.value()); 120 121 super.load(contained); 122 } 123 124 129 protected void 130 loadAsMapping(org.omg.CORBA.Contained contained) 131 { 132 constant_def_ = ConstantDefHelper.narrow(contained); 133 setType(getRepository().getAsMappedTypeRef(constant_def_.type_def())); 134 any_ = new AnyValueImpl(); 135 any_.loadAny(constant_def_.value()); 136 137 super.loadAsMapping(contained); 138 } 139 140 145 protected org.omg.CORBA.Contained 146 getContained() 147 { 148 return constant_def_; 149 } 150 151 157 163 171 public Declaration[] 172 getDependencies() 173 { 174 if (dependencies_!=null) 175 return dependencies_; 176 177 java.util.List constant_depend = new java.util.ArrayList (); 178 179 if (getType().isDeclaration()) 181 constant_depend.add(getType()); 182 183 Declaration[] depend = getType().getDependencies(); 184 for (int i=0;i<depend.length;i++) 185 constant_depend.add(depend[i]); 186 187 dependencies_ = (Declaration[])constant_depend.toArray( 188 new Declaration[0]); 189 return dependencies_; 190 } 191 192 198 203 public long 204 getDeclKind() 205 { 206 return DeclarationKind.dk_constant; 207 } 208 209 212 public void 213 create() 214 { 215 constant_def_ = the_parent_.getContainer(). 216 create_constant(getId(), getName(), getVersion(), 217 getIDLType(), 218 any_.computeAny(getIDLType().type())); 219 220 super.create(); 221 } 222 223 229 234 public void 235 setAnyValue(AnyValue value) 236 { 237 any_ = (AnyValueImpl)value; 238 } 239 240 245 public AnyValue 246 getAnyValue() 247 { 248 return any_; 249 } 250 251 257 } 258 | Popular Tags |