[tor-commits] [onionoo/master] Rename method to better reflect what it does.

karsten at torproject.org karsten at torproject.org
Thu Nov 20 16:22:17 UTC 2014


commit 058923893759a147097908c97b2d3fa5ea040753
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Thu Nov 20 15:09:20 2014 +0100

    Rename method to better reflect what it does.
    
    Suggested by iwakeh on #12651.
---
 .../org/torproject/onionoo/docs/BandwidthStatus.java     |    2 +-
 .../java/org/torproject/onionoo/docs/ClientsStatus.java  |    2 +-
 src/main/java/org/torproject/onionoo/docs/Document.java  |    2 +-
 .../java/org/torproject/onionoo/docs/DocumentStore.java  |    2 +-
 .../java/org/torproject/onionoo/docs/UptimeStatus.java   |    2 +-
 .../java/org/torproject/onionoo/docs/WeightsStatus.java  |    2 +-
 .../org/torproject/onionoo/UptimeDocumentWriterTest.java |    4 ++--
 .../org/torproject/onionoo/UptimeStatusUpdaterTest.java  |    3 ++-
 .../org/torproject/onionoo/docs/BandwidthStatusTest.java |    8 ++++----
 .../org/torproject/onionoo/docs/UptimeStatusTest.java    |   14 +++++++-------
 10 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/src/main/java/org/torproject/onionoo/docs/BandwidthStatus.java b/src/main/java/org/torproject/onionoo/docs/BandwidthStatus.java
index 4c6ea79..8678028 100644
--- a/src/main/java/org/torproject/onionoo/docs/BandwidthStatus.java
+++ b/src/main/java/org/torproject/onionoo/docs/BandwidthStatus.java
@@ -43,7 +43,7 @@ public class BandwidthStatus extends Document {
     return this.readHistory;
   }
 
