// Path: usbtools/src/main/java/io/trygvis/usb/tools/IntelHex.java
// public static enum RecordType {
//     DATA(0),
//     END_OF_FILE(1);
//     //EXTENDED_SEGMENT_ADDRESS_RECORD,
//     //START_SEGMENT_ADDRESS_RECORD,
//     //EXTENDED_LINEAR_ADDRESS_RECORD,
//     //START_LINEAR_ADDRESS_RECORD;
// 
//     byte id;
// 
//     RecordType(int id) {
//         this.id = (byte)id;
//     }
// 
//     public static RecordType lookup(int i) throws IOException {
//         for (RecordType recordType : values()) {
//             if (recordType.id == i) {
//                 return recordType;
//             }
//         }
// 
//         throw new IOException("Unknown record type: " + i + ".");
//     }
// }


import static java.lang.Integer.*;
import static io.trygvis.usb.tools.IntelHex.RecordType.*;
import javax.usb.util.*;
import java.io.*;
import java.util.*;
package io.trygvis.usb.tools;



public class IntelHex {
    public static List<IntelHexPacket> openIntelHexFile(final File file) throws IOException {
        return openIntelHexFile(new FileInputStream(file));
    }

    public static List<IntelHexPacket> openIntelHexFile(final InputStream is) throws IOException {
        final BufferedReader reader = new BufferedReader(new InputStreamReader(is, "ascii"));
        String line = reader.readLine();

        if (line == null) {
            throw new IOException("The Intel hex file must contain at least one line");
        }

        IntelHexPacket packet = parseLine(0, line);

        List<IntelHexPacket> list = new ArrayList<IntelHexPacket>();

        while (true) {
            list.add(packet);

            line = reader.readLine();
            if (line == null) {
                break;
            }

            packet = parseLine(packet.lineNo, line);
        }

        return list;
    }

// Path: usbtools/src/main/java/io/trygvis/usb/tools/IntelHex.java
// public static enum RecordType {
//     DATA(0),
//     END_OF_FILE(1);
//     //EXTENDED_SEGMENT_ADDRESS_RECORD,
//     //START_SEGMENT_ADDRESS_RECORD,
//     //EXTENDED_LINEAR_ADDRESS_RECORD,
//     //START_LINEAR_ADDRESS_RECORD;
// 
//     byte id;
// 
//     RecordType(int id) {
//         this.id = (byte)id;
//     }
// 
//     public static RecordType lookup(int i) throws IOException {
//         for (RecordType recordType : values()) {
//             if (recordType.id == i) {
//                 return recordType;
//             }
//         }
// 
//         throw new IOException("Unknown record type: " + i + ".");
//     }
// }


// Path: usbtools/src/main/java/io/trygvis/usb/tools/IntelHex.java
import static java.lang.Integer.*;
import static io.trygvis.usb.tools.IntelHex.RecordType.*;
import javax.usb.util.*;
import java.io.*;
import java.util.*;

package io.trygvis.usb.tools;



public class IntelHex {
    public static List<IntelHexPacket> openIntelHexFile(final File file) throws IOException {
        return openIntelHexFile(new FileInputStream(file));
    }

    public static List<IntelHexPacket> openIntelHexFile(final InputStream is) throws IOException {
        final BufferedReader reader = new BufferedReader(new InputStreamReader(is, "ascii"));
        String line = reader.readLine();

        if (line == null) {
            throw new IOException("The Intel hex file must contain at least one line");
        }

        IntelHexPacket packet = parseLine(0, line);

        List<IntelHexPacket> list = new ArrayList<IntelHexPacket>();

        while (true) {
            list.add(packet);

            line = reader.readLine();
            if (line == null) {
                break;
            }

            packet = parseLine(packet.lineNo, line);
        }

        return list;
    }

    public static enum RecordType {