org.apache.pivot.wtk.content
Class CalendarDateSpinnerData

java.lang.Object
  extended by org.apache.pivot.wtk.content.CalendarDateSpinnerData
All Implemented Interfaces:
Iterable<CalendarDate>, Collection<CalendarDate>, List<CalendarDate>, Sequence<CalendarDate>

public class CalendarDateSpinnerData
extends Object
implements List<CalendarDate>

Spinner data model that presents a bounded list of calendar dates.

This is a lightweight class that spoofs the actual list data by using an internal calendar instance from which CalendarDate instances are created on demand.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.pivot.collections.List
List.ItemIterator<T>, List.ListListenerList<T>
 
Nested classes/interfaces inherited from interface org.apache.pivot.collections.Sequence
Sequence.Tree<T>
 
Constructor Summary
CalendarDateSpinnerData()
          Creates a new CalendarDateSpinnerData bounded from 1900-01-01 to 2099-12-31.
CalendarDateSpinnerData(CalendarDate lowerBound, CalendarDate upperBound)
          Creates a new CalendarDateSpinnerData bounded by the specified calendar dates (inclusive).
 
Method Summary
 int add(CalendarDate item)
          Throws UnsupportedOperationException.
 void clear()
          Throws UnsupportedOperationException.
 CalendarDate get(int index)
          Gets the calendar date at the specified index.
 Comparator<CalendarDate> getComparator()
          Gets the comparator for this list, which is guaranteed to always be null.
 int getLength()
          Gets the number of entries in this list.
 ListenerList<ListListener<CalendarDate>> getListListeners()
          Returns the list listener list.
 int indexOf(CalendarDate item)
          Returns the index of an item in the sequence.
 void insert(CalendarDate item, int index)
          Throws UnsupportedOperationException.
 boolean isEmpty()
          Tests the emptiness of the collection.
 Iterator<CalendarDate> iterator()
           
 int remove(CalendarDate item)
          Throws UnsupportedOperationException.
 Sequence<CalendarDate> remove(int index, int count)
          Throws UnsupportedOperationException.
 void setComparator(Comparator<CalendarDate> comparator)
          Throws UnsupportedOperationException.
 CalendarDate update(int index, CalendarDate item)
          Throws UnsupportedOperationException.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CalendarDateSpinnerData

public CalendarDateSpinnerData()
Creates a new CalendarDateSpinnerData bounded from 1900-01-01 to 2099-12-31.


CalendarDateSpinnerData

public CalendarDateSpinnerData(CalendarDate lowerBound,
                               CalendarDate upperBound)
Creates a new CalendarDateSpinnerData bounded by the specified calendar dates (inclusive).

Parameters:
lowerBound - The earliest date to include in this spinner data.
upperBound - The latest date to include in this spinner data.
Method Detail

add

public int add(CalendarDate item)
Throws UnsupportedOperationException.

Specified by:
add in interface List<CalendarDate>
Specified by:
add in interface Sequence<CalendarDate>
Parameters:
item - The item to be added to the sequence.
Returns:
The index at which the item was added.
See Also:
ListListener.itemInserted(List, int)

insert

public void insert(CalendarDate item,
                   int index)
Throws UnsupportedOperationException.

Specified by:
insert in interface List<CalendarDate>
Specified by:
insert in interface Sequence<CalendarDate>
Parameters:
item - The item to be added to the list.
index - The index at which the item should be inserted. Must be a value between 0 and getLength().
See Also:
ListListener.itemInserted(List, int)

update

public CalendarDate update(int index,
                           CalendarDate item)
Throws UnsupportedOperationException.

Specified by:
update in interface List<CalendarDate>
Specified by:
update in interface Sequence<CalendarDate>
Parameters:
index - The index of the item to update.
item - The item that will replace any existing value at the given index.
Returns:
The item that was previously stored at the given index.
See Also:
ListListener.itemUpdated(List, int, Object)

remove

public int remove(CalendarDate item)
Throws UnsupportedOperationException.

Specified by:
remove in interface Sequence<CalendarDate>
Parameters:
item - The item to remove.
Returns:
The index of the item that was removed, or -1 if the item could not be found.
See Also:
Sequence.remove(int, int)

remove

public Sequence<CalendarDate> remove(int index,
                                     int count)
Throws UnsupportedOperationException.

Specified by:
remove in interface List<CalendarDate>
Specified by:
remove in interface Sequence<CalendarDate>
Parameters:
index - The starting index to remove.
count - The number of items to remove, beginning with index.
Returns:
A sequence containing the items that were removed.
See Also:
ListListener.itemsRemoved(List, int, Sequence)

get

public CalendarDate get(int index)
Gets the calendar date at the specified index.

Specified by:
get in interface Sequence<CalendarDate>
Parameters:
index - The index of the calendar date to retrieve.

indexOf

public int indexOf(CalendarDate item)
Description copied from interface: Sequence
Returns the index of an item in the sequence.

Specified by:
indexOf in interface Sequence<CalendarDate>
Parameters:
item - The item to locate.
Returns:
The index of first occurrence of the item if it exists in the sequence; -1, otherwise.

clear

public void clear()
Throws UnsupportedOperationException.

Specified by:
clear in interface Collection<CalendarDate>
Specified by:
clear in interface List<CalendarDate>
See Also:
ListListener.itemsRemoved(List, int, Sequence)

isEmpty

public boolean isEmpty()
Description copied from interface: Collection
Tests the emptiness of the collection.

Specified by:
isEmpty in interface Collection<CalendarDate>
Returns:
true if the collection contains no elements; false, otherwise.

getLength

public int getLength()
Gets the number of entries in this list.

Specified by:
getLength in interface List<CalendarDate>
Specified by:
getLength in interface Sequence<CalendarDate>
Returns:
The number of calendar dates in this list.

getComparator

public Comparator<CalendarDate> getComparator()
Gets the comparator for this list, which is guaranteed to always be null. This class does not support comparators since there's no real data to sort (it's all spoofed).

Specified by:
getComparator in interface Collection<CalendarDate>
Returns:
The comparator used to order elements in the collection, or null if the sort order is undefined.
See Also:
Collection.setComparator(Comparator)

setComparator

public void setComparator(Comparator<CalendarDate> comparator)
Throws UnsupportedOperationException.

Specified by:
setComparator in interface Collection<CalendarDate>
Specified by:
setComparator in interface List<CalendarDate>
Parameters:
comparator - The comparator used to order elements in the collection, or null if the collection is unsorted.
See Also:
ListListener.comparatorChanged(List, Comparator)

iterator

public Iterator<CalendarDate> iterator()
Specified by:
iterator in interface Iterable<CalendarDate>

getListListeners

public ListenerList<ListListener<CalendarDate>> getListListeners()
Description copied from interface: List
Returns the list listener list.

Specified by:
getListListeners in interface List<CalendarDate>