KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snmp4j > smi > BitString


1 /*_############################################################################
2   _##
3   _## SNMP4J - BitString.java
4   _##
5   _## Copyright 2003-2007 Frank Fock and Jochen Katz (SNMP4J.org)
6   _##
7   _## Licensed under the Apache License, Version 2.0 (the "License");
8   _## you may not use this file except in compliance with the License.
9   _## You may obtain a copy of the License at
10   _##
11   _## http://www.apache.org/licenses/LICENSE-2.0
12   _##
13   _## Unless required by applicable law or agreed to in writing, software
14   _## distributed under the License is distributed on an "AS IS" BASIS,
15   _## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   _## See the License for the specific language governing permissions and
17   _## limitations under the License.
18   _##
19   _##########################################################################*/

20
21 package org.snmp4j.smi;
22
23 import org.snmp4j.asn1.BER;
24 import java.io.IOException JavaDoc;
25 import java.io.OutputStream JavaDoc;
26 import org.snmp4j.asn1.BERInputStream;
27
28 /**
29  * The <code>BitString</code> class represents the obsolete SMI type
30  * BIT STRING which has been defined in RFC 1442 (an SNMPv2 draft) but
31  * which has been obsoleteted by RFC 1902 and RFC 2578. This type is
32  * provided for compatibility only and should not be used for new
33  * applications.
34  *
35  * @author Frank Fock
36  * @version 1.7.4
37  * @since 1.7.4
38  */

39 public class BitString extends OctetString {
40
41   private static final long serialVersionUID = -8739361280962307248L;
42
43   /**
44    * Creates a BIT STRING value.
45    * @deprecated
46    * The BIT STRING type has been temporarily defined in RFC 1442
47    * and obsoleted by RFC 2578. Use OctetString (i.e. BITS syntax)
48    * instead.
49    */

50   public BitString() {
51   }
52
53   public int getSyntax() {
54     return BER.ASN_BIT_STR;
55   }
56
57   public void encodeBER(OutputStream JavaDoc outputStream) throws java.io.IOException JavaDoc {
58     BER.encodeString(outputStream, BER.BITSTRING, getValue());
59   }
60
61   public void decodeBER(BERInputStream inputStream) throws java.io.IOException JavaDoc {
62     BER.MutableByte type = new BER.MutableByte();
63     byte[] v = BER.decodeString(inputStream, type);
64     if (type.getValue() != BER.BITSTRING) {
65       throw new IOException JavaDoc("Wrong type encountered when decoding BitString: "+
66                             type.getValue());
67     }
68     setValue(v);
69   }
70
71   public Object JavaDoc clone() {
72     BitString clone = new BitString();
73     clone.setValue(super.getValue());
74     return clone;
75   }
76 }
77
Popular Tags