org.crosswire.jsword.book.sword
Class ConfigEntry

java.lang.Object
  extended by org.crosswire.jsword.book.sword.ConfigEntry

public final class ConfigEntry
extends Object

A ConfigEntry holds the value(s) for an entry of ConfigEntryType.

Author:
DM Smith [ dmsmith555 at yahoo dot com]
See Also:
for license details. The copyright to this program is held by it's authors., License

Field Summary
private static Histogram histogram
          A histogram for debugging.
private  String internal
           
private static Logger log
          The log stream
private  String name
           
private  ConfigEntryType type
           
private  String value
           
private  List values
           
 
Constructor Summary
ConfigEntry(String bookName, ConfigEntryType aType, String aValue)
          Create a ConfigEntry directly with an initial value.
ConfigEntry(String bookName, String aName)
          Create a ConfigEntry whose type is not certain and whose value is not known.
 
Method Summary
 void addValue(String val)
          Add a value to the list of values for this ConfigEntry
 boolean allowsContinuation()
          While most fields are single line or single value, some allow continuation.
 boolean allowsRTF()
          RTF is allowed in a few config entries.
static void dumpStatistics()
           
 boolean equals(Object obj)
           
 String getName()
          Get the key of this ConfigEntry
 ConfigEntryType getType()
          Get the type of this ConfigEntry
 Object getValue()
          Get the value(s) of this ConfigEntry.
private  String handleRTF(String aValue)
           
 int hashCode()
           
 boolean isAllowed(String aValue)
          Determines whether the string is allowed.
 boolean isSupported()
          Determine whether this config entry is supported.
 boolean match(Object search)
          Determine whether this Config entry matches the value.
 boolean mayRepeat()
          Some keys can repeat.
private  List processLines(OSISUtil.OSISFactory factory, String aValue)
           
private  String report(String issue, String confEntryName, String aValue)
           
 boolean reportDetails()
           
static void resetStatistics()
           
 String toConf()
          Build's a SWORD conf file as a string.
 org.jdom.Element toOSIS()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private static final Logger log
The log stream


histogram

private static Histogram histogram
A histogram for debugging.


type

private ConfigEntryType type

internal

private String internal

name

private String name

values

private List values

value

private String value
Constructor Detail

ConfigEntry

public ConfigEntry(String bookName,
                   String aName)
Create a ConfigEntry whose type is not certain and whose value is not known.

Parameters:
bookName - the internal name of the book
aName - the name of the ConfigEntry.

ConfigEntry

public ConfigEntry(String bookName,
                   ConfigEntryType aType,
                   String aValue)
Create a ConfigEntry directly with an initial value.

Parameters:
bookName - the internal name of the book
aType - the kind of ConfigEntry
aValue - the initial value for the ConfigEntry
Method Detail

getName

public String getName()
Get the key of this ConfigEntry


getType

public ConfigEntryType getType()
Get the type of this ConfigEntry


isAllowed

public boolean isAllowed(String aValue)
Determines whether the string is allowed. For some config entries, the value is expected to be one of a group, for others the format is defined.

Parameters:
aValue -
Returns:
true if the string is allowed

allowsRTF

public boolean allowsRTF()
RTF is allowed in a few config entries.

Returns:
true if rtf is allowed

allowsContinuation

public boolean allowsContinuation()
While most fields are single line or single value, some allow continuation. A continuation mark is a backslash at the end of a line. It is not to be followed by whitespace.

Returns:
true if continuation is allowed

mayRepeat

public boolean mayRepeat()
Some keys can repeat. When this happens each is a single value pick from a list of choices.

Returns:
true if this ConfigEntryType can occur more than once

reportDetails

public boolean reportDetails()

isSupported

public boolean isSupported()
Determine whether this config entry is supported.

Returns:
true if this ConfigEntry has a type.

getValue

public Object getValue()
Get the value(s) of this ConfigEntry. If mayRepeat() == true then it returns a List. Otherwise it returns a string.

Returns:
a list, value or null.

match

public boolean match(Object search)
Determine whether this Config entry matches the value.

Parameters:
search - the value to match against
Returns:
true if this ConfigEntry matches the value

addValue

public void addValue(String val)
Add a value to the list of values for this ConfigEntry


toOSIS

public org.jdom.Element toOSIS()

resetStatistics

public static void resetStatistics()

dumpStatistics

public static void dumpStatistics()

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

toConf

public String toConf()
Build's a SWORD conf file as a string. The result is not identical to the original, cleaning up problems in the original and re-arranging the entries into a predictable order.

Returns:
the well-formed conf.

handleRTF

private String handleRTF(String aValue)

processLines

private List processLines(OSISUtil.OSISFactory factory,
                          String aValue)

report

private String report(String issue,
                      String confEntryName,
                      String aValue)

Copyright ยจ 2003-2006