{
} // 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