[jsword-svn] r2145 - in trunk/jsword/src/main/java/org/crosswire: common/xml jsword/book jsword/book/sword jsword/index
dmsmith at crosswire.org
dmsmith at crosswire.org
Mon Apr 4 18:15:52 MST 2011
Author: dmsmith
Date: 2011-04-04 18:15:52 -0700 (Mon, 04 Apr 2011)
New Revision: 2145
Modified:
trunk/jsword/src/main/java/org/crosswire/common/xml/XMLFeature.java
trunk/jsword/src/main/java/org/crosswire/common/xml/XMLFeatureSet.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/BookCategory.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryType.java
trunk/jsword/src/main/java/org/crosswire/jsword/index/IndexStatus.java
Log:
JS-141 The old style enums in last in jsword.
Modified: trunk/jsword/src/main/java/org/crosswire/common/xml/XMLFeature.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/common/xml/XMLFeature.java 2011-04-04 23:56:35 UTC (rev 2144)
+++ trunk/jsword/src/main/java/org/crosswire/common/xml/XMLFeature.java 2011-04-05 01:15:52 UTC (rev 2145)
@@ -21,7 +21,6 @@
*/
package org.crosswire.common.xml;
-import java.io.Serializable;
/**
* Wraps an XML Feature. The "known" set of XML Features is found in
@@ -31,39 +30,39 @@
* The copyright to this program is held by it's authors.
* @author DM Smith [dmsmith555 at yahoo dot com]
*/
-public class XMLFeature implements Serializable, Comparable<XMLFeature> {
+public enum XMLFeature {
/** Namespaces feature id */
- public static final XMLFeature NAMESPACES = new XMLFeature("http://xml.org/sax/features/namespaces");
+ NAMESPACES("http://xml.org/sax/features/namespaces"),
/** Namespace prefixes feature id */
- public static final XMLFeature NAMESPACE_PREFIX = new XMLFeature("http://xml.org/sax/features/namespace-prefixes");
+ NAMESPACE_PREFIX("http://xml.org/sax/features/namespace-prefixes"),
/** Validation feature id */
- public static final XMLFeature VALIDATION = new XMLFeature("http://xml.org/sax/features/validation");
+ VALIDATION("http://xml.org/sax/features/validation"),
/** Schema validation feature id */
- public static final XMLFeature SCHEMA_VALIDATION = new XMLFeature("http://apache.org/xml/features/validation/schema");
+ SCHEMA_VALIDATION("http://apache.org/xml/features/validation/schema"),
/** Schema full checking feature id */
- public static final XMLFeature SCHEMA_FULL_CHECKING = new XMLFeature("http://apache.org/xml/features/validation/schema-full-checking");
+ SCHEMA_FULL_CHECKING("http://apache.org/xml/features/validation/schema-full-checking"),
/** Validate schema annotations feature id */
- public static final XMLFeature VALIDATE_ANNOTATIONS = new XMLFeature("http://apache.org/xml/features/validate-annotations");
+ VALIDATE_ANNOTATIONS("http://apache.org/xml/features/validate-annotations"),
/** Dynamic validation feature id */
- public static final XMLFeature DYNAMIC_VALIDATION = new XMLFeature("http://apache.org/xml/features/validation/dynamic");
+ DYNAMIC_VALIDATION("http://apache.org/xml/features/validation/dynamic"),
/** Load external DTD feature id */
- public static final XMLFeature LOAD_EXTERNAL_DTD = new XMLFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd");
+ LOAD_EXTERNAL_DTD("http://apache.org/xml/features/nonvalidating/load-external-dtd"),
/** XInclude feature id */
- public static final XMLFeature XINCLUDE = new XMLFeature("http://apache.org/xml/features/xinclude");
+ XINCLUDE("http://apache.org/xml/features/xinclude"),
/** XInclude fixup base URIs feature id */
- public static final XMLFeature XINCLUDE_FIXUP_BASE_URIS = new XMLFeature("http://apache.org/xml/features/xinclude/fixup-base-uris", true);
+ XINCLUDE_FIXUP_BASE_URIS("http://apache.org/xml/features/xinclude/fixup-base-uris", true),
/** XInclude fixup language feature id */
- public static final XMLFeature XINCLUDE_FIXUP_LANGUAGE = new XMLFeature("http://apache.org/xml/features/xinclude/fixup-language", true);
+ XINCLUDE_FIXUP_LANGUAGE("http://apache.org/xml/features/xinclude/fixup-language", true);
/**
* Construct a feature for xml, setting the initial state
@@ -105,8 +104,7 @@
* Lookup method to convert from a String
*/
public static XMLFeature fromString(String name) {
- for (int i = 0; i < VALUES.length; i++) {
- XMLFeature o = VALUES[i];
+ for (XMLFeature o : XMLFeature.values()) {
if (o.control.equalsIgnoreCase(name)) {
return o;
}
@@ -116,73 +114,12 @@
return null;
}
- /**
- * Lookup method to convert from an integer
- */
- public static XMLFeature fromInteger(int i) {
- return VALUES[i];
- }
-
- /**
- * Prevent subclasses from overriding canonical identity based Object
- * methods
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
- public final boolean equals(Object o) {
- return super.equals(o);
- }
-
- /**
- * Prevent subclasses from overriding canonical identity based Object
- * methods
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public final int hashCode() {
- return super.hashCode();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
public String toString() {
return (state ? "on " : "off ") + control;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo(XMLFeature feature) {
- return this.control.compareTo(feature.control);
- }
-
private String control;
private boolean state;
- // Support for serialization
- private static int nextObj;
- private final int obj = nextObj++;
-
- Object readResolve() {
- return VALUES[obj];
- }
-
- private static final XMLFeature[] VALUES = {
- NAMESPACES, NAMESPACE_PREFIX, VALIDATION, SCHEMA_VALIDATION, SCHEMA_FULL_CHECKING, VALIDATE_ANNOTATIONS, DYNAMIC_VALIDATION, LOAD_EXTERNAL_DTD,
- XINCLUDE, XINCLUDE_FIXUP_BASE_URIS, XINCLUDE_FIXUP_LANGUAGE
- };
-
- /**
- * Serialization UID
- */
- private static final long serialVersionUID = -1972881391399216524L;
-
}
Modified: trunk/jsword/src/main/java/org/crosswire/common/xml/XMLFeatureSet.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/common/xml/XMLFeatureSet.java 2011-04-04 23:56:35 UTC (rev 2144)
+++ trunk/jsword/src/main/java/org/crosswire/common/xml/XMLFeatureSet.java 2011-04-05 01:15:52 UTC (rev 2145)
@@ -1,24 +1,3 @@
-/*
- * This is inspired by DocumentChecker.
- * @author Andy Clark, IBM
- * @author Arnaud Le Hors, IBM
- *
- * Copyright 2000-2002,2004,2005 The Apache Software Foundation.
- *
- * 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.
- *
- */
-
/**
* Distribution License:
* JSword is free software; you can redistribute it and/or modify it under
@@ -40,6 +19,26 @@
*
* ID: $Id$
*/
+/*
+ * This is inspired by DocumentChecker.
+ * @author Andy Clark, IBM
+ * @author Arnaud Le Hors, IBM
+ *
+ * Copyright 2000-2002,2004,2005 The Apache Software Foundation.
+ *
+ * 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 org.crosswire.common.xml;
import java.util.Locale;
@@ -96,11 +95,6 @@
}
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/BookCategory.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/BookCategory.java 2011-04-04 23:56:35 UTC (rev 2144)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/BookCategory.java 2011-04-05 01:15:52 UTC (rev 2145)
@@ -21,8 +21,6 @@
*/
package org.crosswire.jsword.book;
-import java.io.Serializable;
-
import org.crosswire.jsword.JSMsg;
/**
@@ -33,50 +31,50 @@
* @author Joe Walker [joe at eireneh dot com]
* @author DM Smith [dmsmith555 at yahoo dot com]
*/
-public final class BookCategory implements Serializable, Comparable<BookCategory> {
+public enum BookCategory {
/** Books that are Bibles */
// TRANSLATOR: The name for the book category consisting of Bibles.
- public static final BookCategory BIBLE = new BookCategory("Biblical Texts", JSMsg.gettext("Biblical Texts"));
+ BIBLE("Biblical Texts", JSMsg.gettext("Biblical Texts")),
/** Books that are Dictionaries */
// TRANSLATOR: The name for the book category consisting of Lexicons and Dictionaries.
- public static final BookCategory DICTIONARY = new BookCategory("Lexicons / Dictionaries", JSMsg.gettext("Dictionaries"));
+ DICTIONARY("Lexicons / Dictionaries", JSMsg.gettext("Dictionaries")),
/** Books that are Commentaries */
// TRANSLATOR: The name for the book category consisting of Commentaries.
- public static final BookCategory COMMENTARY = new BookCategory("Commentaries", JSMsg.gettext("Commentaries"));
+ COMMENTARY("Commentaries", JSMsg.gettext("Commentaries")),
/** Books that are indexed by day. AKA, Daily Devotions */
// TRANSLATOR: The name for the book category consisting of Daily Devotions, indexed by day of the year.
- public static final BookCategory DAILY_DEVOTIONS = new BookCategory("Daily Devotional", JSMsg.gettext("Daily Devotionals"));
+ DAILY_DEVOTIONS("Daily Devotional", JSMsg.gettext("Daily Devotionals")),
/** Books that map words from one language to another. */
// TRANSLATOR: The name for the book category consisting of Glossaries that map words/phrases from one language into another.
- public static final BookCategory GLOSSARY = new BookCategory("Glossaries", JSMsg.gettext("Glossaries"));
+ GLOSSARY("Glossaries", JSMsg.gettext("Glossaries")),
/** Books that are questionable. */
// TRANSLATOR: The name for the book category consisting of books that are considered unorthodox by mainstream Christianity.
- public static final BookCategory QUESTIONABLE = new BookCategory("Cults / Unorthodox / Questionable Material", JSMsg.gettext("Cults / Unorthodox / Questionable Materials"));
+ QUESTIONABLE("Cults / Unorthodox / Questionable Material", JSMsg.gettext("Cults / Unorthodox / Questionable Materials")),
/** Books that are just essays. */
// TRANSLATOR: The name for the book category consisting of just essays.
- public static final BookCategory ESSAYS = new BookCategory("Essays", JSMsg.gettext("Essays"));
+ ESSAYS("Essays", JSMsg.gettext("Essays")),
/** Books that are predominately images. */
// TRANSLATOR: The name for the book category consisting of books containing mostly images.
- public static final BookCategory IMAGES = new BookCategory("Images", JSMsg.gettext("Images"));
+ IMAGES("Images", JSMsg.gettext("Images")),
/** Books that are a collection of maps. */
// TRANSLATOR: The name for the book category consisting of books containing mostly maps.
- public static final BookCategory MAPS = new BookCategory("Maps", JSMsg.gettext("Maps"));
+ MAPS("Maps", JSMsg.gettext("Maps")),
/** Books that are just books. */
// TRANSLATOR: The name for the book category consisting of general books.
- public static final BookCategory GENERAL_BOOK = new BookCategory("Generic Books", JSMsg.gettext("General Books"));
+ GENERAL_BOOK("Generic Books", JSMsg.gettext("General Books")),
/** Books that are not any of the above. This is a catch all for new book categories. */
// TRANSLATOR: The name for the book category consisting of books not in any of the other categories.
- public static final BookCategory OTHER = new BookCategory("Other", JSMsg.gettext("Other"));
+ OTHER("Other", JSMsg.gettext("Other"));
/**
* @param name
@@ -91,8 +89,7 @@
* Lookup method to convert from a String
*/
public static BookCategory fromString(String name) {
- for (int i = 0; i < VALUES.length; i++) {
- BookCategory o = VALUES[i];
+ for (BookCategory o : BookCategory.values()) {
if (o.name.equalsIgnoreCase(name)) {
return o;
}
@@ -104,8 +101,7 @@
* Lookup method to convert from a String
*/
public static BookCategory fromExternalString(String name) {
- for (int i = 0; i < VALUES.length; i++) {
- BookCategory o = VALUES[i];
+ for (BookCategory o : BookCategory.values()) {
if (o.externalName.equalsIgnoreCase(name)) {
return o;
}
@@ -117,38 +113,14 @@
* Lookup method to convert from an integer
*/
public static BookCategory fromInteger(int i) {
- return VALUES[i];
+ for (BookCategory o : BookCategory.values()) {
+ if (i == o.ordinal()) {
+ return o;
+ }
+ }
+ return OTHER;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo(BookCategory that) {
- return this.name.compareTo(that.name);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object o) {
- return super.equals(o);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- return super.hashCode();
- }
-
/**
* @return the internal name.
*/
@@ -156,10 +128,8 @@
return name;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
+ /**
+ * @return the internationalized name.
*/
@Override
public String toString() {
@@ -171,21 +141,4 @@
*/
private transient String name;
private transient String externalName;
-
- // Support for serialization
- private static int nextObj;
- private final int obj = nextObj++;
-
- Object readResolve() {
- return VALUES[obj];
- }
-
- private static final BookCategory[] VALUES = {
- BIBLE, DICTIONARY, COMMENTARY, DAILY_DEVOTIONS, GLOSSARY, QUESTIONABLE, ESSAYS, IMAGES, MAPS, GENERAL_BOOK, OTHER,
- };
-
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3256727260177708345L;
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryType.java 2011-04-04 23:56:35 UTC (rev 2144)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryType.java 2011-04-05 01:15:52 UTC (rev 2145)
@@ -21,7 +21,6 @@
*/
package org.crosswire.jsword.book.sword;
-import java.io.Serializable;
import java.util.regex.Pattern;
import org.crosswire.common.util.Language;
@@ -42,326 +41,74 @@
* @author Joe Walker [joe at eireneh dot com]
* @author DM Smith [dmsmith555 at yahoo dot com]
*/
-public class ConfigEntryType implements Serializable {
+public enum ConfigEntryType {
/**
- * Constants for direction
+ * The abbreviated name by which this book is known. This is in the [] on
+ * the first non-blank line of the conf. JSword uses this for display and
+ * access purposes.
*/
- public static final String DIRECTION_LTOR = "LtoR";
- public static final String DIRECTION_RTOL = "RtoL";
- public static final String DIRECTION_BIDI = "bidi";
-
- private static final String[] BLOCK_TYPE_PICKS = new String[] {
- "BOOK",
- "CHAPTER",
- "VERSE",
- };
-
- private static final String[] BOOLEAN_PICKS = new String[] {
- "true",
- "false",
- };
-
- private static final String[] CATEGORY_PICKS = new String[] {
- "Daily Devotional",
- "Glossaries",
- "Cults / Unorthodox / Questionable Material",
- "Essays",
- "Maps",
- "Images",
- "Biblical Texts",
- "Commentaries",
- "Lexicons / Dictionaries",
- "Generic Books",
- };
-
- private static final String[] COMPRESS_TYPE_PICKS = new String[] {
- "LZSS",
- "ZIP",
- };
-
- private static final String[] DIRECTION_PICKS = new String[] {
- DIRECTION_LTOR, DIRECTION_RTOL, DIRECTION_BIDI,
- };
-
- private static final String[] KEY_TYPE_PICKS = new String[] {
- "TreeKey",
- "VerseKey",
- };
-
- private static final String[] FEATURE_PICKS = new String[] {
- "StrongsNumbers",
- "GreekDef",
- "HebrewDef",
- "GreekParse",
- "HebrewParse",
- "DailyDevotion",
- "Glossary",
- "Images",
- };
-
- private static final String[] GLOBAL_OPTION_FILTER_PICKS = new String[] {
- "GBFStrongs",
- "GBFFootnotes",
- "GBFScripref",
- "GBFMorph",
- "GBFHeadings",
- "GBFRedLetterWords",
- "ThMLStrongs",
- "ThMLFootnotes",
- "ThMLScripref",
- "ThMLMorph",
- "ThMLHeadings",
- "ThMLVariants",
- "ThMLLemma",
- "UTF8Cantillation",
- "UTF8GreekAccents",
- "UTF8HebrewPoints",
- "OSISStrongs",
- "OSISFootnotes",
- "OSISScripref",
- "OSISMorph",
- "OSISHeadings",
- "OSISRedLetterWords",
- "OSISLemma",
- "OSISRuby",
- };
-
- private static final String[] LICENSE_PICKS = new String[] {
- "Public Domain",
- "Copyrighted",
- "Copyrighted; Free non-commercial distribution",
- "Copyrighted; Permission to distribute granted to CrossWire",
- "Copyrighted; Freely distributable",
- "Copyrighted; Permission granted to distribute non-commercially in Sword format",
- "GFDL",
- "GPL",
- "Creative Commons: by-nc-nd",
- "Creative Commons: by-nc-sa",
- "Creative Commons: by-nc",
- "Creative Commons: by-nd",
- "Creative Commons: by-sa",
- "Creative Commons: by",
- };
-
- private static final String[] ENCODING_PICKS = new String[] {
- "Latin-1",
- "UTF-8",
- };
-
- private static final String[] MOD_DRV_PICKS = new String[] {
- "RawText",
- "zText",
- "RawCom",
- "RawCom4",
- "zCom",
- "HREFCom",
- "RawFiles",
- "RawLD",
- "RawLD4",
- "zLD",
- "RawGenBook",
- };
-
- private static final String[] SOURCE_TYPE_PICKS = new String[] {
- "Plaintext",
- "GBF",
- "ThML",
- "OSIS",
- "TEI",
- "OSIS",
- "TEI",
- };
-
- private static final String[] VERSIFICATION_PICKS = new String[] {
- "KJV",
- "KJVA",
- "NRSV",
- "NRSVA",
- "Leningrad",
- "MT",
- };
-
- /**
- * A ConfigEntryPickType is a ConfigEntryType that allows values from a pick
- * list. Matching is expected to be case-sensitive, but data problems
- * dictate a more flexible approach.
- *
- */
- public static class ConfigEntryPickType extends ConfigEntryType {
- /**
- * Simple ctor
- */
- public ConfigEntryPickType(String name, String[] picks) {
- this(name, picks, null);
- }
-
- /**
- * Simple ctor
- */
- public ConfigEntryPickType(String name, String[] picks, Object defaultPick) {
- super(name, defaultPick);
- choiceArray = picks.clone();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.crosswire.jsword.book.sword.ConfigEntryType#hasChoices()
- */
+ INITIALS("Initials") {
@Override
- protected boolean hasChoices() {
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#isAllowed(java.lang
- * .String)
- */
- @Override
- public boolean isAllowed(String value) {
- for (int i = 0; i < choiceArray.length; i++) {
- if (choiceArray[i].equalsIgnoreCase(value)) {
- return true;
- }
- }
-
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#filter(java.lang.
- * String)
- */
- @Override
- public String filter(String value) {
- // Do we have an exact match?
- for (int i = 0; i < choiceArray.length; i++) {
- if (choiceArray[i].equals(value)) {
- return value;
- }
- }
-
- // Do we have a case insensitive match?
- for (int i = 0; i < choiceArray.length; i++) {
- if (choiceArray[i].equalsIgnoreCase(value)) {
- return choiceArray[i];
- }
- }
-
- // No match at all!
- return value;
- }
-
- /**
- * The array of choices.
- */
- private final String[] choiceArray;
-
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 5642668733730291463L;
- }
-
- /**
- * Represents a ConfigEntryType that is not actually represented by the
- * Sword Config file.
- *
- */
- public static class ConfigEntrySyntheticType extends ConfigEntryType {
- /**
- * Simple ctor
- */
- public ConfigEntrySyntheticType(String name) {
- super(name);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.crosswire.jsword.book.sword.ConfigEntryType#isSynthetic()
- */
- @Override
public boolean isSynthetic() {
return true;
}
+ },
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = -2468890875139856087L;
- }
-
/**
- * The abbreviated name by which this book is known. This is in the [] on
- * the first non-blank line of the conf. JSword uses this for display and
- * access purposes.
- */
- public static final ConfigEntryType INITIALS = new ConfigEntrySyntheticType("Initials");
-
- /**
* Relative path to the data files, some issues with this
*/
- public static final ConfigEntryType DATA_PATH = new ConfigEntryType("DataPath")
- {
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#isAllowed(java.lang
- * .String)
- */
+ DATA_PATH("DataPath") {
@Override
public boolean isAllowed(String value) {
return true;
}
+ },
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3546926870244309296L;
- };
-
/**
* The full name of this book
*/
- public static final ConfigEntryType DESCRIPTION = new ConfigEntryType("Description");
+ DESCRIPTION("Description"),
/**
* This indicates how the book was stored.
*/
- public static final ConfigEntryType MOD_DRV = new ConfigEntryPickType("ModDrv", MOD_DRV_PICKS);
+ MOD_DRV("ModDrv", -1,
+ "RawText",
+ "zText",
+ "RawCom",
+ "RawCom4",
+ "zCom",
+ "HREFCom",
+ "RawFiles",
+ "RawLD",
+ "RawLD4",
+ "zLD",
+ "RawGenBook"
+ ),
/**
* The type of compression in use. JSword does not support LZSS. While it is
* the default, it is not used. At least so far.
*/
- public static final ConfigEntryType COMPRESS_TYPE = new ConfigEntryPickType("CompressType", COMPRESS_TYPE_PICKS, COMPRESS_TYPE_PICKS[0]);
+ COMPRESS_TYPE("CompressType", 0,
+ "LZSS",
+ "ZIP"
+ ),
/**
* The level at which compression is applied, BOOK, CHAPTER, or VERSE
*/
- public static final ConfigEntryType BLOCK_TYPE = new ConfigEntryPickType("BlockType", BLOCK_TYPE_PICKS, BLOCK_TYPE_PICKS[0]);
+ BLOCK_TYPE("BlockType", 1,
+ "BOOK",
+ "CHAPTER",
+ "VERSE"
+ ),
/**
* single value integer, unknown use, some indications that we ought to be
* using it
*/
- public static final ConfigEntryType BLOCK_COUNT = new ConfigEntryType("BlockCount", Integer.valueOf(200))
- {
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#isAllowed(java.lang
- * .String)
- */
+ BLOCK_COUNT("BlockCount", "200") {
@Override
public boolean isAllowed(String aValue) {
try {
@@ -372,13 +119,6 @@
}
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#convert(java.lang
- * .String)
- */
@Override
public Object convert(String input) {
try {
@@ -387,81 +127,115 @@
return getDefault();
}
}
+ },
- /**
- * Comment for <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = 3978711675019212341L;
- };
-
/**
* The kind of key that a Generic Book uses.
*/
- public static final ConfigEntryType KEY_TYPE = new ConfigEntryPickType("KeyType", KEY_TYPE_PICKS, KEY_TYPE_PICKS[0]);
+ KEY_TYPE("KeyType", 0,
+ "TreeKey",
+ "VerseKey"
+ ),
/**
* If this exists in the conf, then the book is encrypted. The value is used
* to unlock the book. The encryption algorithm is Sapphire.
*/
- public static final ConfigEntryType CIPHER_KEY = new ConfigEntryType("CipherKey");
+ CIPHER_KEY("CipherKey"),
/**
* This indicates the versification of the book, with KJV being the default.
*/
- public static final ConfigEntryType VERSIFICATION = new ConfigEntryPickType("Versification", VERSIFICATION_PICKS);
+ VERSIFICATION("Versification", 3,
+ "Catholic",
+ "Catholic2",
+ "German",
+ "KJV",
+ "KJVA",
+ "Leningrad",
+ "Luther",
+ "MT",
+ "NRSV",
+ "NRSVA",
+ "Synodal",
+ "SynodalP",
+ "Vulg"
+ ),
/**
* Global Option Filters are the names of routines in Sword that can be used
* to display the data. These are not used by JSword.
*/
- public static final ConfigEntryType GLOBAL_OPTION_FILTER = new ConfigEntryPickType("GlobalOptionFilter", GLOBAL_OPTION_FILTER_PICKS) {
-
- /*
- * (non-Javadoc)
- *
- * @see org.crosswire.jsword.book.sword.ConfigEntryType#mayRepeat()
- */
+ GLOBAL_OPTION_FILTER("GlobalOptionFilter", -1,
+ "GBFStrongs",
+ "GBFFootnotes",
+ "GBFMorph",
+ "GBFHeadings",
+ "GBFRedLetterWords",
+ "GBFScripref",
+ "ThMLStrongs",
+ "ThMLFootnotes",
+ "ThMLScripref",
+ "ThMLMorph",
+ "ThMLHeadings",
+ "ThMLVariants",
+ "ThMLLemma",
+ "UTF8Cantillation",
+ "UTF8GreekAccents",
+ "UTF8HebrewPoints",
+ "OSISStrongs",
+ "OSISFootnotes",
+ "OSISScripref",
+ "OSISMorph",
+ "OSISHeadings",
+ "OSISVariants",
+ "OSISRedLetterWords",
+ "OSISLemma",
+ "OSISRuby"
+ ) {
@Override
public boolean mayRepeat() {
return true;
}
+ },
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3258417209599931960L;
- };
-
/**
* The layout direction of the text in the book. Hebrew, Arabic and Farsi
* RtoL. Most are 'LtoR'. Some are 'bidi', bi-directional. E.g.
* hebrew-english glossary.
*/
- public static final ConfigEntryType DIRECTION = new ConfigEntryPickType("Direction", DIRECTION_PICKS, DIRECTION_PICKS[0]);
+ DIRECTION("Direction", 0,
+ "LtoR",
+ "RtoL",
+ "bidi"
+ ),
/**
* This indicates the kind of markup used for the book.
*/
- public static final ConfigEntryType SOURCE_TYPE = new ConfigEntryPickType("SourceType", SOURCE_TYPE_PICKS, SOURCE_TYPE_PICKS[0]);
+ SOURCE_TYPE("SourceType", 0,
+ "Plaintext",
+ "GBF",
+ "ThML",
+ "OSIS",
+ "TEI",
+ "OSIS",
+ "TEI"
+ ),
/**
* The character encoding. Only Latin-1 and UTF-8 are supported.
*/
- public static final ConfigEntryType ENCODING = new ConfigEntryPickType("Encoding", ENCODING_PICKS, ENCODING_PICKS[0]);
+ ENCODING("Encoding", 0,
+ "Latin-1",
+ "UTF-8"
+ ),
/**
* Display level is used by GenBooks to do auto expansion in the tree. A
* level of 2 indicates that the first two levels should be shown.
*/
- public static final ConfigEntryType DISPLAY_LEVEL = new ConfigEntryType("DisplayLevel") {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#isAllowed(java.lang
- * .String)
- */
+ DISPLAY_LEVEL("DisplayLevel", "1") {
@Override
public boolean isAllowed(String value) {
try {
@@ -472,13 +246,6 @@
}
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#convert(java.lang
- * .String)
- */
@Override
public Object convert(String input) {
try {
@@ -487,154 +254,92 @@
return null;
}
}
+ },
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3979274654953451830L;
- };
-
/**
* A recommended font to use for the book.
*/
- public static final ConfigEntryType FONT = new ConfigEntryType("Font");
+ FONT("Font"),
/**
* When false do not show quotation marks for OSIS text that has <q>
* elements.
*/
- public static final ConfigEntryType OSIS_Q_TO_TICK = new ConfigEntryPickType("OSISqToTick", BOOLEAN_PICKS, Boolean.TRUE) {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#convert(java.lang
- * .String)
- */
+ OSIS_Q_TO_TICK("OSISqToTick", 0,
+ "true",
+ "false"
+ ) {
@Override
public Object convert(String input) {
return Boolean.valueOf(input);
}
+ },
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3258412850174373936L;
- };
-
/**
* A Feature describes a characteristic of the Book.
*/
- public static final ConfigEntryType FEATURE = new ConfigEntryPickType("Feature", FEATURE_PICKS) {
-
- /*
- * (non-Javadoc)
- *
- * @see org.crosswire.jsword.book.sword.ConfigEntryType#mayRepeat()
- */
+ FEATURE("Feature", -1,
+ "StrongsNumbers",
+ "GreekDef",
+ "HebrewDef",
+ "GreekParse",
+ "HebrewParse",
+ "DailyDevotion",
+ "Glossary",
+ "Images"
+ ) {
@Override
public boolean mayRepeat() {
return true;
}
+ },
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3833181424051172401L;
- };
-
/**
* Books with a Feature of Glossary are used to map words FROM one language
* TO another.
*/
- public static final ConfigEntryType GLOSSARY_FROM = new ConfigEntryType("GlossaryFrom") {
-
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 6619179970516935818L;
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#convert(java.lang
- * .String)
- */
+ GLOSSARY_FROM("GlossaryFrom") {
@Override
public Object convert(String input) {
return new Language(input);
}
+ },
- };
-
/**
* Books with a Feature of Glossary are used to map words FROM one language
* TO another.
*/
- public static final ConfigEntryType GLOSSARY_TO = new ConfigEntryType("GlossaryTo") {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#convert(java.lang
- * .String)
- */
+ GLOSSARY_TO("GlossaryTo") {
@Override
public Object convert(String input) {
return new Language(input);
}
+ },
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3273532519245386866L;
- };
-
/**
* The short name of this book.
*/
- public static final ConfigEntryType ABBREVIATION = new ConfigEntryType("Abbreviation");
+ ABBREVIATION("Abbreviation"),
/**
* Contains rtf that describes the book.
*/
- public static final ConfigEntryType ABOUT = new ConfigEntryType("About") {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#allowsContinuation()
- */
+ ABOUT("About") {
@Override
public boolean allowsContinuation() {
return true;
}
- /*
- * (non-Javadoc)
- *
- * @see org.crosswire.jsword.book.sword.ConfigEntryType#allowsRTF()
- */
@Override
public boolean allowsRTF() {
return true;
}
+ },
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3258416110121334073L;
- };
-
/**
* An informational string indicating the current version of the book.
*/
- public static final ConfigEntryType VERSION = new ConfigEntryType("Version", "1.0") {
-
+ VERSION("Version", "1.0") {
@Override
public boolean isAllowed(String aValue) {
try {
@@ -643,120 +348,76 @@
} catch (NumberFormatException e) {
return false;
}
-
}
+ },
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3256443616242055221L;
- };
-
/**
* multiple values starting with History, some sort of change-log. In the
* conf these are of the form History_x.y. We strip off the x.y and prefix
* the value with it. The x.y corresponds to a current or prior Version
* value.
*/
- public static final ConfigEntryType HISTORY = new ConfigEntryType("History") {
-
- /*
- * (non-Javadoc)
- *
- * @see org.crosswire.jsword.book.sword.ConfigEntryType#mayRepeat()
- */
+ HISTORY("History") {
@Override
public boolean mayRepeat() {
return true;
}
- /*
- * (non-Javadoc)
- *
- * @see org.crosswire.jsword.book.sword.ConfigEntryType#reportDetails()
- */
@Override
public boolean reportDetails() {
return false;
}
+ },
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3979272443195830835L;
- };
-
/**
* single value version number, lowest sword c++ version that can read this
* book JSword does not use this value.
*/
- public static final ConfigEntryType MINIMUM_VERSION = new ConfigEntryType("MinimumVersion", "1.5.1a");
+ MINIMUM_VERSION("MinimumVersion", "1.5.1a"),
/**
* The Category of the book. Used on the web to classify books into a tree.
*/
- public static final ConfigEntryType CATEGORY = new ConfigEntryPickType("Category", CATEGORY_PICKS, BookCategory.OTHER) {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#convert(java.lang
- * .String)
- */
+ CATEGORY("Category", 0,
+ "Other",
+ "Daily Devotional",
+ "Glossaries",
+ "Cults / Unorthodox / Questionable Material",
+ "Essays",
+ "Maps",
+ "Images",
+ "Biblical Texts",
+ "Commentaries",
+ "Lexicons / Dictionaries",
+ "Generic Books"
+ ) {
@Override
public Object convert(String input) {
return BookCategory.fromString(input);
}
+ },
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3258412850174571569L;
- };
-
/**
* Library of Congress Subject Heading. Typically this is of the form
* BookCategory Scope Language, where scope is typically O.T., N.T.
*/
- public static final ConfigEntryType LCSH = new ConfigEntryType("LCSH");
+ LCSH("LCSH"),
/**
* single value string, defaults to en, the language of the book
*/
- public static final ConfigEntryType LANG = new ConfigEntryType("Lang", new Language(null)) {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#convert(java.lang
- * .String)
- */
+ LANG("Lang", "en") {
@Override
public Object convert(String input) {
return new Language(input);
}
+ },
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3257008752317379897L;
- };
-
/**
* The installed size of the book in bytes. This is not the size of the zip
* that is downloaded.
*/
- public static final ConfigEntryType INSTALL_SIZE = new ConfigEntryType("InstallSize") {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#isAllowed(java.lang
- * .String)
- */
+ INSTALL_SIZE("InstallSize") {
@Override
public boolean isAllowed(String value) {
try {
@@ -767,13 +428,6 @@
}
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#convert(java.lang
- * .String)
- */
@Override
public Object convert(String input) {
try {
@@ -782,373 +436,253 @@
return null;
}
}
+ },
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3256720680388408370L;
- };
-
/**
* The date that this version of the book was last updated. Informational
* only.
*/
- public static final ConfigEntryType SWORD_VERSION_DATE = new ConfigEntryType("SwordVersionDate") {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#isAllowed(java.lang
- * .String)
- */
+ SWORD_VERSION_DATE("SwordVersionDate") {
@Override
public boolean isAllowed(String value) {
return validDatePattern.matcher(value).matches();
}
private Pattern validDatePattern = Pattern.compile("\\d{4}-\\d{2}-\\d{2}");
+ },
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3618697504682948150L;
- };
-
/**
- * A list of prior "initials" for the current book.
- * TODO(dms): when a user installs a book with an obsoletes that matches
- * an installed book, offer the user the opportunity to delete the old book.
+ * A list of prior "initials" for the current book. TODO(dms): when a user
+ * installs a book with an obsoletes that matches an installed book, offer
+ * the user the opportunity to delete the old book.
*/
- public static final ConfigEntryType OBSOLETES = new ConfigEntryType("Obsoletes") {
-
- /*
- * (non-Javadoc)
- *
- * @see org.crosswire.jsword.book.sword.ConfigEntryType#mayRepeat()
- */
+ OBSOLETES("Obsoletes") {
@Override
public boolean mayRepeat() {
return true;
}
- /*
- * (non-Javadoc)
- *
- * @see org.crosswire.jsword.book.sword.ConfigEntryType#reportDetails()
- */
@Override
public boolean reportDetails() {
return false;
}
+ },
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3258412850157400372L;
- };
-
/**
* Informational copyright notice.
*/
- public static final ConfigEntryType COPYRIGHT = new ConfigEntryType("Copyright") {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#allowsContinuation()
- */
+ COPYRIGHT("Copyright") {
@Override
public boolean allowsContinuation() {
return true;
}
+ },
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3256441412957517110L;
- };
-
/**
* single value string, unknown use
*/
- public static final ConfigEntryType COPYRIGHT_HOLDER = new ConfigEntryType("CopyrightHolder");
+ COPYRIGHT_HOLDER("CopyrightHolder"),
/**
- * Copyright info. Informational only. This is a year, a year range or a
- * comma separated list of these.
+ * Copyright info. Informational only.
+ * This is a year, a year range or a comma separated list of these.
*/
- public static final ConfigEntryType COPYRIGHT_DATE = new ConfigEntryType("CopyrightDate") {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#isAllowed(java.lang
- * .String)
- */
+ COPYRIGHT_DATE("CopyrightDate") {
@Override
public boolean isAllowed(String value) {
return validDatePattern.matcher(value).matches();
}
private Pattern validDatePattern = Pattern.compile("\\d{4}(\\s*-\\s*\\d{4})?(\\s*,\\s*\\d{4}(\\s*-\\s*\\d{4})?)*");
+ },
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3258126977217935671L;
- };
-
/**
* Copyright info. Informational only.
*/
- public static final ConfigEntryType COPYRIGHT_NOTES = new ConfigEntryType("CopyrightNotes") {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#allowsContinuation()
- */
+ COPYRIGHT_NOTES("CopyrightNotes") {
@Override
public boolean allowsContinuation() {
return true;
}
- /*
- * (non-Javadoc)
- *
- * @see org.crosswire.jsword.book.sword.ConfigEntryType#allowsRTF()
- */
@Override
public boolean allowsRTF() {
return true;
}
+ },
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3906926794258199608L;
- };
-
/**
* Copyright info. Informational only.
*/
- public static final ConfigEntryType COPYRIGHT_CONTACT_NAME = new ConfigEntryType("CopyrightContactName") {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#allowsContinuation()
- */
+ COPYRIGHT_CONTACT_NAME("CopyrightContactName") {
@Override
public boolean allowsContinuation() {
return true;
}
- /*
- * (non-Javadoc)
- *
- * @see org.crosswire.jsword.book.sword.ConfigEntryType#allowsRTF()
- */
@Override
public boolean allowsRTF() {
return true;
}
+ },
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3257001060181620787L;
- };
-
/**
* Copyright info. Informational only.
*/
- public static final ConfigEntryType COPYRIGHT_CONTACT_NOTES = new ConfigEntryType("CopyrightContactNotes") {
+ COPYRIGHT_CONTACT_NOTES("CopyrightContactNotes") {
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#allowsContinuation()
- */
@Override
public boolean allowsContinuation() {
return true;
}
- /*
- * (non-Javadoc)
- *
- * @see org.crosswire.jsword.book.sword.ConfigEntryType#allowsRTF()
- */
@Override
public boolean allowsRTF() {
return true;
}
+ },
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3257001060181620787L;
- };
-
/**
* Copyright info. Informational only.
*/
- public static final ConfigEntryType COPYRIGHT_CONTACT_ADDRESS = new ConfigEntryType("CopyrightContactAddress") {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#allowsContinuation()
- */
+ COPYRIGHT_CONTACT_ADDRESS("CopyrightContactAddress") {
@Override
public boolean allowsContinuation() {
return true;
}
- /*
- * (non-Javadoc)
- *
- * @see org.crosswire.jsword.book.sword.ConfigEntryType#allowsRTF()
- */
@Override
public boolean allowsRTF() {
return true;
}
+ },
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3256721784077365556L;
- };
-
/**
* Copyright info. Informational only.
*/
- public static final ConfigEntryType COPYRIGHT_CONTACT_EMAIL = new ConfigEntryType("CopyrightContactEmail");
+ COPYRIGHT_CONTACT_EMAIL("CopyrightContactEmail"),
/**
* A one line promo statement, required by Lockman for NASB
*/
- public static final ConfigEntryType SHORT_PROMO = new ConfigEntryType("ShortPromo");
+ SHORT_PROMO("ShortPromo"),
/**
* A one line copyright statement, required by Lockman for NASB
*/
- public static final ConfigEntryType SHORT_COPYRIGHT = new ConfigEntryType("ShortCopyright");
+ SHORT_COPYRIGHT("ShortCopyright"),
/**
* Copyright info. Informational only.
*/
- public static final ConfigEntryType DISTRIBUTION_LICENSE = new ConfigEntryPickType("DistributionLicense", LICENSE_PICKS, LICENSE_PICKS[0]);
+ DISTRIBUTION_LICENSE("DistributionLicense", 0,
+ "Public Domain",
+ "Copyrighted",
+ "Copyrighted; Free non-commercial distribution",
+ "Copyrighted; Permission to distribute granted to CrossWire",
+ "Copyrighted; Freely distributable",
+ "Copyrighted; Permission granted to distribute non-commercially in Sword format",
+ "GFDL",
+ "GPL",
+ "Creative Commons: by-nc-nd",
+ "Creative Commons: by-nc-sa",
+ "Creative Commons: by-nc",
+ "Creative Commons: by-nd",
+ "Creative Commons: by-sa",
+ "Creative Commons: by"
+ ),
/**
* Copyright info. Informational only.
*/
- public static final ConfigEntryType DISTRIBUTION_NOTES = new ConfigEntryType("DistributionNotes") {
+ DISTRIBUTION_NOTES("DistributionNotes") {
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#allowsContinuation()
- */
@Override
public boolean allowsContinuation() {
return true;
}
+ },
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3257005453916518196L;
- };
-
/**
* Information on where the book's text was obtained.
*/
- public static final ConfigEntryType TEXT_SOURCE = new ConfigEntryType("TextSource") {
+ TEXT_SOURCE("TextSource") {
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#allowsContinuation()
- */
@Override
public boolean allowsContinuation() {
return true;
}
-
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3258126968594772272L;
- };
-
+ },
/**
+ * Contains the URL (a bare URL, not an HTML <a> link) of a web page for unlocking instructions/payment.
+ */
+ UNLOCK_URL("UnlockURL"),
+ /**
* Similar to DataPath. It gives where on the CrossWire server the book can
* be found. Informational only.
*/
- public static final ConfigEntryType DISTRIBUTION_SOURCE = new ConfigEntryType("DistributionSource") {
+ DISTRIBUTION_SOURCE("DistributionSource") {
- /*
- * (non-Javadoc)
- *
- * @see
- * org.crosswire.jsword.book.sword.ConfigEntryType#allowsContinuation()
- */
@Override
public boolean allowsContinuation() {
return true;
}
+ },
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3763093051127904307L;
- };
-
/**
- * single value version number, lowest sword c++ version that can read this
+ * Single value version number, lowest sword c++ version that can read this
* book JSword does not use this value.
*/
- public static final ConfigEntryType OSIS_VERSION = new ConfigEntryType("OSISVersion", "2.0");
+ OSIS_VERSION("OSISVersion", "2.0"),
/**
* The location of a collection of modules. JSword uses this to install and
* delete a module.
*/
- public static final ConfigEntryType LIBRARY_URL = new ConfigEntrySyntheticType("LibraryURL");
+ LIBRARY_URL("LibraryURL") {
+ @Override
+ public boolean isSynthetic() {
+ return true;
+ }
+ },
/**
* The location of the module. JSword uses this to access a module.
*/
- public static final ConfigEntryType LOCATION_URL = new ConfigEntrySyntheticType("LocationURL");
+ LOCATION_URL("LocationURL") {
+ @Override
+ public boolean isSynthetic() {
+ return true;
+ }
+ };
/**
* Simple ctor
*/
- protected ConfigEntryType(String name) {
- this(name, null);
+ private ConfigEntryType(String name) {
+ this.name = name;
}
/**
* Simple ctor
*/
- protected ConfigEntryType(String name, Object defaultValue) {
+ private ConfigEntryType(String name, String defaultValue) {
this.name = name;
- this.defaultValue = defaultValue;
+ this.defaultValue = convert(defaultValue);
}
/**
+ * Simple ctor
+ */
+ private ConfigEntryType(String name, int defaultPick, String... picks) {
+ this.name = name;
+ if (defaultPick >= 0 && defaultPick < picks.length) {
+ this.defaultValue = picks[defaultPick];
+ }
+ this.picks = picks;
+ }
+
+ /**
* Returns the normalized name of this ConfigEntry.
*
* @return the name
@@ -1166,6 +700,15 @@
* @return true if the string is allowed
*/
public boolean isAllowed(String value) {
+ if (hasChoices()) {
+ for (String pick : picks) {
+ if (pick.equalsIgnoreCase(value)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
return value != null;
}
@@ -1177,13 +720,30 @@
* @return either value or a modified version of it.
*/
public String filter(String value) {
+ // Look through the choice array, if present, for matches.
+ if (hasChoices()) {
+ // Do we have an exact match?
+ for (String pick : picks) {
+ if (pick.equals(value)) {
+ return value;
+ }
+ }
+
+ // Do we have a case insensitive match?
+ for (String pick : picks) {
+ if (pick.equalsIgnoreCase(value)) {
+ return pick;
+ }
+ }
+ }
+
return value;
}
/**
* RTF is allowed in a few config entries.
*
- * @return true if rtf is allowed
+ * @return true if RTF is allowed
*/
public boolean allowsRTF() {
return false;
@@ -1226,7 +786,7 @@
* @return true if this ConfigEntryType can occur more than once
*/
protected boolean hasChoices() {
- return false;
+ return picks != null;
}
/**
@@ -1269,8 +829,7 @@
return ConfigEntryType.HISTORY;
}
- for (int i = 0; i < VALUES.length; i++) {
- ConfigEntryType o = VALUES[i];
+ for (ConfigEntryType o : ConfigEntryType.values()) {
if (name.equals(o.name)) {
return o;
}
@@ -1284,41 +843,7 @@
return null;
}
- /**
- * Lookup method to convert from an integer
- */
- public static ConfigEntryType fromInteger(int i) {
- return VALUES[i];
- }
-
- /**
- * Prevent subclasses from overriding canonical identity based Object
- * methods
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
- public final boolean equals(Object o) {
- return super.equals(o);
- }
-
- /**
- * Prevent subclasses from overriding canonical identity based Object
- * methods
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public final int hashCode() {
- return super.hashCode();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
public String toString() {
return name;
}
@@ -1334,32 +859,15 @@
private Object defaultValue;
/**
- * Serialization ID
+ * The array of choices.
*/
- private static final long serialVersionUID = 3258125873411273014L;
+ private String[] picks;
- // Support for serialization
- private static int nextObj;
- private final int obj = nextObj++;
+ /**
+ * Constants for direction
+ */
+ public static final String DIRECTION_LTOR = "LtoR";
+ public static final String DIRECTION_RTOL = "RtoL";
+ public static final String DIRECTION_BIDI = "bidi";
- Object readResolve() {
- return VALUES[obj];
- }
-
- private static final ConfigEntryType[] VALUES = {
- INITIALS, DATA_PATH, DESCRIPTION, MOD_DRV,
-
- COMPRESS_TYPE, BLOCK_TYPE, BLOCK_COUNT, KEY_TYPE, CIPHER_KEY, VERSIFICATION,
-
- GLOBAL_OPTION_FILTER, DIRECTION, SOURCE_TYPE, ENCODING, DISPLAY_LEVEL, FONT, OSIS_Q_TO_TICK, FEATURE, GLOSSARY_FROM, GLOSSARY_TO,
-
- ABBREVIATION, ABOUT, VERSION, HISTORY, MINIMUM_VERSION, CATEGORY, LCSH, LANG, INSTALL_SIZE, SWORD_VERSION_DATE, OBSOLETES,
-
- COPYRIGHT, COPYRIGHT_HOLDER, COPYRIGHT_DATE, COPYRIGHT_NOTES, COPYRIGHT_CONTACT_NAME, COPYRIGHT_CONTACT_NOTES, COPYRIGHT_CONTACT_ADDRESS,
- COPYRIGHT_CONTACT_EMAIL, SHORT_PROMO, SHORT_COPYRIGHT, DISTRIBUTION_LICENSE, DISTRIBUTION_NOTES, TEXT_SOURCE,
-
- DISTRIBUTION_SOURCE, OSIS_VERSION,
-
- LIBRARY_URL, LOCATION_URL,
- };
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/index/IndexStatus.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/index/IndexStatus.java 2011-04-04 23:56:35 UTC (rev 2144)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/index/IndexStatus.java 2011-04-05 01:15:52 UTC (rev 2145)
@@ -21,7 +21,6 @@
*/
package org.crosswire.jsword.index;
-import java.io.Serializable;
/**
* An Enumeration of the possible states of an index.
@@ -31,40 +30,33 @@
* @author Joe Walker [joe at eireneh dot com]
* @author DM Smith [dmsmith555 at yahoo dot com]
*/
-public final class IndexStatus implements Serializable {
+public enum IndexStatus {
/**
* There is a complete and ready to use search index
*/
- public static final IndexStatus DONE = new IndexStatus("Indexed");
+ DONE("Indexed"),
/**
* There is no search index, and no plans to create one
*/
- public static final IndexStatus UNDONE = new IndexStatus("No Index");
+ UNDONE("No Index"),
/**
* This Book has been scheduled for index creation
*/
- public static final IndexStatus SCHEDULED = new IndexStatus("Scheduled");
+ SCHEDULED("Scheduled"),
/**
* An index is currently being generated for this Book
*/
- public static final IndexStatus CREATING = new IndexStatus("Creating");
+ CREATING("Creating"),
/**
* An index is no longer valid and needs to be discarded.
*/
- public static final IndexStatus INVALID = new IndexStatus("Invalid");
+ INVALID("Invalid");
/**
- * All the known values
- */
- private static final IndexStatus[] VALUES = {
- DONE, UNDONE, SCHEDULED, CREATING, INVALID
- };
-
- /**
* @param name
* The name of the BookCategory
*/
@@ -76,8 +68,7 @@
* Lookup method to convert from a String
*/
public static IndexStatus fromString(String name) {
- for (int i = 0; i < VALUES.length; i++) {
- IndexStatus o = VALUES[i];
+ for (IndexStatus o: IndexStatus.values()) {
if (o.name.equalsIgnoreCase(name)) {
return o;
}
@@ -87,38 +78,14 @@
return null;
}
- /**
- * Lookup method to convert from an integer
- */
- public static IndexStatus fromInteger(int i) {
- return VALUES[i];
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
@Override
public String toString() {
return name;
}
/**
- * The name of the BookCategory
+ * The name of the IndexStatus
*/
private String name;
- // Support for serialization
- private static int nextObj;
- private final int obj = nextObj++;
-
- Object readResolve() {
- return VALUES[obj];
- }
-
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3256718472791537204L;
}
More information about the jsword-svn
mailing list