com.adventnet.snmp.mibs
Class RangeList

java.lang.Object
  |
  +--com.adventnet.snmp.mibs.RangeList

class RangeList
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

The class represents the type of constraints defined in a MIB. These constraints take the shape of a set of enumerations or a set of ranges of type 1 | 3..5 | 7 . The constraints could either be on the length or the value and the appropriate parameter should be passed for verification. In case of a DisplayString (Size (1.255)) syntax the value which should be passed to the isValid method would be the length of the string and not the string itself which may or may not be a number.

See Also:
Serialized Form

Field Summary
(package private)  boolean addSizeTag
           
(package private)  boolean isRanged
           
(package private)  int labelcount
           
(package private)  java.lang.String[] labels
           
(package private)  long[] max
           
(package private)  long[] min
           
(package private)  boolean preDefinedRange
           
(package private)  int rangecount
           
(package private)  boolean[] rangetype
           
(package private)  long[] values
           
 
Constructor Summary
RangeList()
           
RangeList(int size, boolean isEnumerated)
          Create a range entity.
 
Method Summary
 void addEnum(java.lang.String str, long value)
          Adds this enum to the RangeList
 void addRange(long rangeVal)
          set the fixed value range
 void addRange(long mx, long mn)
          set the max and min range
protected  java.lang.Object clone()
           
 void expandSize(int size, boolean isRanged)
          Expands the size of the list.
 int[] getEnumint()
          Returns the array containing the enums
 int getEnumInt(java.lang.String enum)
          Returns the int value for this enumeration string
 java.lang.String[] getEnumlabels()
          Returns the array containing the enums
(package private)  RangeList getInstance(java.io.DataInputStream inp)
          Extracts the rangeList item from the data stream and returns the object representing it.
 RangeList getInstance(java.io.DataInputStream inp, RangeList range)
          Extracts the rangeList item from the data stream.
 RangeList getInstance(RangeList synRan, RangeList range)
           
 java.lang.String getLabel(long val)
          Returns the String label for the particular value
(package private)  boolean getRange(java.lang.String val)
           
 boolean isEnumerated()
          Indicates if this type is enumerated { other(1), iso8183(2)...}
 boolean isRanged()
          Whether the syntax is Ranged (0 | 2..7 | 9 )
 boolean isValid(long val)
          to verify if the value is valid from the Mib.
 boolean isValid(java.lang.String val)
          to verify if the string value is valid from the Mib.
 java.lang.String toString()
          This method has been added to maintain some degree of compatibility for the displayed strings with the non-compiled versions.
 
Methods inherited from class java.lang.Object
, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

isRanged

boolean isRanged

values

long[] values

labels

java.lang.String[] labels

max

long[] max

min

long[] min

rangetype

boolean[] rangetype

preDefinedRange

boolean preDefinedRange

addSizeTag

boolean addSizeTag

labelcount

int labelcount

rangecount

int rangecount
Constructor Detail

RangeList

public RangeList()

RangeList

public RangeList(int size,
                 boolean isEnumerated)
Create a range entity. This could contain either enumerations or size constraints etc..
Parameters:
size - The number of range elements or enumerations
isEnumerated - true if this will contain enumerations. false if it will be set of range constraints.
Method Detail

getEnumlabels

public java.lang.String[] getEnumlabels()
Returns the array containing the enums

getEnumint

public int[] getEnumint()
Returns the array containing the enums
Returns:
the int array containing the enum values. null if the type is ranged such as 1..2 | 3 and is not enumerated as in INTEGER{ ethernet(2) }

isEnumerated

public boolean isEnumerated()
Indicates if this type is enumerated { other(1), iso8183(2)...}

isRanged

public boolean isRanged()
Whether the syntax is Ranged (0 | 2..7 | 9 )

addEnum

public void addEnum(java.lang.String str,
                    long value)
Adds this enum to the RangeList

addRange

public void addRange(long mx,
                     long mn)
set the max and min range

addRange

public void addRange(long rangeVal)
set the fixed value range

getLabel

public java.lang.String getLabel(long val)
Returns the String label for the particular value
Parameters:
val - the value for which the corresponding enumeration is required.
Returns:
string representation of the enumerated type. null if not present.
See Also:
isValid.

getRange

boolean getRange(java.lang.String val)

getEnumInt

public int getEnumInt(java.lang.String enum)
Returns the int value for this enumeration string
Parameters:
enum - The enumeration string
Returns:
integer representing the enumeration string -1 if not found.

isValid

public boolean isValid(long val)
to verify if the value is valid from the Mib.

isValid

public boolean isValid(java.lang.String val)
to verify if the string value is valid from the Mib.

toString

public java.lang.String toString()
This method has been added to maintain some degree of compatibility for the displayed strings with the non-compiled versions. It still however perhaps breaks compatibility for types with multiple ranges.
Overrides:
toString in class java.lang.Object

expandSize

public void expandSize(int size,
                       boolean isRanged)
Expands the size of the list. The object can in the case handle more range elements of the specified type. Typical usage will be for sub-typed TCs or enumerated types(which might be redefined with additional enums.

getInstance

RangeList getInstance(java.io.DataInputStream inp)
                throws java.io.IOException
Extracts the rangeList item from the data stream and returns the object representing it.
Parameters:
inp - DataInputStream for the compiled mib file. The descriptions file is not required.

getInstance

public RangeList getInstance(java.io.DataInputStream inp,
                             RangeList range)
                      throws java.io.IOException
Extracts the rangeList item from the data stream. Returns the object representing it. If the passed RangeList item is non-null it returns the same RangeList object updated.

getInstance

public RangeList getInstance(RangeList synRan,
                             RangeList range)

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object