package com.hughes.android.dictionary.engine; import java.io.IOException; import java.io.RandomAccessFile; import java.util.ArrayList; import java.util.List; import com.hughes.util.raf.RAFList; import com.hughes.util.raf.RAFSerializer; public class Dictionary { // persisted final List pairEntries; // persisted final List sources; // persisted final List indices; public Dictionary() { pairEntries = new ArrayList(); sources = new ArrayList(); indices = new ArrayList(); } public Dictionary(final RandomAccessFile raf) throws IOException { pairEntries = RAFList.create(raf, PairEntry.SERIALIZER, raf.getFilePointer()); sources = new ArrayList(); final RAFSerializer indexSerializer = new RAFSerializer() { @Override public Index read(RandomAccessFile raf) throws IOException { return new Index(Dictionary.this, raf); } @Override public void write(RandomAccessFile raf, Index t) throws IOException { t.write(raf); }}; indices = RAFList.create(raf, indexSerializer, raf.getFilePointer()); } }