]> gitweb.fperrin.net Git - Dictionary.git/blob - src/com/hughes/android/dictionary/engine/TokenRow.java
Clean up order of imports.
[Dictionary.git] / src / com / hughes / android / dictionary / engine / TokenRow.java
1 // Copyright 2011 Google Inc. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package com.hughes.android.dictionary.engine;
16
17 import java.io.DataInput;
18 import java.io.IOException;
19 import java.io.PrintStream;
20 import java.util.List;
21 import java.util.regex.Pattern;
22
23 import com.hughes.android.dictionary.engine.Index.IndexEntry;
24 import com.ibm.icu.text.Transliterator;
25
26 public class TokenRow extends RowBase {
27
28     public final boolean hasMainEntry;
29
30     TokenRow(final DataInput raf, final int thisRowIndex, final Index index,
31              final boolean hasMainEntry, int extra) throws IOException {
32         super(raf, thisRowIndex, index, extra);
33         this.hasMainEntry = hasMainEntry;
34     }
35
36     TokenRow(final int referenceIndex, final int thisRowIndex, final Index index,
37              final boolean hasMainEntry) {
38         super(referenceIndex, thisRowIndex, index);
39         this.hasMainEntry = hasMainEntry;
40     }
41
42     public String toString() {
43         return getToken() + "@" + referenceIndex;
44     }
45
46     @Override
47     public TokenRow getTokenRow(final boolean search) {
48         return this;
49     }
50
51     @Override
52     public void setTokenRow(TokenRow tokenRow) {
53         throw new RuntimeException("Shouldn't be setting TokenRow's TokenRow!");
54     }
55
56     public String getToken() {
57         return getIndexEntry().token;
58     }
59
60     public IndexEntry getIndexEntry() {
61         return index.sortedIndexEntries.get(referenceIndex);
62     }
63
64     @Override
65     public void print(final PrintStream out) {
66         final String surrounder = hasMainEntry ? "***" : "===";
67         out.println(surrounder + getToken() + surrounder);
68         for (final HtmlEntry htmlEntry : index.sortedIndexEntries.get(referenceIndex).htmlEntries) {
69             out.println("HtmlEntry: " + htmlEntry.title + " <<<" + htmlEntry.getHtml() + ">>>");
70         }
71     }
72
73     @Override
74     public String getRawText(boolean compact) {
75         return getToken();
76     }
77
78     @Override
79     public RowMatchType matches(List<String> searchTokens, final Pattern orderedMatchPattern,
80                                 Transliterator normalizer, boolean swapPairEntries) {
81         return RowMatchType.NO_MATCH;
82     }
83
84 }