mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
add test: IdentifierWrapper
This commit is contained in:
1 parent
e0f36a740e
commit
2d4a57beeb
5 files changed
+189
-11
No files matched your search
@@ -263,7 +263,6 @@ public class Identifier implements TlvComponentBase, IEncodingAble {
|
||||
}
|
||||
|
||||
// 解析子 TLV
|
||||
|
||||
if (!block.parseSubElements()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -154,7 +154,9 @@ public class IdentifierComponent implements TlvComponentBase, IEncodingAble {
|
||||
* @return
|
||||
*/
|
||||
public IdentifierComponent(Block block) throws ComponentException {
|
||||
this.wireDecode(block);
|
||||
if(!this.wireDecode(block)){
|
||||
throw new ComponentException("IdentifierComponent(Block block): block invalid");
|
||||
}
|
||||
}
|
||||
|
||||
public byte getMarker() {
|
||||
|
||||
@@ -10,11 +10,10 @@ import encoding.*;
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class IdentifierWrapper implements TlvComponentBase, IEncodingAble {
|
||||
private Identifier identifier;
|
||||
private VlInt tlvType;
|
||||
private Identifier identifier=new Identifier();
|
||||
private VlInt tlvType=new VlInt(TLV.TlvInvalid);
|
||||
|
||||
public IdentifierWrapper() {
|
||||
identifier = new Identifier();
|
||||
}
|
||||
|
||||
public VlInt getTlvType() {
|
||||
@@ -41,6 +40,11 @@ public class IdentifierWrapper implements TlvComponentBase, IEncodingAble {
|
||||
}
|
||||
}
|
||||
|
||||
public IdentifierWrapper(VlInt tlvType,Identifier identifier){
|
||||
this.tlvType=tlvType;
|
||||
this.identifier=identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义标识类型,根据标识的字符串标识创建一个自定义的标识
|
||||
*
|
||||
@@ -52,7 +56,7 @@ public class IdentifierWrapper implements TlvComponentBase, IEncodingAble {
|
||||
* // <Identifier>
|
||||
*/
|
||||
public IdentifierWrapper(VlInt tlvType, String identifierString) throws ComponentException {
|
||||
if (TLV.isValidIdentifierType(tlvType)) {
|
||||
if (!TLV.isValidIdentifierType(tlvType)) {
|
||||
throw new ComponentException("IdentifierWrapper(VlInt tlvType,String identifierString): "
|
||||
+ "tlvType invalid");
|
||||
}
|
||||
@@ -71,7 +75,7 @@ public class IdentifierWrapper implements TlvComponentBase, IEncodingAble {
|
||||
* // <Identifier>
|
||||
*/
|
||||
public IdentifierWrapper(VlInt tlvType, IdentifierComponentContainer container) throws ComponentException {
|
||||
if (TLV.isValidIdentifierType(tlvType)) {
|
||||
if (!TLV.isValidIdentifierType(tlvType)) {
|
||||
throw new ComponentException("IdentifierWrapper(VlInt tlvType,IdentifierComponentContainer container): "
|
||||
+ "tlvType invalid");
|
||||
}
|
||||
@@ -87,11 +91,15 @@ public class IdentifierWrapper implements TlvComponentBase, IEncodingAble {
|
||||
* @return
|
||||
*/
|
||||
public IdentifierWrapper(VlInt tlvType, Block block) throws ComponentException {
|
||||
if (TLV.isValidIdentifierType(tlvType)) {
|
||||
// todo: 报错
|
||||
if (!TLV.isValidIdentifierType(tlvType)) {
|
||||
throw new ComponentException("IdentifierWrapper(VlInt tlvType,Block block): "
|
||||
+ "tlvType invalid");
|
||||
}
|
||||
this.tlvType = tlvType;
|
||||
this.identifier.buildIdentifierByBlock(block);
|
||||
if(!this.identifier.buildIdentifierByBlock(block)){
|
||||
throw new ComponentException
|
||||
("IdentifierWrapper(VlInt tlvType, Block block): Identifier block is valid");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user