|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.planet_ink.coffee_mud.Common.DefaultItemCollection
public class DefaultItemCollection
Abstract collection of item objects, complete with some finders and various accessors. Also, the copyOf method does a deep copy.
| Constructor Summary | |
|---|---|
DefaultItemCollection()
|
|
| Method Summary | |
|---|---|
void |
addItem(Item item)
Adds a new item to its possessor. |
int |
compareTo(CMObject o)
|
CMObject |
copyOf()
Similar to Cloneable.clone(), but does its best to make sure that any internal objects to this class are also copyOfed. |
void |
delAllItems(boolean destroy)
Removes all items from this collection |
void |
delItem(Item item)
Removes the item from this possessor. |
void |
eachItem(EachApplicable<Item> applier)
Applies the given code to each item in this collection |
Item |
findItem(Item goodLocation,
java.lang.String itemID)
Returns the item in the given container that matches the given itemID, whether by full name, description, class ID, or partial name (if no fuller name is found). |
Item |
findItem(java.lang.String itemID)
Returns the item in this possessor that matches the given itemID, whether by full name, description, class ID, or partial name (if no fuller name is found). |
java.util.List<Item> |
findItems(Item goodLocation,
java.lang.String itemID)
Returns all items in the given container that matches the given itemID, whether by full name, description, class ID, or partial name (if no fuller names are found). |
java.util.List<Item> |
findItems(java.lang.String itemID)
Returns all items in this possessor that matches the given itemID, whether by full name, description, class ID, or partial name (if no fuller names are found). |
Item |
getItem(int i)
Returns the item at the given index, regardless of container status, visibility, or other modifiers. |
Item |
getRandomItem()
Returns a random item in this collection, or null |
java.lang.String |
ID()
The CoffeeMud Java Class ID shared by all instances of this object. |
void |
initializeClass()
Called ONCE after all objects are loaded, but before the map is read in during initialization. |
boolean |
isContent(Item item)
Returns whether the given item is in this possessors list. |
java.util.Enumeration<Item> |
items()
An enumeration of all the items at this possessor. |
java.lang.String |
name()
The displayable name of this object. |
CMObject |
newInstance()
Returns a new instance of this class. |
int |
numItems()
Returns the total number of items at this possessor, regardless of container status. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DefaultItemCollection()
| Method Detail |
|---|
public java.lang.String ID()
CMObject
ID in interface CMObjectpublic java.lang.String name()
CMObject
name in interface CMObjectEnvironmental.Name()public CMObject copyOf()
CMObject
copyOf in interface CMObjectpublic void initializeClass()
CMObject
initializeClass in interface CMObjectpublic CMObject newInstance()
CMObject
newInstance in interface CMObjectpublic int compareTo(CMObject o)
compareTo in interface java.lang.Comparable<CMObject>public Item findItem(java.lang.String itemID)
ItemCollection
findItem in interface ItemCollectionitemID - the name or partial name of the item to fetch
public java.util.Enumeration<Item> items()
ItemCollection
items in interface ItemCollection
public Item findItem(Item goodLocation,
java.lang.String itemID)
ItemCollection
findItem in interface ItemCollectiongoodLocation - the container to look in, or null for noneitemID - the name or partial name of the item to fetch
public java.util.List<Item> findItems(Item goodLocation,
java.lang.String itemID)
ItemCollection
findItems in interface ItemCollectiongoodLocation - the container to look in, or null for noneitemID - the name or partial name of the item to fetch
public java.util.List<Item> findItems(java.lang.String itemID)
ItemCollection
findItems in interface ItemCollectionitemID - the name or partial name of the item to fetch
public void addItem(Item item)
ItemCollection
addItem in interface ItemCollectionitem - the item to addItemCollection.delItem(Item)public void delItem(Item item)
ItemCollection
delItem in interface ItemCollectionitem - the item to removepublic int numItems()
ItemCollection
numItems in interface ItemCollectionpublic boolean isContent(Item item)
ItemCollection
isContent in interface ItemCollectionitem - the item to check
public void delAllItems(boolean destroy)
ItemCollection
delAllItems in interface ItemCollectiondestroy - true to also destroy the itemspublic void eachItem(EachApplicable<Item> applier)
ItemCollection
eachItem in interface ItemCollectionapplier - code to execute against each objectpublic Item getItem(int i)
ItemCollection
getItem in interface ItemCollectioni - the index of the item
public Item getRandomItem()
ItemCollection
getRandomItem in interface ItemCollection
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||