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
FieldsModifier and TypeFieldDescriptionstatic intThis is the word size for the system, api is provided to change this if necessary -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructorByteConverter(FieldMetaData metaData, byte[] recordData) constructor that accepts FieldMetaData and record data, this is the preferred constructor -
Method Summary
Modifier and TypeMethodDescriptiongetter forFieldMetaDatabyte[]getter for record dataprotected StringgetStringFromBinaryData(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 Stringthis method builds a string value from a byte array containing packed-decimal dataintmethod returns wordSize attributeprotected voidno-argument initializerprotected voidinitialize(FieldMetaData metaData, byte[] recordData) accepts FieldMetaData and record data.protected StringinsertDecimalInString(String string) This method checks the field to see if it should have a decimal point added and inserts it if needed.booleanmethod returns littleEndian attributeprotected StringremoveDecimalInString(String string) This method removes the decimal if neededprotected voidsetBinaryDataToStringValue(String value, int offset, int size) this method sets a section of byte array to the value represented by the stringvalueusing a binary representation.protected voidthis method sets byte array data to a packed-decimal value held in the value argumentvoidsetBytesToValue(String value) This is the primary public access for writing string values associated with a field to a byte array associated with a record.voidsetFieldMetaData(FieldMetaData newFieldMetaData) setter forFieldMetaDatavoidsetIsLittleEndian(boolean newValue) method sets littleEndian attributevoidsetRecordData(byte[] newRecordData) setter for record datavoidsetWordSize(int newWordSize) method sets wordSize attributeprotected voidswapEndians(int offset, int end) this method will swap the ends of a byte in a byte array starting atoffsetand ending atendprotected voidtwosComplement(int offset, int length) this method performs a bitwise twos complement on a section of a byte array starting atoffsetand 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 atoffsetand 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 atoffsetand 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 stringvalueusing a binary representation.
-