Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.i2p.addressbook
Class AddressBook

    java.lang.Object
      net.i2p.addressbook.AddressBook

    public class AddressBook

extends Object

An address book for storing human readable names mapped to base64 i2p destinations. AddressBooks can be created from local and remote files, merged together, and written out to local files.

Author:
  Ragnarok

Field Summary
`(package private) static long` | `MAX_SUB_SIZE`

Constructor Summary
`AddressBook(File file)` Construct an AddressBook from the contents of the file at file.
`AddressBook(Map addresses)` Construct an AddressBook from the contents of the Map addresses.
`AddressBook(Subscription subscription, String proxyHost, int proxyPort)` Construct an AddressBook from the Subscription subscription.

Method Summary
`Map` | `getAddresses()` Return a Map containing the addresses in the AddressBook.
`String` | `getLocation()` Return the location of the file this AddressBook was constructed from.
`void` | `merge(AddressBook other, boolean overwrite, Log log)` Merge this AddressBook with AddressBook other, writing messages about new addresses or conflicts to log.
`String` | `toString()` Return a string representation of the contents of the AddressBook.
`void` | `write()` Write this AddressBook out to the file it was read from.
`void` | `write(File file)` Write the contents of this AddressBook out to the File file.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### MAX_SUB_SIZE

    static final long MAX_SUB_SIZE

See Also:
  Constant Field Values

Constructor Detail

### AddressBook

    public AddressBook(Map addresses)

  Construct an AddressBook from the contents of the Map addresses.

  Parameters:
    `addresses` - A Map containing human readable addresses as keys, mapped to base64 i2p destinations.

### AddressBook

    public AddressBook(Subscription subscription,
                       String proxyHost,
                       int proxyPort)

  Construct an AddressBook from the Subscription subscription. If the address book at subscription has not changed since the last time it was read or cannot be read, return an empty AddressBook. Set a maximum size of the remote book to make it a little harder for a malicious book-sender.

  Parameters:
    `subscription` - A Subscription instance pointing at a remote address book.
    `proxyHost` - hostname of proxy
    `proxyPort` - port number of proxy

### AddressBook

    public AddressBook(File file)

  Construct an AddressBook from the contents of the file at file. If the file cannot be read, construct an empty AddressBook

  Parameters:
    `file` - A File pointing at a file with lines in the format "key=value", where key is a human readable name, and value is a base64 i2p destination.

Method Detail

### getAddresses

    public Map getAddresses()

  Return a Map containing the addresses in the AddressBook.

  Returns:
    A Map containing the addresses in the AddressBook, where the key is a human readable name, and the value is a base64 i2p destination.

### getLocation

    public String getLocation()

  Return the location of the file this AddressBook was constructed from.

  Returns:
    A String representing either an abstract path, or a url, depending on how the instance was constructed.

### toString

    public String toString()

  Return a string representation of the contents of the AddressBook.

  Overrides:
    `toString` in class `Object`
  Returns:
    A String representing the contents of the AddressBook.

### merge

    public void merge(AddressBook other,
                      boolean overwrite,
                      Log log)

  Merge this AddressBook with AddressBook other, writing messages about new addresses or conflicts to log. Addresses in AddressBook other that are not in this AddressBook are added to this AddressBook. In case of a conflict, addresses in this AddressBook take precedence

  Parameters:
    `other` - An AddressBook to merge with.
    `overwrite` - True to overwrite
    `log` - The log to write messages about new addresses or conflicts to.

### write

    public void write(File file)

  Write the contents of this AddressBook out to the File file. If the file cannot be writen to, this method will silently fail.

  Parameters:
    `file` - The file to write the contents of this AddressBook too.

### write

    public void write()

  Write this AddressBook out to the file it was read from. Requires that AddressBook was constructed from a file on the local filesystem. If the file cannot be writen to, this method will silently fail.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD