org.starhope.appius.game.inventory.collections
Class ItemCollection

java.lang.Object
  extended by org.starhope.appius.util.SimpleDataRecord<ItemCollection>
      extended by org.starhope.appius.game.inventory.collections.ItemCollection
All Implemented Interfaces:
com.whirlycott.cache.Cacheable, Serializable, Comparable<ItemCollection>, Iterable<GenericItemReference>, Collection<GenericItemReference>, CTime, DataRecord, HasSubversionRevision

public class ItemCollection
extends SimpleDataRecord<ItemCollection>
implements Collection<GenericItemReference>

WRITEME: Document this type.

Author:
twheys@gmail.com, brpocock@star-hope.org
See Also:
Serialized Form

Field Summary
private  int collectionID
          Unique ID of the collection
private  EventType onBreakEvent
          event fired when a previously-complete collection is broken
private  EventType onCompleteEvent
          event fired when the user completes the collection
private static long serialVersionUID
          WRITEME: Document this brpocock@star-hope.org
private  List<GenericItemReference> set
          Internal implementation pass-through collection
private  String title
          Unique name of the collection
 
Fields inherited from class org.starhope.appius.util.SimpleDataRecord
myLoader, timeLastChanged, timeLastSaved
 
Constructor Summary
ItemCollection(RecordLoader<ItemCollection> loader)
          constructor for collection being loaded
ItemCollection(String newName)
          constructor to create a new collection
 
