|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectname.benjaminjwhite.zdecimal.ZoneDec
public class ZoneDec
Utility class to handle IBM Z/Series zone decimal data in Java. All zone
decimal number operands must be valid format with valid sign. Java long will
not hold the maximum size number. java.math.BigDecimal can be used to handle
larger numbers than will fit in java long.
"Zone decimal" format is a method of representing numbers in the IBM Z/series
computers. It was also present in the 360, 370 and 390 series. Decimal digits
are stored as lower 4 bits of each byte. The upper 4 bits are binary 1111
except for the last byte. The first four bits are the last byte is the sign
of the number. Positive are binary 1010, 1100 1110 and 1111. Negative is 1011
and 1101.
COBOL is a popular mainframe language that has a number format with a "USAGE"
of "DISPLAY". When a "USAGE DISPLAY" number has a sign on the picture, the
number is stored a s zone decimal.
An example:
The PART-STOCK-LEVEL would be stored in memory as zone decimal and occupy 7
bytes. The implied decimal does not reserve any storage
01 PART-NUMBER.
05 PART-NAME PIC X(20).
05 PART-NUMBER PIC 9(5) USAGE IS COMP-3.
05 PART-COST PIC 9(5)V99 USAGE IS COMP-3.
05 PART-STOCK-LEVEL PIC S9(5)V99 USAGE IS DISPLAY.
05 FILLER PIC X(10).
Z/Series, 360, 370 and 390 is a trademark of IBM Corporation
Constructor Summary | |
---|---|
ZoneDec()
|
Method Summary | |
---|---|
static byte[] |
longToZone(long lnum)
Converts Java long to zone decimal |
static void |
longToZone(long lnum,
byte[] bytearray,
int offset,
int len)
Convert long to zone decimal and store in byte array |
static byte[] |
stringToZone(java.lang.String znstr)
Converts a java String to Z Series zoned decimal |
static void |
stringToZone(java.lang.String str,
byte[] bytearray,
int offset,
int len)
Converts java.lang.String to zone decimal and store in byte array |
static long |
zoneToLong(byte[] bytearray)
Convert byte array containing zone decimal number |
static long |
zoneToLong(byte[] bytearray,
int offset,
int len)
Convert selected bytes of array of zone decimal format to long |
static java.lang.String |
zoneToString(byte[] znbytes)
Converts a byte array of zoned decimal to a string |
static java.lang.String |
zoneToString(byte[] znbytes,
int offset,
int len)
Converts byte array of zone decimal to string |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ZoneDec()
Method Detail |
---|
public static byte[] longToZone(long lnum) throws java.io.UnsupportedEncodingException
lnum
- long number
java.io.UnsupportedEncodingException
- Invalid codepagepublic static void longToZone(long lnum, byte[] bytearray, int offset, int len) throws java.io.UnsupportedEncodingException, DecimalOverflowException
lnum
- Number to convertbytearray
- Target byte arrayoffset
- Into byte arraylen
- Length of field in byte array
java.io.UnsupportedEncodingException
- Invalid code page
DecimalOverflowException
- Number will not fit in field.public static byte[] stringToZone(java.lang.String znstr) throws DataException, java.io.UnsupportedEncodingException
znstr
- input number
DataException
- Invalid characters
java.io.UnsupportedEncodingException
- Invalid code pagepublic static void stringToZone(java.lang.String str, byte[] bytearray, int offset, int len) throws DecimalOverflowException, DataException, java.io.UnsupportedEncodingException
str
- Input stringbytearray
- Output byte arrayoffset
- Into output byte arraylen
- of sub array
DecimalOverflowException
- Input number too big for output
DataException
- Invalid characters
java.io.UnsupportedEncodingException
- Invalid code pagepublic static long zoneToLong(byte[] bytearray) throws java.io.UnsupportedEncodingException
bytearray
- input number
java.io.UnsupportedEncodingException
- Invalid code pagepublic static long zoneToLong(byte[] bytearray, int offset, int len) throws java.io.UnsupportedEncodingException
bytearray
- Input zone decimal numberoffset
- Into byte arraylen
- Length of byte array field
java.io.UnsupportedEncodingException
public static java.lang.String zoneToString(byte[] znbytes) throws java.io.UnsupportedEncodingException
znbytes
- zone decimal byte array
java.io.UnsupportedEncodingException
- Invalid code pagepublic static java.lang.String zoneToString(byte[] znbytes, int offset, int len) throws java.io.UnsupportedEncodingException
znbytes
- byte array zone decimal numberoffset
- Into byte arraylen
- Length of zone decimal field
java.io.UnsupportedEncodingException
- Invalid code page
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |