1 // Copyright 2011 Google Inc. All Rights Reserved.
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
15 package com.hughes.android.dictionary.engine;
17 import java.io.DataInput;
18 import java.io.DataOutput;
19 import java.io.IOException;
21 import com.hughes.util.IndexedObject;
22 import com.hughes.util.raf.RAFListSerializer;
24 public class EntrySource extends IndexedObject {
27 @SuppressWarnings("CanBeFinal")
30 @SuppressWarnings("WeakerAccess")
31 public EntrySource(final int index, final String name, int numEntries) {
34 this.numEntries = numEntries;
38 public String toString() {
42 public int getNumEntries() {
46 public String getName() {
50 public static final class Serializer implements RAFListSerializer<EntrySource> {
52 final Dictionary dictionary;
54 Serializer(Dictionary dictionary) {
55 this.dictionary = dictionary;
59 public EntrySource read(DataInput raf, int readIndex)
61 final String name = raf.readUTF();
62 final int numEntries = dictionary.dictFileVersion >= 3 ? raf.readInt() : 0;
63 return new EntrySource(readIndex, name, numEntries);
67 public void write(DataOutput raf, EntrySource t) throws IOException {
69 raf.writeInt(t.numEntries);