MqttAccess/src/mqtt_acess/parser/factory.py
2025-07-14 16:24:02 +08:00

13 lines
471 B
Python

from .json_parser import JsonParser
from .xml_parser import XmlParser
class ParserFactory:
def get_parser(self, protocol_type: str):
if protocol_type == "json":
return JsonParser()
elif protocol_type == "xml":
return XmlParser()
elif protocol_type == "custom":
from .custom_parser import CustomParser
return CustomParser()
raise ValueError(f"不支持的协议类型: {protocol_type}")