1 26 27 package org.objectweb.openccm.pss.generator.common.lib; 28 29 import org.objectweb.openccm.generator.java.ast.api.*; 31 import org.objectweb.openccm.generator.java.ast.lib.*; 32 33 34 41 42 public class HolderMapping 43 implements org.objectweb.openccm.pss.generator.common.api.HolderMapping 44 { 45 46 52 53 private String type_; 54 55 56 private String package_name_; 57 58 64 69 70 public HolderMapping(String type, String package_name) 71 { 72 type_ = type; 74 package_name_ = package_name; 75 } 76 77 83 89 94 public void 95 toJava(org.objectweb.openccm.generator.java.ast.api.Repository repository) 96 { 97 ClassObject clazz = null; 98 AttributeObject att = null; 99 ConstructorObject ct = null; 100 MethodObject method = null; 101 ParameterObject param = null; 102 103 clazz = new ClassObjectImpl(type_ + "Holder"); 104 clazz.addComment("Holder class for : " + type_); 105 clazz.addComment(""); 106 clazz.addComment(" @author OpenCCM PSDL Compiler"); 107 clazz.setModifier(ModifierKindImpl.mk_public); 108 clazz.setPackage(package_name_); 109 clazz.addImplementedObject("org.omg.CORBA.portable.Streamable"); 110 111 att = new AttributeObjectImpl(); 113 att.addComment("Internal " + type_ + " value"); 114 att.setName("value_"); 115 att.setType(package_name_ + "." + type_); 116 att.setModifier( ModifierKindImpl.mk_public ); 117 clazz.addAttribute(att); 118 119 ct = new ConstructorObjectImpl(); 121 ct.addComment("The default constructor."); 122 clazz.addConstructor(ct); 123 ct = new ConstructorObjectImpl(); 125 ct.addComment("Constructor with initial value."); 126 ct.addComment(" "); 127 ct.addComment("@param value - The initial value."); 128 param = new ParameterObjectImpl(); 129 param.setName("value"); 130 param.setType(package_name_ + "." + type_); 131 ct.addParameter(param); 132 ct.getImpl().setMacro("HOLDER_CONSTRUCTOR"); 133 ct.getImpl().addContextValue("var", "value_"); 134 clazz.addConstructor(ct); 135 136 method = new MethodObjectImpl(); 138 method.addComment("Reads data from istream and initalizes the value "+ 139 "field of the Holder with the unmarshalled data."); 140 method.addComment(" "); 141 method.addComment("@param istream - the InputStream that represents the CDR data from the wire."); 142 method.setName("_read"); 143 method.setReturnType("void"); 144 param = new ParameterObjectImpl(); 145 param.setName("istream"); 146 param.setType("org.omg.CORBA.portable.InputStream"); 147 method.addParameter(param); 148 method.getImpl().setMacro("CORBA_NO_IMPLEMENT"); 149 clazz.addMethod(method); 150 151 method = new MethodObjectImpl(); 153 method.addComment("Marshals to ostream the value in the value field of the Holder."); 154 method.addComment(" "); 155 method.addComment("@param ostream - the CDR OutputStream."); 156 method.setName("_write"); 157 method.setReturnType("void"); 158 param = new ParameterObjectImpl(); 159 param.setName("ostream"); 160 param.setType("org.omg.CORBA.portable.OutputStream"); 161 method.addParameter(param); 162 method.getImpl().setMacro("CORBA_NO_IMPLEMENT"); 163 clazz.addMethod(method); 164 165 method = new MethodObjectImpl(); 167 method.addComment("Retrieves the TypeCode object corresponding to the value"+ 168 " in the value field of the Holder."); 169 method.addComment(" "); 170 method.addComment("@return The TypeCode object for the value held in the holder."); 171 method.setName("_type"); 172 method.setReturnType("org.omg.CORBA.TypeCode"); 173 method.getImpl().setMacro("CORBA_NO_IMPLEMENT"); 174 clazz.addMethod(method); 175 176 repository.addObject(clazz); 177 } 178 } 179 | Popular Tags |