net.i2p.client.naming

## Class SingleFileNamingService

- java.lang.Object
- - net.i2p.client.naming.NamingService
  - - net.i2p.client.naming.SingleFileNamingService

-     public class SingleFileNamingService
      extends NamingService

  A naming service based on a single file using the "hosts.txt" format. Supports adds, removes, and listeners. All methods here are case-sensitive. Conversion to lower case is done in HostsTxtNamingService. This does NOT provide .b32.i2p or {b64} resolution. It also does not do any caching. Use from HostsTxtNamingService or chain with another NamingService via MetaNamingService if you need those features.
  Since:
    0.8.7

- - ### Field Summary

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

      `_context, _listeners, _log, _updaters, PROP_IMPL`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SingleFileNamingService(I2PAppContext context, String filename)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Map<String,Destination>` | `getEntries(Properties options)`
    `String` | `getName()`
    `Set<String>` | `getNames(Properties options)`
    `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 B32 addresses is NamingService-specific.
    `static void` | `main(String[] args)`
    `boolean` | `put(String hostname, Destination d, Properties options)`
    `boolean` | `putIfAbsent(String hostname, Destination d, Properties options)` Fails if entry previously exists
    `boolean` | `remove(String hostname, Properties options)`
    `String` | `reverseLookup(Destination dest, Properties options)` Same as reverseLookup(dest) but with options
    `void` | `shutdown()` Parent will call when removed.
    `int` | `size(Properties options)`

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

      `addNamingService, addNamingService, createInstance, getBase64Entries, getConfiguration, getEntries, getNames, getNamingServices, getParent, lookup, lookup, lookupBase32, lookupBase64, put, putAll, putIfAbsent, registerListener, registerUpdater, remove, removeNamingService, requestUpdate, reverseLookup, reverseLookup, setConfiguration, size, start, toString, unregisterListener, unregisterUpdater, update`

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

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

- - ### Constructor Detail

    - #### SingleFileNamingService

          public SingleFileNamingService(I2PAppContext context,
                                 String filename)

  - ### Method Detail

    - #### getName

          public String getName()

      Overrides:
        `getName` in class `NamingService`
      Returns:
        the file's absolute path

    - #### 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 B32 addresses is NamingService-specific.
      Specified by:
        `lookup` in class `NamingService`
      Parameters:
        `hostname` - case-sensitive; caller should convert to lower case
        `lookupOptions` - ignored
        `storedOptions` - ignored
      Returns:
        dest or null

    - #### reverseLookup

          public String reverseLookup(Destination dest,
                             Properties options)

      Description copied from class: `NamingService`
      Same as reverseLookup(dest) but with options
      Overrides:
        `reverseLookup` in class `NamingService`
      Parameters:
        `options` - ignored
      Returns:
        host name or null

    - #### put

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

      Overrides:
        `put` in class `NamingService`
      Parameters:
        `hostname` - case-sensitive; caller should convert to lower case
        `options` - ignored
      Returns:
        success

    - #### putIfAbsent

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

      Description copied from class: `NamingService`
      Fails if entry previously exists
      Overrides:
        `putIfAbsent` in class `NamingService`
      Parameters:
        `hostname` - case-sensitive; caller should convert to lower case
        `options` - ignored
      Returns:
        success

    - #### remove

          public boolean remove(String hostname,
                       Properties options)

      Overrides:
        `remove` in class `NamingService`
      Parameters:
        `hostname` - case-sensitive; caller should convert to lower case
        `options` - ignored
      Returns:
        success

    - #### getEntries

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

      Overrides:
        `getEntries` in class `NamingService`
      Parameters:
        `options` - As follows: Key "search": return only those matching substring Key "startsWith": return only those starting with ("[0-9]" allowed)
      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)

      Overrides:
        `getNames` in class `NamingService`
      Parameters:
        `options` - ignored
      Returns:
        all known host names, unsorted

    - #### size

          public int size(Properties options)

      Overrides:
        `size` in class `NamingService`
      Parameters:
        `options` - ignored
      Returns:
        number of entries (matching the options if non-null) or -1 if unknown

    - #### 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`

    - #### main

          public static void main(String[] args)