Method Summary
 boolean add(GenericItemReference e)
           
 boolean addAll(Collection<? extends GenericItemReference> c)
           
 void clear()
           
 boolean contains(Object o)
           
 boolean containsAll(Collection<?> c)
           
 GenericItemReference get(int i)
          Return an item from a specific position in the set
 int getCacheableID()
          Note that all records must have either a numeric ID ( DataRecord.getCacheableID() or a string identifier ( DataRecord.getCacheableIdent() or both.
 String getCacheableIdent()
          Note that all records must have either a numeric ID ( DataRecord.getCacheableID() or a string identifier ( DataRecord.getCacheableIdent() or both.
 EventType getOnBreakEvent()
           
 EventType getOnCompleteEvent()
           
 String getSubversionRevision()
           Return the Subversion revision level of this class's source code file, as supplied via the special "$Rev: " sequence.
 boolean isEmpty()
           
 Iterator<GenericItemReference> iterator()
           
 boolean remove(Object o)
           
 boolean removeAll(Collection<?> c)
           
 boolean retainAll(Collection<?> c)
           
 void setID(int newID)
           
 void setOnBreakEvent(EventType newOnBreakEvent)
           
 void setOnCompleteEvent(EventType newOnCompleteEvent)
           
 void setTitle(String newTitle)
           
 int size()
           
 Object[] toArray()
           
<T> T[]
toArray(T[] a)
           
 
Methods inherited from class org.starhope.appius.util.SimpleDataRecord
changed, checkStale, compareTo, equals, finalize, getRecordLoader, getTimeLastChanged, getTimeLastSaved, hashCode, isBeingLoaded, markAsLoaded, markAsSaved, markForReload, onRemove, onRetrieve, onStore, save, setRecordLoader, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Field Detail

serialVersionUID

private static final long serialVersionUID
WRITEME: Document this brpocock@star-hope.org

See Also:
Constant Field Values

set

private final List<GenericItemReference> set
Internal implementation pass-through collection


title

private String title
Unique name of the collection


collectionID

private int collectionID
Unique ID of the collection


onCompleteEvent

private EventType onCompleteEvent
event fired when the user completes the collection


onBreakEvent

private EventType onBreakEvent
event fired when a previously-complete collection is broken

Constructor Detail

ItemCollection

ItemCollection(RecordLoader<ItemCollection> loader)
constructor for collection being loaded

Parameters:
loader - WRITEME

ItemCollection

ItemCollection(String newName)
         throws AlreadyExistsException
constructor to create a new collection

Parameters:
newName - WRITEME
Throws:
AlreadyExistsException - if the name is in use already
Method Detail

add

public boolean add(GenericItemReference e)
Specified by:
add in interface Collection<GenericItemReference>
See Also:
Collection.add(java.lang.Object)

addAll

public boolean addAll(Collection<? extends GenericItemReference> c)
Specified by:
addAll in interface Collection<GenericItemReference>
See Also:
Collection.addAll(java.util.Collection)

clear

public void clear()
Specified by:
clear in interface Collection<GenericItemReference>
See Also:
Collection.clear()

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection<GenericItemReference>
See Also:
Collection.contains(java.lang.Object)

containsAll

public boolean containsAll(Collection<?> c)
Specified by:
containsAll in interface Collection<GenericItemReference>
See Also:
Collection.containsAll(java.util.Collection)

get

public GenericItemReference get(int i)
Return an item from a specific position in the set

Parameters:
i - index
Returns:
the item at that position

getCacheableID

public int getCacheableID()
                   throws NotFoundException
Description copied from interface: DataRecord
Note that all records must have either a numeric ID ( DataRecord.getCacheableID() or a string identifier ( DataRecord.getCacheableIdent() or both.

Specified by:
getCacheableID in interface DataRecord
Returns:
an unique ID number
Throws:
NotFoundException - if the item doesn't have a distinct numeric ID
See Also:
DataRecord.getCacheableID()

getCacheableIdent

public String getCacheableIdent()
                         throws NotFoundException
Description copied from interface: DataRecord
Note that all records must have either a numeric ID ( DataRecord.getCacheableID() or a string identifier ( DataRecord.getCacheableIdent() or both.

Specified by:
getCacheableIdent in interface DataRecord
Returns:
an unique identifier string
Throws:
NotFoundException - if the item doesn't have a distinct string identifier
See Also:
DataRecord.getCacheableIdent()

getOnBreakEvent

public EventType getOnBreakEvent()
Returns:
the onBreakEvent

getOnCompleteEvent

public EventType getOnCompleteEvent()
Returns:
the onCompleteEvent

getSubversionRevision

public String getSubversionRevision()
Description copied from interface: HasSubversionRevision

Return the Subversion revision level of this class's source code file, as supplied via the special "$Rev: " sequence.

As an example,the Subversion revision string for this file is "$Rev: 1968 $"

 
 @Override
 public String getSubversionRevision () {
        return "$Rev: ";
 }
 

Specified by:
getSubversionRevision in interface HasSubversionRevision
Returns:
The Subversion revision level for this class's source code file.
See Also:
HasSubversionRevision.getSubversionRevision()

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection<GenericItemReference>
See Also:
Collection.isEmpty()

iterator

public Iterator<GenericItemReference> iterator()
Specified by:
iterator in interface Iterable<GenericItemReference>
Specified by:
iterator in interface Collection<GenericItemReference>
See Also:
Collection.iterator()

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection<GenericItemReference>
See Also:
Collection.remove(java.lang.Object)

removeAll

public boolean removeAll(Collection<?> c)
Specified by:
removeAll in interface Collection<GenericItemReference>
See Also:
Collection.removeAll(java.util.Collection)

retainAll

public boolean retainAll(Collection<?> c)
Specified by:
retainAll in interface Collection<GenericItemReference>
See Also:
Collection.retainAll(java.util.Collection)

setID

public void setID(int newID)
Parameters:
newID - the ID for this collection

setOnBreakEvent

public void setOnBreakEvent(EventType newOnBreakEvent)
Parameters:
newOnBreakEvent - the onBreakEvent to set

setOnCompleteEvent

public void setOnCompleteEvent(EventType newOnCompleteEvent)
Parameters:
newOnCompleteEvent - the onCompleteEvent to set

setTitle

public void setTitle(String newTitle)
Parameters:
newTitle - the new title of the collection

size

public int size()
Specified by:
size in interface Collection<GenericItemReference>
See Also:
Collection.size()

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection<GenericItemReference>
See Also:
Collection.toArray()

toArray

public <T> T[] toArray(T[] a)
Specified by:
toArray in interface Collection<GenericItemReference>
See Also:
java.util.Collection#toArray(T[])