]> gitweb.fperrin.net Git - Dictionary.git/commitdiff
go
authorThad Hughes <thad.hughes@gmail.com>
Sat, 24 Jul 2010 01:10:52 +0000 (18:10 -0700)
committerThad Hughes <thad.hughes@gmail.com>
Sat, 24 Jul 2010 01:10:52 +0000 (18:10 -0700)
src/com/hughes/android/dictionary/engine/Dictionary.java
src/com/hughes/android/dictionary/engine/Index.java [new file with mode: 0644]
src/com/hughes/android/dictionary/engine/PairEntry.java
src/com/hughes/android/dictionary/engine/Row.java
src/com/hughes/android/dictionary/engine/RowWithIndex.java
src/com/hughes/android/dictionary/engine/TokenRow.java

index 8f1db2d40f38db67f400e0a474d03010bccd3dea..861ba4373b511a691f7944f9368240b5d3f815e7 100644 (file)
@@ -1,44 +1,17 @@
 package com.hughes.android.dictionary.engine;
 
-import java.io.IOException;
-import java.io.RandomAccessFile;
 import java.util.List;
 
-import com.hughes.util.raf.RAFSerializable;
 
 public class Dictionary {
   
   // persisted
-  List<PairEntry> pairEntries;
+  final List<PairEntry> pairEntries;
   
   // persisted
-  List<EntrySource> sources;
-
-  // --------------------------------------------------------------------------
+  final List<EntrySource> sources;
   
-  final class Index {
-    // One big list!
-    // Various sub-types.
-    // persisted
-    List<Row> rows;
-    
-    // persisted
-    List<IndexEntry> sortedIndexEntries;
-    
-    Dictionary getDict() {
-      return Dictionary.this;
-    }
-  }
-
-  static final class IndexEntry implements RAFSerializable<IndexEntry> {
-    String token;
-    int startRow;
-    
-    public void write(RandomAccessFile raf) throws IOException {
-      raf.writeUTF(token);
-      raf.write(startRow);
-    }
-  }
+  final List<Index> indices;
 
   
 }
\ No newline at end of file
diff --git a/src/com/hughes/android/dictionary/engine/Index.java b/src/com/hughes/android/dictionary/engine/Index.java
new file mode 100644 (file)
index 0000000..62c3324
--- /dev/null
@@ -0,0 +1,34 @@
+/**
+ * 
+ */
+package com.hughes.android.dictionary.engine;
+
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.util.List;
+
+import com.hughes.android.dictionary.engine.Dictionary.Index.IndexEntry;
+import com.hughes.util.raf.RAFSerializable;
+
+final class Index {
+  final Dictionary dict; 
+  final String name;
+  
+  // One big list!
+  // Various sub-types.
+  // persisted
+  final List<Row> rows;
+  
+  // persisted
+  final List<Index.IndexEntry> sortedIndexEntries;
+
+  static final class IndexEntry implements RAFSerializable<Index.IndexEntry> {
+    String token;
+    int startRow;
+    
+    public void write(RandomAccessFile raf) throws IOException {
+      raf.writeUTF(token);
+      raf.write(startRow);
+    }
+  }
+}
\ No newline at end of file
index 40282a039ed2fea566047bc3a99c0f6d9b926e32..efdfa002c800861ab0ed5988b2ef692edfb8d1d2 100644 (file)
@@ -18,11 +18,12 @@ public class PairEntry extends Entry {
 
   
   public static class Row extends RowWithIndex {
-    Row(final RandomAccessFile raf, final int thisRowIndex, final Dictionary.Index index) throws IOException {
+    Row(final RandomAccessFile raf, final int thisRowIndex,
+        final Index index) throws IOException {
       super(raf, thisRowIndex, index);
     }
     public PairEntry getEntry() {
-      return index.getDict().pairEntries.get(referenceIndex);
+      return index.dict.pairEntries.get(referenceIndex);
     }
   }
 
index 7c2c9275e235c11e601da2d713eb2f1e850271a7..0f52c30332838b8b6c1de48b7f3d569fd7637af2 100644 (file)
@@ -21,9 +21,9 @@ public interface Row {
   // dealt with in the normal manner.
   static class Serializer implements RAFListSerializer<Row> {
     
-    final Dictionary.Index index;
+    final Index index;
     
-    Serializer(final Dictionary.Index index) {
+    Serializer(final Index index) {
       this.index = index;
     }
 
index 00d7db805de4795dfe58b63b54a593ba4d772109..b947ff8eebbda89737f585dc568b42ccb67177a7 100644 (file)
@@ -4,16 +4,16 @@ import java.io.IOException;
 import java.io.RandomAccessFile;
 
 public abstract class RowWithIndex implements Row {
-  final Dictionary.Index index;
+  final Index index;
   int thisRowIndex;
   int referenceIndex;
 
   TokenRow tokenRow = null;
   
-  RowWithIndex(final RandomAccessFile raf, final int thisRowIndex, final Dictionary.Index index) throws IOException {
+  RowWithIndex(final RandomAccessFile raf, final int thisRowIndex, final Index index) throws IOException {
     this.index = index;
-    this.thisRowIndex = thisRowIndex;
-    this.referenceIndex = raf.readInt();
+    this.thisRowIndex = thisRowIndex;  // where this was inside the list.
+    this.referenceIndex = raf.readInt();  // what this points to.
   }
 
   @Override
index 61a35d26d8d3b0269357008e4ebffd926b797743..3335d285aecb010082a5fd1ffe72ffa4860a027c 100644 (file)
@@ -5,7 +5,7 @@ import java.io.RandomAccessFile;
 
 public class TokenRow extends RowWithIndex {
   
-  TokenRow(final RandomAccessFile raf, final int thisRowIndex, final Dictionary.Index index) throws IOException {
+  TokenRow(final RandomAccessFile raf, final int thisRowIndex, final Index index) throws IOException {
     super(raf, thisRowIndex, index);
   }