]> gitweb.fperrin.net Git - Dictionary.git/blob - src/com/hughes/android/dictionary/engine/EntrySource.java
80c4ebf8fe290d8b04871fa827259114e4da4e4f
[Dictionary.git] / src / com / hughes / android / dictionary / engine / EntrySource.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.IOException;
18 import java.io.RandomAccessFile;
19 import java.io.Serializable;
20
21 import com.hughes.util.IndexedObject;
22 import com.hughes.util.raf.RAFListSerializer;
23
24 public class EntrySource extends IndexedObject implements Serializable {
25   
26   private static final long serialVersionUID = -1323165134846120269L;
27   
28   final String name;
29   
30   public EntrySource(final int index, final String name) {
31     super(index);
32     this.name = name;
33   }
34   
35   @Override
36   public String toString() {
37     return name;
38   }
39
40
41   public static RAFListSerializer<EntrySource> SERIALIZER = new RAFListSerializer<EntrySource>() {
42
43     @Override
44     public EntrySource read(RandomAccessFile raf, int readIndex)
45         throws IOException {
46       final String name = raf.readUTF();
47       return new EntrySource(readIndex, name);
48     }
49
50     @Override
51     public void write(RandomAccessFile raf, EntrySource t) throws IOException {
52       raf.writeUTF(t.name);
53     }    
54   };
55   
56 }