IBM Java Toolbox for i data conversion class

Source: Internet
Author: User
Tags integer numeric

From an object-oriented perspective, IBM Java Toolbox for I provides a as400datatype interface to describe the specific transformation logic and rules between IBM I data types and Java data types. The implementation classes corresponding to the As400datatype interface can be roughly divided into:

Numerical

Text

Date

Compound type (numbers and text)

Table 1 corresponds to the As400datatype implementation class that is related to numbers.

Table 1. As400datatype-related implementation classes

For IBM i RPG programs, PACKED decimal and zoned decimal are two common numeric types, although they can hold numeric data as they function, but they occupy different storage space. ZONED decimal holds a number in one byte, while packed decimal holds two digits in one byte. As a result, PACKED decimal saves storage space. Based on storage space considerations, IBM I's RPG compiler automatically converts zoned decimal data to packed decimal type. Therefore, it is recommended that you use the packed decimal type to save storage controls and improve compilation efficiency. In addition, the length of the PACKED decimal is defined as an odd length that saves more storage space.

Numeric conversion Classes

As an example, listing 1 describes how to use the As400bin4 conversion class to convert the IBM I format value to Java shaping. It should be emphasized here that all the data for IBM I are represented by byte arrays.

Listing 1. IBM I numeric type conversion Java int type

byte[] data = new BYTE[100];

...

Number Converter

As400bin4 bin4converter = new As400bin4 ();

Integer intobject = (integer) bin4converter.toobject (data,0);

int i = Intobject.intvalue ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.