net.percederberg.mibble.type
Class SizeConstraint

java.lang.Object
  extended by net.percederberg.mibble.type.SizeConstraint
All Implemented Interfaces:
Constraint

public class SizeConstraint
extends java.lang.Object
implements Constraint

A MIB type size constraint.

Since:
2.0

Constructor Summary
SizeConstraint(FileLocation location, Constraint values)
          Creates a new size constraint.
 
Method Summary
 java.util.ArrayList getValues()
          Returns a list of the value constraints on the size.
 void initialize(MibType type, MibLoaderLog log)
          Initializes the constraint.
 boolean isCompatible(MibType type)
          Checks if the specified type is compatible with this constraint.
 boolean isCompatible(MibValue value)
          Checks if the specified value is compatible with this constraint.
 int nextValue(int start)
          Returns the next compatible size constraint value from a start value.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SizeConstraint

public SizeConstraint(FileLocation location,
                      Constraint values)
Creates a new size constraint.

Parameters:
location - the constraint location
values - the constrained size values
Method Detail

initialize

public void initialize(MibType type,
                       MibLoaderLog log)
                throws MibException
Initializes the constraint. This will remove all levels of indirection present, such as references to types or values. No constraint information is lost by this operation. This method may modify this object as a side-effect, and will be called by the MIB loader.

Specified by:
initialize in interface Constraint
Parameters:
type - the type to constrain
log - the MIB loader log
Throws:
MibException - if an error was encountered during the initialization

isCompatible

public boolean isCompatible(MibType type)
Checks if the specified type is compatible with this constraint.

Specified by:
isCompatible in interface Constraint
Parameters:
type - the type to check
Returns:
true if the type is compatible, or false otherwise

isCompatible

public boolean isCompatible(MibValue value)
Checks if the specified value is compatible with this constraint. Only octet string values can be compatible with a size constraint, and only if the string length is compatible with the value range in the size constraint.

Specified by:
isCompatible in interface Constraint
Parameters:
value - the value to check
Returns:
true if the value is compatible, or false otherwise

getValues

public java.util.ArrayList getValues()
Returns a list of the value constraints on the size.

Returns:
a list of the value constraints

nextValue

public int nextValue(int start)
Returns the next compatible size constraint value from a start value. The values will be enumerated from lower values to higher.

Parameters:
start - the initial start value
Returns:
the next compatible value, or -1 if no such value exists
Since:
2.9

toString

public java.lang.String toString()
Returns a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this object