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}")