org.crosswire.jsword.passage
Class AbstractKeyList

java.lang.Object
  extended by org.crosswire.jsword.passage.AbstractKeyList
All Implemented Interfaces:
Serializable, Cloneable, Comparable, Iterable, Key
Direct Known Subclasses:
DefaultKeyList, SetKeyList, TreeKey

public abstract class AbstractKeyList
extends Object
implements Key

An implementation of some of the easier methods from Key.

Author:
Joe Walker [joe at eireneh dot com]
See Also:
for license details. The copyright to this program is held by it's authors., Serialized Form

Nested Class Summary
(package private) static class AbstractKeyList.NameVisitor
          The NameVisitor constructs a readable representation of the Passage.
(package private) static class AbstractKeyList.OsisIDVisitor
          The OsisRefVisitor constructs a readable representation of the Passage, using OSIS names.
(package private) static class AbstractKeyList.OsisRefVisitor
          The OsisRefVisitor constructs a readable representation of the Passage, using OSIS names.
 
Field Summary
private  String name
          The common user visible name for this work
 
Constructor Summary
protected AbstractKeyList(String name)
          Build an AbstractKeyList with the given name.
 
Method Summary
 Object clone()
          This needs to be declared here so that it is visible as a method on a derived Key.
 int compareTo(Object obj)
           
 boolean contains(Key key)
          Returns true if this set contains the specified element.
 boolean equals(Object obj)
          This needs to be declared here so that it is visible as a method on a derived Key.
 String getName()
          A Human readable version of the Key.
 String getName(Key base)
          Translate the Key into a human readable string, with the assumption that the specified Key has just been output, so if we are in the same region, we do not need to display the region name, and so on.
 String getOsisID()
          The OSIS defined id specification for this Key.
 String getOsisRef()
          The OSIS defined reference specification for this Key.
 String getRootName()
          A Human readable version of the Key's top level name.
 int hashCode()
          This needs to be declared here so that it is visible as a method on a derived Key.
 boolean isEmpty()
          Does this Key have 0 members
protected static void retain(Key alter, Key base)
          Utility to remove all the keys from alter that are not in base
 void retainAll(Key key)
          Removes all but the specified element from this set.
 void setName(String name)
          Override the default name with a custom name.
 String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.crosswire.jsword.passage.Key
addAll, blur, canHaveChildren, clear, get, getCardinality, getChildCount, getParent, indexOf, removeAll
 
Methods inherited from interface org.crosswire.common.util.Iterable
iterator
 

Field Detail

name

private String name
The common user visible name for this work

Constructor Detail

AbstractKeyList

protected AbstractKeyList(String name)
Build an AbstractKeyList with the given name.

Parameters:
name -
Method Detail

isEmpty

public boolean isEmpty()
Description copied from interface: Key
Does this Key have 0 members

Specified by:
isEmpty in interface Key
Returns:
true if this set contains no elements.

contains

public boolean contains(Key key)
Description copied from interface: Key
Returns true if this set contains the specified element.

Specified by:
contains in interface Key
Parameters:
key - element whose presence in this set is to be tested.
Returns:
true if this set contains the specified element.

retainAll

public void retainAll(Key key)
Description copied from interface: Key
Removes all but the specified element from this set.

Specified by:
retainAll in interface Key
Parameters:
key - object to be left in this set.

retain

protected static void retain(Key alter,
                             Key base)
Utility to remove all the keys from alter that are not in base

Parameters:
alter - The key to remove keys from
base - The check key

toString

public String toString()
Overrides:
toString in class Object

setName

public void setName(String name)
Override the default name with a custom name. If the name is null then a name will be generated by concatenating the names of all the elements of this node.


getName

public String getName()
Description copied from interface: Key
A Human readable version of the Key. For Biblical passages this uses short books names, and the shortest sensible rendering eg "Mat 3:1-4" and "Mar 1:1, 3, 5" and "3Jo, Jude"

Specified by:
getName in interface Key
Returns:
a String containing a description of the Key

getName

public String getName(Key base)
Description copied from interface: Key
Translate the Key into a human readable string, with the assumption that the specified Key has just been output, so if we are in the same region, we do not need to display the region name, and so on.

Specified by:
getName in interface Key
Parameters:
base - The key to use to cut down unnecessary output.
Returns:
The string representation

getRootName

public String getRootName()
Description copied from interface: Key
A Human readable version of the Key's top level name. For Biblical passages this uses short books names. For a dictionary it might return A-Z.

Specified by:
getRootName in interface Key
Returns:
a String containing a description of the Key

getOsisRef

public String getOsisRef()
Description copied from interface: Key
The OSIS defined reference specification for this Key. When the key is a single element, it is an OSIS book name with '.' separating the parts. When the key is multiple elements, it uses a range notation. Note, this will create a comma separated list of ranges, which is improper OSIS.

Specified by:
getOsisRef in interface Key
Returns:
a String containing the OSIS description of the verses

getOsisID

public String getOsisID()
Description copied from interface: Key
The OSIS defined id specification for this Key. When the key is a single element, it is an OSIS book name with '.' separating the parts. When the key is multiple elements, it uses a space to separate each.

Specified by:
getOsisID in interface Key
Returns:
a String containing the OSIS description of the verses

equals

public boolean equals(Object obj)
Description copied from interface: Key
This needs to be declared here so that it is visible as a method on a derived Key.

Specified by:
equals in interface Key
Overrides:
equals in class Object
Returns:
true if equal

hashCode

public int hashCode()
Description copied from interface: Key
This needs to be declared here so that it is visible as a method on a derived Key.

Specified by:
hashCode in interface Key
Overrides:
hashCode in class Object
Returns:
the hashcode

compareTo

public int compareTo(Object obj)
Specified by:
compareTo in interface Comparable

clone

public Object clone()
Description copied from interface: Key
This needs to be declared here so that it is visible as a method on a derived Key.

Specified by:
clone in interface Key
Overrides:
clone in class Object
Returns:
A complete copy of ourselves

Copyright ยจ 2003-2007