Addressbook: Rename ConfigIterator to HostTxtIterator

This commit is contained in:
zzz
2016-04-18 13:17:57 +00:00
parent 2d3d6f73b5
commit 909622fbd7
2 changed files with 11 additions and 11 deletions

View File

@@ -184,9 +184,9 @@ class AddressBook implements Iterable<Map.Entry<String, HostTxtEntry>> {
public Iterator<Map.Entry<String, HostTxtEntry>> iterator() {
if (this.subFile != null) {
try {
return new ConfigIterator(this.subFile);
return new HostTxtIterator(this.subFile);
} catch (IOException ioe) {
return new ConfigIterator();
return new HostTxtIterator();
}
}
return this.addresses.entrySet().iterator();

View File

@@ -42,25 +42,25 @@ import net.i2p.data.DataHelper;
* Callers should iterate all the way through or call close()
* to ensure the underlying stream is closed.
*
* Warning - misnamed - this is not used for config files.
* This is not used for config files.
* It is only used for subscriptions.
*
* @since 0.8.7
* @since 0.8.7, renamed from ConfigIterator in 0.9.26
*/
class ConfigIterator implements Iterator<Map.Entry<String, HostTxtEntry>>, Closeable {
class HostTxtIterator implements Iterator<Map.Entry<String, HostTxtEntry>>, Closeable {
private BufferedReader input;
private ConfigEntry next;
private MapEntry next;
/**
* A dummy iterator in which hasNext() is always false.
*/
public ConfigIterator() {}
public HostTxtIterator() {}
/**
* An iterator over the key/value pairs in the file.
*/
public ConfigIterator(File file) throws IOException {
public HostTxtIterator(File file) throws IOException {
FileInputStream fileStream = new FileInputStream(file);
input = new BufferedReader(new InputStreamReader(fileStream, "UTF-8"));
}
@@ -76,7 +76,7 @@ class ConfigIterator implements Iterator<Map.Entry<String, HostTxtEntry>>, Close
HostTxtEntry he = HostTxtParser.parse(inputLine);
if (he == null)
continue;
next = new ConfigEntry(he.getName(), he);
next = new MapEntry(he.getName(), he);
return true;
}
} catch (IOException ioe) {}
@@ -112,11 +112,11 @@ class ConfigIterator implements Iterator<Map.Entry<String, HostTxtEntry>>, Close
/**
* The object returned by the iterator.
*/
private static class ConfigEntry implements Map.Entry<String, HostTxtEntry> {
private static class MapEntry implements Map.Entry<String, HostTxtEntry> {
private final String key;
private final HostTxtEntry value;
public ConfigEntry(String k, HostTxtEntry v) {
public MapEntry(String k, HostTxtEntry v) {
key = k;
value = v;
}