JASMI API

com.agentpp.smi
Interface IRepositoryManager

All Known Implementing Classes:
SMIRepositoryManager

public interface IRepositoryManager

Interface for Repository Managers of SNMP MIB repositories.

Version:
1.8.1
Author:
Frank fock

Field Summary
static int NOCHECK_INCONSISTENT_ACCESS
           
static int NOCHECK_INCONSISTENT_STATUS
           
static int NOCHECK_INCONSISTENT_SYNTAX
           
static int NOCHECK_NOT_IN_GROUP
           
 
Method Summary
 void addModule(IModule module)
          Adds a MIB module to the repository.
 IModuleInfo[] addModules(java.io.File file)
          Adds a MIB file to the repository.
 void addRepositoryListener(RepositoryListener listener)
          Adds a RepositoryListener to this repository that provides Input- and OutputStreams to read and write MIB modules from persistent storage (i.e. the MIB repository).
 void checkModules(java.io.InputStream file)
          Check whether an InputStream contains valid MIB modules.
 IModuleInfo[] checkModules(java.io.InputStream file, boolean lenientSyntaxCheck)
          Check whether an InputStream contains valid MIB modules.
 java.lang.Integer createModuleID()
          Creates a new unique module ID for the current MIB repository.
 java.lang.String getErrorText(int errorCode, java.lang.String message)
          Deprecated.  
 java.lang.String getErrorText(com.agentpp.smiparser.SMIParseException parseException)
          Get an error text for a SMIParseException.
 IObject[] getImportedObjects(java.lang.String moduleName)
          Get those MIBObjects for a MIB module with the specified name, that are imported from other MIBs.
 IObject[] getImportedObjects(java.lang.String moduleName, java.util.Hashtable moduleIDs)
          Get those MIBObjects for a MIB module with the specified name, that are imported from other MIBs.
 IModule getModule(java.lang.String moduleName)
          Return a given MIB module including its objects.
 IModuleInfo[] getModuleInfo(java.io.File file)
          Get MIB module information (module name and imports) from a MIB file.
 IModuleInfo[] getModuleInfo(java.io.InputStream inputStream, java.lang.String name)
          Get MIB module information (module name and imports) from an input stream.
 IModuleInfo[] getModuleInfos()
          Get module information about all MIB modules in the MIB repository.
 java.lang.String[] getModuleNames()
          Return an array of all module names available from the repository managed by the receiver.
 IModule[] getModules()
          Return an array of all MIB modules.
 IModule[] getModules(java.io.InputStream stream, ImportModuleListener importer)
          Get the modules contained in a MIB file.
 IObject[] getObjects(java.lang.String moduleName)
          Get the MIBObjects of the MIB module with the given name.
 int getParserOptions()
          Get actual parser options.
 java.io.File getRepositoryDirectory()
          Gets the repository directory used to store compiled MIB modules by default.
 void initialize()
          Initialize the repository, thus remove all modules from the repository.
 void open(java.io.File directory)
          Open the MIB Repository located at the given path.
 boolean removeModule(java.lang.String moduleName)
          Remove a module from the repository.
 void removeRepositoryListener(RepositoryListener listener)
          Removes a RepositoryListener from this repository.
 void setParserOptions(int options)
          Set parser options.
 

Field Detail

NOCHECK_NOT_IN_GROUP

static final int NOCHECK_NOT_IN_GROUP
See Also:
Constant Field Values

NOCHECK_INCONSISTENT_SYNTAX

static final int NOCHECK_INCONSISTENT_SYNTAX
See Also:
Constant Field Values

NOCHECK_INCONSISTENT_STATUS

static final int NOCHECK_INCONSISTENT_STATUS
See Also:
Constant Field Values

NOCHECK_INCONSISTENT_ACCESS

static final int NOCHECK_INCONSISTENT_ACCESS
See Also:
Constant Field Values
Method Detail

open

void open(java.io.File directory)
          throws java.io.IOException
Open the MIB Repository located at the given path.

Parameters:
directory - a possibly empty directory to store MIB repository data.
Throws:
java.io.IOException - if given MIB repository path is invalid.

addModules

