// Path: src/com/hughes/android/dictionary/engine/Index.java
// public static final class IndexEntry {
//     public final String token;
//     private final String normalizedToken;
//     public final int startRow;
//     final int numRows; // doesn't count the token row!
//     public List<HtmlEntry> htmlEntries;
// 
//     public IndexEntry(final Index index, final String token, final String normalizedToken,
//                       final int startRow, final int numRows, final List<HtmlEntry> htmlEntries) {
//         assert token.equals(token.trim());
//         assert !token.isEmpty();
//         this.token = token;
//         this.normalizedToken = normalizedToken;
//         this.startRow = startRow;
//         this.numRows = numRows;
//         this.htmlEntries = htmlEntries;
//     }
// 
//     IndexEntry(final Index index, final DataInput raf) throws IOException {
//         token = raf.readUTF();
//         if (index.dict.dictFileVersion >= 7) {
//             startRow = StringUtil.readVarInt(raf);
//             numRows = StringUtil.readVarInt(raf);
//         } else {
//             startRow = raf.readInt();
//             numRows = raf.readInt();
//         }
//         final boolean hasNormalizedForm = raf.readBoolean();
//         normalizedToken = hasNormalizedForm ? raf.readUTF() : token;
//         if (index.dict.dictFileVersion >= 7) {
//             int size = StringUtil.readVarInt(raf);
//             if (size == 0) {
//                 this.htmlEntries = Collections.emptyList();
//             } else {
//                 final int[] htmlEntryIndices = new int[size];
//                 for (int i = 0; i < size; ++i) {
//                     htmlEntryIndices[i] = StringUtil.readVarInt(raf);
//                 }
//                 this.htmlEntries = new AbstractList<HtmlEntry>() {
//                     @Override
//                     public HtmlEntry get(int i) {
//                         return index.dict.htmlEntries.get(htmlEntryIndices[i]);
//                     }
// 
//                     @Override
//                     public int size() {
//                         return htmlEntryIndices.length;
//                     }
//                 };
//             }
//         } else if (index.dict.dictFileVersion >= 6) {
//             this.htmlEntries = CachingList.create(
//                                    RAFList.create((DataInputBuffer)raf, index.dict.htmlEntryIndexSerializer,
//                                                   index.dict.dictFileVersion,
//                                                   index.dict.dictInfo + " htmlEntries: "), 1, false);
//         } else {
//             this.htmlEntries = Collections.emptyList();
//         }
//     }
// 
//     public void write(DataOutput raf) throws IOException {
//         raf.writeUTF(token);
//         StringUtil.writeVarInt(raf, startRow);
//         StringUtil.writeVarInt(raf, numRows);
//         final boolean hasNormalizedForm = !token.equals(normalizedToken);
//         raf.writeBoolean(hasNormalizedForm);
//         if (hasNormalizedForm) {
//             raf.writeUTF(normalizedToken);
//         }
//         StringUtil.writeVarInt(raf, htmlEntries.size());
//         for (HtmlEntry e : htmlEntries)
//             StringUtil.writeVarInt(raf, e.index());
//     }
// 
//     public String toString() {
//         return String.format("%s@%d(%d)", token, startRow, numRows);
//     }
// 
//     String normalizedToken() {
//         return normalizedToken;
//     }
// }


import java.io.DataInput;
import java.io.IOException;
import java.io.PrintStream;
import java.util.List;
import java.util.regex.Pattern;
import com.hughes.android.dictionary.engine.Index.IndexEntry;
import com.ibm.icu.text.Transliterator;
// 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;



public class TokenRow extends RowBase {

    public final boolean hasMainEntry;

    TokenRow(final DataInput raf, final int thisRowIndex, final Index index,
             final boolean hasMainEntry, int extra) throws IOException {
        super(raf, thisRowIndex, index, extra);
        this.hasMainEntry = hasMainEntry;
    }

    TokenRow(final int referenceIndex, final int thisRowIndex, final Index index,
             final boolean hasMainEntry) {
        super(referenceIndex, thisRowIndex, index);
        this.hasMainEntry = hasMainEntry;
    }

    public String toString() {
        return getToken() + "@" + referenceIndex;
    }

    @Override
    public TokenRow getTokenRow(final boolean search) {
        return this;
    }

    @Override
    public void setTokenRow(TokenRow tokenRow) {
        throw new RuntimeException("Shouldn't be setting TokenRow's TokenRow!");
    }

