]> gitweb.fperrin.net Git - Dictionary.git/blob - src/com/hughes/android/dictionary/DictionaryInfo.java
Theme, different color rows, dictionary_info, long click begin.
[Dictionary.git] / src / com / hughes / android / dictionary / DictionaryInfo.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;
16
17 import java.io.Serializable;
18
19 public class DictionaryInfo implements Serializable {
20   
21   private static final long serialVersionUID = -6850863377577700388L;
22   
23   // Stuff populated from the text file.
24   public final String[] langIsos = new String[2];
25   public String uncompressedFilename;
26   public String downloadUrl;
27   public long uncompressedSize;
28   public long creationMillis;
29   public final int[] allTokenCounts = new int[2];
30   public final int[] mainTokenCounts = new int[2];
31
32   String name;  // Determined at runtime based on locale on device--user editable.
33   String localFile;  // Determined based on device's Environment.
34   
35   public String toTabSeparatedString() {
36     return String.format("%s\t%s\t%s\t%s\t%d\t%d\t%d\t%d\t%d\t%d", langIsos[0],
37         langIsos[1], uncompressedFilename, downloadUrl, creationMillis, uncompressedSize,
38         mainTokenCounts[0], mainTokenCounts[1], allTokenCounts[0],
39         allTokenCounts[1]);
40   }
41
42   public DictionaryInfo(final String line) {
43     final String[] fields = line.split("\t");
44     int i = 0;
45     langIsos[0] = fields[i++];
46     langIsos[1] = fields[i++];
47     uncompressedFilename = fields[i++];
48     downloadUrl = fields[i++];
49     creationMillis = Long.parseLong(fields[i++]);
50     uncompressedSize = Long.parseLong(fields[i++]);
51     mainTokenCounts[0] = Integer.parseInt(fields[i++]);
52     mainTokenCounts[1] = Integer.parseInt(fields[i++]);
53     allTokenCounts[0] = Integer.parseInt(fields[i++]);
54     allTokenCounts[1] = Integer.parseInt(fields[i++]);
55   }
56
57   public DictionaryInfo() {
58     // Blank object.
59   }
60
61   @Override
62   public String toString() {
63     return name;
64   }
65
66
67 }