CERN -> IPT Group -> FrameMaker at CERN
Information Service User's Guide

A.2 IS Information in Java

A.2.1 Example

1: public class Person extends is.Info {
2: public static final int male = 0;
3: public static final int female = 1;
4: public String[] names;
5: public int age;
6: public int income;
7: public int sex;
8: public void publishGuts( is.Ostream out ){
9: super.publishGuts( out );
10: out.put( names ).put( age, true ).put( income, false ).put( sex, true );
11: }
12: public void refreshGuts( is.Istream in ){
13: super.refreshGuts( in );
14: names = in.getStringArray( );
15: age = in.getInt( );
16: income = in.getInt( );
17: sex = getInt( );
18: }
19: }

A.2.2 Explanation

In order to define a new information type, one must declare a new Java class which has to do the following:

  1. Extend either the is.Info or the is.NamedInfo class
  2. Declare all the necessary attributes. For a valid attribute types see Appendix D.
  3. Implement two methods declared by the is.Info class: publishGuts and refreshGuts. The publishGuts method must put all the attributes of the class to the out parameter of the method. The refreshGuts method must read all the attributes from the in parameter of the method in the same order as they have been put to the ISostream by the publishGuts.

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