mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
update ElementContainer & finished component: ReadOnlyField
This commit is contained in:
1 parent
c9b2d830df
commit
416f7a6498
3 files changed
+200
-67
No files matched your search
@@ -13,73 +13,6 @@ import java.util.List;
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
|
||||
// TLV 组件容器
|
||||
class ElementContainer{
|
||||
private List<Block> elementContainer;
|
||||
public ElementContainer(){
|
||||
elementContainer = new LinkedList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有Block
|
||||
* @return
|
||||
*/
|
||||
public List<Block> getElements(){
|
||||
return elementContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取block个数
|
||||
* @return
|
||||
*/
|
||||
public int length(){
|
||||
return elementContainer.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除 elements 中所有的子TLV
|
||||
*/
|
||||
public void clear(){
|
||||
elementContainer.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* 往 elements 中添加一个子tlv
|
||||
* @param block
|
||||
*/
|
||||
public void addElement(Block block){
|
||||
elementContainer.add(block);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除所有指定type的子tlv
|
||||
* @param tlvType
|
||||
*/
|
||||
public void removeElements(VlInt tlvType){
|
||||
List<Block> elementContainer=new LinkedList<>();
|
||||
for(Block block: this.elementContainer){
|
||||
if(!block.getTlvType().isEqual(tlvType)){
|
||||
elementContainer.add(block);
|
||||
}
|
||||
}
|
||||
this.elementContainer =elementContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 elements 中找到第一个指定type的子TLV
|
||||
* @param tlvType
|
||||
* @return
|
||||
*/
|
||||
public Block getElement(VlInt tlvType){
|
||||
for(Block block: this.elementContainer){
|
||||
if(block.getTlvType().isEqual(tlvType)){
|
||||
return block;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class Block {
|
||||
private VlInt tlvType; // TLV-TYPE
|
||||
private VlInt length; // TLV-LENGTH
|
||||
|
||||
Reference in new issue
Block a user