Stream Helper Methods in Java Compat
The stream classes provide all of the low-level methods necessary for encoding and decoding Ice types. However, it would be tedious and error-prone to manually encode complex Ice types such as classes, structs, and dictionaries using these low-level functions. For this reason, the Slice compiler generates helper methods for streaming complex Ice types.
We will use the following Slice definitions to demonstrate the language mapping:
Slice
module M
{
sequence<...> Seq;
dictionary<...> Dict;
struct S
{
...
}
enum E { ... }
class C
{
...
}
interface I
{
...
}
}
The Slice compiler generates the corresponding helper classes and methods shown below:
Java Compat
package M;
public class SeqHelper
{
public static T[] read(Ice.InputStream in);
public static void write(Ice.OutputStream out, T[] v);
...
}
public class DictHelper
{
public static java.util.Map<..., ...> read(Ice.InputStream in);
public static void write(Ice.OutputStream out, java.util.Map<..., ...> v);
...
}
public class S ...
{
public static S ice_read(Ice.InputStream in);
public static void ice_write(Ice.OutputStream out, S v);
// Instance methods
public void ice_readMembers(Ice.InputStream in);
public void ice_writeMembers(Ice.OutputStream out);
...
}
public enum E ...
{
public static E ice_read(Ice.InputStream in);
public static void ice_write(Ice.OutputStream out, E v);
// Instance method
public void ice_write(Ice.OutputStream out);
...
}
public class CHolder implements Ice.ReadValueCallback ...
{
public CHolder();
public CHolder(C v);
public C value;
...
}
public class IPrxHelper ...
{
public static IPrx read(Ice.InputStream in);
public static void write(Ice.OutputStream out, IPrx v);
...
}