remove unused fields in DictionaryHeader

This commit is contained in:
Helium314 2024-05-15 22:54:11 +02:00
parent 528bbb4f7f
commit 82705e5d5e
3 changed files with 7 additions and 29 deletions

View file

@ -21,7 +21,6 @@ import helium314.keyboard.latin.common.FileUtils;
import helium314.keyboard.latin.common.InputPointers;
import helium314.keyboard.latin.common.StringUtils;
import helium314.keyboard.latin.makedict.DictionaryHeader;
import helium314.keyboard.latin.makedict.FormatSpec;
import helium314.keyboard.latin.makedict.FormatSpec.DictionaryOptions;
import helium314.keyboard.latin.makedict.UnsupportedFormatException;
import helium314.keyboard.latin.makedict.WordProperty;
@ -245,10 +244,7 @@ public final class BinaryDictionary extends Dictionary {
outAttributeValues.get(i));
attributes.put(attributeKey, attributeValue);
}
final boolean hasHistoricalInfo = DictionaryHeader.ATTRIBUTE_VALUE_TRUE.equals(
attributes.get(DictionaryHeader.HAS_HISTORICAL_INFO_KEY));
return new DictionaryHeader(outHeaderSize[0], new DictionaryOptions(attributes),
new FormatSpec.FormatOptions(outFormatVersion[0], hasHistoricalInfo));
return new DictionaryHeader(new DictionaryOptions(attributes));
}
@Override

View file

@ -6,10 +6,8 @@
package helium314.keyboard.latin.makedict
import helium314.keyboard.latin.common.LocaleUtils
import helium314.keyboard.latin.common.LocaleUtils.constructLocale
import helium314.keyboard.latin.makedict.FormatSpec.DictionaryOptions
import helium314.keyboard.latin.makedict.FormatSpec.FormatOptions
import java.text.DateFormat
import java.util.Date
import java.util.Locale
@ -18,12 +16,8 @@ import java.util.Locale
* Class representing dictionary header.
*/
class DictionaryHeader(
headerSize: Int,
@JvmField
val mDictionaryOptions: DictionaryOptions,
val mFormatOptions: FormatOptions
@JvmField val mDictionaryOptions: DictionaryOptions,
) {
val mBodyOffset = if (mFormatOptions.mVersion < FormatSpec.VERSION4) headerSize else 0
val mLocaleString = mDictionaryOptions.mAttributes[DICTIONARY_LOCALE_KEY]
?: throw UnsupportedFormatException("Cannot create a FileHeader without a locale")
@JvmField
@ -34,7 +28,7 @@ class DictionaryHeader(
@JvmField
val mIdString = mDictionaryOptions.mAttributes[DICTIONARY_ID_KEY]
?: throw UnsupportedFormatException("Cannot create a FileHeader without an ID")
val mDate = mDictionaryOptions.mAttributes[DICTIONARY_DATE_KEY]?.toIntOrNull()
private val mDate = mDictionaryOptions.mAttributes[DICTIONARY_DATE_KEY]?.toIntOrNull()
val description: String?
// Helper method to get the description

View file

@ -6,6 +6,8 @@
package helium314.keyboard.latin.makedict;
import androidx.annotation.NonNull;
import helium314.keyboard.latin.define.DecoderSpecificConstants;
import java.util.Date;
@ -236,19 +238,6 @@ public final class FormatSpec {
static final int MINIMAL_ONE_BYTE_CHARACTER_VALUE = 0x20;
static final int MAXIMAL_ONE_BYTE_CHARACTER_VALUE = 0xFF;
/**
* Options about file format.
*/
public static final class FormatOptions {
public final int mVersion;
public final boolean mHasTimestamp;
public FormatOptions(final int version, final boolean hasTimestamp) {
mVersion = version;
mHasTimestamp = hasTimestamp;
}
}
/**
* Options global to the dictionary.
*/
@ -258,7 +247,7 @@ public final class FormatSpec {
mAttributes = attributes;
}
@Override
public String toString() { // Convenience method
@NonNull public String toString() { // Convenience method
return toString(0, false);
}
public String toString(final int indentCount, final boolean plumbing) {
@ -277,8 +266,7 @@ public final class FormatSpec {
s.append(" = ");
if ("date".equals(optionKey) && !plumbing) {
// Date needs a number of milliseconds, but the dictionary contains seconds
s.append(new Date(
1000 * Long.parseLong(mAttributes.get(optionKey))).toString());
s.append(new Date(1000 * Long.parseLong(mAttributes.get(optionKey))));
} else {
s.append(mAttributes.get(optionKey));
}