1 20 21 22 23 24 25 package org.snmp4j.smi; 26 27 import java.io.*; 28 import org.snmp4j.asn1.BER; 29 import org.snmp4j.asn1.BERInputStream; 30 31 38 public class Opaque extends OctetString { 39 40 private static final long serialVersionUID = -17056771587100877L; 41 42 public Opaque() { 43 super(); 44 } 45 46 public Opaque(byte[] bytes) { 47 super(bytes); 48 } 49 50 public int getSyntax() { 51 return SMIConstants.SYNTAX_OPAQUE; 52 } 53 54 public void encodeBER(OutputStream outputStream) throws IOException { 55 BER.encodeString(outputStream, BER.OPAQUE, getValue()); 56 } 57 58 public void decodeBER(BERInputStream inputStream) throws IOException { 59 BER.MutableByte type = new BER.MutableByte(); 60 byte[] v = BER.decodeString(inputStream, type); 61 if (type.getValue() != (BER.ASN_APPLICATION | 0x04)) { 62 throw new IOException("Wrong type encountered when decoding OctetString: "+ 63 type.getValue()); 64 } 65 setValue(v); 66 } 67 68 public void setValue(OctetString value) { 69 this.setValue(new byte[0]); 70 append(value); 71 } 72 73 public String toString() { 74 return super.toHexString(); 75 } 76 77 public Object clone() { 78 return new Opaque(super.getValue()); 79 } 80 81 } 82 83 | Popular Tags |