public class Person extends is.Info { public static final int male = 0; public static final int female = 1; public String[] names; public int age; public int income; public int sex; public void publishGuts( is.Ostream out ){ super.publishGuts( out ); out.put( names ).put( age, true ).put( income, false ).put( sex, true ); } public void refreshGuts( is.Istream in ){ super.refreshGuts( in ); names = in.getStringArray( ); age = in.getInt( ); income = in.getInt( ); sex = getInt( ); }}In order to define a new information type, one must declare a new Java class which has to do the following:
Contrary to C++ Java doesn't have unsigned built-in types. In order to support compatibility between C++ and Java, the put methods of the is.Ostream class for the byte, short and int types have one extra argument of type boolean. If this argument is true, the first attribute will be interpreted as signed value, otherwise as unsigned (see line 15 of the Java example).
Old Java versions did not support enumerations. The IS Java library uses the int Java built-in type to represent enumerations. One must make sure that the integer representation for the enumeration values is the same in C++ and Java (compare line 5 of the C++ example and lines 3,4 of the Java example). The latest revision of Java language (JDK 1.5) has enumerations. The new version of IS will support them soon.
The first instruction in the publishGuts and refreshGuts implementation must be a call the same method of the is.Info class (see lines 14 and 19 of the Java example).| 2 July 1998 - WebMaster | Copyright © CERN 1998 |