com.ds.fw.types.collections
Class FwList

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.ArrayList
                    |
                    +--com.ds.fw.types.collections.FwList
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, FwCopyableIF, FwDisplayableIF, FwListIF, java.util.List, java.util.RandomAccess, java.io.Serializable

public class FwList
extends java.util.ArrayList
implements FwListIF

This class is a subclass of the ArrayList class. It implements the FwListIF interface which adds some convenient methodsbut does not add any new core functionality to the ArrayList.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
FwList()
          Default constructor method.
FwList(java.util.Collection c)
          Constructor.
FwList(java.util.Iterator i)
          Constructor.
 
Method Summary
 void addAll(java.util.Iterator i)
          Adds to the list the collection the given iterator points.
 boolean addAssociation(java.lang.Object key, java.lang.Object value)
          Adds an association object to the list.
 boolean addInt(int value)
          Adds an int value to the list.
 boolean containsInt(int value)
          Checks if the list contains a value.
 com.ds.fw.types.collections.FwCursorIteratorIF cursorIterator()
          Gets a FwCursorIterator for the list.
 com.ds.fw.types.FwCodeIF findCode(java.lang.String s)
          Finds an element of the list with the given code s.
 com.ds.fw.types.FwIdIF findId(java.lang.String s)
          Finds an element of the list with the given id s.
 java.lang.String getClassName()
          Returns the class name of the current instance.
 java.lang.Object getClone()
          Clones the list.
 java.lang.Object getCopy()
          Clones the list.
 java.lang.Object getCopy(java.lang.Object e)
          Clones the object e.
 java.lang.Object getDeepCopy()
          Copies the list.
 java.lang.String getDisplayString()
          Returns the class name and the size of the list.
 java.lang.String getDisplayStringFor(java.lang.Object e)
          Gets the String representstion of the object e.
 java.lang.Object getFirst()
          Gets the first element of the list.
 java.lang.String getFullDisplayString()
          Returns a String representation of the list content.
 int getIntAt(int index)
          Gets the int value with index index.
 java.lang.Object getLast()
          Gets the last element of the list.
 java.lang.String getString(int i)
          Gets the element at position i and casts it to String.
 boolean hasCode(java.lang.String s)
          Checks if the list contains element with the given code.
 boolean hasId(java.lang.String s)
          Checks if the list contains element with the given id.
 java.util.Iterator iterator()
          Gets an Iterator for the list.
 java.util.ListIterator listIterator()
          Gets a ListIterator for the list.
 boolean matches(java.util.Collection c)
          Compares the current list with the given collection c
 void postCopy()
          Copies elements content.
 void removeDuplicateInstances()
          Removes duplicated elements from the list.
 boolean removeInt(int value)
          Removes the value from the list.
 boolean reorderIds(java.util.List ids)
          Reorders the list by the order of the IDs in the given list ids.
 void replaceAll(java.util.Collection c)
          Replaces the list content with that of the given collection.
 void replaceAll(java.util.Iterator i)
          Replaces the list content with that the given iterator points.
 void reverse()
          Reverses the order of the list elements.
 java.util.Iterator reverseIterator()
          Gets an Iterator for the list, which works backward, the opposite of the standart Iterator.
 void setIntAt(int index, int value)
          Sets an int value at position index
 void shuffle()
          Shuffles the list.
 void sort()
          Sorts the list.
 void sort(java.util.Comparator c)
          Sorts the list using the given comparator.
 java.lang.String toString()
          Returns the class name and the size of the list.
 java.lang.String toStringValue()
          Returns the size of the list.
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, remove, removeAll, retainAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, lastIndexOf, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray
 

Constructor Detail

FwList

public FwList()
Default constructor method.


FwList

public FwList(java.util.Collection c)
Constructor. Initializes the list with the given collection

Parameters:
c - a collection object

FwList

public FwList(java.util.Iterator i)
Constructor. Initializes the list using the given iterator.

Parameters:
i - an iterator object
Method Detail

getString

public java.lang.String getString(int i)
Gets the element at position i and casts it to String.

Specified by:
getString in interface FwListIF
Parameters:
i - an element's index
Returns:
a String representation of the element
Throws:
java.lang.IndexOutOfBoundsException - if i is not in the array bounds

getCopy

public java.lang.Object getCopy()
Clones the list. This method uses getClone() method.

Specified by:
getCopy in interface FwListIF
Returns:
the copy of the list
Throws:
FwFatalException - if could not clone
See Also:
FwCopyableIF

getCopy

public java.lang.Object getCopy(java.lang.Object e)
Clones the object e. This method uses getCopy() method of the FwCopyableIF interface.

Specified by:
getCopy in interface FwCopyableIF
Returns:
the copy of the object
Throws:
UsupportedOperationException - the object does not implements FwCopyableIF interface.

getDeepCopy

public java.lang.Object getDeepCopy()
Copies the list. This method copies the list content.

Specified by:
getDeepCopy in interface FwListIF
Returns:
a deep copy of the list
See Also:
FwCopyableIF

postCopy

public void postCopy()
Copies elements content.

Specified by:
postCopy in interface FwCopyableIF

getClone

public java.lang.Object getClone()
Clones the list.

Specified by:
getClone in interface FwCopyableIF
Returns:
the copy of the list
Throws:
FwFatalException - if could not clone

toString

public java.lang.String toString()
Returns the class name and the size of the list.

Specified by:
toString in interface FwDisplayableIF
Overrides:
toString in class java.util.AbstractCollection

toStringValue

public java.lang.String toStringValue()
Returns the size of the list.

Specified by:
toStringValue in interface FwDisplayableIF

getDisplayString

public java.lang.String getDisplayString()
Returns the class name and the size of the list.

