]> gitweb.fperrin.net Git - Dictionary.git/blobdiff - src/com/hughes/android/dictionary/engine/TextEntry.java
Faster multi search, exact search, moved Normalization around.
[Dictionary.git] / src / com / hughes / android / dictionary / engine / TextEntry.java
index 87d29d7c0c8bbac45854eadee749e88e68c8f87f..8d878dd87a35a5dd00c8d9623fbbaf76a00c6eee 100644 (file)
@@ -1,28 +1,55 @@
+// Copyright 2011 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 package com.hughes.android.dictionary.engine;
 
 import java.io.IOException;
 import java.io.PrintStream;
 import java.io.RandomAccessFile;
+import java.util.List;
+import java.util.regex.Pattern;
 
 import com.hughes.util.raf.RAFSerializable;
 import com.hughes.util.raf.RAFSerializer;
+import com.ibm.icu.text.Transliterator;
 
-public class TextEntry extends Entry implements RAFSerializable<TextEntry> {
+public class TextEntry extends AbstractEntry implements RAFSerializable<TextEntry> {
   
   final String text;
   
-  public TextEntry(final RandomAccessFile raf) throws IOException {
+  public TextEntry(final Dictionary dictionary, final RandomAccessFile raf) throws IOException {
+    super(dictionary, raf);
     text = raf.readUTF();
+    throw new RuntimeException();
   }
   @Override
   public void write(RandomAccessFile raf) throws IOException {
+    super.write(raf);
     raf.writeUTF(text);
   }
   
-  static final RAFSerializer<TextEntry> SERIALIZER = new RAFSerializer<TextEntry>() {
+  static final class Serializer implements RAFSerializer<TextEntry> {
+    
+    final Dictionary dictionary;
+    
+    Serializer(Dictionary dictionary) {
+      this.dictionary = dictionary;
+    }
+
     @Override
     public TextEntry read(RandomAccessFile raf) throws IOException {
-      return new TextEntry(raf);
+      return new TextEntry(dictionary, raf);
     }
 
     @Override
@@ -30,7 +57,13 @@ public class TextEntry extends Entry implements RAFSerializable<TextEntry> {
       t.write(raf);
     }
   };
+
   
+  @Override
+  public int addToDictionary(final Dictionary dictionary) {
+    dictionary.textEntries.add(this);
+    return dictionary.textEntries.size() - 1;
+  }
 
   public static class Row extends RowBase {
     
@@ -44,14 +77,18 @@ public class TextEntry extends Entry implements RAFSerializable<TextEntry> {
     }
     
     @Override
-    public Object draw(String searchText) {
-      // TODO Auto-generated method stub
-      return null;
+    public void print(PrintStream out) {
+      out.println("  " + getEntry().text);
     }
 
     @Override
-    public void print(PrintStream out) {
-      out.println("  " + getEntry().text);
+    public String getRawText(boolean compact) {
+      return getEntry().text;
+    }
+    
+    @Override
+    public RowMatchType matches(final List<String> searchTokens, final Pattern orderedMatchPattern, Transliterator normalizer, boolean swapPairEntries) {
+      return null;
     }
   }