net.i2p.client.naming

## Class MetaNamingService

- java.lang.Object
- - net.i2p.client.naming.NamingService
  - - net.i2p.client.naming.DummyNamingService
    - - net.i2p.client.naming.MetaNamingService

- Direct Known Subclasses:
    HostsTxtNamingService

      public class MetaNamingService
      extends DummyNamingService

  A naming service of multiple naming services. Supports .b32.i2p and {b64} lookups. Supports caching.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected List<NamingService>` | `_services`

    - ### Fields inherited from class net.i2p.client.naming.DummyNamingService

      `BASE32_HASH_LENGTH, CACHE_MAX_SIZE, DEST_SIZE, PROP_B32`

    - ### Fields inherited from class net.i2p.client.naming.NamingService

      `_context, _listeners, _log, _updaters, PROP_IMPL`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MetaNamingService(I2PAppContext context)` Adds the services from the i2p.nameservicelist property, in order, as chained services.
    `MetaNamingService(I2PAppContext context, List<NamingService> services)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `addNamingService(NamingService ns, boolean head)` Only for chaining-capable NamingServices.
    `void` | `export(Writer out, Properties options)` All services aggregated.
    `Map<String,String>` | `getBase64Entries(Properties options)` All services aggregated
    `Map<String,Destination>` | `getEntries(Properties options)` All services aggregated
    `Set<String>` | `getNames(Properties options)` All services aggregated
    `List<NamingService>` | `getNamingServices()` This implementation returns null.
    `Destination` | `lookup(String hostname, Properties lookupOptions, Properties storedOptions)` Same as lookup(hostname) but with in and out options Note that whether this (and lookup(hostname)) resolve Base 32 addresses in the form {52 chars}.b32.i2p is NamingService-specific.
    `boolean` | `put(String hostname, Destination d, Properties options)` Stores in the last service
    `boolean` | `putIfAbsent(String hostname, Destination d, Properties options)` Stores in the last service
    `void` | `registerListener(NamingServiceListener nsl)` Register a listener for naming service changes.
    `boolean` | `remove(String hostname, Properties options)` Removes from all services
    `boolean` | `removeNamingService(NamingService ns)` Only for chaining-capable NamingServices.
    `String` | `reverseLookup(Destination dest, Properties options)` Same as reverseLookup(dest) but with options This implementation returns null.
    `void` | `shutdown()` Parent will call when removed.
    `int` | `size(Properties options)` All services aggregated
    `void` | `unregisterListener(NamingServiceListener nsl)` Unregister a listener for naming service changes.

    - ### Methods inherited from class net.i2p.client.naming.DummyNamingService

      `clearCache, getCache, putCache, removeCache`

    - ### Methods inherited from class net.i2p.client.naming.NamingService

      `addDestination, addDestination, addNamingService, createInstance, export, getConfiguration, getEntries, getName, getNames, getParent, isB32Host, isBlindedHost, isI2PHost, lookup, lookup, lookupAll, lookupAll, lookupBase32, lookupBase64, put, putAll, putIfAbsent, registerUpdater, remove, remove, remove, requestUpdate, reverseLookup, reverseLookup, reverseLookupAll, reverseLookupAll, reverseLookupAll, setConfiguration, size, start, toString, unregisterUpdater, update`

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### _services

          protected final List<NamingService> _services

  - ### Constructor Detail

    - #### MetaNamingService

          public MetaNamingService(I2PAppContext context)

      Adds the services from the i2p.nameservicelist property, in order, as chained services.

    - #### MetaNamingService

          public MetaNamingService(I2PAppContext context,
                                   List<NamingService> services)

      Parameters:
        `services` - if non-null, services to be added. If null, this will only handle b32 and b64, until addNamingService() is called later.

  - ### Method Detail

    - #### addNamingService

          public boolean addNamingService(NamingService ns,
                                          boolean head)

      Description copied from class: `NamingService`
      Only for chaining-capable NamingServices. This implementation returns false. Subclasses implementing chaining should override.
      Overrides:
        `addNamingService` in class `NamingService`
      Parameters:
        `ns` - the naming service to add
        `head` - or tail
      Returns:
        success

    - #### export

          public void export(Writer out,
                             Properties options)
                      throws IOException

      All services aggregated. Duplicates not removed (for efficiency)
      Overrides:
        `export` in class `NamingService`
      Parameters:
        `out` - the writer to export to
        `options` - NamingService-specific, can be null
      Throws:
        `IOException` - if an I/O error occurs

    - #### getBase64Entries

          public Map<String,String> getBase64Entries(Properties options)

      All services aggregated
      Overrides:
        `getBase64Entries` in class `NamingService`
      Parameters:
        `options` - NamingService-specific, can be null
      Returns:
        all mappings (matching the options if non-null) or empty Map if none; Returned Map is not necessarily sorted, implementation dependent

    - #### getEntries

          public Map<String,Destination> getEntries(Properties options)

      All services aggregated
      Overrides:
        `getEntries` in class `NamingService`
      Parameters:
        `options` - NamingService-specific, can be null
      Returns:
        all mappings (matching the options if non-null) or empty Map if none; Returned Map is not necessarily sorted, implementation dependent

    - #### getNames

          public Set<String> getNames(Properties options)

      All services aggregated
      Overrides:
        `getNames` in class `NamingService`
      Parameters:
        `options` - NamingService-specific, can be null
      Returns:
        all known hostnames (matching the options if non-null) or empty Set if none; Returned Set is not necessarily sorted, implementation dependent

    - #### getNamingServices

          public List<NamingService> getNamingServices()

      Description copied from class: `NamingService`
      This implementation returns null. Subclasses implementing chaining should override.
      Overrides:
        `getNamingServices` in class `NamingService`
      Returns:
        chained naming services or null

    - #### lookup

          public Destination lookup(String hostname,
                                    Properties lookupOptions,
                                    Properties storedOptions)

      Description copied from class: `NamingService`
      Same as lookup(hostname) but with in and out options Note that whether this (and lookup(hostname)) resolve Base 32 addresses in the form {52 chars}.b32.i2p is NamingService-specific.
      Overrides:
        `lookup` in class `DummyNamingService`
      Parameters:
        `hostname` - mixed case as it could be a key
        `lookupOptions` - input parameter, NamingService-specific, can be null
        `storedOptions` - output parameter, NamingService-specific, any stored properties will be added if non-null
      Returns:
        dest or null

    - #### put

          public boolean put(String hostname,
                             Destination d,
                             Properties options)

      Stores in the last service
      Overrides:
        `put` in class `NamingService`
      Parameters:
        `hostname` - the hostname to add
        `d` - the destination for the hostname
        `options` - NamingService-specific, can be null
      Returns:
        success

    - #### putIfAbsent

          public boolean putIfAbsent(String hostname,
                                     Destination d,
                                     Properties options)

      Stores in the last service
      Overrides:
        `putIfAbsent` in class `NamingService`
      Parameters:
        `hostname` - the hostname to add
        `d` - the destination for the hostname
        `options` - NamingService-specific, can be null
      Returns:
        success

    - #### registerListener

          public void registerListener(NamingServiceListener nsl)

      Description copied from class: `NamingService`
      Register a listener for naming service changes.
      Overrides:
        `registerListener` in class `NamingService`
      Parameters:
        `nsl` - the listener to register

    - #### remove

          public boolean remove(String hostname,
                                Properties options)

      Removes from all services
      Overrides:
        `remove` in class `NamingService`
      Parameters:
        `hostname` - the hostname to remove
        `options` - NamingService-specific, can be null
      Returns:
        true if removed successfully, false on error or if it did not exist

    - #### removeNamingService

          public boolean removeNamingService(NamingService ns)

      Description copied from class: `NamingService`
      Only for chaining-capable NamingServices. This implementation returns false. Subclasses implementing chaining should override.
      Overrides:
        `removeNamingService` in class `NamingService`
      Parameters:
        `ns` - the naming service to remove
      Returns:
        success

    - #### reverseLookup

          public String reverseLookup(Destination dest,
                                      Properties options)

      Description copied from class: `NamingService`
      Same as reverseLookup(dest) but with options This implementation returns null. Subclasses implementing reverse lookups should override.
      Overrides:
        `reverseLookup` in class `NamingService`
      Parameters:
        `dest` - non-null destination to look up
        `options` - NamingService-specific, can be null
      Returns:
        hostname or null

    - #### shutdown

          public void shutdown()

      Description copied from class: `NamingService`
      Parent will call when removed. If this is the root naming service, the core will stop it. Should not be called by others.
      Overrides:
        `shutdown` in class `NamingService`

    - #### size

          public int size(Properties options)

      All services aggregated
      Overrides:
        `size` in class `NamingService`
      Parameters:
        `options` - NamingService-specific, can be null
      Returns:
        number of entries (matching the options if non-null) or -1 if unknown

    - #### unregisterListener

          public void unregisterListener(NamingServiceListener nsl)

      Description copied from class: `NamingService`
      Unregister a listener for naming service changes.
      Overrides:
        `unregisterListener` in class `NamingService`
      Parameters:
        `nsl` - the listener to unregister