-  public void fromDocumentString(String documentString) {
+  public void setFromDocumentString(String documentString) {
     Scanner s = new Scanner(documentString);
     while (s.hasNextLine()) {
       String line = s.nextLine();
diff --git a/src/main/java/org/torproject/onionoo/docs/ClientsStatus.java b/src/main/java/org/torproject/onionoo/docs/ClientsStatus.java
index a15ff56..adb80a0 100644
--- a/src/main/java/org/torproject/onionoo/docs/ClientsStatus.java
+++ b/src/main/java/org/torproject/onionoo/docs/ClientsStatus.java
@@ -32,7 +32,7 @@ public class ClientsStatus extends Document {
     return this.history;
   }
 
-  public void fromDocumentString(String documentString) {
+  public void setFromDocumentString(String documentString) {
     Scanner s = new Scanner(documentString);
     while (s.hasNextLine()) {
       String line = s.nextLine();
diff --git a/src/main/java/org/torproject/onionoo/docs/Document.java b/src/main/java/org/torproject/onionoo/docs/Document.java
index a581795..71068ff 100644
--- a/src/main/java/org/torproject/onionoo/docs/Document.java
+++ b/src/main/java/org/torproject/onionoo/docs/Document.java
@@ -12,7 +12,7 @@ public abstract class Document {
     return this.documentString;
   }
 
-  public void fromDocumentString(String documentString) {
+  public void setFromDocumentString(String documentString) {
     /* Subclasses may override this method to parse documentString. */
   }
 
diff --git a/src/main/java/org/torproject/onionoo/docs/DocumentStore.java b/src/main/java/org/torproject/onionoo/docs/DocumentStore.java
index 393904b..23ac03f 100644
--- a/src/main/java/org/torproject/onionoo/docs/DocumentStore.java
+++ b/src/main/java/org/torproject/onionoo/docs/DocumentStore.java
@@ -452,7 +452,7 @@ public class DocumentStore {
     T result = null;
     try {
       result = documentType.newInstance();
-      result.fromDocumentString(documentString);
+      result.setFromDocumentString(documentString);
     } catch (InstantiationException e) {
       /* Handle below. */
       log.error(e.getMessage(), e);
diff --git a/src/main/java/org/torproject/onionoo/docs/UptimeStatus.java b/src/main/java/org/torproject/onionoo/docs/UptimeStatus.java
index eaa28ff..e48fd09 100644
--- a/src/main/java/org/torproject/onionoo/docs/UptimeStatus.java
+++ b/src/main/java/org/torproject/onionoo/docs/UptimeStatus.java
@@ -40,7 +40,7 @@ public class UptimeStatus extends Document {
     return this.bridgeHistory;
   }
 
-  public void fromDocumentString(String documentString) {
+  public void setFromDocumentString(String documentString) {
     Scanner s = new Scanner(documentString);
     while (s.hasNextLine()) {
       String line = s.nextLine();
diff --git a/src/main/java/org/torproject/onionoo/docs/WeightsStatus.java b/src/main/java/org/torproject/onionoo/docs/WeightsStatus.java
index 0e4eff8..6d2f63f 100644
--- a/src/main/java/org/torproject/onionoo/docs/WeightsStatus.java
+++ b/src/main/java/org/torproject/onionoo/docs/WeightsStatus.java
@@ -36,7 +36,7 @@ public class WeightsStatus extends Document {
     return this.history;
   }
 
-  public void fromDocumentString(String documentString) {
+  public void setFromDocumentString(String documentString) {
     Scanner s = new Scanner(documentString);
     while (s.hasNextLine()) {
       String line = s.nextLine();
diff --git a/src/test/java/org/torproject/onionoo/UptimeDocumentWriterTest.java b/src/test/java/org/torproject/onionoo/UptimeDocumentWriterTest.java
index bb87721..9b19e79 100644
--- a/src/test/java/org/torproject/onionoo/UptimeDocumentWriterTest.java
+++ b/src/test/java/org/torproject/onionoo/UptimeDocumentWriterTest.java
@@ -66,10 +66,10 @@ public class UptimeDocumentWriterTest {
   private void addStatusOneWeekSample(String allRelaysUptime,
       String gabelmooUptime) {
     UptimeStatus status = new UptimeStatus();
-    status.fromDocumentString(allRelaysUptime);
+    status.setFromDocumentString(allRelaysUptime);
     this.documentStore.addDocument(status, ALL_RELAYS_FINGERPRINT);
     status = new UptimeStatus();
-    status.fromDocumentString(gabelmooUptime);
+    status.setFromDocumentString(gabelmooUptime);
     this.documentStore.addDocument(status, GABELMOO_FINGERPRINT);
     this.descriptorSource.addFingerprint(DescriptorType.RELAY_CONSENSUSES,
         GABELMOO_FINGERPRINT);
diff --git a/src/test/java/org/torproject/onionoo/UptimeStatusUpdaterTest.java b/src/test/java/org/torproject/onionoo/UptimeStatusUpdaterTest.java
index d1cd709..b418879 100644
--- a/src/test/java/org/torproject/onionoo/UptimeStatusUpdaterTest.java
+++ b/src/test/java/org/torproject/onionoo/UptimeStatusUpdaterTest.java
@@ -90,7 +90,8 @@ public class UptimeStatusUpdaterTest {
 
   private void addAllRelaysAndBridgesUptimeSample() {
     UptimeStatus uptimeStatus = new UptimeStatus();
-    uptimeStatus.fromDocumentString(ALL_RELAYS_AND_BRIDGES_UPTIME_SAMPLE);
+    uptimeStatus.setFromDocumentString(
+        ALL_RELAYS_AND_BRIDGES_UPTIME_SAMPLE);
     this.documentStore.addDocument(uptimeStatus,
         ALL_RELAYS_AND_BRIDGES_FINGERPRINT);
   }
diff --git a/src/test/java/org/torproject/onionoo/docs/BandwidthStatusTest.java b/src/test/java/org/torproject/onionoo/docs/BandwidthStatusTest.java
index 91d086d..b943d34 100644
--- a/src/test/java/org/torproject/onionoo/docs/BandwidthStatusTest.java
+++ b/src/test/java/org/torproject/onionoo/docs/BandwidthStatusTest.java
@@ -99,7 +99,7 @@ public class BandwidthStatusTest {
     String existingLines =
         "w 2014-07-31 23:52:22 2014-08-01 00:07:22 4096\n"
         + "w 2014-08-01 00:07:22 2014-08-01 00:22:22 30720\n";
-    bandwidthStatus.fromDocumentString(existingLines);
+    bandwidthStatus.setFromDocumentString(existingLines);
     bandwidthStatus.addToWriteHistory(new DummyBandwidthHistory(
         "write-history 2014-08-01 00:37:22 (900 s) 0"));
     assertEquals("New interval should be appended.",
@@ -113,7 +113,7 @@ public class BandwidthStatusTest {
     String existingLines =
         "w 2014-08-01 00:07:22 2014-08-01 00:22:22 30720\n"
         + "w 2014-08-01 00:22:22 2014-08-01 00:37:22 4096\n";
-    bandwidthStatus.fromDocumentString(existingLines);
+    bandwidthStatus.setFromDocumentString(existingLines);
     bandwidthStatus.compressHistory();
     assertEquals("Two recent intervals should not be compressed.",
         existingLines, bandwidthStatus.toDocumentString());
@@ -122,7 +122,7 @@ public class BandwidthStatusTest {
   @Test()
   public void testCompressOldIntervals() {
     BandwidthStatus bandwidthStatus = new BandwidthStatus();
-    bandwidthStatus.fromDocumentString(
+    bandwidthStatus.setFromDocumentString(
         "w 2013-08-01 00:07:22 2013-08-01 00:22:22 30720\n"
         + "w 2013-08-01 00:22:22 2013-08-01 00:37:22 4096\n");
     bandwidthStatus.compressHistory();
@@ -137,7 +137,7 @@ public class BandwidthStatusTest {
     String statusLines =
         "w 2013-07-31 23:52:22 2013-08-01 00:07:22 4096\n"
         + "w 2013-08-01 00:07:22 2013-08-01 00:22:22 30720\n";
-    bandwidthStatus.fromDocumentString(statusLines);
+    bandwidthStatus.setFromDocumentString(statusLines);
     bandwidthStatus.compressHistory();
     assertEquals("Two old intervals should not be merged over month end.",
         statusLines, bandwidthStatus.toDocumentString());
diff --git a/src/test/java/org/torproject/onionoo/docs/UptimeStatusTest.java b/src/test/java/org/torproject/onionoo/docs/UptimeStatusTest.java
index 043ea80..b4bcdc8 100644
--- a/src/test/java/org/torproject/onionoo/docs/UptimeStatusTest.java
+++ b/src/test/java/org/torproject/onionoo/docs/UptimeStatusTest.java
@@ -72,7 +72,7 @@ public class UptimeStatusTest {
   @Test()
   public void testGabelmooFillInGaps() {
     UptimeStatus uptimeStatus = new UptimeStatus();
-    uptimeStatus.fromDocumentString(RELAY_UPTIME_SAMPLE);
+    uptimeStatus.setFromDocumentString(RELAY_UPTIME_SAMPLE);
     uptimeStatus.addToHistory(true, new TreeSet<Long>(Arrays.asList(
         new Long[] { DateTimeHelper.parse("2013-09-09 02:00:00"),
         DateTimeHelper.parse("2013-12-20 00:00:00") })));
@@ -95,7 +95,7 @@ public class UptimeStatusTest {
   @Test()
   public void testAddExistingHourToIntervalStart() {
     UptimeStatus uptimeStatus = new UptimeStatus();
-    uptimeStatus.fromDocumentString(RELAY_UPTIME_SAMPLE);
+    uptimeStatus.setFromDocumentString(RELAY_UPTIME_SAMPLE);
     uptimeStatus.addToHistory(true, new TreeSet<Long>(Arrays.asList(
         new Long[] { DateTimeHelper.parse("2013-07-22 17:00:00") })));
     uptimeStatus.compressHistory();
@@ -106,7 +106,7 @@ public class UptimeStatusTest {
   @Test()
   public void testAddExistingHourToIntervalEnd() {
     UptimeStatus uptimeStatus = new UptimeStatus();
-    uptimeStatus.fromDocumentString(RELAY_UPTIME_SAMPLE);
+    uptimeStatus.setFromDocumentString(RELAY_UPTIME_SAMPLE);
     uptimeStatus.addToHistory(true, new TreeSet<Long>(Arrays.asList(
         new Long[] { DateTimeHelper.parse("2013-09-09 01:00:00") })));
     uptimeStatus.compressHistory();
@@ -117,7 +117,7 @@ public class UptimeStatusTest {
   @Test()
   public void testTwoHoursOverlappingWithIntervalStart() {
     UptimeStatus uptimeStatus = new UptimeStatus();
-    uptimeStatus.fromDocumentString(RELAY_UPTIME_SAMPLE);
+    uptimeStatus.setFromDocumentString(RELAY_UPTIME_SAMPLE);
     uptimeStatus.addToHistory(true, new TreeSet<Long>(Arrays.asList(
         new Long[] { DateTimeHelper.parse("2013-07-22 16:00:00"),
         DateTimeHelper.parse("2013-07-22 17:00:00")})));
@@ -138,7 +138,7 @@ public class UptimeStatusTest {
   @Test()
   public void testTwoHoursOverlappingWithIntervalEnd() {
     UptimeStatus uptimeStatus = new UptimeStatus();
-    uptimeStatus.fromDocumentString(RELAY_UPTIME_SAMPLE);
+    uptimeStatus.setFromDocumentString(RELAY_UPTIME_SAMPLE);
     uptimeStatus.addToHistory(true, new TreeSet<Long>(Arrays.asList(
         new Long[] { DateTimeHelper.parse("2013-09-09 01:00:00"),
         DateTimeHelper.parse("2013-09-09 02:00:00")})));
@@ -163,7 +163,7 @@ public class UptimeStatusTest {
   @Test()
   public void testAddRelayUptimeHours() {
     UptimeStatus uptimeStatus = new UptimeStatus();
-    uptimeStatus.fromDocumentString(RELAYS_AND_BRIDGES_UPTIME_SAMPLE);
+    uptimeStatus.setFromDocumentString(RELAYS_AND_BRIDGES_UPTIME_SAMPLE);
     uptimeStatus.addToHistory(true, new TreeSet<Long>(Arrays.asList(
         new Long[] { DateTimeHelper.parse("2013-07-22 16:00:00"),
         DateTimeHelper.parse("2014-03-21 20:00:00")})));
@@ -184,7 +184,7 @@ public class UptimeStatusTest {
   @Test()
   public void testAddBridgeUptimeHours() {
     UptimeStatus uptimeStatus = new UptimeStatus();
-    uptimeStatus.fromDocumentString(RELAYS_AND_BRIDGES_UPTIME_SAMPLE);
+    uptimeStatus.setFromDocumentString(RELAYS_AND_BRIDGES_UPTIME_SAMPLE);
     uptimeStatus.addToHistory(false, new TreeSet<Long>(Arrays.asList(
         new Long[] { DateTimeHelper.parse("2013-07-22 16:00:00"),
         DateTimeHelper.parse("2014-03-21 20:00:00")})));



More information about the tor-commits mailing list