    public String getToken() {
        return getIndexEntry().token;
    }

// Path: src/com/hughes/android/dictionary/engine/Index.java
// public static final class IndexEntry {
//     public final String token;
//     private final String normalizedToken;
//     public final int startRow;
//     final int numRows; // doesn't count the token row!
//     public List<HtmlEntry> htmlEntries;
// 
//     public IndexEntry(final Index index, final String token, final String normalizedToken,
//                       final int startRow, final int numRows, final List<HtmlEntry> htmlEntries) {
//         assert token.equals(token.trim());
//         assert !token.isEmpty();
//         this.token = token;
//         this.normalizedToken = normalizedToken;
//         this.startRow = startRow;
//         this.numRows = numRows;
//         this.htmlEntries = htmlEntries;
//     }
// 
//     IndexEntry(final Index index, final DataInput raf) throws IOException {
//         token = raf.readUTF();
//         if (index.dict.dictFileVersion >= 7) {
//             startRow = StringUtil.readVarInt(raf);
//             numRows = StringUtil.readVarInt(raf);
//         } else {
//             startRow = raf.readInt();
//             numRows = raf.readInt();
//         }
//         final boolean hasNormalizedForm = raf.readBoolean();
//         normalizedToken = hasNormalizedForm ? raf.readUTF() : token;
//         if (index.dict.dictFileVersion >= 7) {
//             int size = StringUtil.readVarInt(raf);
//             if (size == 0) {
//                 this.htmlEntries = Collections.emptyList();
//             } else {
//                 final int[] htmlEntryIndices = new int[size];
//                 for (int i = 0; i < size; ++i) {
//                     htmlEntryIndices[i] = StringUtil.readVarInt(raf);
//                 }
//                 this.htmlEntries = new AbstractList<HtmlEntry>() {
//                     @Override
//                     public HtmlEntry get(int i) {
//                         return index.dict.htmlEntries.get(htmlEntryIndices[i]);
//                     }
// 
//                     @Override
//                     public int size() {
//                         return htmlEntryIndices.length;
//                     }
//                 };
//             }
//         } else if (index.dict.dictFileVersion >= 6) {
//             this.htmlEntries = CachingList.create(
//                                    RAFList.create((DataInputBuffer)raf, index.dict.htmlEntryIndexSerializer,
//                                                   index.dict.dictFileVersion,
//                                                   index.dict.dictInfo + " htmlEntries: "), 1, false);
//         } else {
//             this.htmlEntries = Collections.emptyList();
//         }
//     }
// 
//     public void write(DataOutput raf) throws IOException {
//         raf.writeUTF(token);
//         StringUtil.writeVarInt(raf, startRow);
//         StringUtil.writeVarInt(raf, numRows);
//         final boolean hasNormalizedForm = !token.equals(normalizedToken);
//         raf.writeBoolean(hasNormalizedForm);
//         if (hasNormalizedForm) {
//             raf.writeUTF(normalizedToken);
//         }
//         StringUtil.writeVarInt(raf, htmlEntries.size());
//         for (HtmlEntry e : htmlEntries)
//             StringUtil.writeVarInt(raf, e.index());
//     }
// 
//     public String toString() {
//         return String.format("%s@%d(%d)", token, startRow, numRows);
//     }
// 
//     String normalizedToken() {
//         return normalizedToken;
//     }
// }


// Path: src/com/hughes/android/dictionary/engine/TokenRow.java
import java.io.DataInput;
import java.io.IOException;
import java.io.PrintStream;
import java.util.List;
import java.util.regex.Pattern;
import com.hughes.android.dictionary.engine.Index.IndexEntry;
import com.ibm.icu.text.Transliterator;

// 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;



public class TokenRow extends RowBase {

    public final boolean hasMainEntry;

    TokenRow(final DataInput raf, final int thisRowIndex, final Index index,
             final boolean hasMainEntry, int extra) throws IOException {
        super(raf, thisRowIndex, index, extra);
        this.hasMainEntry = hasMainEntry;
    }

    TokenRow(final int referenceIndex, final int thisRowIndex, final Index index,
             final boolean hasMainEntry) {
        super(referenceIndex, thisRowIndex, index);
        this.hasMainEntry = hasMainEntry;
    }

    public String toString() {
        return getToken() + "@" + referenceIndex;
    }

    @Override
    public TokenRow getTokenRow(final boolean search) {
        return this;
    }

    @Override
    public void setTokenRow(TokenRow tokenRow) {
        throw new RuntimeException("Shouldn't be setting TokenRow's TokenRow!");
    }

    public String getToken() {
        return getIndexEntry().token;
    }

    public IndexEntry getIndexEntry() {