ilog.cpl.list
Class IlpDefaultListModel

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by ilog.cpl.list.IlpDefaultListModel
All Implemented Interfaces:
AttributeValueListener, Serializable, EventListener, ListModel

public class IlpDefaultListModel
extends AbstractListModel
implements ListModel, AttributeValueListener

ILOG CPL list model. This list extends the Swing DefaultListModel. It recognizes the representation objects that are inserted and listens to their notifications, changing the AttributeValueEvents into regular ListDataEvents.

Since:
JTGO 3.0
See Also:
IlpRepresentationObject, AttributeValueEvent, Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
IlpDefaultListModel()
          Default constructor
IlpDefaultListModel(boolean listeningToAttributeValueChange)
          Creates a new model instance.
 
Method Summary
 void add(int index, Object o)
          Inserts the specified element at the specified position in this list.
 boolean add(Object o)
          Appends the specified element to this list (optional operation).
 void addAll(Collection collection)
          Adds the specified collection of elements at the end of this list.
 void attributeValueChange(AttributeValueEvent ev)
          This method is called when an attribute value is changed.
 void clear()
          Removes all of the elements from this list.
 Object get(int index)
          Returns the value at the specified index.
 Object getElementAt(int index)
          Returns the value at the specified index.
 int getSize()
          Returns the length of the list.
 int indexOf(Object o)
          Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.
 int lastIndexOf(Object o)
          Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element.
 Object remove(int index)
          Removes the element at the specified position in this list.
 boolean remove(Object o)
          Removes the first occurrence in this list of the specified element (optional operation).
 void removeRange(int fromIndex, int toIndex)
          Deletes the components at the specified range of indexes.
 Object set(int index, Object o)
          Replaces the element at the specified position in this list with the specified element.
 int size()
          Returns the length of the list.
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.ListModel
addListDataListener, removeListDataListener
 

Constructor Detail

IlpDefaultListModel

public IlpDefaultListModel()
Default constructor


IlpDefaultListModel

public IlpDefaultListModel(boolean listeningToAttributeValueChange)
Creates a new model instance.

Parameters:
listeningToAttributeValueChange - Indicates that this model will listen to attribute value change events on its contained objects.
Method Detail

getSize

public int getSize()
Returns the length of the list.

Specified by:
getSize in interface ListModel

size

public int size()
Returns the length of the list.


getElementAt

public Object getElementAt(int index)
Returns the value at the specified index.

Specified by:
getElementAt in interface ListModel

get

public Object get(int index)
Returns the value at the specified index.


attributeValueChange

public void attributeValueChange(AttributeValueEvent ev)
This method is called when an attribute value is changed.

Specified by:
attributeValueChange in interface AttributeValueListener
Internal method or field: do not use!

set

public Object set(int index,
                  Object o)
Replaces the element at the specified position in this list with the specified element.

Parameters:
index - Index of element to replace.
o - Object to be stored at the specified position.
Returns:
The element previously at the specified position.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

add

public boolean add(Object o)
Appends the specified element to this list (optional operation).

Parameters:
o - Element to be appended to this list.
Returns:
true (according to the general contract of the Collection.add method).
Internal method or field: do not use!

add

public void add(int index,
                Object o)
Inserts the specified element at the specified position in this list.

Parameters:
index - index at which the specified element is to be inserted.
o - object to be inserted.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

remove

public Object remove(int index)
Removes the element at the specified position in this list. Returns the element that was removed from the list.

Throws an IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size()).

Parameters:
index - the index of the element to removed.

remove

public boolean remove(Object o)
Removes the first occurrence in this list of the specified element (optional operation). If this list does not contain the element, it is unchanged. More formally, removes the element with the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))) (if such an element exists).

Parameters:
o - Element to be removed from this list, if present.
Returns:
true if this list contained the specified element.
Throws:
UnsupportedOperationException - if the remove method is not supported by this list.
Internal method or field: do not use!

clear

public void clear()
Removes all of the elements from this list. The list will be empty after this call returns (unless it throws an exception).


removeRange

public void removeRange(int fromIndex,
                        int toIndex)
Deletes the components at the specified range of indexes. The removal is inclusive, so specifying a range of (1,5) removes the component at index 1 and the component at index 5, as well as all components in between.

Parameters:
fromIndex - The index of the lower end of the range.
toIndex - The index of the upper end of the range.
Throws:
IndexOutOfBoundsException - if the index was invalid.
IllegalArgumentException - if fromIndex > toIndex.
See Also:
remove(int)

addAll

public void addAll(Collection collection)
Adds the specified collection of elements at the end of this list.


indexOf

public int indexOf(Object o)
Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.

Parameters:
o - Element to search for.
Returns:
The index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.
Internal method or field: do not use!

lastIndexOf

public int lastIndexOf(Object o)
Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element. More formally, returns the highest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.

Parameters:
o - Element to search for.
Returns:
The index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element.
Internal method or field: do not use!


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.   . All Rights Reserved.