org.crosswire.jsword.passage
Class SetKeyList

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

public class SetKeyList
extends AbstractKeyList

A Key that uses a Set of Keys as it's store of data.

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
 
Nested classes/interfaces inherited from class org.crosswire.jsword.passage.AbstractKeyList
AbstractKeyList.NameVisitor, AbstractKeyList.OsisIDVisitor, AbstractKeyList.OsisRefVisitor
 
Field Summary
private  List list
          The Set that we are proxying to
private static Logger log
          The log stream
private  Key parent
          The parent of this key
private static long serialVersionUID
          Serialization ID
 
Constructor Summary
SetKeyList(Set set)
          Simple ctor
SetKeyList(Set set, Key parent)
          Simple ctor
SetKeyList(Set set, Key parent, String name)
          Simple ctor
SetKeyList(Set set, 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 false 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.
 boolean equals(Object obj)
          This needs to be declared here so that it is visible as a method on a derived Key.
 Key get(int index)
          Gets a key from a specific point in this list of children.
 int getCardinality()
          Returns the number of elements in this set (its cardinality).
 int getChildCount()
          Returns the number of children that this node has.
 Key getParent()
          All keys have parents unless they are the root of a Key.
 int hashCode()
          This needs to be declared here so that it is visible as a method on a derived Key.
 int indexOf(Key that)
          Reverse a Key into the position the key holds in the list of children
 boolean isEmpty()
          Does this Key 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
clone, compareTo, getName, getName, getOsisID, getOsisRef, getRootName, retain, retainAll, setName, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

private Key parent
The parent of this key


list

private List list
The Set that we are proxying to


serialVersionUID

private static final long serialVersionUID
Serialization ID

See Also:
Constant Field Values

log

private static final Logger log
The log stream

Constructor Detail

SetKeyList

public SetKeyList(Set set)
Simple ctor


SetKeyList

public SetKeyList(Set set,
                  String name)
Simple ctor


SetKeyList

public SetKeyList(Set set,
                  Key parent)
Simple ctor


SetKeyList

public SetKeyList(Set set,
                  Key parent,
                  String name)
Simple ctor

Method Detail

addAll

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

Parameters:
key - element to be added to this set.

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).


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.

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 AbstractKeyList
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 AbstractKeyList
Returns:
the hashcode

isEmpty

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

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

iterator

public Iterator iterator()

removeAll

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

Parameters:
key - object to be removed from this set, if present.

getCardinality

public int getCardinality()
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.

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

canHaveChildren

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


getChildCount

public int getChildCount()
Description copied from interface: Key
Returns the number of children that this node has. Leaf nodes return 0.


get

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

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 of children

Parameters:
that - The Key to find
Returns:
The index of the key or < 0 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.

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.

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

Copyright ยจ 2003-2007