IModuleInfo[] addModules(java.io.File file)
                         throws com.agentpp.smiparser.SMIParseException
Adds a MIB file to the repository.

Parameters:
file - a file containing one or more MIB modules.
Returns:
an array containing ModuleInfo instances with information about the parsed modules contained in file.
Throws:
com.agentpp.smiparser.SMIParseException - if file contains any errors.

getModules

IModule[] getModules(java.io.InputStream stream,
                     ImportModuleListener importer)
                     throws com.agentpp.smiparser.SMIParseException
Get the modules contained in a MIB file. The modules will NOT be added to the repository, however the files in the repository will be used the solve any dependencies

Parameters:
stream - an InputStream containing one or more MIB modules.
importer - an ImportModuleListener instance used as callback to parse or load objects of imported MIB modules and for creating a module ID for any MIB modules parsed from stream.
Returns:
an array of IModule instances representing all MIB modules defined in file.
Throws:
com.agentpp.smiparser.SMIParseException - if any syntax or semantic error has been detected in file.

checkModules

void checkModules(java.io.InputStream file)
                  throws com.agentpp.smiparser.SMIParseException
Check whether an InputStream contains valid MIB modules.

Parameters:
file - an InputStream containing SMIv1/v2 MIB module(s).
Throws:
com.agentpp.smiparser.SMIParseException - if file has an error.

checkModules

IModuleInfo[] checkModules(java.io.InputStream file,
                           boolean lenientSyntaxCheck)
                           throws com.agentpp.smiparser.SMIParseException
Check whether an InputStream contains valid MIB modules.

Parameters:
file - an InputStream containing SMIv1/v2 MIB module(s).
lenientSyntaxCheck - if true the syntax checking is minimal, otherwise it is the default (SMI standard).
Returns:
returns information about the contained MIB modules.
Throws:
com.agentpp.smiparser.SMIParseException - if the syntax check fails.
Since:
2.0.1

getModuleInfo

IModuleInfo[] getModuleInfo(java.io.File file)
                            throws com.agentpp.smiparser.SMIParseException
Get MIB module information (module name and imports) from a MIB file.

Parameters:
file - a SMIv1/v2 MIB File instance.
Returns:
an array of IModuleInfo instances.
Throws:
com.agentpp.smiparser.SMIParseException - if file contains any errors.

getModuleInfo

IModuleInfo[] getModuleInfo(java.io.InputStream inputStream,
                            java.lang.String name)
                            throws com.agentpp.smiparser.SMIParseException
Get MIB module information (module name and imports) from an input stream.

Parameters:
inputStream - an InputStream instance containing SMIv1/v2 MIB modules.
name - a String representing name of the source, for example the path of a FileInputStream.
Returns:
an array of IModuleInfo instances.
Throws:
com.agentpp.smiparser.SMIParseException - if inputStream contains any errors.

getModuleInfos

IModuleInfo[] getModuleInfos()
                             throws java.io.IOException
Get module information about all MIB modules in the MIB repository.

Returns:
a possibly empty array of IModuleInfo instances.
Throws:
java.io.IOException - if the MIB repository is invalid or on any other IO error.

removeModule

boolean removeModule(java.lang.String moduleName)
                     throws java.io.IOException
Remove a module from the repository.

Parameters:
moduleName - the name of the victim.
Returns:
true if the module could be removed, false if it could not be found or if only read access to the MIB repository is granted.
Throws:
java.io.IOException

initialize

void initialize()
                throws java.io.IOException
Initialize the repository, thus remove all modules from the repository. (Note: This method has no effect in read-only mode.)

Throws:
java.io.IOException - thrown if an exception occured while accessing the MIB repository.

getModules

IModule[] getModules()
                     throws java.io.IOException
Return an array of all MIB modules.

Returns:
an array of IModule instances.
Throws:
java.io.IOException

getModule

IModule getModule(java.lang.String moduleName)
                  throws java.io.IOException
Return a given MIB module including its objects.

Parameters:
moduleName - a module name.
Returns:
the MIBModule instance with the given module name, or null if such a module could not be found.
Throws:
java.io.IOException

getModuleNames

java.lang.String[] getModuleNames()
                                  throws java.io.IOException
