Version 7.4.3
 —  Using Jadabas  —

Generating Java Class Objects

This document uses a class generated from the Employees DDM as an example, providing detailed information about the class generation process. This document covers the following topics:


Overview

Jadabas provides two utilities for generating Java class objects:

Object Properties

The generation process creates an object that has properties and methods. With a few exceptions, the properties correspond to fields derived from the DDM from which the class was generated. To improve performance, all properties derived from field names are public. This means that any application can examine and modify the property directly (the field is declared final if it is read only and therefore cannot be modified). If desired, the Java source for the class can be manually modified to make these properties private and to add the corresponding accessor and modifier methods. Group fields in the DDM are never present in the Java class. The group field itself does not have data, and the fields contained within are always part of the Java class if selected.

The property names are of mixed case (upper and lower). When generating a class, the GENERATE utility applies the following rules:

For example, the field "MIDDLE-NAME" in the DDM becomes property "middleName" in the Java class.

If this scheme generates duplicate names, you will need to edit the source file manually and correct the duplicates.

Every generated class has a public ISN property, that is, an "int" representing the ISN of the object.

If the Adabas field option of "NC" is used, Jadabas will generate a special field for it. For example, if a field named "BIRTH_DATE" uses the "NC" option, Jadabas generates a field called "BIRTH_DATE_NC".

Object Descriptors

Descriptors are class constants that are derived from the descriptor fields in the DDM. They are used in the find methods to indicate search keys and in the readFrom method to indicate sequential read order.

Descriptor property names are the original field names. When generating the descriptor property, the GENERATE utility applies the following rules:

For example, the descriptor "PHONETIC-NAME" in the DDM becomes "PHONETIC_NAME" in the Java class.

Field Types

Natural supports several field types, some of which can be adequately represented by the Java native types and some of which need the supporting classes provided in the Jadabas installation kit. When a record is read from the database, the properties of the class are set by converting the value from a byte stream in the record buffer to Java native types and objects. The following table shows the Natural Data Type (format) and the resulting Java Type or Object:

Natural Data Type Java Type or Object
A - alphanumeric String
N - numeric Decimal (class delivered with Jadabas)
P - packed numeric Decimal (class delivered with Jadabas)
F - floating point Double
B - binary Binary (class delivered with Jadabas)
L - logical boolean
I - integer int
D - date date
T - time date

MU and PE periodic group fields are stored as arrays, as follows:

Top of page

Using the GENERATE Utility

Start of instruction setTo use the GENERATE utility, follow the steps below:

  1. Store in an Adabas file accessible to Jadabas a Natural DDM that corresponds to the view of the file you are using.

  2. The Web Utility Server enables the GENERATE utility. Start it as described in the section Web Utility Server.

  3. Start the Jadabas Proxy if you are connecting to any Adabas other than Adabas V7.

  4. In Windows, start your browser and navigate to GENERATE as follows:

    http://WebServerMachine:port/html/GENERATE.HTM

    where WebServerMachine:port is the name and port number of the host where the WebServer is executing (the default port is "9980").

    Example: "http://localhost:9980/html/GENERATE.HTM"

    In UNIX, open a command prompt and enter generate.sh.

    The page that appears is similar to the following example:

    graphics/gen01.png

  5. Enter the DBID and FNR (database ID and file number) of the FDIC file (Predict dictionary file) in the text fields labeled FDIC dbid and FNR, respectively, and click the Go button.

    The screen that appears contains a button for each DDM in the given FDIC:

    graphics/gen02.png

  6. Click the button with the desired DDM name.

    The page that appears contains the DDM details:

    graphics/gen03.png

    In addition to the Generate button, used to generate the Java class, this screen contains three other function buttons:

  7. Clear the Select box for each field that is not to be included in the Java class object.

    Radio buttons are used instead of check boxes if the field contains duplicate short Adabas names. The radio buttons ensure that only one of the fields can be selected. The first field of such a "duplicate group" has two radio buttons. Selecting the right-hand button excludes the field (the equivalent of unchecking a regular field).

    Open the Encoding drop-down list box to select a character encoding for alpha fields. Note that an encoding class is required for execution at the view or field level.

    Click the Readonly box to make a field "read only".

    For fields within a PE group, set the PE occurrences field to a number between "1" and "199" if the field is to be included. The specified number of occurrences will be read from the file for each record.

  8. When all selections have been made, click the Generate button.

  9. Save the result in a .java file, and compile using the Java compiler (javac).

Top of page

Using the GENDDM Utility

