net.percederberg.mibble
Class MibValue

java.lang.Object
  extended bynet.percederberg.mibble.MibValue
Direct Known Subclasses:
BitSetValue, BooleanValue, NullValue, NumberValue, ObjectIdentifierValue, StringValue, ValueReference

public abstract class MibValue
extends java.lang.Object

The base MIB value class. There are only a few MIB value classes, each corresponding to a primitive ASN.1 type. To extract the basic Java representation of the MIB value, the toObject() method should be used.

Since:
2.0

Constructor Summary
protected MibValue(java.lang.String name)
          Creates a new MIB value instance.
 
Method Summary
 MibValue createReference()
          Creates a value reference to this value.
 java.lang.String getName()
          Returns the value name.
 MibValueSymbol getReferenceSymbol()
          Returns the value reference symbol.
abstract  MibValue initialize(MibLoaderLog log)
          Initializes the MIB value.
 boolean isReferenceTo(java.lang.String name)
          Checks if this value referenced the specified value symbol.
 boolean isReferenceTo(java.lang.String module, java.lang.String name)
          Checks if this value referenced the specified value symbol.
 void setReferenceSymbol(MibValueSymbol symbol)
          Sets the value reference symbol.
abstract  java.lang.Object toObject()
          Returns a Java object representation of this value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MibValue

protected MibValue(java.lang.String name)
Creates a new MIB value instance.

Parameters:
name - the value name
Method Detail

initialize

public abstract MibValue initialize(MibLoaderLog log)
                             throws MibException
Initializes the MIB value. This will remove all levels of indirection present, such as references to other values. No value information is lost by this operation. This method may modify this object as a side-effect, and will return the basic value.

NOTE: This is an internal method that should only be called by the MIB loader.

Parameters:
log - the MIB loader log
Returns:
the basic MIB value
Throws:
MibException - if an error was encountered during the initialization

createReference

public MibValue createReference()
                         throws java.lang.UnsupportedOperationException
Creates a value reference to this value. The value reference is normally an identical value. Only certain values support being referenced, and the default implementation of this method throws an exception.

NOTE: This is an internal method that should only be called by the MIB loader.

Returns:
the MIB value reference
Throws:
java.lang.UnsupportedOperationException - if a value reference couldn't be created
Since:
2.2

isReferenceTo

public boolean isReferenceTo(java.lang.String name)
Checks if this value referenced the specified value symbol.

Parameters:
name - the value symbol name
Returns:
true if this value was a reference to the symbol, or false otherwise
Since:
2.2

isReferenceTo

public boolean isReferenceTo(java.lang.String module,
                             java.lang.String name)
Checks if this value referenced the specified value symbol.

Parameters:
module - the value symbol module (MIB) name
name - the value symbol name
Returns:
true if this value was a reference to the symbol, or false otherwise
Since:
2.2

getName

public java.lang.String getName()
Returns the value name.

Returns:
the value name, or an empty string if not applicable
Since:
2.2

getReferenceSymbol

public MibValueSymbol getReferenceSymbol()
Returns the value reference symbol. A value reference is created whenever a value is defined in a value assignment, and later referenced by name from some other symbol. The complete chain of value references is available by calling getReference() recursively on the value of the returned value symbol.

Returns:
the value reference symbol, or null if this value never referenced another value
Since:
2.2

setReferenceSymbol

public void setReferenceSymbol(MibValueSymbol symbol)
Sets the value reference symbol. The value reference is set whenever a value is defined in a value assignment, and later referenced by name from some other symbol.

NOTE: This is an internal method that should only be called by the MIB loader.

Parameters:
symbol - the referenced value symbol
Since:
2.2

toObject

public abstract java.lang.Object toObject()
Returns a Java object representation of this value.

Returns:
a Java object representation of this value