< prev index next >

src/java.corba/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/MethodGen24.java

Print this page




  79     boolean firstTime = true;
  80     Enumeration e = m.parameters ().elements ();
  81     while (e.hasMoreElements ())
  82     {
  83       if (firstTime)
  84         firstTime = false;
  85       else
  86         stream.print (", ");
  87       ParameterEntry parm = (ParameterEntry)e.nextElement ();
  88       if (listTypes) {
  89         writeParmType (parm.type (), parm.passType ());
  90         stream.print (' ');
  91       }
  92       // Print parm name
  93       stream.print (parm.name ());
  94       // end of parameter list
  95     }
  96   }
  97 
  98   /**
  99    * <d62023> Write the methodEntry for a valuetype factory method into
 100    *          the Value Helper class. Contents from email from Simon,
 101    *          4/25/99.
 102    **/
 103   protected void helperFactoryMethod (Hashtable symbolTable, MethodEntry m, SymtabEntry t, PrintWriter stream)
 104   {
 105     this.symbolTable = symbolTable;
 106     this.m = m;
 107     this.stream = stream;
 108     String initializerName = m.name ();
 109     String typeName = Util.javaName (t);
 110     String factoryName = typeName + "ValueFactory";
 111 
 112     // Step 1. Print factory method decl up to parms.
 113     stream.print  ("  public static " + typeName + " " + initializerName +
 114             " (org.omg.CORBA.ORB $orb");
 115     if (!m.parameters ().isEmpty ())
 116       stream.print (", "); // <d62794>
 117 
 118     // Step 2. Print the declaration parameter list.
 119     writeParmList (m, true, stream);
 120 
 121     // Step 3. Print the body of the factory method
 122     stream.println (")");
 123     stream.println ("  {");
 124     stream.println ("    try {");
 125     stream.println ("      " + factoryName + " $factory = (" + factoryName + ")");
 126     stream.println ("          ((org.omg.CORBA_2_3.ORB) $orb).lookup_value_factory(id());");
 127     stream.print   ("      return $factory." + initializerName + " (");
 128     writeParmList (m, false, stream);
 129     stream.println (");");
 130     stream.println ("    } catch (ClassCastException $ex) {");
 131     stream.println ("      throw new org.omg.CORBA.BAD_PARAM ();");
 132     stream.println ("    }");
 133     stream.println ("  }");
 134     stream.println ();
 135   } // helperFactoryMethod
 136 
 137   /**
 138    * <d62023> - write an abstract method definition
 139    **/
 140   protected void abstractMethod (Hashtable symbolTable, MethodEntry m, PrintWriter stream)
 141   {
 142     this.symbolTable = symbolTable;
 143     this.m           = m;
 144     this.stream      = stream;
 145     if (m.comment () != null)
 146       m.comment ().generate ("  ", stream);
 147     stream.print ("  ");
 148     stream.print ("public abstract ");
 149     writeMethodSignature ();
 150     stream.println (";");
 151     stream.println ();
 152   } // abstractMethod
 153 
 154   /**
 155    * <d62023> - write a default factory method implementation for the
 156    *            <value>DefaultFactory. m is a methodEntry for a factory
 157    *            method contained in a non-abstract ValueEntry.
 158    **/
 159   protected void defaultFactoryMethod (Hashtable symbolTable, MethodEntry m, PrintWriter stream)
 160   {
 161     this.symbolTable = symbolTable;
 162     this.m           = m;
 163     this.stream      = stream;
 164     String typeName = m.container (). name ();
 165     stream.println ();
 166     if (m.comment () != null)
 167       m.comment ().generate ("  ", stream);
 168     stream.print   ("  public " + typeName + " " + m.name () + " (");
 169     writeParmList  (m, true, stream);
 170     stream.println (")");
 171     stream.println ("  {");
 172     stream.print   ("    return new " + typeName + "Impl (");
 173     writeParmList (m, false, stream);
 174     stream.println (");");
 175     stream.println ("  }");
 176   } // defaultFactoryMethod
 177 
 178   /**
 179    * <d62023> - remove all valueInitializer junk
 180    **/
 181   protected void writeMethodSignature ()
 182   {
 183     // Step 0.  Print the return type and name.
 184     // A return type of null indicates the "void" return type. If m is a
 185     // Valuetype factory method, it has a null return type,
 186     if (m.type () == null)
 187     {
 188         // if factory method, result type is container
 189         if (isValueInitializer ())
 190             stream.print (m.container ().name ());
 191         else
 192             stream.print ("void");
 193     }
 194     else
 195     {
 196       stream.print (Util.javaName (m.type ()));
 197     }
 198     stream.print (' ' + m.name () + " (");
 199 


 225     // Step 3.  Print the throws clause (if necessary).
 226     if (m.exceptions ().size () > 0)
 227     {
 228       stream.print (") throws ");
 229       e = m.exceptions ().elements ();
 230       firstTime = true;
 231       while (e.hasMoreElements ())
 232       {
 233         if (firstTime)
 234           firstTime = false;
 235         else
 236           stream.print (", ");
 237         stream.print (Util.javaName ((SymtabEntry)e.nextElement ()));
 238       }
 239     }
 240     else
 241       stream.print (')');
 242   } // writeMethodSignature
 243 
 244   /**
 245    * <d62023> - delete method templates for valuetypes
 246    **/
 247   protected void interfaceMethod (Hashtable symbolTable, MethodEntry m, PrintWriter stream)
 248   {
 249     this.symbolTable = symbolTable;
 250     this.m           = m;
 251     this.stream      = stream;
 252     if (m.comment () != null)
 253       m.comment ().generate ("  ", stream);
 254     stream.print ("  ");
 255     writeMethodSignature ();
 256     stream.println (";");
 257   } // interfaceMethod
 258 }


  79     boolean firstTime = true;
  80     Enumeration e = m.parameters ().elements ();
  81     while (e.hasMoreElements ())
  82     {
  83       if (firstTime)
  84         firstTime = false;
  85       else
  86         stream.print (", ");
  87       ParameterEntry parm = (ParameterEntry)e.nextElement ();
  88       if (listTypes) {
  89         writeParmType (parm.type (), parm.passType ());
  90         stream.print (' ');
  91       }
  92       // Print parm name
  93       stream.print (parm.name ());
  94       // end of parameter list
  95     }
  96   }
  97 
  98   /**
  99    * d62023 - write the methodEntry for a valuetype factory method into
 100    *          the Value Helper class. Contents from email from Simon,
 101    *          4/25/99.
 102    **/
 103   protected void helperFactoryMethod (Hashtable symbolTable, MethodEntry m, SymtabEntry t, PrintWriter stream)
 104   {
 105     this.symbolTable = symbolTable;
 106     this.m = m;
 107     this.stream = stream;
 108     String initializerName = m.name ();
 109     String typeName = Util.javaName (t);
 110     String factoryName = typeName + "ValueFactory";
 111 
 112     // Step 1. Print factory method decl up to parms.
 113     stream.print  ("  public static " + typeName + " " + initializerName +
 114             " (org.omg.CORBA.ORB $orb");
 115     if (!m.parameters ().isEmpty ())
 116       stream.print (", "); // <d62794>
 117 
 118     // Step 2. Print the declaration parameter list.
 119     writeParmList (m, true, stream);
 120 
 121     // Step 3. Print the body of the factory method
 122     stream.println (")");
 123     stream.println ("  {");
 124     stream.println ("    try {");
 125     stream.println ("      " + factoryName + " $factory = (" + factoryName + ")");
 126     stream.println ("          ((org.omg.CORBA_2_3.ORB) $orb).lookup_value_factory(id());");
 127     stream.print   ("      return $factory." + initializerName + " (");
 128     writeParmList (m, false, stream);
 129     stream.println (");");
 130     stream.println ("    } catch (ClassCastException $ex) {");
 131     stream.println ("      throw new org.omg.CORBA.BAD_PARAM ();");
 132     stream.println ("    }");
 133     stream.println ("  }");
 134     stream.println ();
 135   } // helperFactoryMethod
 136 
 137   /**
 138    * d62023 - write an abstract method definition
 139    **/
 140   protected void abstractMethod (Hashtable symbolTable, MethodEntry m, PrintWriter stream)
 141   {
 142     this.symbolTable = symbolTable;
 143     this.m           = m;
 144     this.stream      = stream;
 145     if (m.comment () != null)
 146       m.comment ().generate ("  ", stream);
 147     stream.print ("  ");
 148     stream.print ("public abstract ");
 149     writeMethodSignature ();
 150     stream.println (";");
 151     stream.println ();
 152   } // abstractMethod
 153 
 154   /**
 155    * d62023   - write a default factory method implementation for the
 156    *            {@code <value>DefaultFactory}. m is a methodEntry for a factory
 157    *            method contained in a non-abstract ValueEntry.
 158    **/
 159   protected void defaultFactoryMethod (Hashtable symbolTable, MethodEntry m, PrintWriter stream)
 160   {
 161     this.symbolTable = symbolTable;
 162     this.m           = m;
 163     this.stream      = stream;
 164     String typeName = m.container (). name ();
 165     stream.println ();
 166     if (m.comment () != null)
 167       m.comment ().generate ("  ", stream);
 168     stream.print   ("  public " + typeName + " " + m.name () + " (");
 169     writeParmList  (m, true, stream);
 170     stream.println (")");
 171     stream.println ("  {");
 172     stream.print   ("    return new " + typeName + "Impl (");
 173     writeParmList (m, false, stream);
 174     stream.println (");");
 175     stream.println ("  }");
 176   } // defaultFactoryMethod
 177 
 178   /**
 179    * d62023 - remove all valueInitializer junk
 180    **/
 181   protected void writeMethodSignature ()
 182   {
 183     // Step 0.  Print the return type and name.
 184     // A return type of null indicates the "void" return type. If m is a
 185     // Valuetype factory method, it has a null return type,
 186     if (m.type () == null)
 187     {
 188         // if factory method, result type is container
 189         if (isValueInitializer ())
 190             stream.print (m.container ().name ());
 191         else
 192             stream.print ("void");
 193     }
 194     else
 195     {
 196       stream.print (Util.javaName (m.type ()));
 197     }
 198     stream.print (' ' + m.name () + " (");
 199 


 225     // Step 3.  Print the throws clause (if necessary).
 226     if (m.exceptions ().size () > 0)
 227     {
 228       stream.print (") throws ");
 229       e = m.exceptions ().elements ();
 230       firstTime = true;
 231       while (e.hasMoreElements ())
 232       {
 233         if (firstTime)
 234           firstTime = false;
 235         else
 236           stream.print (", ");
 237         stream.print (Util.javaName ((SymtabEntry)e.nextElement ()));
 238       }
 239     }
 240     else
 241       stream.print (')');
 242   } // writeMethodSignature
 243 
 244   /**
 245    * d62023 - delete method templates for valuetypes
 246    **/
 247   protected void interfaceMethod (Hashtable symbolTable, MethodEntry m, PrintWriter stream)
 248   {
 249     this.symbolTable = symbolTable;
 250     this.m           = m;
 251     this.stream      = stream;
 252     if (m.comment () != null)
 253       m.comment ().generate ("  ", stream);
 254     stream.print ("  ");
 255     writeMethodSignature ();
 256     stream.println (";");
 257   } // interfaceMethod
 258 }
< prev index next >