org.crosswire.jsword.passage
Interface Key

All Superinterfaces:
Comparable
All Known Subinterfaces:
Passage, VerseBase
All Known Implementing Classes:
AbstractKeyList, AbstractPassage, BitwisePassage, DefaultKeyList, DefaultLeafKeyList, DistinctPassage, PassageTally, RangedPassage, RawLDBackend.IndexKey, ReadingsKey, ReadOnlyKeyList, ReadOnlyPassage, RocketPassage, SetKeyList, SynchronizedPassage, Verse, VerseRange

public interface Key
extends Comparable

A Key is a Key that can contain other Keys. The interface is modelled on the java.util.Set interface customized because KeyLists can only store other Keys and simplified by making add() and remove() return void and not a boolean.

Distribution Licence:
JSword is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
The License is available on the internet here, or by writing to: Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
The copyright to this program is held by it's authors.

Version:
$Id: Key.java,v 1.4 2004/08/25 22:54:37 joe Exp $
Author:
Joe Walker [joe at eireneh dot com]
See Also:
Licence

Method Summary
 void addAll(Key key)
          Adds the specified element to this set if it is not already present.
 void blur(int by, RestrictionType restrict)
          Widen the range of the verses/keys in this list.
 boolean canHaveChildren()
          Returns true if the receiver is a leaf node and can not have children.
 void clear()
          Removes all of the elements from this set (optional operation).
 boolean contains(Key key)
          Returns true if this set contains the specified element.
 Key get(int index)
          Gets a key from a specific point in this list.
 int getChildCount()
          Returns the number of elements in this set (its cardinality).
 String getName()
          A Human readable version of the Key.
 String getOSISName()
          The OSIS defined specification for this Passage.
 Key getParent()
          All keys have parents unless they are the root of a Key.
 int indexOf(Key that)
          Reverse a Key into the position the key holds in the list
 boolean isEmpty()
          Does this Passage have 0 members
 Iterator iterator()
           
 void removeAll(Key key)
          Removes the specified elements from this set if it is present.
 void retainAll(Key key)
          Removes all but the specified element from this set.
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

getName

String getName()
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"

Returns:
a String containing a description of the Key

getOSISName

String getOSISName()
The OSIS defined specification for this Passage. Uses short books names, with "." as a verse part separator.

Returns:
a String containing the OSIS description of the verses

getParent

Key getParent()
All keys have parents unless they are the root of a Key.

Returns:
The parent of this tree, or null if this Key is the root.

canHaveChildren

boolean canHaveChildren()
Returns true if the receiver is a leaf node and can not have children. Any attempt to add()/remove() wlll throw


getChildCount

int getChildCount()
Returns the number of elements in this set (its cardinality). If this set contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:
the number of elements in this set (its cardinality).

isEmpty

boolean isEmpty()
Does this Passage have 0 members

Returns:
true if this set contains no elements.

contains

boolean contains(Key key)
Returns true if this set contains the specified element.

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

iterator

Iterator iterator()
Returns:
an iterator over the elements in this set.

addAll

void addAll(Key key)
Adds the specified element to this set if it is not already present.

Parameters:
key - element to be added to this set.
Throws:
NullPointerException - if the specified element is null

removeAll

void removeAll(Key key)
Removes the specified elements from this set if it is present.

Parameters:
key - object to be removed from this set, if present.
Throws:
NullPointerException - if the specified element is null

retainAll

void retainAll(Key key)
Removes all but the specified element from this set.

Parameters:
key - object to be left in this set.
Throws:
NullPointerException - if the specified element is null

clear

void clear()
Removes all of the elements from this set (optional operation). This set will be empty after this call returns (unless it throws an exception).


get

Key get(int index)
Gets a key from a specific point in this list.

Parameters:
index - The index of the Key to retrieve
Returns:
The specified key

indexOf

int indexOf(Key that)
Reverse a Key into the position the key holds in the list

Parameters:
that - The Key to find
Returns:
The index of the key or -1 if the key is not in the list

blur

void blur(int by,
          RestrictionType restrict)
Widen the range of the verses/keys in this list. This is primarily for "find x within n verses of y" type applications.

Parameters:
by - The number of verses/keys to widen by
restrict - How should we restrict the blurring?
See Also:
Passage

Copyright ? 2003-2004