1 20 21 package org.snmp4j.smi; 22 23 import org.snmp4j.asn1.BER; 24 import java.io.IOException ; 25 import java.io.OutputStream ; 26 import org.snmp4j.asn1.BERInputStream; 27 28 39 public class BitString extends OctetString { 40 41 private static final long serialVersionUID = -8739361280962307248L; 42 43 50 public BitString() { 51 } 52 53 public int getSyntax() { 54 return BER.ASN_BIT_STR; 55 } 56 57 public void encodeBER(OutputStream outputStream) throws java.io.IOException { 58 BER.encodeString(outputStream, BER.BITSTRING, getValue()); 59 } 60 61 public void decodeBER(BERInputStream inputStream) throws java.io.IOException { 62 BER.MutableByte type = new BER.MutableByte(); 63 byte[] v = BER.decodeString(inputStream, type); 64 if (type.getValue() != BER.BITSTRING) { 65 throw new IOException ("Wrong type encountered when decoding BitString: "+ 66 type.getValue()); 67 } 68 setValue(v); 69 } 70 71 public Object clone() { 72 BitString clone = new BitString(); 73 clone.setValue(super.getValue()); 74 return clone; 75 } 76 } 77 | Popular Tags |