< prev index next >

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

Print this page




  52 import com.sun.tools.corba.se.idl.ValueBoxEntry;
  53 import com.sun.tools.corba.se.idl.InterfaceState;
  54 import com.sun.tools.corba.se.idl.MethodEntry;
  55 import com.sun.tools.corba.se.idl.PrimitiveEntry;
  56 import com.sun.tools.corba.se.idl.SequenceEntry;
  57 import com.sun.tools.corba.se.idl.StringEntry;
  58 
  59 /**
  60  *
  61  **/
  62 public class ValueBoxGen24 extends ValueBoxGen
  63 {
  64   /**
  65    * Public zero-argument constructor.
  66    **/
  67   public ValueBoxGen24 ()
  68   {
  69   } // ctor
  70 
  71   /**
  72    * <d62023> - Move from helper to mapped class
  73    **/
  74   protected void writeTruncatable () // <d60929>
  75   {
  76       stream.print   ("  private static String[] _truncatable_ids = {");
  77       stream.println (Util.helperName(v, true) + ".id ()};");
  78       stream.println ();
  79       stream.println ("  public String[] _truncatable_ids() {");
  80       stream.println ("    return _truncatable_ids;");
  81       stream.println ("  }");
  82       stream.println ();
  83   } // writeTruncatable
  84 
  85 
  86   /**
  87    * <d62023>
  88    **/
  89   public void helperRead (String entryName, SymtabEntry entry, PrintWriter stream)
  90   {
  91     stream.println ("    if (!(istream instanceof org.omg.CORBA_2_3.portable.InputStream)) {");
  92     stream.println ("      throw new org.omg.CORBA.BAD_PARAM(); }");
  93     stream.println ("    return (" + entryName +") ((org.omg.CORBA_2_3.portable.InputStream) istream).read_value (_instance);");
  94     stream.println ("  }");
  95     stream.println ();
  96 
  97     // done with "read", now do "read_value with real marshalling code.
  98 
  99     stream.println ("  public java.io.Serializable read_value (org.omg.CORBA.portable.InputStream istream)"); // <d60929>
 100     stream.println ("  {");
 101 
 102     String indent = "    ";
 103     Vector vMembers = ((ValueBoxEntry) entry).state ();
 104     TypedefEntry member = ((InterfaceState) vMembers.elementAt (0)).entry;
 105     SymtabEntry mType = member.type ();
 106     if (mType instanceof PrimitiveEntry ||
 107         mType instanceof SequenceEntry ||


 127   {
 128     stream.println ("    if (!(ostream instanceof org.omg.CORBA_2_3.portable.OutputStream)) {");
 129     stream.println ("      throw new org.omg.CORBA.BAD_PARAM(); }");
 130     stream.println ("    ((org.omg.CORBA_2_3.portable.OutputStream) ostream).write_value (value, _instance);");
 131     stream.println ("  }");
 132     stream.println ();
 133 
 134     // done with "write", now do "write_value with real marshalling code.
 135 
 136     stream.println ("  public void write_value (org.omg.CORBA.portable.OutputStream ostream, java.io.Serializable value)");
 137     stream.println ("  {");
 138 
 139     String entryName = Util.javaName(entry);
 140     stream.println ("    if (!(value instanceof " + entryName + ")) {");
 141     stream.println ("      throw new org.omg.CORBA.MARSHAL(); }");
 142     stream.println ("    " + entryName + " valueType = (" + entryName + ") value;");
 143     write (0, "    ", "valueType", entry, stream);
 144   } // helperWrite
 145 
 146   /**
 147    * <d62023>
 148    **/
 149   public int write (int index, String indent, String name, SymtabEntry entry, PrintWriter stream)
 150   {
 151     Vector vMembers = ( (ValueEntry) entry ).state ();
 152     TypedefEntry member = ((InterfaceState) vMembers.elementAt (0)).entry;
 153     SymtabEntry mType = member.type ();
 154 
 155     if (mType instanceof PrimitiveEntry || !member.arrayInfo ().isEmpty ())
 156       index = ((JavaGenerator)member.generator ()).write (index, indent, name + ".value", member, stream);
 157     else if (mType instanceof SequenceEntry || mType instanceof StringEntry || mType instanceof TypedefEntry || !member.arrayInfo ().isEmpty ())
 158       index = ((JavaGenerator)member.generator ()).write (index, indent, name, member, stream);
 159     else
 160       stream.println (indent + Util.helperName (mType, true) + ".write (ostream, " + name + ");"); // <d61056>
 161     return index;
 162   } // write
 163 }


  52 import com.sun.tools.corba.se.idl.ValueBoxEntry;
  53 import com.sun.tools.corba.se.idl.InterfaceState;
  54 import com.sun.tools.corba.se.idl.MethodEntry;
  55 import com.sun.tools.corba.se.idl.PrimitiveEntry;
  56 import com.sun.tools.corba.se.idl.SequenceEntry;
  57 import com.sun.tools.corba.se.idl.StringEntry;
  58 
  59 /**
  60  *
  61  **/
  62 public class ValueBoxGen24 extends ValueBoxGen
  63 {
  64   /**
  65    * Public zero-argument constructor.
  66    **/
  67   public ValueBoxGen24 ()
  68   {
  69   } // ctor
  70 
  71   /**
  72    * d62023 - Move from helper to mapped class
  73    **/
  74   protected void writeTruncatable () // <d60929>
  75   {
  76       stream.print   ("  private static String[] _truncatable_ids = {");
  77       stream.println (Util.helperName(v, true) + ".id ()};");
  78       stream.println ();
  79       stream.println ("  public String[] _truncatable_ids() {");
  80       stream.println ("    return _truncatable_ids;");
  81       stream.println ("  }");
  82       stream.println ();
  83   } // writeTruncatable
  84 
  85 
  86   /**
  87    * d62023
  88    **/
  89   public void helperRead (String entryName, SymtabEntry entry, PrintWriter stream)
  90   {
  91     stream.println ("    if (!(istream instanceof org.omg.CORBA_2_3.portable.InputStream)) {");
  92     stream.println ("      throw new org.omg.CORBA.BAD_PARAM(); }");
  93     stream.println ("    return (" + entryName +") ((org.omg.CORBA_2_3.portable.InputStream) istream).read_value (_instance);");
  94     stream.println ("  }");
  95     stream.println ();
  96 
  97     // done with "read", now do "read_value with real marshalling code.
  98 
  99     stream.println ("  public java.io.Serializable read_value (org.omg.CORBA.portable.InputStream istream)"); // <d60929>
 100     stream.println ("  {");
 101 
 102     String indent = "    ";
 103     Vector vMembers = ((ValueBoxEntry) entry).state ();
 104     TypedefEntry member = ((InterfaceState) vMembers.elementAt (0)).entry;
 105     SymtabEntry mType = member.type ();
 106     if (mType instanceof PrimitiveEntry ||
 107         mType instanceof SequenceEntry ||


 127   {
 128     stream.println ("    if (!(ostream instanceof org.omg.CORBA_2_3.portable.OutputStream)) {");
 129     stream.println ("      throw new org.omg.CORBA.BAD_PARAM(); }");
 130     stream.println ("    ((org.omg.CORBA_2_3.portable.OutputStream) ostream).write_value (value, _instance);");
 131     stream.println ("  }");
 132     stream.println ();
 133 
 134     // done with "write", now do "write_value with real marshalling code.
 135 
 136     stream.println ("  public void write_value (org.omg.CORBA.portable.OutputStream ostream, java.io.Serializable value)");
 137     stream.println ("  {");
 138 
 139     String entryName = Util.javaName(entry);
 140     stream.println ("    if (!(value instanceof " + entryName + ")) {");
 141     stream.println ("      throw new org.omg.CORBA.MARSHAL(); }");
 142     stream.println ("    " + entryName + " valueType = (" + entryName + ") value;");
 143     write (0, "    ", "valueType", entry, stream);
 144   } // helperWrite
 145 
 146   /**
 147    * d62023
 148    **/
 149   public int write (int index, String indent, String name, SymtabEntry entry, PrintWriter stream)
 150   {
 151     Vector vMembers = ( (ValueEntry) entry ).state ();
 152     TypedefEntry member = ((InterfaceState) vMembers.elementAt (0)).entry;
 153     SymtabEntry mType = member.type ();
 154 
 155     if (mType instanceof PrimitiveEntry || !member.arrayInfo ().isEmpty ())
 156       index = ((JavaGenerator)member.generator ()).write (index, indent, name + ".value", member, stream);
 157     else if (mType instanceof SequenceEntry || mType instanceof StringEntry || mType instanceof TypedefEntry || !member.arrayInfo ().isEmpty ())
 158       index = ((JavaGenerator)member.generator ()).write (index, indent, name, member, stream);
 159     else
 160       stream.println (indent + Util.helperName (mType, true) + ".write (ostream, " + name + ");"); // <d61056>
 161     return index;
 162   } // write
 163 }
< prev index next >