-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNSCmdlineCommand.java
More file actions
59 lines (50 loc) · 1.33 KB
/
Copy pathNSCmdlineCommand.java
File metadata and controls
59 lines (50 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package com.nullspace.cmdline;
import java.util.ArrayList;
import java.util.List;
/**
* 命令行处理抽象类
* @author kay.yang
*
*/
public abstract class NSCmdlineCommand
{
private String mCmdLineType;
private String mDescription;
private List<NSCmdParameters> mParameters;
public NSCmdlineCommand(String type, String des)
{
mParameters = new ArrayList<>();
this.mCmdLineType = type;
this.mDescription = des;
}
public final void execute() throws Exception
{
System.out.println("命令: " + this.mCmdLineType + " description: " + mDescription + " 运行开始.");
executeBefore();
executeRunning();
executeAfter();
System.out.println("命令: " + this.mCmdLineType + " description: " + mDescription + " 运行完成.");
}
//对参数进行验证等功能,在执行函数之前执行
protected abstract void executeBefore() throws Exception;
//对命令进行执行的函数
protected abstract void executeRunning() throws Exception;
//命令执行完毕之后的处理
protected abstract void executeAfter() throws Exception;
public String cmdLineType()
{
return mCmdLineType;
}
public String description()
{
return mDescription;
}
public List<NSCmdParameters> parameters()
{
return mParameters;
}
public void addParameter(String value)
{
this.mParameters.add(new NSCmdParameters(value));
}
}