net.percederberg.mibble

## Class MibSource

- java.lang.Object
- - net.percederberg.mibble.MibSource

-     public class MibSource
      extends java.lang.Object

  A MIB input source. This class encapsulates the different ways of locating a MIB file, either through a file or a URL.
  Since:
    2.10

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `` | `MibSource(java.io.File file)` Creates a new MIB input source.
    `protected` | `MibSource(java.io.Reader input)` Creates a new MIB input source.
    `` | `MibSource(java.lang.String path, java.net.URL url)` Creates a new MIB input source.
    `` | `MibSource(java.net.URL url)` Creates a new MIB input source.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(java.lang.Object obj)` Checks if this object is equal to another.
    `java.io.File` | `getFile()` Returns the MIB file if set.
    `java.io.Reader` | `getReader()` Returns a stream reader for the MIB file.
    `java.net.URL` | `getURL()` Returns the MIB URL if set.
    `int` | `hashCode()` Returns the hash code value for the object.

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### MibSource

          public MibSource(java.io.File file)

      Creates a new MIB input source. The MIB will be read from the specified file.
      Parameters:
        `file` - the file to read from

    - #### MibSource

          public MibSource(java.net.URL url)

      Creates a new MIB input source. The MIB will be read from the specified URL.
      Parameters:
        `url` - the URL to read from

    - #### MibSource

          public MibSource(java.lang.String path,
                   java.net.URL url)

      Creates a new MIB input source. The MIB will be read from the specified URL. This method also creates a reference file from the specified MIB path to better report error locations.
      Parameters:
        `path` - the resource path (i.e. error location)
        `url` - the URL to read from

    - #### MibSource

          protected MibSource(java.io.Reader input)

      Creates a new MIB input source. The MIB will be read from the specified input reader. The input reader will be closed after reading the MIB.
      Parameters:
        `input` - the input stream to read from

  - ### Method Detail

    - #### equals

          public boolean equals(java.lang.Object obj)

      Checks if this object is equal to another. This method will only return true for another MIB source object with the same input source.
      Overrides:
        `equals` in class `java.lang.Object`
      Parameters:
        `obj` - the object to compare with
      Returns:
        true if the object is equal to this, or false otherwise

    - #### hashCode

          public int hashCode()

      Returns the hash code value for the object. This method is re-implemented to fulfill the contract of returning the same hash code for objects that are considered equal.
      Overrides:
        `hashCode` in class `java.lang.Object`
      Returns:
        the hash code value for the object
      Since:
        2.6

    - #### getFile

          public java.io.File getFile()

      Returns the MIB file if set. If the MIB source is a URL, the file may still be set (and contain only the known MIB name).
      Returns:
        the MIB file, or null

    - #### getURL

          public java.net.URL getURL()

      Returns the MIB URL if set.
      Returns:
        the MIB URL, or null

    - #### getReader

          public java.io.Reader getReader()
                                   throws java.io.IOException

      Returns a stream reader for the MIB file. It is the responsibility of the caller to ensure closing the stream (after use).
      Returns:
        a stream reader for the MIB file
      Throws:
        `java.io.IOException` - if the MIB file couldn't be opened