Package com.sun.tools.corba.se.idl

Examples of com.sun.tools.corba.se.idl.SequenceEntry


  {
  } // helperWrite

  public int read (int index, String indent, String name, SymtabEntry entry, PrintWriter stream)
  {
    SequenceEntry seq = (SequenceEntry)entry;
    String length = "_len" + index++;
    stream.println (indent + "int " + length + " = istream.read_long ();");
    if (seq.maxSize () != null)
    {
      stream.println (indent + "if (" + length + " > (" + Util.parseExpression (seq.maxSize ()) + "))");
      stream.println (indent + "  throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);");
    }
    String seqOfName;
    try
    {
      seqOfName = Util.sansArrayInfo ((String)seq.dynamicVariable (Compile.typedefInfo));
    }
    catch (NoSuchFieldException e)
    {
      seqOfName = seq.name ();
    }
    int startArray = seqOfName.indexOf ('[');
    String arrayDcl = seqOfName.substring (startArray);
    seqOfName = seqOfName.substring (0, startArray);

    // For interfaces having state, e.g., valuetypes.
    SymtabEntry seqOfEntry = (SymtabEntry)Util.symbolTable.get (seqOfName.replace ('.', '/'));
    if (seqOfEntry != null && seqOfEntry instanceof InterfaceEntry && ((InterfaceEntry)seqOfEntry).state () != null)
      // <f46082.51> Remove -stateful feature; javaStatefulName() obsolete.
      //seqOfName = Util.javaStatefulName ((InterfaceEntry)seqOfEntry);
      seqOfName = Util.javaName ((InterfaceEntry)seqOfEntry);

    arrayDcl = arrayDcl.substring (2);
    stream.println (indent + name + " = new " + seqOfName + '[' + length + ']' + arrayDcl + ';');
    if (seq.type () instanceof PrimitiveEntry)
      // <d61961> Check for CORBA::Principal, too
      //if (seq.type ().name ().equals ("any") || seq.type ().name ().equals ("TypeCode"))
      if (seq.type ().name ().equals ("any") ||
          seq.type ().name ().equals ("TypeCode") ||
          seq.type ().name ().equals ("Principal"))
      {
        String loopIndex = "_o" + index;
        stream.println (indent + "for (int " + loopIndex + " = 0;" + loopIndex + " < " + name + ".length; ++" + loopIndex + ')');
        stream.println (indent + "  " + name + '[' + loopIndex + "] = istream.read_" + seq.type ().name () + " ();");
      }
      else
      { // special case for ValueBox: if name is "xxx tmp", drop xxx
        String varName = name;
        int nameIndex = varName.indexOf (' ');
        if ( nameIndex != -1 )
          varName = varName.substring( nameIndex + 1 );
        stream.println (indent + "istream.read_" + Util.collapseName (entry.type ().name ()) + "_array (" + varName + ", 0, " + length + ");");
      }
    else if (entry.type () instanceof StringEntry)
    {
      String loopIndex = "_o" + index;
      stream.println (indent + "for (int " + loopIndex + " = 0;" + loopIndex + " < " + name + ".length; ++" + loopIndex + ')');
      stream.println (indent + "  " + name + '[' + loopIndex + "] = istream.read_" + seq.type ().name () + " ();");
    }
    else if (entry.type () instanceof SequenceEntry)
    {
      String loopIndex = "_o" + index;
      stream.println (indent + "for (int " + loopIndex + " = 0;" + loopIndex + " < " + name + ".length; ++" + loopIndex + ')');
      stream.println (indent + '{');
      index = ((JavaGenerator)seq.type ().generator ()).read (index, indent + "  ", name + '[' + loopIndex + ']', seq.type (), stream);
      stream.println (indent + '}');
    }
    else
    { // special case for ValueBox: if name is "xxx tmp", drop xxx
      String varName = name;
      int nameIndex = varName.indexOf (' ');
      if ( nameIndex != -1 )
        varName = varName.substring( nameIndex + 1 );
      String loopIndex = "_o" + index;
      stream.println (indent + "for (int " + loopIndex + " = 0;" + loopIndex + " < " + varName + ".length; ++" + loopIndex + ')');
      stream.println (indent + "  " + varName + '[' + loopIndex + "] = " + Util.helperName (seq.type (), true) + ".read (istream);"); // <d61056>
    }
    return index;
  } // read
View Full Code Here


    return index;
  } // read

  public int write (int index, String indent, String name, SymtabEntry entry, PrintWriter stream)
  {
    SequenceEntry seq = (SequenceEntry)entry;
    if (seq.maxSize () != null)
    {
      stream.println (indent + "if (" + name + ".length > (" + Util.parseExpression (seq.maxSize ()) + "))");
      stream.println (indent + "  throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);");
    }
    stream.println (indent + "ostream.write_long (" + name + ".length);");
    if (entry.type () instanceof PrimitiveEntry)
      // <d61961> Check for CORBA::Principal, too.
      //if (entry.type ().name ().equals ("any") || entry.type ().name ().equals ("TypeCode"))
      if (entry.type ().name ().equals ("any") ||
          entry.type ().name ().equals ("TypeCode") ||
          entry.type ().name ().equals ("Principal"))
      {
        String loopIndex = "_i" + index++;
        stream.println (indent + "for (int " + loopIndex + " = 0;" + loopIndex + " < " + name + ".length; ++" + loopIndex + ')');
        stream.println (indent + "  ostream.write_" + seq.type ().name () + " (" + name + '[' + loopIndex + "]);");
      }
      else
        stream.println (indent + "ostream.write_" + Util.collapseName (entry.type ().name ()) + "_array (" + name + ", 0, " + name + ".length);");
    else if (entry.type () instanceof StringEntry)
    {
      String loopIndex = "_i" + index++;
      stream.println (indent + "for (int " + loopIndex + " = 0;" + loopIndex + " < " + name + ".length; ++" + loopIndex + ')');
      stream.println (indent + "  ostream.write_" + seq.type ().name () + " (" + name + '[' + loopIndex + "]);");
    }
    else if (entry.type () instanceof SequenceEntry)
    {
      String loopIndex = "_i" + index++;
      stream.println (indent + "for (int " + loopIndex + " = 0;" + loopIndex + " < " + name + ".length; ++" + loopIndex + ')');
      stream.println (indent + '{');
      index = ((JavaGenerator)seq.type ().generator ()).write (index, indent + "  ", name + '[' + loopIndex + ']', seq.type (), stream);
      stream.println (indent + '}');
    }
    else
    {
      String loopIndex = "_i" + index++;
      stream.println (indent + "for (int " + loopIndex + " = 0;" + loopIndex + " < " + name + ".length; ++" + loopIndex + ')');
      stream.println (indent + "  " + Util.helperName (seq.type (), true) + ".write (ostream, " + name + '[' + loopIndex + "]);"); // <d61056>
    }
    return index;
  } // write
View Full Code Here

TOP

Related Classes of com.sun.tools.corba.se.idl.SequenceEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.