public SingleCfnSpecification loadSingleResourceSpecification()

in src/main/java/aws/cfn/codegen/SpecificationLoader.java [73:97]


    public SingleCfnSpecification loadSingleResourceSpecification(URL location) throws IOException {
        try (PushbackInputStream stream = new PushbackInputStream(location.openStream(), 8)) {
            byte[] magic = new byte[4];
            int nread = stream.read(magic);
            if (nread < 4) {
                throw new IOException("Can not read stream");
            }
            int magicNum =  0x01 << (int)magic[3] | 0x01 << (int)magic[2] |
                            0x01 << (int)magic[2] | 0x01 << (int)magic[2];
            Reader reader;
            if (GZIPInputStream.GZIP_MAGIC == magicNum) {
                stream.unread(magic);
                reader = new InputStreamReader(new GZIPInputStream(stream), StandardCharsets.UTF_8);
            }
            else if (magicNum == 0x0403) {
                stream.unread(magic);
                reader = new InputStreamReader(new ZipInputStream(stream), StandardCharsets.UTF_8);
            }
            else {
                stream.unread(magic);
                reader = new InputStreamReader(stream, StandardCharsets.UTF_8);
            }
            return mapperForJSON.readValue(reader, SingleCfnSpecification.class);
        }
    }