]> gitweb.fperrin.net Git - Dictionary.git/blobdiff - src/com/hughes/android/dictionary/engine/RowBase.java
go
[Dictionary.git] / src / com / hughes / android / dictionary / engine / RowBase.java
index d62edf16a49ac550df3a7866c52962e124f19ee0..7ac86d0bc9e502dd59ba840891a2822937ea5d80 100644 (file)
@@ -11,17 +11,17 @@ public abstract class RowBase extends IndexedObject {
   /**
    * the Index owning this RowBase.
    */
-  final Index index;
+  public final Index index;
   
   /**
    * Where this RowBase points to.
    */
-  int referenceIndex;
+  public final int referenceIndex;
 
   /**
    * the TokenRow above this RowBase, populated on demand.
    */
-  TokenRow tokenRow = null;
+  private TokenRow tokenRow = null;
   
   RowBase(final RandomAccessFile raf, final int thisRowIndex, final Index index) throws IOException {
     super(thisRowIndex);
@@ -41,6 +41,7 @@ public abstract class RowBase extends IndexedObject {
   public TokenRow getTokenRow(final boolean search) {
     if (tokenRow == null && search) {
       int r = index() - 1;
+      int rUp = index() + 1;
       while (r >= 0) {
         final RowBase row = index.rows.get(r);
         final TokenRow candidate = row.getTokenRow(false);
@@ -50,6 +51,17 @@ public abstract class RowBase extends IndexedObject {
           }
           break;
         }
+        if (rUp < index.rows.size()) {
+          final RowBase rowUp = index.rows.get(rUp);
+          final TokenRow candidateUp = rowUp.getTokenRow(false);
+          if (candidateUp != null) {
+            for (--rUp; rUp >= index(); --rUp) {
+              index.rows.get(rUp).setTokenRow(candidateUp);
+            }
+            break;
+          }
+          rUp++;
+        }
         --r;
       }
       assert tokenRow != null;
@@ -63,11 +75,9 @@ public abstract class RowBase extends IndexedObject {
     this.tokenRow = tokenRow;
   }
 
-
   public abstract void print(PrintStream out);
-  
-  public abstract Object draw(final String searchText);
 
+  public abstract String getRawText(final boolean compact);
 
   // RowBase must manage "disk-based" polymorphism.  All other polymorphism is
   // dealt with in the normal manner.
@@ -101,5 +111,4 @@ public abstract class RowBase extends IndexedObject {
     }
   }
 
-
 }