Specified by:
getDisplayString in interface FwDisplayableIF

getDisplayStringFor

public java.lang.String getDisplayStringFor(java.lang.Object e)
Gets the String representstion of the object e.

Specified by:
getDisplayStringFor in interface FwDisplayableIF

getClassName

public java.lang.String getClassName()
Returns the class name of the current instance. The returned name is not the full one but only the class name.

Specified by:
getClassName in interface FwDisplayableIF

getFullDisplayString

public java.lang.String getFullDisplayString()
Returns a String representation of the list content.

Specified by:
getFullDisplayString in interface FwListIF

iterator

public java.util.Iterator iterator()
Gets an Iterator for the list.

Specified by:
iterator in interface java.util.List
Overrides:
iterator in class java.util.AbstractList
Returns:
an Iterator object

listIterator

public java.util.ListIterator listIterator()
Gets a ListIterator for the list.

Specified by:
listIterator in interface java.util.List
Overrides:
listIterator in class java.util.AbstractList
Returns:
an ListIterator object

cursorIterator

public com.ds.fw.types.collections.FwCursorIteratorIF cursorIterator()
Gets a FwCursorIterator for the list. This iterator does not throws exceptions but its methods return null if any problem arise.

Specified by:
cursorIterator in interface FwListIF
Returns:
an FwCursorIterator interface object

reverseIterator

public java.util.Iterator reverseIterator()
Gets an Iterator for the list, which works backward, the opposite of the standart Iterator.

Specified by:
reverseIterator in interface FwListIF
Returns:
an Iterator object

getFirst

public java.lang.Object getFirst()
Gets the first element of the list.

Specified by:
getFirst in interface FwListIF

getLast

public java.lang.Object getLast()
Gets the last element of the list.

Specified by:
getLast in interface FwListIF

findId

public com.ds.fw.types.FwIdIF findId(java.lang.String s)
Finds an element of the list with the given id s.

Specified by:
findId in interface FwListIF
Parameters:
s - the id to search for
Returns:
the id if found or null otherwise

findCode

public com.ds.fw.types.FwCodeIF findCode(java.lang.String s)
Finds an element of the list with the given code s.

Specified by:
findCode in interface FwListIF
Parameters:
s - the code to search for
Returns:
the code if found or null otherwise

hasId

public boolean hasId(java.lang.String s)
Checks if the list contains element with the given id.

Specified by:
hasId in interface FwListIF
Parameters:
s - the id to search for
Returns:
true if found otherwise false
See Also:
findId(String)

hasCode

public boolean hasCode(java.lang.String s)
Checks if the list contains element with the given code.

Specified by:
hasCode in interface FwListIF
Parameters:
s - the code to search for
Returns:
true if found otherwise false
See Also:
findCode(String)

matches

public boolean matches(java.util.Collection c)
Compares the current list with the given collection c

Specified by:
matches in interface FwListIF
Returns:
true if the content is same otherwise false

addInt

public boolean addInt(int value)
Adds an int value to the list.

Specified by:
addInt in interface FwListIF
Parameters:
value - the value to be added
Returns:
true if successfuly added otherwise false

removeInt

public boolean removeInt(int value)
Removes the value from the list.

Specified by:
removeInt in interface FwListIF
Parameters:
value - the value to be removed
Returns:
true if successfuly removed otherwise false

containsInt

public boolean containsInt(int value)
Checks if the list contains a value.

Specified by:
containsInt in interface FwListIF
Parameters:
value - the value to be searched
Returns:
true if found otherwise false

getIntAt

public int getIntAt(int index)
Gets the int value with index index.

Specified by:
getIntAt in interface FwListIF
Parameters:
index - the index
Returns:
the value

setIntAt

public void setIntAt(int index,
                     int value)
Sets an int value at position index

Specified by:
setIntAt in interface FwListIF
Parameters:
index - the position
value - the value

addAssociation

public boolean addAssociation(java.lang.Object key,
                              java.lang.Object value)
Adds an association object to the list.

Specified by:
addAssociation in interface FwListIF
Parameters:
key - object's key
value - object's value
Returns:
true if successfuly added otherwise false

reverse

public void reverse()
Reverses the order of the list elements.

Specified by:
reverse in interface FwListIF

replaceAll

public void replaceAll(java.util.Collection c)
Replaces the list content with that of the given collection.

Specified by:
replaceAll in interface FwListIF
Parameters:
c - the collection which content replaces the current list content
See Also:
replaceAll(Iterator)

replaceAll

public void replaceAll(java.util.Iterator i)
Replaces the list content with that the given iterator points.

Specified by:
replaceAll in interface FwListIF
Parameters:
i - the iterator

addAll

public void addAll(java.util.Iterator i)
Adds to the list the collection the given iterator points.

Specified by:
addAll in interface FwListIF
Parameters:
i - the iterator

sort

public void sort()
Sorts the list. This method uses the Collection.sort() method.

Specified by:
sort in interface FwListIF

sort

public void sort(java.util.Comparator c)
Sorts the list using the given comparator. This method uses the Collection.sort() method.

Specified by:
sort in interface FwListIF
Parameters:
c - the comparator

reorderIds

public boolean reorderIds(java.util.List ids)
Reorders the list by the order of the IDs in the given list ids. The elements of the current list have to have IDs.

Specified by:
reorderIds in interface FwListIF
Parameters:
ids - list with new ID order
Returns:
true if successfuly reordered otherwise false

shuffle

public void shuffle()
Shuffles the list.

Specified by:
shuffle in interface FwListIF

removeDuplicateInstances

public void removeDuplicateInstances()
Removes duplicated elements from the list.

Specified by:
removeDuplicateInstances in interface FwListIF