org.crosswire.jsword.passage
Class DefaultKeyList

java.lang.Object
  extended by org.crosswire.jsword.passage.AbstractKeyList
      extended by org.crosswire.jsword.passage.DefaultKeyList
All Implemented Interfaces:
Comparable, Key

public class DefaultKeyList
extends AbstractKeyList
implements Key

A default implementation of Key.

This implementation uses java.util.TreeSet to store keys.

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: DefaultKeyList.java,v 1.5 2004/08/25 22:54:37 joe Exp $
Author:
Joe Walker [joe at eireneh dot com]
See Also:
Licence

Field Summary
private  List keys
          The store of Keys
private static Logger log
          The log stream
private  Key parent
          The parent of this key
 
Constructor Summary
DefaultKeyList()
          Simple ctor
DefaultKeyList(Key parent, String name)
          Simple ctor
 
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).
 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.
 
Methods inherited from class org.crosswire.jsword.passage.AbstractKeyList
compareTo, getName, getOSISName, retain, retainAll, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.crosswire.jsword.passage.Key
getName, getOSISName, retainAll
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

parent

private Key parent
The parent of this key


keys

private List keys
The store of Keys


log

private static final Logger log
The log stream

Constructor Detail

DefaultKeyList

public DefaultKeyList()
Simple ctor


DefaultKeyList

public DefaultKeyList(Key parent,
                      String name)
Simple ctor

Method Detail

canHaveChildren

public boolean canHaveChildren()
Description copied from interface: Key
Returns true if the receiver is a leaf node and can not have children. Any attempt to add()/remove() wlll throw

Specified by:
canHaveChildren in interface Key

getChildCount

public int getChildCount()
Description copied from interface: Key
Returns the number of elements in this set (its cardinality). If this set contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Specified by:
getChildCount in interface Key
Returns:
the number of elements in this set (its cardinality).

isEmpty

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

Specified by:
isEmpty in interface Key
Overrides:
isEmpty in class AbstractKeyList
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
Overrides:
contains in class AbstractKeyList
Parameters:
key - element whose presence in this set is to be tested.
Returns:
true if this set contains the specified element.

iterator

public Iterator iterator()
Specified by:
iterator in interface Key
Returns:
an iterator over the elements in this set.

addAll

public void addAll(Key key)
Description copied from interface: Key
Adds the specified element to this set if it is not already present.

Specified by:
addAll in interface Key
Parameters:
key - element to be added to this set.

removeAll

public void removeAll(Key key)
Description copied from interface: Key
Removes the specified elements from this set if it is present.

Specified by:
removeAll in interface Key
Parameters:
key - object to be removed from this set, if present.

clear

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

Specified by:
clear in interface Key

get

public Key get(int index)
Description copied from interface: Key
Gets a key from a specific point in this list.

Specified by:
get in interface Key
Parameters:
index - The index of the Key to retrieve
Returns:
The specified key

indexOf

public int indexOf(Key that)
Description copied from interface: Key
Reverse a Key into the position the key holds in the list

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

getParent

public Key getParent()
Description copied from interface: Key
All keys have parents unless they are the root of a Key.

Specified by:
getParent in interface Key
Returns:
The parent of this tree, or null if this Key is the root.

blur

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

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

Copyright ? 2003-2004