import java.util.List; public class AnalyzeCommand2 implements Command2 { private final StrategyFactory2 factory; public AnalyzeCommand2(StrategyFactory2 factory) { this.factory = factory; } @Override public String getName() { return "analyze"; } @Override public void execute(String[] args, List articles) { if (args == null || args.length == 0) { System.out.println("格式:analyze 网址"); return; } String url = args[0]; CrawlStrategy2 strategy = factory.getMatchStrategy(url); System.out.println("===== 分析结果 ====="); if (strategy != null) { System.out.println("链接:" + url); System.out.println("状态:可以解析 ✅"); } else { System.out.println("链接:" + url); System.out.println("状态:不支持 ❌"); } } }