]> gitweb.fperrin.net Git - Dictionary.git/blob - src/com/hughes/android/dictionary/engine/TextEntry.java
go
[Dictionary.git] / src / com / hughes / android / dictionary / engine / TextEntry.java
1 package com.hughes.android.dictionary.engine;
2
3 import java.io.IOException;
4 import java.io.PrintStream;
5 import java.io.RandomAccessFile;
6
7 import com.hughes.util.raf.RAFSerializable;
8 import com.hughes.util.raf.RAFSerializer;
9
10 public class TextEntry extends Entry implements RAFSerializable<TextEntry> {
11   
12   final String text;
13   
14   public TextEntry(final RandomAccessFile raf) throws IOException {
15     text = raf.readUTF();
16   }
17   @Override
18   public void write(RandomAccessFile raf) throws IOException {
19     raf.writeUTF(text);
20   }
21   
22   static final RAFSerializer<TextEntry> SERIALIZER = new RAFSerializer<TextEntry>() {
23     @Override
24     public TextEntry read(RandomAccessFile raf) throws IOException {
25       return new TextEntry(raf);
26     }
27
28     @Override
29     public void write(RandomAccessFile raf, TextEntry t) throws IOException {
30       t.write(raf);
31     }
32   };
33   
34
35   public static class Row extends RowBase {
36     
37     Row(final RandomAccessFile raf, final int thisRowIndex,
38         final Index index) throws IOException {
39       super(raf, thisRowIndex, index);
40     }
41     
42     public TextEntry getEntry() {
43       return index.dict.textEntries.get(referenceIndex);
44     }
45     
46     @Override
47     public void print(PrintStream out) {
48       out.println("  " + getEntry().text);
49     }
50   }
51
52
53
54 }