打字猴:1.700481052e+09
1700481052
1700481053 if(this.nextOperator!=null){
1700481054
1700481055 result=this.nextOperator.handleMessage(vo);
1700481056
1700481057 }else{
1700481058
1700481059 result=“命令无法执行”;
1700481060
1700481061 }
1700481062
1700481063 }
1700481064
1700481065 return result;
1700481066
1700481067 }
1700481068
1700481069 //设置剩余参数由谁来处理
1700481070
1700481071 public void setNext(CommandName_operator){
1700481072
1700481073 this.nextOperator=_operator;
1700481074
1700481075 }
1700481076
1700481077 //每个处理者都要处理一个后缀参数
1700481078
1700481079 protected abstract String getOperateParam();
1700481080
1700481081 //每个处理者都必须实现处理任务
1700481082
1700481083 protected abstract String echo(CommandVO vo);
1700481084
1700481085 }
1700481086
1700481087 很简单,就是责任链模式中的handler,也就是中控程序,控制一个链应该如何建立。我们再来看3个ls命令族,先看AbstractLS抽象类,如代码清单34-2所示。
1700481088
1700481089 代码清单34-2 抽象ls命令
1700481090
1700481091 public abstract class AbstractLS extends CommandName{
1700481092
1700481093 //默认参数
1700481094
1700481095 public final static String DEFAULT_PARAM=””;
1700481096
1700481097 //参数a
1700481098
1700481099 public final static String A_PARAM=“a”;
1700481100
1700481101 //参数l
[ 上一页 ]  [ :1.700481052e+09 ]  [ 下一页 ]