All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sdsu.util.List

java.lang.Object
   |
   +----sdsu.util.List

public class List
extends Object
implements OrderedCollection, Stringizable
A List object is a vector that can convert itself to a string and "recreate" itself from that string. The original List object can contain any objects, but the recreated List object will only contain string representations of the original elements in the list. In a List object string representation (Losr) the list elements are separated by a separatorChar, which defaults to ',', but can be changed. If the string representation of a list element contains a special character it is quoted. Special characters include separatorChar, a comment character, and white space characters. See sdsu.util.TokenCharacters for default values. White space and comments can be added to a Losr for readability. Comments start with a comment character and continue upto and include the next '\n' character.

Author:
Roger Whitney (whitney@cs.sdsu.edu)
See Also:
Stringizer, SimpleTokenizer, TokenCharacters

Variable Index

 o internalVector

Constructor Index

 o List()
Create a new list
 o List(int)
Create a list with initial given size
 o List(Object[])
Create a list initial items from a list
 o List(Vector)
Create a list initial items from a list

Method Index

 o addElement(double)
Adds the specified double as the last element of the list.
 o addElement(int)
Adds the specified int as the last element of the list.
 o addElement(Object)
 o addElements(Object[])
Adds the array to the end of the list.
 o addElements(Vector)
Adds the vector to the end of the list.
 o capacity()
 o clone()
 o contains(Object)
 o doubleAt(int)
Returns the double at the specified index.
 o elementAt(int)
 o elements()
 o elementsReversed()
Returns an enumeration of the elements inrevese order.
 o ensureCapacity(int)
 o firstElement()
 o fromString(String)
Converts a string to a list.
 o indexOf(Object)
 o indexOf(Object, int)
 o insertElementAt(Object, int)
 o intAt(int)
Returns the int at the specified index.
 o isEmpty()
 o lastElement()
 o lastIndexOf(Object)
 o lastIndexOf(Object, int)
 o load(InputStream)
Converts a string to a list.
 o main(String[])
 o removeAllElements()
 o removeElement(Object)
 o removeElementAt(int)
 o replaceElements(Object[])
 o reversed()
Returns a list with elements in the reverse order from present list
 o save(OutputStream, String)
Writes ascii representation of List to Outputstream
 o setElementAt(Object, int)
 o setSeparatorChar(char)
Set character used to separate elements of list in String representation of List
 o setSize(int)
 o setTokenCharacters(TokenCharacters)
Sets TokenCharacters used to convert List from/to strings/streams.
 o shuffled()
Returns a list with elements from present list, but in random order.
 o size()
 o toArray()
Converts the list to an array.
 o toString()
Converts the list to a string
 o toString(String)
Converts the list to a string with given header information.
 o toVector()
Converts the list to a vector.
 o trimToSize()

Variables

 o internalVector
 protected Vector internalVector

Constructors

 o List
 public List()
Create a new list

 o List
 public List(int initialSize)
Create a list with initial given size

 o List
 public List(Vector initialElements)
Create a list initial items from a list

 o List
 public List(Object list[])
Create a list initial items from a list

Methods

 o fromString
 public void fromString(String listString) throws ConversionException
Converts a string to a list. Converts strings created by a list or vector Items in string are separated by separatorChar

 o load
 public void load(InputStream in) throws ConversionException
Converts a string to a list. Converts strings created by a list or vector Items in string are separated by separatorChar

 o toString
 public String toString()
Converts the list to a string

Overrides:
toString in class Object
 o toString
 public String toString(String header)
Converts the list to a string with given header information.

 o toVector
 public Vector toVector()
Converts the list to a vector.

 o toArray
 public Object[] toArray()
Converts the list to an array.

 o save
 public void save(OutputStream out,
                  String header)
Writes ascii representation of List to Outputstream

 o setSeparatorChar
 public void setSeparatorChar(char separatorChar)
Set character used to separate elements of list in String representation of List

 o setTokenCharacters
 public void setTokenCharacters(TokenCharacters newParseTable)
Sets TokenCharacters used to convert List from/to strings/streams. Current values for separatorChar override separator settings in TokenCharacters object.

 o elementsReversed
 public final synchronized Enumeration elementsReversed()
Returns an enumeration of the elements inrevese order. That is starts at the back of the list and goes toward the front of the list.

 o intAt
 public final synchronized int intAt(int index)
Returns the int at the specified index.

Parameters:
index - the index of the desired element
Throws: ArrayIndexOutOfBoundsException
If an invalid index was given.
Throws: ClassCastException
If element at index is not really a numeric type which can be converted to an int.
 o doubleAt
 public final synchronized double doubleAt(int index)
Returns the double at the specified index.

Parameters:
index - the index of the desired element
Throws: ArrayIndexOutOfBoundsException
If an invalid index was given.
Throws: ClassCastException
If element at index is not really a numeric type which can be converted to a double.
 o addElement
 public final synchronized void addElement(int anInt)
Adds the specified int as the last element of the list.

Parameters:
anInt - the element to be added
 o addElement
 public final synchronized void addElement(double aDouble)
Adds the specified double as the last element of the list.

Parameters:
aFloat - the element to be added
 o addElements
 public void addElements(Object elementsToAdd[])
Adds the array to the end of the list.

 o addElements
 public void addElements(Vector elementsToAdd)
Adds the vector to the end of the list.

 o reversed
 public synchronized OrderedCollection reversed()
Returns a list with elements in the reverse order from present list

 o shuffled
 public synchronized OrderedCollection shuffled()
Returns a list with elements from present list, but in random order.

 o elements
 public Enumeration elements()
 o trimToSize
 public void trimToSize()
 o ensureCapacity
 public void ensureCapacity(int minCapacity)
 o setSize
 public void setSize(int size)
 o capacity
 public int capacity()
 o size
 public int size()
 o isEmpty
 public boolean isEmpty()
 o contains
 public boolean contains(Object obj)
 o indexOf
 public int indexOf(Object obj)
 o indexOf
 public int indexOf(Object obj,
                    int i)
 o lastIndexOf
 public int lastIndexOf(Object obj)
 o lastIndexOf
 public int lastIndexOf(Object obj,
                        int i)
 o elementAt
 public Object elementAt(int i)
 o firstElement
 public Object firstElement()
 o lastElement
 public Object lastElement()
 o setElementAt
 public void setElementAt(Object obj,
                          int i)
 o removeElementAt
 public void removeElementAt(int i)
 o insertElementAt
 public void insertElementAt(Object obj,
                             int i)
 o addElement
 public void addElement(Object obj)
 o removeElement
 public boolean removeElement(Object obj)
 o removeAllElements
 public void removeAllElements()
 o replaceElements
 public void replaceElements(Object objs[])
 o clone
 public synchronized Object clone()
Overrides:
clone in class Object
 o main
 public static void main(String argv[])

All Packages  Class Hierarchy  This Package  Previous  Next  Index