JASMI API

com.agentpp.smi
Class SMIRepository

java.lang.Object
  extended by com.agentpp.smi.SMIRepository
All Implemented Interfaces:
IRepository

public class SMIRepository
extends java.lang.Object
implements IRepository

The SMIRepository provides methods and services for managing MIB modules.

Version:
1.8
Author:
Frank Fock

Constructor Summary
SMIRepository()
           
 
Method Summary
 void addObject(IObject object)
          Adds an IObject to the MIB repository.
 java.util.Vector getChildren(IObject object)
          Gets the children of a given object.
 java.util.Vector getChildren(IObjectID oid)
          Gets the children of an object given by its object ID.
 java.util.Vector getChildren(java.lang.String objectName)
          Gets the children of an object given by its name.
 java.util.Vector getDescendants(IObject object)
          Gets the descendants of a given object.
 ITextualConvention getEffectiveSyntax(ISyntax syntax)
          Get the effective syntax for a given ISyntax.
 IModule getModule(java.lang.String moduleName)
          Gets a MIB module with a given name.
 java.util.Vector getModuleNames()
          Gets a Vector of module names of this MIB repository.
 java.util.Enumeration getModulesSortedByName()
          Gets an Enumeration of all modules sorted by name.
 java.util.Vector getNonOidObjects(boolean textualConventionsOnly)
          Get all objects in the repository that do not have an object identifier.
 IObject getObject(IObjectID oid)
          Gets an IObject with a given object ID.
 IObject getObject(java.lang.String name)
          Gets a MIB object with a given name.
 IObject getObject(java.lang.String moduleName, java.lang.String name)
          Gets the MIB object with a given name from a given module.
 IObject getObjectByOID(java.lang.String oid)
          Gets an IObject with a given object ID string.
 IObjectType getObjectClass(java.lang.String oid)
          Gets the object class OBJECT-TYPE definition for the supplied instance OID.
 java.util.Vector getObjectClassOID(java.lang.String oid)
          Gets the class OID of a given instance OID and the corresponding instance suffix.
 IObjectID getObjectID(java.lang.String name)
          Gets the object ID for a given name.
 IObjectID getObjectID(java.lang.String moduleName, java.lang.String name)
          Gets the object ID for a given name.
 java.lang.String getObjectName(IObjectID oid)
          Gets the object name for a given object ID.
 IObject[] getObjectsByName(java.lang.String name)
          Gets all objects with a given name.
 IObject[] getObjectsByOid(IObjectID oid)
          Gets all objects with a given OID.
 IObject[] getObjectsByOid(java.lang.String oid)
          Gets all objects with a given OID string.
 IObject getParent(IObject object)
          Gets the parent MIBObject for a given object
 java.lang.String getPath(IObjectID oid, boolean withID)
          Get the object name path for a given object ID.
 java.lang.String getPath(java.lang.String oid, boolean withID)
          Get the object name path for a given object ID.
 IObjectID makeObjectID(java.lang.String oid)
          Creates an IObjectID from a dotted string or object name path.
 int moduleCount()
          Return the number of modules in the MIB repository.
 java.util.Enumeration modules()
          Returns an Enumeration of all modules.
 java.util.Iterator modulesIterator()
          Returns an Iterator of all modules.
 java.util.Enumeration objects()
          Returns an Enumeration of all objects.
 java.util.Enumeration objectsByName()
          Returns an Enumeration of all objects ordered by name.
 java.util.Iterator objectsOrderedByOccurance()
          Returns an Iterator on the objects contained in this module ordered by their occurance in the original (compiled) MIB module.
 java.lang.String printModule(java.lang.String moduleName)
          Return the SMI definition of a given module.
 void remove(IModule module)
          Remove an IModule including its content from the MIB repository.
 boolean removeModule(java.lang.String name)
          Removes a MIB module given by its module name.
 void removeObject(IObject object)
          Removes the given object from the MIB repository.
 int size()
          Return the size of the repository.
 void structureChanged()
          This method should always called when the structure of the repository has been changed (i.e., a MIB module has been added or MIB objects have been added or deleted).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SMIRepository

public SMIRepository()
Method Detail

size

