writing component: IdentifierComponent

This commit is contained in:
free will committed 2021-03-09 21:59:59 +08:00
1 parent e9ce657092
commit 37cb1a9b36
1 file changed
+47
@@ -0,0 +1,47 @@
package component;
/*
* @Author: Wang Feng
* @Description: 名称组件
* @Version: 1.0.0
* @Date: 21:26 2021/3/9
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
*/
import encoding.Block;
import encoding.Encoder;
import encoding.IEncodingAble;
// @Description:
// 1. 参考 => https://named-data.net/doc/tech-memos/naming-conventions.pdf ,借鉴但不是按这个实现的
// 2. 格式如下:
// IdentifierComponent = 100 TLV-LENGTH
// <Marker>
// *OCTET
// Marker = OCTET
// 3. Marker 用来标记不同类型的 IdentifierComponent,目前分配如下
// Marker value Description
// 0x00 普通的UTF-8编码的字符串
// 0x01 非负整数(可以用1、2、4、8个字节表示)
// 0x02 任意字节数组
public class IdentifierComponent implements TlvComponentBase, IEncodingAble {
private Block block;
private byte marker; // 标记 => 用来区分不同类型的 IdentifierComponent
private String stringValue; // 如果 Marker == 0x00,则本组件存储一个字符串
private long intValue; // 如果 Marker == 0x01,则本组件存储一个非负整型
private byte[] byteArrayValue; // 如果 Marker == 0x02,则本组件存储一个字节数组
public static final byte MarkerString = 0x00;
public static final byte MarkerNonNegativeInteger = 0x01;
public static final byte MarkerByteArray = 0x02;
@Override
public int wireEncode(Encoder encoder) {
return 0;
}
@Override
public boolean wireDecode(Block block) {
return false;
}
}