# Path: logparser/MoLFI/main/org/core/utility/message.py
# class Message:
#     """ This class represents a log message as a list of strings
#     """
# 
#     def __init__(self, p_message: List[str]):
#         """ Initialize the objet with an list of strings
#         :param p_message
#         """
#         self.words = p_message
# 
#     def get_length(self):
#         """ Get the number of strings in the list
#         """
#         return len(self.words)
# 
#     def to_string(self):
#         """ Convert the list of words to one string
#         """
#         string = ""
#         for index in range(0, len(self.words)):
#             if index < len(self.words) - 1:
#                 string = string + self.words[index] + " "
#             else:
#                 string = string + self.words[index]
#         return string


import re
from numpy.core.defchararray import startswith
from ..utility.message import Message


    is_hex1 = re.findall('(^|\s)([0-9a-f]){8,}(\s|$)', log_message)
    if is_hex1:
        log_message = re.sub('(^|\s)([0-9a-f]){8,}(\s|$)', sub_sign, log_message)

    is_mac_address = re.findall('([0-9A-F]{2}[:-]){5,}([0-9A-F]{2})', log_message)
    if is_mac_address:
        log_message = re.sub('([0-9A-F]{2}[:-]){5,}([0-9A-F]{2})', sub_sign, log_message)

    is_number = re.findall('(^| )\d+( |$)', log_message)
    if is_number:
        log_message = re.sub('(^| )\d+( |$)', sub_sign, log_message)

    # add space around '-->' [=:,] <> () [ ] { }
    log_message = re.sub("([<>=:,;'\(\)\{\}\[\]])", r' \1 ', log_message)
    # regex is empty if not given as parameter
    if regex is None:
        regex = []
    for i in range(len(regex)):
        match = re.findall(regex[i], log_message)
        if match:
            log_message = re.sub(regex[i], sub_sign, log_message)

    # let's identify the prefixes that we don't have to change
    prefix_regex = "^[ ]*\[[A-Z *]+\]"
    match = re.findall(prefix_regex, log_message)
    if len(match) > 0:
        log_message = log_message.replace(match[0], match[0].replace(' ', ''))

    log_message = log_message.replace("-- >", "-->")

# Path: logparser/MoLFI/main/org/core/utility/message.py
# class Message:
#     """ This class represents a log message as a list of strings
#     """
# 
#     def __init__(self, p_message: List[str]):
#         """ Initialize the objet with an list of strings
#         :param p_message
#         """
#         self.words = p_message
# 
#     def get_length(self):
#         """ Get the number of strings in the list
#         """
#         return len(self.words)
# 
#     def to_string(self):
#         """ Convert the list of words to one string
#         """
#         string = ""
#         for index in range(0, len(self.words)):
#             if index < len(self.words) - 1:
#                 string = string + self.words[index] + " "
#             else:
#                 string = string + self.words[index]
#         return string


# Path: logparser/MoLFI/main/org/core/utility/log_message_adaptation.py
import re
from numpy.core.defchararray import startswith
from ..utility.message import Message


    is_hex1 = re.findall('(^|\s)([0-9a-f]){8,}(\s|$)', log_message)
    if is_hex1:
        log_message = re.sub('(^|\s)([0-9a-f]){8,}(\s|$)', sub_sign, log_message)

    is_mac_address = re.findall('([0-9A-F]{2}[:-]){5,}([0-9A-F]{2})', log_message)
    if is_mac_address:
        log_message = re.sub('([0-9A-F]{2}[:-]){5,}([0-9A-F]{2})', sub_sign, log_message)

    is_number = re.findall('(^| )\d+( |$)', log_message)
    if is_number:
        log_message = re.sub('(^| )\d+( |$)', sub_sign, log_message)

    # add space around '-->' [=:,] <> () [ ] { }
    log_message = re.sub("([<>=:,;'\(\)\{\}\[\]])", r' \1 ', log_message)
    # regex is empty if not given as parameter
    if regex is None:
        regex = []
    for i in range(len(regex)):
        match = re.findall(regex[i], log_message)
        if match:
            log_message = re.sub(regex[i], sub_sign, log_message)

    # let's identify the prefixes that we don't have to change
    prefix_regex = "^[ ]*\[[A-Z *]+\]"
    match = re.findall(prefix_regex, log_message)
    if len(match) > 0:
        log_message = log_message.replace(match[0], match[0].replace(' ', ''))

    log_message = log_message.replace("-- >", "-->")

    message = Message(log_message.split())