public int size()
Description copied from interface: IRepository
Return the size of the repository. The size is equal to the count of MIBObjects returned by the objects() enumeration.

Specified by:
size in interface IRepository
Returns:
the size of the repository

moduleCount

public int moduleCount()
Description copied from interface: IRepository
Return the number of modules in the MIB repository.

Specified by:
moduleCount in interface IRepository
Returns:
the MIB module count.

addObject

public void addObject(IObject object)
Description copied from interface: IRepository
Adds an IObject to the MIB repository. Modules should be added before their objects are added, otherwise, after adding all objects, IRepository.structureChanged() must be called to ensure, that the modules know about their objects.

Specified by:
addObject in interface IRepository
Parameters:
object - an IObject instance.

getObjectName

public java.lang.String getObjectName(IObjectID oid)
Description copied from interface: IRepository
Gets the object name for a given object ID.

Specified by:
getObjectName in interface IRepository
Parameters:
oid - an object identifier.
Returns:
an object name associated with the given object ID. Note, that there may be more than one name associated with the same object ID. In that case it is undefined which name is returned. If the given object ID could not be found, null is returned.

getObjectID

public IObjectID getObjectID(java.lang.String name)
Description copied from interface: IRepository
Gets the object ID for a given name.

Specified by:
getObjectID in interface IRepository
Parameters:
name - an object name.
Returns:
an object ID associated with the given object name. Note, that there may be more than one object ID associated with the same object name, because it is allowed in SMI to use the same name for different objects within different modules. In that case it is not defined which ID is returned. If the given object name could not be found, null is returned.

getObjectID

public IObjectID getObjectID(java.lang.String moduleName,
                             java.lang.String name)
Description copied from interface: IRepository
Gets the object ID for a given name.

Specified by:
getObjectID in interface IRepository
Parameters:
moduleName - the name of the MIB module to search for the object ID.
name - an object name.
Returns:
an object ID associated with the given object name. If the given object name could not be found in the MIB module moduleName, null is returned.

getObject

public IObject getObject(java.lang.String moduleName,
                         java.lang.String name)
Description copied from interface: IRepository
Gets the MIB object with a given name from a given module.

Specified by:
getObject in interface IRepository
Parameters:
moduleName - a module name.
name - the object's name.
Returns:
an IObject instance if the requested object could be found, or null otherwise.

getChildren

public java.util.Vector getChildren(java.lang.String objectName)
Description copied from interface: IRepository
Gets the children of an object given by its name.

Specified by:
getChildren in interface IRepository
Parameters:
objectName - an object name.
Returns:
a possibly empty Vector of children if the object could be found, or null otherwise.

getChildren

public java.util.Vector getChildren(IObjectID oid)
Description copied from interface: IRepository
Gets the children of an object given by its object ID.

Specified by:
getChildren in interface IRepository
Parameters:
oid - an IObjectID instance.
Returns:
a possibly empty Vector of children.

getChildren

public java.util.Vector getChildren(IObject object)
Description copied from interface: IRepository
Gets the children of a given object.

Specified by:
getChildren in interface IRepository
Parameters:
object - an IObject instance.
Returns:
a possibly empty Vector of children.

getDescendants

public java.util.Vector getDescendants(IObject object)
Description copied from interface: IRepository
Gets the descendants of a given object. Thus, all objects in the subtree of the given object are returned.

Specified by:
getDescendants in interface IRepository
Parameters:
object - an IObject instance.
Returns:
a possibly empty Vector of children.

getParent

public IObject getParent(IObject object)
Description copied from interface: IRepository
Gets the parent MIBObject for a given object

Specified by:
getParent in interface IRepository
Parameters:
object - an IObject instance.
Returns:
an IObject instance if there exists an object with an object ID that matches the object ID object without its last sub-identifier. In any other case null is returned.

getObjectsByName

public IObject[] getObjectsByName(java.lang.String name)
Description copied from interface: IRepository
Gets all objects with a given name.

Specified by:
getObjectsByName in interface IRepository
Parameters:
name - an object name.
Returns:
a possibly empty array of IObject instances.

getObjectsByOid

public IObject[] getObjectsByOid(IObjectID oid)
Description copied from interface: IRepository
Gets all objects with a given OID.

