wyvern.lib.properties
Class StringList

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byjava.util.ArrayList
              extended bywyvern.lib.properties.StringList
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.util.List, MutableProperty, java.util.RandomAccess, SelfExternalizable, java.io.Serializable

public class StringList
extends java.util.ArrayList
implements SelfExternalizable, MutableProperty

This property knows how to read & write itself as a list of strings. Each string is on a separate line. Doesn't perform well when the list gets long; consider using a hash for more than about 20-30 strings or so.

Version:
1.0, Apr 18, 2001
Author:
Steve Yegge
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
StringList()
          Constructs a new, empty StringList.
StringList(java.util.List strings)
          Constructs a new StringList with the specified strings.
 
Method Summary
 void add(java.lang.String s)
          Adds a string to the list.
 boolean contains(java.lang.String item)
          Returns true if the passed string is in the list.
 java.lang.Object createClone()
          Produces a clone of the property for the caller.
 java.util.List getList()
          Gets the list of strings.
 void readData(org.w3c.dom.Node bean)
          Initializes the object from the passed lines-list.
 boolean remove(java.lang.String s)
          Removes the specified string from the list.
 void setList(java.util.List locs)
          Sets the list of strings in this StringList.
 boolean shouldWrite()
          Returns true if we should write the object at all.
 java.lang.String toString()
          Returns a String representation of the list.
 java.util.List writeData()
          Writes the object's externalized representation to the specified output stream.
 
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, iterator, listIterator, 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
containsAll, equals, hashCode, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList
 

Constructor Detail

StringList

public StringList()
Constructs a new, empty StringList.


StringList

public StringList(java.util.List strings)
Constructs a new StringList with the specified strings.

Parameters:
strings - the new list of strings to use
Method Detail

getList

public java.util.List getList()
Gets the list of strings.

Returns:
the list of strings in this StringList

setList

public void setList(java.util.List locs)
Sets the list of strings in this StringList.

Parameters:
locs - the new list of strings to use

add

public void add(java.lang.String s)
Adds a string to the list.


remove

public boolean remove(java.lang.String s)
Removes the specified string from the list.

Returns:
true if the string was in the list

readData

public void readData(org.w3c.dom.Node bean)
              throws java.lang.Exception
Initializes the object from the passed lines-list.

Specified by:
readData in interface SelfExternalizable
Parameters:
bean - the node representing the SelfExternalizable bean object, which should have at least one child data node.
Throws:
java.lang.Exception

writeData

public java.util.List writeData()
                         throws java.lang.Exception
Writes the object's externalized representation to the specified output stream.

Specified by:
writeData in interface SelfExternalizable
Returns:
a String containing the serialized version of the object.
Throws:
java.lang.Exception

shouldWrite

public boolean shouldWrite()
Returns true if we should write the object at all.

Specified by:
shouldWrite in interface SelfExternalizable
Returns:
true

createClone

public java.lang.Object createClone()
Produces a clone of the property for the caller.

Specified by:
createClone in interface MutableProperty

toString

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


contains

public boolean contains(java.lang.String item)
Returns true if the passed string is in the list. Case is significant.

Returns:
true if the string is in the list (using equals())