java.lang.Object
org.eclipse.persistence.internal.eis.cobol.helper.ByteConverter

public class ByteConverter extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    static int
    This is the word size for the system, api is provided to change this if necessary
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor
    ByteConverter(FieldMetaData metaData, byte[] recordData)
    constructor that accepts FieldMetaData and record data, this is the preferred constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    getter for FieldMetaData
    byte[]
    getter for record data
    protected String
    getStringFromBinaryData(int offset, int size)
    This method builds a string value from a byte array section containing binary data
    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.
    protected String
    this method builds a string value from a byte array containing packed-decimal data
    int
    method returns wordSize attribute
    protected void
    no-argument initializer
    protected void
    initialize(FieldMetaData metaData, byte[] recordData)
    accepts FieldMetaData and record data.
    protected 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 attribute
    protected String
    This method removes the decimal if needed
    protected void
    setBinaryDataToStringValue(String value, int offset, int size)
    this method sets a section of byte array to the value represented by the string value using a binary representation.
    protected void
    this method sets byte array data to a packed-decimal value held in the value argument
    void
    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 for FieldMetaData
    void
    setIsLittleEndian(boolean newValue)
    method sets littleEndian attribute
    void
    setRecordData(byte[] newRecordData)
    setter for record data
    void
    setWordSize(int newWordSize)
    method sets wordSize attribute
    protected void
    swapEndians(int offset, int end)
    this method will swap the ends of a byte in a byte array starting at offset and ending at end
    protected void
    twosComplement(int offset, int length)
    this method performs a bitwise twos complement on a section of a byte array starting at offset and ending at offset + length

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • wordSize

      public static int wordSize
      This is the word size for the system, api is provided to change this if necessary
  • Constructor Details

    • ByteConverter

      public ByteConverter()
      Default constructor
    • ByteConverter

      public ByteConverter(FieldMetaData metaData, byte[] recordData)
      constructor that accepts FieldMetaData and record data, this is the preferred constructor
  • Method Details

    • initialize

      protected void initialize()
      no-argument initializer
    • initialize

      protected void initialize(FieldMetaData metaData, byte[] recordData)
      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

      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.
    • removeDecimalInString

      protected String removeDecimalInString(String string)
      This method removes the decimal if needed
    • getStringValue

      public String 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

      public void 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.
    • getFieldMetaData

      public FieldMetaData getFieldMetaData()
      getter for FieldMetaData
    • setFieldMetaData

      public void setFieldMetaData(FieldMetaData newFieldMetaData)
      setter for FieldMetaData
    • getRecordData

      public byte[] getRecordData()
      getter for record data
    • setRecordData

      public void setRecordData(byte[] newRecordData)
      setter for record data
    • getStringValueFromPackedDecimal

      protected String getStringValueFromPackedDecimal()
      this method builds a string value from a byte array containing packed-decimal data
    • setByteArrayToPackedDecimalValue

      protected void setByteArrayToPackedDecimalValue(String value)
      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 at offset and ending at end
    • twosComplement

      protected void twosComplement(int offset, int length)
      this method performs a bitwise twos complement on a section of a byte array starting at offset and ending at offset + length
    • getStringFromBinaryData

      protected String getStringFromBinaryData(int offset, int size)
      This method builds a string value from a byte array section containing binary data
    • setBinaryDataToStringValue

      protected void setBinaryDataToStringValue(String value, int offset, int size)
      this method sets a section of byte array to the value represented by the string value using a binary representation.