mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-06-18 04:50:25 +08:00
finished component: MustBeRefresh
This commit is contained in:
@@ -79,6 +79,7 @@ public class CanBePrefix implements TlvComponentBase,InitialAble, IEncodingAble
|
||||
return false;
|
||||
}
|
||||
|
||||
// 这是一个存在性组件,所以存在则为 true
|
||||
this.canBePrefix=true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import encoding.*;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description:
|
||||
* @Description: 表示一个内容的新鲜期 TLV 组件
|
||||
* @Version: 1.0.0
|
||||
* @Date: 16:10 2021/3/9
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package component;
|
||||
|
||||
import encoding.*;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description: 表示内容兴趣包中的组件 MustBeRefresh
|
||||
* @Version: 1.0.0
|
||||
* @Date: 16:30 2021/3/9
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class MustBeRefresh implements TlvComponentBase,InitialAble, IEncodingAble {
|
||||
// 成员变量
|
||||
private boolean mustBeRefresh;
|
||||
|
||||
// 函数
|
||||
public boolean getMustBeRefresh() {
|
||||
return mustBeRefresh;
|
||||
}
|
||||
|
||||
public void setMustBeRefresh(boolean mustBeRefresh) {
|
||||
this.mustBeRefresh = mustBeRefresh;
|
||||
}
|
||||
|
||||
// 接口实现-变量区
|
||||
private boolean initial=false;
|
||||
|
||||
// 接口实现-方法区
|
||||
@Override
|
||||
public void doInitial() {
|
||||
initial=true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitial() {
|
||||
return initial;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 MustBeRefresh 线速编码为一个 TLV
|
||||
* @param encoder
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int wireEncode(Encoder encoder) {
|
||||
// 这是一个存在性组件,所以如果值为false,则无需编码
|
||||
if(!this.mustBeRefresh){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int totalLength=0;
|
||||
|
||||
// 编码 TLV-LENGTH
|
||||
int tmplen=encoder.prependVarNumber(new VlInt(totalLength));
|
||||
if(tmplen==0){
|
||||
return 0;
|
||||
}
|
||||
totalLength+=tmplen;
|
||||
|
||||
// 编码 TLV-TYPE
|
||||
tmplen=encoder.prependVarNumber(new VlInt(TLV.TlvMustBeRefresh));
|
||||
if(tmplen==0){
|
||||
return 0;
|
||||
}
|
||||
totalLength+=tmplen;
|
||||
|
||||
return totalLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 TLV Block 中解码出一个 MustBeRefresh
|
||||
* @param block
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean wireDecode(Block block) {
|
||||
// 检查 Type 是否正确
|
||||
if(!TLV.expectType(block.getTlvType(),new VlInt(TLV.TlvMustBeRefresh))){
|
||||
return false;
|
||||
}
|
||||
|
||||
// 这是一个存在性组件,所以存在则为 true
|
||||
this.mustBeRefresh=true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user