1
10package org.jstk.asn1;
11
12import java.io.IOException;
13public class ASN1Explicit extends ASN1Type {
14 private ASN1Type instance = null;
15 public ASN1Explicit(){
16 super(UNIVERSAL, NONE, ANY, ANY);
17 }
18 public ASN1Explicit(byte tagClass, int taggingMethod, int tagNumber){
19 super(tagClass, taggingMethod, tagNumber, ANY);
20 consMask = CONSTRUCTED;
21 }
22 public void decode(ASN1PullParser parser) throws ASN1PullParserException, IOException {
23 int event = parser.next();
24
25 if ((event != tagNumber) || (parser.getTagClass() != tagClass)){
26 parser.prev(); return;
28 }
29 length = parser.getLength();
30 if (length > 0){
31 instance = new ASN1Any();
32 instance.decode(parser);
33 }
34 }
35
36 public byte[] encode(){
37 logger.entering(getClass().getName(), "encode");
38 if (instance == null)
39 setValue(null);
40 else
41 setValue(instance.encode());
42 byte[] bytes = encode1();
43 logger.exiting(getClass().getName(), "encode");
44 return bytes;
45 }
46
47 public void setInstance(ASN1Type instance){
48 this.instance = instance;
49 }
50
51 public ASN1Type getInstance(){
52 return instance;
53 }
54}