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() { public Iterator<Map.Entry<String, HostTxtEntry>> iterator() {
if (this.subFile != null) { if (this.subFile != null) {
try { try {
return new ConfigIterator(this.subFile); return new HostTxtIterator(this.subFile);
} catch (IOException ioe) { } catch (IOException ioe) {
return new ConfigIterator(); return new HostTxtIterator();
} }
} }
return this.addresses.entrySet().iterator(); 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() * Callers should iterate all the way through or call close()
* to ensure the underlying stream is closed. * 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. * 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 BufferedReader input;
private ConfigEntry next; private MapEntry next;
/** /**
* A dummy iterator in which hasNext() is always false. * A dummy iterator in which hasNext() is always false.
*/ */
public ConfigIterator() {} public HostTxtIterator() {}
/** /**
* An iterator over the key/value pairs in the file. * 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); FileInputStream fileStream = new FileInputStream(file);
input = new BufferedReader(new InputStreamReader(fileStream, "UTF-8")); 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); HostTxtEntry he = HostTxtParser.parse(inputLine);
if (he == null) if (he == null)
continue; continue;
next = new ConfigEntry(he.getName(), he); next = new MapEntry(he.getName(), he);
return true; return true;
} }
} catch (IOException ioe) {} } catch (IOException ioe) {}
@@ -112,11 +112,11 @@ class ConfigIterator implements Iterator<Map.Entry<String, HostTxtEntry>>, Close
/** /**
* The object returned by the iterator. * 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 String key;
private final HostTxtEntry value; private final HostTxtEntry value;
public ConfigEntry(String k, HostTxtEntry v) { public MapEntry(String k, HostTxtEntry v) {
key = k; key = k;
value = v; value = v;
} }