wyvern.lib.properties
Class ItemList

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

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

This class allows a wyvern.lib.Bag implementation to serialize its contents to & from a map file.

Version:
1.0, Nov 01, 1998
Author:
Steve Yegge
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
ItemList()
           
 
Method Summary
 java.lang.Object createClone()
          Produces a clone of the property for the caller.
 boolean equals(java.lang.Object o)
          Returns true if the passed ItemList equals this one.
 GameObject getParent()
          Returns the parent (usually a bag or inventory).
 void readData(org.w3c.dom.Node bean)
          Tells the object to parse its externalized representation from a list of lines.
 void setParent(GameObject parent)
          Sets the parent container.
 boolean shouldWrite()
          Returns true if we should write the object at all.
protected  boolean skipUniqueItem(GameObject obj)
          Returns true if we should skip this item because it's unique, and being carried by a player.
 java.lang.String toString()
          Returns a String representation of this list.
 java.util.List writeData()
          Writes a list of items (game objects) to the file.
 
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
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, hashCode, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList
 

Constructor Detail

ItemList

public ItemList()
Method Detail

getParent

public GameObject getParent()
Returns the parent (usually a bag or inventory).

Returns:
the parent, if one was set, or null

setParent

public void setParent(GameObject parent)
Sets the parent container.


readData

public void readData(org.w3c.dom.Node bean)
              throws java.lang.Exception
Tells the object to parse its externalized representation from a list of lines.

Specified by:
readData in interface SelfExternalizable
Parameters:
bean - the DOM Node representing the bean
Throws:
java.lang.Exception

writeData

public java.util.List writeData()
                         throws java.lang.Exception
Writes a list of items (game objects) to the file.

Specified by:
writeData in interface SelfExternalizable
Returns:
a list of strings that can be written to the output file.
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

skipUniqueItem

protected boolean skipUniqueItem(GameObject obj)
Returns true if we should skip this item because it's unique, and being carried by a player.


toString

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


equals

public boolean equals(java.lang.Object o)
Returns true if the passed ItemList equals this one. They're considered equal if they have the same contents.

Specified by:
equals in interface java.util.List
Parameters:
o - the ItemList to compare to
Returns:
true if they have equal contents

createClone

public java.lang.Object createClone()
Produces a clone of the property for the caller. Note: it's called createClone, not makeClone, because GameObject already has a makeClone. Some GameObjects can be properties (e.g inventories) and we can't do overloaded methods based only on the return type.

Specified by:
createClone in interface MutableProperty