OpMath

com.opmath.util.datastruct
Interface ComparableList

All Known Implementing Classes:
ComparableResultSet, ComparableVector, ComparableArray, ComparableArrayRO

public interface ComparableList

The interface required for a column of a DisplayTable

An object that implements the ComparableList interface can act as a column within a DisplayTable. Note that column objects are not required to support CREATE, UPDATE or DELETE operations.

Copyright: (c) 2002 The Open Math Company Limited

The Terms of Distribution of this software are stipulated in the javadoc Overview for this project.

Since:
J2SE 1.3
Version:
DataStruct v1.0 r1
Author:
Bruno Beloff bruno.beloff@opmath.com

Method Summary
 boolean add(Comparable element)
          Appends the specified element to the end of this ComparableList.
 void clear()
          Removes all of the elements from this ComparableList.
 Enumeration elements()
          Returns an enumeration of the components of this ComparableList.
 Object get(int index)
          Returns the element at the specified position in this ComparableList.
 int indexOf(Object element)
          Searches for the first occurence of the given argument, testing for equality using the equals(Object) method.
 Comparable set(int index, Comparable element)
          Replaces the element at the specified position in this list with the specified element.
 int size()
          Returns the number of elements in this list.
 String toString()
          Returns a string representation of the implementing object, containing a String representation of each element.
 

Method Detail

elements

public Enumeration elements()
Returns an enumeration of the components of this ComparableList. The returned Enumeration object will generate all items in this list.

Returns:
an enumeration of the components of this list.
Since:
J2SE 1.3

clear

public void clear()
Removes all of the elements from this ComparableList. This list will be empty after this call returns.

NOTE: All implementations of ComparableList must support the clear() method. However, implementations are free to interpret the clear function in any way, and may in fact do nothing.

Since:
J2SE 1.3

add

public boolean add(Comparable element)
            throws UnsupportedOperationException
Appends the specified element to the end of this ComparableList.

Lists may place limitations on what elements may be added to this list. In particular, some lists will refuse to add null elements, and others will impose restrictions on the type of elements that may be added.

Parameters:
element - the Comparable to be added.
Returns:
true (as per the general contract of the Collection.add method).
Since:
J2SE 1.3

set

public Comparable set(int index,
                      Comparable element)
               throws UnsupportedOperationException
Replaces the element at the specified position in this list with the specified element.

Lists may place limitations on what elements may be added to this list. In particular, some lists will refuse to add null elements, and others will impose restrictions on the type of elements that may be added.

Parameters:
index - the int index of element to replace.
element - the Comparable element to be stored at the specified position.
Throws:
UnsupportedOperationException - if the set(int,Comparable) method is not supported by this list.
Since:
J2SE 1.3

get

public Object get(int index)
           throws IndexOutOfBoundsException
Returns the element at the specified position in this ComparableList.

Parameters:
index - the int index of element.
Returns:
the Object at the specified position in this list.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).
Since:
J2SE 1.3

indexOf

public int indexOf(Object element)
Searches for the first occurence of the given argument, testing for equality using the equals(Object) method.

Parameters:
index - the Comparable element.
Returns:
the index of the first occurrence of the argument in this vector, that is, the smallest value k such that elem.equals(elementData[k]) is true; returns -1 if the object is not found.
Since:
J2SE 1.3

size

public int size()
Returns the number of elements in this list. If this list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:
the number of elements in this list.
Since:
J2SE 1.3

toString

public String toString()
Returns a string representation of the implementing object, containing a String representation of each element.

Overrides:
toString in class Object
Returns:
a string representation of this list.
Since:
J2SE 1.3

OpMath

Submit a bug or feature to Open Math
Copyright © 2002 Open Math Company Limited, Brighton, UK