From 9f5b9db2c8cdbcf74bd2eecefc3557d4048b8d4c Mon Sep 17 00:00:00 2001 From: fuliqi <fuliqi@qq.com> Date: 星期三, 28 八月 2024 17:54:51 +0800 Subject: [PATCH] 打通大华OSD --- ycl-server/src/main/java/com/ycl/api/DH/common/CaseMenu.java | 30 +++++++++++++++--------------- 1 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ycl-server/src/main/java/com/ycl/api/DH/common/CaseMenu.java b/ycl-server/src/main/java/com/ycl/api/DH/common/CaseMenu.java index 7a573ab..901b3ad 100644 --- a/ycl-server/src/main/java/com/ycl/api/DH/common/CaseMenu.java +++ b/ycl-server/src/main/java/com/ycl/api/DH/common/CaseMenu.java @@ -1,4 +1,4 @@ -package com.netsdk.common; +package com.ycl.api.DH.common; import java.lang.reflect.Method; import java.util.NoSuchElementException; @@ -6,12 +6,12 @@ import java.util.Vector; public class CaseMenu { - + public static class Item { private Object object; private String itemName; private String methodName; - + public Item(Object object, String itemName, String methodName) { super(); this.object = object; @@ -31,33 +31,33 @@ return methodName; } } - + private Vector<Item> items; public CaseMenu() { super(); items = new Vector<Item>(); } - + public void addItem(Item item) { items.add(item); } - + private void showItem() { final String format = "%2d\t%-20s\n"; - int index = 0; + int index = 0; System.out.printf(format, index++, "exit App"); for (Item item : items) { System.out.printf(format, index++, item.getItemName()); } System.out.println("Please input a item index to invoke the method:"); } - + public void run() { Scanner scanner = new Scanner(System.in); - while(true) { - showItem(); - try { + while(true) { + showItem(); + try { int input = Integer.parseInt(scanner.nextLine()); if (input <= 0 ) { @@ -66,12 +66,12 @@ // System.exit(0); break; } - + if (input < 0 || input > items.size()) { System.err.println("Input Error Item Index."); continue; } - + Item item = items.get(input - 1); Class<?> itemClass = item.getObject().getClass(); Method method = itemClass.getMethod(item.getMethodName()); @@ -85,9 +85,9 @@ continue; } catch (Exception e) { e.printStackTrace(); - } + } } - + scanner.close(); } } -- Gitblit v1.8.0