SNMP Stack 5_1

uk.co.westhawk.snmp.stack
Class BitsHelper

java.lang.Object
  |
  +--uk.co.westhawk.snmp.stack.BitsHelper

public class BitsHelper
extends java.lang.Object

This class help with the BITS construct. The AsnOctets class is growing too big, because of all the different representations. Note that BITS is different from the ANS.1 BIT STRING. Apparently BIT STRING was in v1, but was depreceated in favour of BITS.

 An instance with bits 0, 3 and 10 set will have the value:

      10010000 00100000
      ^  ^       ^
 bit  0  3      10

 so will consist of the two bytes (octets) 0x90 & 0x20.
 
See also section 7.1.4. of SNMPv2-SMI and section 8. (3) of SNMPv2-TM.

Since:
5_0
Version:
$Revision: 3.1 $ $Date: 2006/03/23 15:09:48 $
Author:
Birgit Arkesteijn

Constructor Summary
BitsHelper()
           
 
Method Summary
static boolean isFlagged(AsnOctets oct, int index)
          Returns if the flag (bit) on the specified index is set.
static void setFlagged(AsnOctets oct, int index, boolean toset)
          Sets or unsets the flag (bit) on the specified index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitsHelper

public BitsHelper()
Method Detail

setFlagged

public static void setFlagged(AsnOctets oct,
                              int index,
                              boolean toset)
                       throws java.lang.IllegalArgumentException
Sets or unsets the flag (bit) on the specified index. The bit will be set to zero if toset is false, set to one if toset is true. Note, as a side effect the size of the asn octet might grow.

Parameters:
oct - The AsnOctets that represents the BITS
index - The index (0 - X)
toset - Whether to set (true) or unset (false) the bit
java.lang.IllegalArgumentException

isFlagged

public static boolean isFlagged(AsnOctets oct,
                                int index)
                         throws java.lang.IllegalArgumentException
Returns if the flag (bit) on the specified index is set. The bit will be set to zero if toset is false, set to one if toset is true.

Parameters:
oct - The AsnOctets that represents the BITS
index - The index (0 - X)
Returns:
Whether the bit is set (true) or unset (false)
java.lang.IllegalArgumentException

SNMP Stack 5_1