altoslib: Hack up AltosEepromFile to support new eeprom code
authorKeith Packard <keithp@keithp.com>
Tue, 9 May 2017 07:20:23 +0000 (00:20 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 9 May 2017 07:20:23 +0000 (00:20 -0700)
Redirect when asked to read an eeprom file using the "Reader" type.

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosEepromFile.java

index 5544ec37935a2a102d394ad362be01f167c03433..bb8abf87fa334cfa3be713ba271a464f7804a780 100644 (file)
@@ -58,6 +58,7 @@ public class AltosEepromFile extends AltosStateIterable {
 
        AltosEepromIterable     headers;
        AltosEepromIterable     body;
+       AltosEepromRecordSet    set;
        AltosState              start;
 
        public void write_comments(PrintStream out) {
@@ -69,6 +70,11 @@ public class AltosEepromFile extends AltosStateIterable {
                body.write(out);
        }
 
+       public AltosEepromFile(Reader input) throws IOException {
+               set = new AltosEepromRecordSet(input);
+
+       }
+
        public AltosEepromFile(FileInputStream input) {
                headers = new AltosEepromIterable(AltosEepromHeader.read(input));
 
@@ -130,6 +136,9 @@ public class AltosEepromFile extends AltosStateIterable {
        }
 
        public Iterator<AltosState> iterator() {
+               if (set != null)
+                       return set.iterator();
+
                AltosState              state = start.clone();
                Iterator<AltosEeprom>   i = body.iterator();