Specified by:
getObjectsByOid in interface IRepository
Parameters:
oid - an IObjectID instance.
Returns:
a possibly empty array of IObject instances.

remove

public void remove(IModule module)
Description copied from interface: IRepository
Remove an IModule including its content from the MIB repository.

Specified by:
remove in interface IRepository
Parameters:
module - an IModule instance.

removeObject

public void removeObject(IObject object)
Description copied from interface: IRepository
Removes the given object from the MIB repository.

Specified by:
removeObject in interface IRepository
Parameters:
object - an IObject instance.

removeModule

public boolean removeModule(java.lang.String name)
Description copied from interface: IRepository
Removes a MIB module given by its module name. The contents of the module is removed too.

Specified by:
removeModule in interface IRepository
Parameters:
name - a module name.
Returns:
true if the module could be removed, false otherwise.

getModule

public IModule getModule(java.lang.String moduleName)
Description copied from interface: IRepository
Gets a MIB module with a given name.

Specified by:
getModule in interface IRepository
Parameters:
moduleName - a module name.
Returns:
an IModule instance if such an instance could be found, null otherwise.

getObject

public IObject getObject(java.lang.String name)
Description copied from interface: IRepository
Gets a MIB object with a given name.

Specified by:
getObject in interface IRepository
Parameters:
name - an object name, for example "sysDescr" or "SNMPv2-MIB.sysDescr".
Returns:
an IObject instance if such an instance could be found, null otherwise.

getObject

public IObject getObject(IObjectID oid)
Description copied from interface: IRepository
Gets an IObject with a given object ID.

Specified by:
getObject in interface IRepository
Parameters:
oid - an IObjectID.
Returns:
an IObject instance if such an instance could be found, null otherwise.

modules

public java.util.Enumeration modules()
Description copied from interface: IRepository
Returns an Enumeration of all modules.

Specified by:
modules in interface IRepository
Returns:
an Enumeration of IModule instances.

modulesIterator

public java.util.Iterator modulesIterator()
Description copied from interface: IRepository
Returns an Iterator of all modules.

Specified by:
modulesIterator in interface IRepository
Returns:
an Enumeration of IModule instances.

getModulesSortedByName

public java.util.Enumeration getModulesSortedByName()
Description copied from interface: IRepository
Gets an Enumeration of all modules sorted by name.

Specified by:
getModulesSortedByName in interface IRepository
Returns:
an Enumeration of IModule instances.

getModuleNames

public java.util.Vector getModuleNames()
Description copied from interface: IRepository
Gets a Vector of module names of this MIB repository.

Specified by:
getModuleNames in interface IRepository
Returns:
a Vector of Strings.

objects

public java.util.Enumeration objects()
Description copied from interface: IRepository
Returns an Enumeration of all objects.

Specified by:
objects in interface IRepository
Returns:
an Enumeration of IObject instances.

objectsByName

public java.util.Enumeration objectsByName()
Description copied from interface: IRepository
Returns an Enumeration of all objects ordered by name.

Specified by:
objectsByName in interface IRepository
Returns:
an Enumeration of IObject instances.

objectsOrderedByOccurance

public java.util.Iterator objectsOrderedByOccurance()
Description copied from interface: IRepository
Returns an Iterator on the objects contained in this module ordered by their occurance in the original (compiled) MIB module.

Specified by:
objectsOrderedByOccurance in interface IRepository
Returns:
an Iterator on the MIB objects of this module.

structureChanged

public void structureChanged()
Description copied from interface: IRepository
This method should always called when the structure of the repository has been changed (i.e., a MIB module has been added or MIB objects have been added or deleted).

Specified by:
structureChanged in interface IRepository

getPath

public java.lang.String getPath(IObjectID oid,
                                boolean withID)
Description copied from interface: IRepository
Get the object name path for a given object ID. For example, an object ID "1.3.6.1" will return "iso.org.dod.internet".

Specified by:
getPath in interface IRepository
Parameters:
oid - an IObjectID instance to convert.
withID - if true after each name, the corresponding sub-identifier will be returned, for example "1.3.6.1" will return "iso(1).org(3).dod(6).internet(1)".

