def get_constant_table(self):
        byte_location = 10  # First tag is at byte 10
        constant = ""
        constant_table = []
        size = 0

        # Loop will stop once all constant values have been collected
        for i in range(self.get_pool_count_int()):
            data_value = format(self.data[byte_location], "02X")
            # Tag represents a string, which means there is still a 2 byte size value that needs to be read
            if data_value == "01":
                constant += data_value
                # Get the 2 prefix bytes that describe the string size
                byte_location += 1
                data_value = format(self.data[byte_location], "02X")
                byte_location += 1
                data_value += format(self.data[byte_location], "02X")
                byte_location += 1
                constant += data_value
                size += 3
                # Get the offset for a string from the ConstantPoolTag Class
                tag = ConstantPoolTag("01")
                num_bytes = int(data_value, 16)
                for k in range(byte_location, byte_location + int(num_bytes)):
                    constant += format(self.data[k], "02X")
                    size += 1

                constant_table.append(constant)
                constant = ""
                byte_location += int(num_bytes)
            # Tag represents something else, which means only that value needs to be read
            else:
                tag = ConstantPoolTag(data_value)
                num_bytes = tag.get_byte_length(data_value)
                constant += data_value
                byte_location += 1
                size += 1
                for j in range(byte_location, byte_location + int(num_bytes)):
                    constant += format(self.data[j], "02X")
                    size += 1

                constant_table.append(constant)
                constant = ""
                byte_location += int(num_bytes)

        self.classfile_constant_table_size = size
        self.classfile_constant_table = constant_table
        return constant_table
 def float_helper(self, tag):
     self.constant_parts.append(ConstantPoolTag(tag).get_tag_type(tag))
     float_hex = ""
     for i in range(1, len(self.constant_split)):
         float_hex = float_hex + self.constant_split[i]
     self.constant_parts.append(
         struct.unpack('!f', bytes.fromhex(float_hex))[0])
     self.formatted_constant_table.append(self.constant_parts)
     self.constant_parts = []
 def tag_utf8_helper(self, tag):
     self.constant_parts.append(ConstantPoolTag(tag).get_tag_type(tag))
     hex_list = []
     for i in self.constant_split[3:]:
         hex_list.append(chr(int(i, 16)))
     ref = "".join(map(str, hex_list))
     self.constant_parts.append(ref)
     self.formatted_constant_table.append(self.constant_parts)
     self.constant_parts = []
    def display_data(self):  # pragma: no cover
        values = {}
        index = 1
        class_file_constant_table = self.classfile_constant_table
        class_file_interface_table = self.classfile_interface_table
        class_file_field_table = self.classfile_field_table
        print("-----CONSTANT TABLE-----\n")
        for i in range(len(self.classfile_constant_table)):
            tag = str(class_file_constant_table[i][0:2])
            data = class_file_constant_table[i][2:]

            if tag == "01":  # String
                tag_type = ConstantPoolTag(tag).get_tag_type(tag)
                data = data[4:]
                data = bytes.fromhex(data).decode("utf-8")
                values[index] = [tag_type, data]

            elif tag == "07":  # Class Ref
                tag_type = ConstantPoolTag(tag).get_tag_type(tag)
                data = "#" + str(int(data, 16))
                values[index] = [tag_type, data]

            elif tag == "08":  # String Ref
                tag_type = ConstantPoolTag(tag).get_tag_type(tag)
                data = "#" + str(int(data, 16))
                values[index] = [tag_type, data]

            elif tag == "09":  # Field Ref
                tag_type = ConstantPoolTag(tag).get_tag_type(tag)
                data_index_01 = data[0:4]
                data_index_02 = data[4:]
                data = ("#" + str(int(data_index_01, 16)) + ", " + "#" +
                        str(int(data_index_02, 16)))
                values[index] = [tag_type, data]

            elif tag == "0A":  # Method Ref
                tag_type = ConstantPoolTag(tag).get_tag_type(tag)
                data_index_01 = data[0:4]
                data_index_02 = data[4:]
                data = ("#" + str(int(data_index_01, 16)) + ", " + "#" +
                        str(int(data_index_02, 16)))
                values[index] = [tag_type, data]

            elif tag == "0C":  # Name and Type Description
                tag_type = ConstantPoolTag(tag).get_tag_type(tag)
                data_index_01 = data[0:4]
                data_index_02 = data[4:]
                data = ("#" + str(int(data_index_01, 16)) + ", " + "#" +
                        str(int(data_index_02, 16)))
                values[index] = [tag_type, data]

            else:
                tag_type = ConstantPoolTag(tag).get_tag_type(tag)
                values[index] = [tag_type, data]

            index += 1
        for i in range(1, len(class_file_constant_table) + 1):
            print(str(i) + ": " + str(values[i]))

        print("\n-----INTERFACE TABLE-----")
        print("TODO")
        print("-----INTERFACE TABLE-----\n")