The data conversion classes provide the capability to convert numeric and character data between iSeries™ and Java™ formats. Conversion may be needed when accessing iSeries data from a Java program. The data conversion classes support conversion of various numeric formats and between various EBCDIC code pages and Unicode.
The data description classes build on the data conversion classes to convert all fields in a record with a single method call. The RecordFormat class allows the program to describe data that makes up a DataQueueEntry, ProgramCall parameter, a record in a database file accessed through record-level access classes, or any buffer of iSeries data. The Record class allows the program to convert the contents of the record and access the data by field name or index.
The converter classes provide fast and efficient conversion between Java and your iSeries server. BinaryConverter converts between Java byte arrays and Java simple types. CharConverter converts between Java String objects and i5/OS™ code pages. For more information, see the following:
Converters
The AS400DataType is an interface that defines the methods required for data conversion. A Java program uses data types when individual pieces of data need to be converted. Conversion classes exist for the following types of data:
Example: Using AS400DataType classes
The following example illustrates using AS400DataType classes with ProgramCall to supply data for program parameters and to interpret the data returned in program parameters.
Example: Using AS400DataType classes with ProgramCall
The IBM® Toolbox for Java provides classes for building on the data types classes to handle converting data one record at a time instead of one field at a time. For example, suppose a Java program reads data off a data queue. The data queue object returns a byte array of iSeries data to the Java program. This array can potentially contain many types of iSeries data. The application can convert one field at a time out of the byte array by using the data types classes, or the program can create a record format that describes the fields in the byte array. That record then does the conversion.
Record format conversion can be useful when you are working with data from the program call, data queue, and record-level access classes. The input and output from these classes are byte arrays that can contain many fields of various types. Record format converters can make it easier to convert this data between iSeries format and Java format.
Conversion through record format uses three classes:
Examples: Using record format conversion classes
The following examples illustrate using the record format conversion classes with data queues:
Using the Record and RecordFormat classes to put data on a queue
Using the FieldDescription, RecordFormat, and Record classes