@Test(expected = InvalidIndexException.class) public void testUnrecognizedMagicNumber() throws Exception { Buffer buffer = Buffer.allocate(Integer.SIZE); buffer.duplicate().putInt(0xDEADBEEF); try { loadIndex(buffer); } catch (InvalidIndexException e) { assertEquals("Unrecognized magic number", e.getMessage()); throw e; } }
public Index loadIndex(ReaderAtEnd reader) throws IOException, InvalidIndexException { switch (readMagic(reader)) { case IndexLoaderV1.MAGIC: return v1.loadIndex(reader); case IndexLoaderV2.MAGIC: return v2.loadIndex(reader); default: throw new InvalidIndexException("Unrecognized magic number"); } }
IndexLoader { public Index loadIndex(ReaderAtEnd reader) throws IOException, InvalidIndexException { switch (readMagic(reader)) { case IndexLoaderV1.MAGIC: return v1.loadIndex(reader); case IndexLoaderV2.MAGIC: return v2.loadIndex(reader); default: throw new InvalidIndexException("Unrecognized magic number"); } } }
IndexLoader { public Index loadIndex(ReaderAtEnd reader) throws IOException, InvalidIndexException { switch (readMagic(reader)) { case IndexLoaderV1.MAGIC: return v1.loadIndex(reader); case IndexLoaderV2.MAGIC: return v2.loadIndex(reader); default: throw new InvalidIndexException("Unrecognized magic number"); } } private  IndexLoader(int blockSize); }
IndexLoader { public Index loadIndex(ReaderAtEnd reader) throws IOException, InvalidIndexException { switch (readMagic(reader)) { case IndexLoaderV1.MAGIC: return v1.loadIndex(reader); case IndexLoaderV2.MAGIC: return v2.loadIndex(reader); default: throw new InvalidIndexException("Unrecognized magic number"); } } private  IndexLoader(int blockSize); static IndexLoader newIndexLoader(int blockSize); Index loadIndex(ReaderAtEnd reader); }
IndexLoader { public Index loadIndex(ReaderAtEnd reader) throws IOException, InvalidIndexException { switch (readMagic(reader)) { case IndexLoaderV1.MAGIC: return v1.loadIndex(reader); case IndexLoaderV2.MAGIC: return v2.loadIndex(reader); default: throw new InvalidIndexException("Unrecognized magic number"); } } private  IndexLoader(int blockSize); static IndexLoader newIndexLoader(int blockSize); Index loadIndex(ReaderAtEnd reader);  }