class AddressBook extends Object implements Iterable<Map.Entry<String,HostTxtEntry>>
| Modifier and Type | Field and Description |
|---|---|
(package private) static long |
MAX_SUB_SIZE
Maximum permitted size of a hosts subscription file - 5MB or around 8000 hosts
|
| Constructor and Description |
|---|
AddressBook(File file)
Construct an AddressBook from the contents of the file at file.
|
AddressBook(Map<String,HostTxtEntry> addresses)
Construct an AddressBook from the contents of the Map addresses.
|
AddressBook(String testsubfile)
Test only.
|
AddressBook(Subscription subscription,
String proxyHost,
int proxyPort)
Construct an AddressBook from the Subscription subscription.
|
| Modifier and Type | Method and Description |
|---|---|
void |
delete()
Delete the temp file or clear the map.
|
String |
getLocation()
Return the location of the file this AddressBook was constructed from.
|
static boolean |
isValidKey(String host)
Basic validation of the hostname.
|
Iterator<Map.Entry<String,HostTxtEntry>> |
iterator()
Return an iterator over the addresses in the AddressBook.
|
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 origin 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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorstatic final long MAX_SUB_SIZE
public AddressBook(File file)
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.public AddressBook(Map<String,HostTxtEntry> addresses)
addresses - A Map containing human readable addresses as keys, mapped to base64 i2p destinations.public AddressBook(String testsubfile)
testsubfile - path to a file containing the simulated fetch of a subscriptionpublic AddressBook(Subscription subscription, String proxyHost, int proxyPort)
subscription - A Subscription instance pointing at a remote address book.proxyHost - hostname of proxyproxyPort - port number of proxypublic void delete()
public String getLocation()
public static boolean isValidKey(String host)
host - the hostname to validatepublic Iterator<Map.Entry<String,HostTxtEntry>> iterator()
iterator in interface Iterable<Map.Entry<String,HostTxtEntry>>public void merge(AddressBook other, boolean overwrite, Log log)
other - An AddressBook to merge with.overwrite - True to overwritelog - The log to write messages about new addresses or conflicts to. May be null.IllegalStateException - if this was created with the Subscription constructor.public String toString()
public void write()
IllegalStateException - if this was not created with the File constructor.public void write(File file)
file - The file to write the contents of this AddressBook too.IllegalStateException - if this was created with the Subscription constructor.