getNonOidObjects

public java.util.Vector getNonOidObjects(boolean textualConventionsOnly)
Description copied from interface: IRepository
Get all objects in the repository that do not have an object identifier. These objects are likely to be textual conventions and SMIv1 MIB modules.

Specified by:
getNonOidObjects in interface IRepository
Parameters:
textualConventionsOnly - if true only ITextualConvention instances are returned.
Returns:
a vector of IObject instances.

printModule

public java.lang.String printModule(java.lang.String moduleName)
Description copied from interface: IRepository
Return the SMI definition of a given module.

Specified by:
printModule in interface IRepository
Parameters:
moduleName - a module name.
Returns:
the SMI definition of the module.

makeObjectID

public IObjectID makeObjectID(java.lang.String oid)
Description copied from interface: IRepository
Creates an IObjectID from a dotted string or object name path.

Specified by:
makeObjectID in interface IRepository
Parameters:
oid - a dotted String, for example "1.3.6.1.2" or "iso.org.dod.internet".
Returns:
an IObjectID. If a non-numerical OID string cannot be resolved, then null will be returned.

getPath

public java.lang.String getPath(java.lang.String oid,
                                boolean withID)
Description copied from interface: IRepository
Get the object name path for a given object ID. For example, an object ID "1.3.6.1" will return "iso.org.dod.internet".

Specified by:
getPath in interface IRepository
Parameters:
oid - a numerical OID string to convert.
withID - if true after each name, the corresponding sub-identifier will be returned, for example "1.3.6.1" will return "iso(1).org(3).dod(6).internet(1)".

getObjectByOID

public IObject getObjectByOID(java.lang.String oid)
Description copied from interface: IRepository
Gets an IObject with a given object ID string.

Specified by:
getObjectByOID in interface IRepository
Parameters:
oid - an OID string with numerical subidentifiers.
Returns:
an IObject instance if such an instance could be found, null otherwise.

getObjectsByOid

public IObject[] getObjectsByOid(java.lang.String oid)
Description copied from interface: IRepository
Gets all objects with a given OID string.

Specified by:
getObjectsByOid in interface IRepository
Parameters:
oid - an OID string with numerical subidentifiers.
Returns:
a possibly empty array of IObject instances.

getEffectiveSyntax

public ITextualConvention getEffectiveSyntax(ISyntax syntax)
Description copied from interface: IRepository
Get the effective syntax for a given ISyntax. The effective syntax is the base syntax with possibly additional range restrictions or enumerations.

Specified by:
getEffectiveSyntax in interface IRepository
Parameters:
syntax - a ISyntax instance.
Returns:
a ITextualConvention instance containing a ISyntax instance possibly indentical to 'syntax' and, if available, a display hint String. If 'syntax' is not of type SMI.SYN_CONVENTION or if its base syntax cannot be determined, then syntax is returned.

getObjectClassOID

public java.util.Vector getObjectClassOID(java.lang.String oid)
Description copied from interface: IRepository
Gets the class OID of a given instance OID and the corresponding instance suffix. For example, for "1.3.6.1.2.1.1.1.0" it will return "1.3.6.1.2.1.1.1" and "0".

Specified by:
getObjectClassOID in interface IRepository
Parameters:
oid - a dotted String.
Returns:
a Vector of two elements. The first contains the object class OID as a dotted String with numerical sub-identifiers, if the object class could be determined by the information in the repository (otherwise the first element will be null). The second element contains the instance OID suffix as a dotted numerical String. If the object class is null, then the second element is identical to oid.

getObjectClass

public IObjectType getObjectClass(java.lang.String oid)
Description copied from interface: IRepository
Gets the object class OBJECT-TYPE definition for the supplied instance OID. If the object type for the instance OID cannot be determined, null is returned. See also IRepository.getObjectClassOID(String oid).

Specified by:
getObjectClass in interface IRepository
Parameters:
oid - the instance OID as a dotted String.
Returns:
the OBJECT-TYPE definition of the corresponding MIB object if it can be determined, otherwise null is returned.

JASMI API

JASMI 3
Copyright 2001-2010 Frank Fock
All Rights Reserved