Start of instruction setTo use the GENDDM utility, follow the steps below:

  1. Store in an Adabas file accessible to Jadabas a Natural SYSTRANS or object manager that corresponds to the view of the file you are using.

  2. The Web Utility Server enables the GENDDM utility. Start it as described in the section Web Utility Server.

  3. Start the Jadabas Proxy.

  4. In Windows, start your browser and navigate to GENDDM as follows:

    http://WebServerMachine:port/html/GENDDM.HTM

    where WebServerMachine:port is the name and port number of the host where the WebServer is executing (the default port is "9980").

    Example: "http://localhost:9980/html/GENDDM.HTM"

    In UNIX, open a command prompt and enter genddm.sh.

    The screen that appears is similar to the following:

    graphics/gen04.png

  5. Enter the name of the SYSTRANS file, and click the Go button.

    The screen that appears contains a button for each DDM in the given SYSTRANS file:

    graphics/gen05.png

  6. Click the button with the desired DDM name.

    A sreen containing the DDM details appears:

    graphics/gen06.png

    In addition to the Generate button, used to generate the Java class, this screen contains three other function buttons:

  7. Clear the Select box for each field that is not to be included in the Java class object.

    Radio buttons are used instead of checkboxes if the field contains duplicate short Adabas names. The radio buttons ensure that only one of the fields can be selected. The first field of such a "duplicate group" has two radio buttons. Selecting the right-hand button excludes the field (the equivalent of unchecking a regular field).

    Open the Encoding drop-down list box to select a character encoding for alpha fields. Note that an encoding class is required for execution at the view or field level.

    Click the Readonly box to make a field "read only".

    For fields within a PE group, set the PE occurrences field to a number between "1" and "199" if the field is to be included. The specified number of occurrences will be read from the file for each record.

  8. When all selections have been made, click the Generate button.

  9. Save the result in a .java file, and compile using the Java compiler (javac).

Top of page

Creating Input to GENDDM

The following layout for a flat file description of a DDM can be used to create input to GENDDM. The layout includes the following parts as well as an example:

Comments

Columns Contents Number of Characters
01 - 04 Constant "****" 4

DDM Name

Columns Contents Number of Characters
01 - 04 Constant "*C**" 4
45 - 76 DDM Name 32
77 Constant "X" 1

DBID and FNR

Columns Contents Number of Characters
01 - 04 Constant "*D04" 4
05 - 09 Database ID 5
10 - 14 File Number 5

Fields

Note that Jadabas supports the Adabas NC (null not counted) option used by Adabas SQL Server and other structured query languages. For example, the field 'BIRTH' in the EMPLOYEES file would be as follows:

*S**_1AHBIRTH D0060 D *S**_1AHN@BIRTH I0020 D

Columns Contents Number of Characters
01 - 04 Constant "*S**" 4
05

Group (G, M, P)

G = group field (set Length/Decimal Places to 0000)

M = multiple-value field

P = periodic group

1
06 Level (1 - 7) 1
07 - 08 Short Name 2
09 - 40 Long Name 32
41

Format (A, B, D, F, I, L, N, P, T)

A - type = alpha B - type = binary

D - type = date

F - type = float

I - type = integer

L - type = logical

N - type = decimal

P - type = decimal

T - type = time

1
42 - 44 Length 3
45 Decimal Places 1
46

Option (' ', F, M, N)

F = fixed storage (F)

M = null not allowed (Adabas NN option indicating an SQL-significant null)

N = null value suppression (Adabas NU option)

\
1
47

Descriptor Flag (' ", D, H, P, S, U)

D = normal descriptor

H = hyper descriptor

P = phonetic descriptor

S = super descriptor

U = sub descriptor

1

End of All DDMs

Columns Contents Number of Characters
01 - 02 Constant "*E" 2

Example

          1    1    2    2    3    3    4    4    5    5    6    6    7    7    8
01   5    0    5    0    5    0    5    0    5    0    5    0    5    0    5    0
*C**                                         EMPLOYEES                       X
*D040019800011
*S**  1AAPERSONNEL-ID                     A0080 D
*S**G1ABFULL-NAME                          0000
*S** 2ACFIRST-NAME                        A0200N
*S** 2ADMIDDLE-I                          A0010N
*S** 2ADMIDDLE-NAME                       A0200N
*S** 2AENAME                              A0200 D
*S** 1AFMAR-STAT                          A0010F
*S** 1AGSEX                               A0010F
*S** 1AHBIRTH                             N0060 D
*S**G1A1FULL-ADDRESS                       0000
*S**M2AIADDRESS-LINE                      A0200N
*S** 2AJCITY                              A0200ND
*S** 2ADKIP                               A0100N
*S** 2ADPOST-CODE                         A0100N
*S** 2ALCOUNTRY                           A0030N
*S**G1A2TELEPHONE                          0000
*S** 2ANAREA-CODE                         A0060N
*S** 2AMPHONE                             A0150N
*S** 1AODEPT                              A0060
*S** 1APJOB-TITLE                         A0250ND
*S**P1AQINCOME                             0000
*S** 2ARCURR-CODE                         A0030N
*S** 2ASSALARY                            P0090N
*S**M2ATBONUS                             P0090N
*S**G1A3LEAVE-DATA                         0000
*S** 2AULEAVE-DUE                         N0020
*S** 2AVLEAVE-TAKEN                       N0020N
*S**P1AWLEAVE-BOOKED                       0000
*S** 2AXLEAVE-START                       N0060N
*S** 2AYLEAVE-END                         N0060N
*S**M1AZLANG                              A0030ND
*S** 1PHPHON-NAME                         A0200 P
*S** 1H1LEAVE-LEFT                        B0040 S
*S** 1S1DEPARTMENT                        A0040 S
*S** 1S2DEPT-PERSON                       A0260 S
*S** 1S3CURRENCY-SALARY                   A0120 S 
*E

Top of page