Return an array of all module names available from the repository managed by the receiver.

Returns:
an array of module names.
Throws:
java.io.IOException

getObjects

IObject[] getObjects(java.lang.String moduleName)
                     throws java.io.IOException
Get the MIBObjects of the MIB module with the given name.

Parameters:
moduleName - the name of a MIB module.
Returns:
an array of MIBObjects.
Throws:
java.io.IOException

getImportedObjects

IObject[] getImportedObjects(java.lang.String moduleName)
                             throws java.io.IOException
Get those MIBObjects for a MIB module with the specified name, that are imported from other MIBs.

Parameters:
moduleName - the name of a MIB module.
Returns:
an array of IObject instances.
Throws:
java.io.IOException

getImportedObjects

IObject[] getImportedObjects(java.lang.String moduleName,
                             java.util.Hashtable moduleIDs)
                             throws java.io.IOException
Get those MIBObjects for a MIB module with the specified name, that are imported from other MIBs.

Parameters:
moduleName - the name of a MIB module.
moduleIDs - an empty Hashtable. On return, it contains a mapping from all module names of the visited MIB modules to their respective module IDs.
Returns:
an array of IObject instances.
Throws:
java.io.IOException
Since:
1.7

getErrorText

java.lang.String getErrorText(int errorCode,
                              java.lang.String message)
Deprecated. 

Get an error text from the error code and error message of the SMIParseException.

Parameters:
errorCode - the errorCode from a com.agentpp.smiparser.SMIParseException.
message - the message of a com.agentpp.smiparser.SMIParseException.
Returns:
an error text.

getErrorText

java.lang.String getErrorText(com.agentpp.smiparser.SMIParseException parseException)
Get an error text for a SMIParseException.

Parameters:
parseException - a com.agentpp.smiparser.SMIParseException.
Returns:
an error text.

setParserOptions

void setParserOptions(int options)
Set parser options. A value of 0 will activate all checks. Checks can be individually disabled by bitwise OR of the corresponding constants defined in this interface.

Parameters:
options - a bitwise OR of option values.

getParserOptions

int getParserOptions()
Get actual parser options.

Returns:
the actual parser options as an integer value.

getRepositoryDirectory

java.io.File getRepositoryDirectory()
Gets the repository directory used to store compiled MIB modules by default. If MIB modules should be stored and loaded in/from a different location or media, a RepositoryListener has to be added by using the addRepositoryListener(com.agentpp.smi.event.RepositoryListener) method.

Returns:
a File instance representing a directory.

addRepositoryListener

void addRepositoryListener(RepositoryListener listener)
Adds a RepositoryListener to this repository that provides Input- and OutputStreams to read and write MIB modules from persistent storage (i.e. the MIB repository). This can be used, for example, to store and read compiled MIB modules from JAR or ZIP files instead from a directory, which is the default.

Parameters:
listener - a RepositoryListener that provides InputStreams and OutputStreams on demand to read or write a precompiled MIB module identified by its name from persistent storage.

removeRepositoryListener

void removeRepositoryListener(RepositoryListener listener)
Removes a RepositoryListener from this repository. If no listeners are left, MIB modules will be read and written from the default MIB repository directory.

Parameters:
listener - a RepositoryListener.

addModule

void addModule(IModule module)
               throws java.io.IOException
Adds a MIB module to the repository.

Parameters:
module - an IModule instance that will be written to the MIB repository. RepositoryEvent listeners will be called to provide an alternative output stream.
Throws:
java.io.IOException

createModuleID

java.lang.Integer createModuleID()
                                 throws java.io.IOException
Creates a new unique module ID for the current MIB repository. Calling this method is required to allocate a new module ID for a IModule instance when this instance has been created programmatically by using means provided by the JASMI Ext API for example.

When parsing MIB modules from a text source file, a module ID is automatically allocated.

When a MIB module is removed from a IB repository, its module ID is freed and can be reused again for any other new module.

Returns:
a unique module ID number for this MIB repository.
Throws:
java.io.IOException
Since:
2.5

JASMI API

JASMI 3
Copyright 2001-2010 Frank Fock
All Rights Reserved