Generated Java Method Format and Calling Parameters

The signature for a Java print method is as follows:

   public void print (PrintStream out, String varName, int level)

The out argument specifies a PrintStream object to which the output should be written. The Java class System.out should be specified to write to standard output.

The varName argument is used to specify the top-level variable name of the item being printed. Normally, this would be set to the same name as the variable declared in your program that holds the object being printed. For example, if you declared a variable called personnelRecord to hold a PersonnelRecord object, the varName object would be set to "personnelRecord".

The level argument is used to specify the indentation level for printing nested types. The user would always want to set this to zero at the outer-level.

For example, the call to print the personnelRecord from the previous examples would be as follows:

   personnelRecord.print (System.out, "personnelRecord", 0);

The output would be formatted as follows:

   personnelRecord {
      name {
         givenName = 'John'
         initial = 'P'
         familyName = 'Smith'
      }
      number = 51
      title = 'Director'
      dateOfHire = '19710917'
      nameOfSpouse {
         givenName = 'Mary'
         initial = 'T'
         familyName = 'Smith'
      }
      children[0] {
         name {
            givenName = 'Ralph'
            initial = 'T'
            familyName = 'Smith'
         }
         dateOfBirth = '19571111'
      }
      children[1] {
         name {
            givenName = 'Susan'
            initial = 'B'
            familyName = 'Jones'
         }
         dateOfBirth = '19590717'
      }
   }