Class ByteConverter
java.lang.Object
org.eclipse.persistence.internal.eis.cobol.helper.ByteConverter
Purpose: This class handles all the byte <-> string conversions. It handles
ascii/binary/packed-decimal conversions. This class is used by and dependent on
FieldMetaData
-
Field Summary
Modifier and TypeFieldDescriptionstatic int
This is the word size for the system, api is provided to change this if necessary -
Constructor Summary
ConstructorDescriptionDefault constructorByteConverter
(FieldMetaData metaData, byte[] recordData) constructor that accepts FieldMetaData and record data, this is the preferred constructor -
Method Summary
Modifier and TypeMethodDescriptiongetter forFieldMetaData
byte[]
getter for record dataprotected String
getStringFromBinaryData
(int offset, int size) This method builds a string value from a byte array section containing binary dataThis method is the primary public access for the byte converter to extract a string value associated with a field, from a byte array associated with a record.protected String
this method builds a string value from a byte array containing packed-decimal dataint
method returns wordSize attributeprotected void
no-argument initializerprotected void
initialize
(FieldMetaData metaData, byte[] recordData) accepts FieldMetaData and record data.protected String
insertDecimalInString
(String string) This method checks the field to see if it should have a decimal point added and inserts it if needed.boolean
method returns littleEndian attributeprotected String
removeDecimalInString
(String string) This method removes the decimal if neededprotected void
setBinaryDataToStringValue
(String value, int offset, int size) this method sets a section of byte array to the value represented by the stringvalue
using a binary representation.protected void
this method sets byte array data to a packed-decimal value held in the value argumentvoid
setBytesToValue
(String value) This is the primary public access for writing string values associated with a field to a byte array associated with a record.void
setFieldMetaData
(FieldMetaData newFieldMetaData) setter forFieldMetaData
void
setIsLittleEndian
(boolean newValue) method sets littleEndian attributevoid
setRecordData
(byte[] newRecordData) setter for record datavoid
setWordSize
(int newWordSize) method sets wordSize attributeprotected void
swapEndians
(int offset, int end) this method will swap the ends of a byte in a byte array starting atoffset
and ending atend
protected void
twosComplement
(int offset, int length) this method performs a bitwise twos complement on a section of a byte array starting atoffset
and ending atoffset + length
-
Field Details
-
wordSize
public static int wordSizeThis is the word size for the system, api is provided to change this if necessary
-
-
Constructor Details
-
ByteConverter
public ByteConverter()Default constructor -
ByteConverter
constructor that accepts FieldMetaData and record data, this is the preferred constructor
-
-
Method Details
-
initialize
protected void initialize()no-argument initializer -
initialize
accepts FieldMetaData and record data. -
isLittleEndian
public boolean isLittleEndian()method returns littleEndian attribute -
setIsLittleEndian
public void setIsLittleEndian(boolean newValue) method sets littleEndian attribute -
getWordSize
public int getWordSize()method returns wordSize attribute -
setWordSize
public void setWordSize(int newWordSize) method sets wordSize attribute -
insertDecimalInString
This method checks the field to see if it should have a decimal point added and inserts it if needed. -
removeDecimalInString
This method removes the decimal if needed -
getStringValue
This method is the primary public access for the byte converter to extract a string value associated with a field, from a byte array associated with a record. -
setBytesToValue
This is the primary public access for writing string values associated with a field to a byte array associated with a record. -
getFieldMetaData
getter forFieldMetaData
-
setFieldMetaData
setter forFieldMetaData
-
getRecordData
public byte[] getRecordData()getter for record data -
setRecordData
public void setRecordData(byte[] newRecordData) setter for record data -
getStringValueFromPackedDecimal
this method builds a string value from a byte array containing packed-decimal data -
setByteArrayToPackedDecimalValue
this method sets byte array data to a packed-decimal value held in the value argument -
swapEndians
protected void swapEndians(int offset, int end) this method will swap the ends of a byte in a byte array starting atoffset
and ending atend
-
twosComplement
protected void twosComplement(int offset, int length) this method performs a bitwise twos complement on a section of a byte array starting atoffset
and ending atoffset + length
-
getStringFromBinaryData
This method builds a string value from a byte array section containing binary data -
setBinaryDataToStringValue
this method sets a section of byte array to the value represented by the stringvalue
using a binary representation.
-