|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.starhope.appius.util.SimpleDataRecord<SimpleDataRecordSet<DataRecordClass,DataRecordSetClass>>
org.starhope.appius.util.SimpleDataRecordSet<InventoryItem,Inventory>
org.starhope.appius.game.inventory.Inventory
public class Inventory
The Inventory represent an SQL-backed set of InventoryItem
objects owned by a given user.
Field Summary | |
---|---|
(package private) ConcurrentSkipListSet<InventoryItem> |
items
The internal cache of the user's inventory is kept in this set |
private int |
ownerID
The user whose inventory is represented by this object |
private static long |
serialVersionUID
WRITEME: Document this brpocock@star-hope.org |
Fields inherited from class org.starhope.appius.util.SimpleDataRecord |
---|
myLoader, timeLastChanged, timeLastSaved |
Constructor Summary | |
---|---|
Inventory(RecordLoader<SimpleDataRecordSet<InventoryItem,Inventory>> loader)
WRITEME: Document this constructor brpocock@star-hope.org |
Method Summary | ||
---|---|---|
void |
add(GenericItemReference example)
WRITEME: Document this method brpocock@star-hope.org |
|
InventoryItem |
add(int itemID)
WRITEME: Document this method brpocock@star-hope.org |
|
boolean |
add(InventoryItem item)
This is an overriding method. |
|
boolean |
addAll(Collection<? extends InventoryItem> c)
This is an overriding method. |
|
InventoryItem |
addDefaultFreeItem(int i)
|
|
InventoryItem |
addDefaultFreeItem(int id,
boolean forceActive)
Add an item which every user gets for free to the user's inventory, if it does not already exist. |
|
void |
clear()
This is an overriding method. |
|
boolean |
contains(Object o)
This is an overriding method. |
|
boolean |
containsAll(Collection<?> c)
This is an overriding method. |
|
void |
doff(InventoryItem item)
Doff a wearable item |
|
void |
doff(InventoryItemType type)
Un-equip all items of a type |
|
void |
don(InventoryItem item,
Colour colour)
Put on a wearable item, to include Pivitz as well as clothing and so forth. |
|
InventoryItem |
findItem(int id)
Checks if an item with the ID of parameter id is contained in the set, and if so, returns it. |
|
private void |
flush(Object o)
Update an individual item in the database if necessary. |
|
org.json.JSONObject |
getActiveClothing_JSON()
Get the set of all clothing being worn (as a JSON object). |
|
Collection<InventoryItem> |
getActiveClothing()
Get all active clothing items in a collection. |
|
InventoryItem |
getActiveItemByType(InventoryItemType inventoryItemType)
Find a singular active item of a type. |
|
Collection<InventoryItem> |
getActiveItemsByType(Collection<InventoryItemType> types)
|
|
Collection<InventoryItem> |
getActiveItemsByType(InventoryItemType t)
|
|
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. |
|
org.json.JSONObject |
getEquippedItems_JSON()
|
|
Collection<InventoryItem> |
getEquippedItems(boolean includePassive)
Get the set of equipped items which are either ACTIVE or PASSIVE. |
|
InventoryItem |
getFurnitureBySlot(int slotNumber)
Get a home décor (furniture or structure) item from this user's inventory by its slot number. |
|
Collection<InventoryItem> |
getItemsByType(Collection<InventoryItemType> types)
get all items of given types |
|
Collection<InventoryItem> |
getItemsByType(InventoryItemType inventoryItemType)
WRITEME: Document this method brpocock@star-hope.org |
|
AbstractUser |
getOwner()
|
|
int |
getOwnerID()
|
|
String |
getSubversionRevision()
Return the Subversion revision level of this class's source code file, as supplied via the special "$Rev: " sequence. |
|
boolean |
hasEquipped(int itemID)
|
|
boolean |
hasItem(int id)
Checks if an item with the ID of parameter id is contained in the set. |
|
boolean |
isEmpty()
This is an overriding method. |
|
Iterator<InventoryItem> |
iterator()
This is an overriding method. |
|
void |
notifyEquipChange()
Notify the owner of a change to equipped items |
|
boolean |
remove(Object o)
This is an overriding method. |
|
boolean |
removeAll(Collection<?> c)
This is an overriding method. |
|
boolean |
retainAll(Collection<?> c)
This is an overriding method. |
|
void |
setOwnerID(int userID)
WRITEME: Document this method brpocock@star-hope.org |
|
void |
setStructure(InventoryItem item)
Activate one structural element in lieu of any others that occupy the same slot. |
|
int |
size()
This is an overriding method. |
|
Object[] |
toArray()
This is an overriding method. |
|
|
toArray(T[] a)
This is an overriding method. |
|
String |
toString()
|
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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Collection |
---|
equals, hashCode |
Methods inherited from interface org.starhope.appius.util.DataRecord |
---|
checkStale, getRecordLoader, isBeingLoaded, markAsLoaded, markAsSaved, setRecordLoader |
Methods inherited from interface org.starhope.appius.util.CTime |
---|
getTimeLastChanged, getTimeLastSaved |
Methods inherited from interface com.whirlycott.cache.Cacheable |
---|
onRemove, onRetrieve, onStore |
Field Detail |
---|
private static final long serialVersionUID
ConcurrentSkipListSet<InventoryItem> items
private int ownerID
Constructor Detail |
---|
public Inventory(RecordLoader<SimpleDataRecordSet<InventoryItem,Inventory>> loader)
loader
- WRITEMEMethod Detail |
---|
public void add(GenericItemReference example)
example
- WRITEMEpublic InventoryItem add(int itemID)
itemID
- the ID of a new item to be added
public boolean add(InventoryItem item)
add
in interface Collection<InventoryItem>
add
in class SimpleDataRecordSet<InventoryItem,Inventory>
Collection.add(java.lang.Object)
public boolean addAll(Collection<? extends InventoryItem> c)
addAll
in interface Collection<InventoryItem>
addAll
in class SimpleDataRecordSet<InventoryItem,Inventory>
Collection.addAll(java.util.Collection)
public InventoryItem addDefaultFreeItem(int i)
i
- item ID
addDefaultFreeItem(int, boolean)
public InventoryItem addDefaultFreeItem(int id, boolean forceActive)
id
- the item IDforceActive
- if true, force the item to be active upon
adding it to the user's inventory
public void clear()
clear
in interface Collection<InventoryItem>
clear
in class SimpleDataRecordSet<InventoryItem,Inventory>
Collection.clear()
public boolean contains(Object o)
contains
in interface Collection<InventoryItem>
contains
in class SimpleDataRecordSet<InventoryItem,Inventory>
Collection.contains(java.lang.Object)
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<InventoryItem>
containsAll
in class SimpleDataRecordSet<InventoryItem,Inventory>
Collection.containsAll(java.util.Collection)
public void doff(InventoryItem item)
item
- the item to be removeddon(InventoryItem,Colour)
public void doff(InventoryItemType type)
type
- the item type, of which all items are to be
deactivatedpublic void don(InventoryItem item, Colour colour)
item
- The item to be worncolour
- The color to set for the item. If the colour is not
being overridden, set this to null.public InventoryItem findItem(int id)
id
- the item ID of the item being checked
private void flush(Object o)
o
- an object that's probably an InventoryItempublic Collection<InventoryItem> getActiveClothing()
org.starhope.appius.game.inventory.clothingTypes
;
this routine, in turn, uses
getActiveItemsByType(Collection)
.
public org.json.JSONObject getActiveClothing_JSON()
getActiveClothing()
to identify clothes, and
creates a JSON array-type map
public InventoryItem getActiveItemByType(InventoryItemType inventoryItemType) throws NotFoundException
inventoryItemType
- a type
NotFoundException
- if the user has no items of the given
typepublic Collection<InventoryItem> getActiveItemsByType(Collection<InventoryItemType> types)
types
- a set of types of items to be searched
public Collection<InventoryItem> getActiveItemsByType(InventoryItemType t)
t
- the item type in question
public int getCacheableID() throws NotFoundException
DataRecord
DataRecord.getCacheableID()
or a string identifier (
DataRecord.getCacheableIdent()
or both.
NotFoundException
- if the item doesn't have a distinct
numeric IDDataRecord.getCacheableID()
public String getCacheableIdent() throws NotFoundException
DataRecord
DataRecord.getCacheableID()
or a string identifier (
DataRecord.getCacheableIdent()
or both.
NotFoundException
- if the item doesn't have a distinct
string identifierDataRecord.getCacheableIdent()
public Collection<InventoryItem> getEquippedItems(boolean includePassive)
includePassive
- whether to include PASSIVE equipped items,
as well.
public org.json.JSONObject getEquippedItems_JSON()
getEquippedItems(boolean)
public InventoryItem getFurnitureBySlot(int slotNumber) throws NotFoundException
slotNumber
- the slot number for the user's inventory
NotFoundException
- if the item is not found.public Collection<InventoryItem> getItemsByType(Collection<InventoryItemType> types)
types
- the types
public Collection<InventoryItem> getItemsByType(InventoryItemType inventoryItemType)
inventoryItemType
- WRITEME
public AbstractUser getOwner()
public int getOwnerID()
public String getSubversionRevision()
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: "; }
HasSubversionRevision.getSubversionRevision()
public boolean hasEquipped(int itemID)
itemID
- the type of item being searched-for
public boolean hasItem(int id)
id
- the item ID of the item being checked
public boolean isEmpty()
isEmpty
in interface Collection<InventoryItem>
isEmpty
in class SimpleDataRecordSet<InventoryItem,Inventory>
Collection.isEmpty()
public Iterator<InventoryItem> iterator()
iterator
in interface Iterable<InventoryItem>
iterator
in interface Collection<InventoryItem>
iterator
in class SimpleDataRecordSet<InventoryItem,Inventory>
Collection.iterator()
public void notifyEquipChange()
public boolean remove(Object o)
remove
in interface Collection<InventoryItem>
remove
in class SimpleDataRecordSet<InventoryItem,Inventory>
Collection.remove(java.lang.Object)
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<InventoryItem>
removeAll
in class SimpleDataRecordSet<InventoryItem,Inventory>
Collection.removeAll(java.util.Collection)
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<InventoryItem>
retainAll
in class SimpleDataRecordSet<InventoryItem,Inventory>
Collection.retainAll(java.util.Collection)
public void setOwnerID(int userID)
userID
- WRITEMEpublic void setStructure(InventoryItem item)
item
- the structural itempublic int size()
size
in interface Collection<InventoryItem>
size
in class SimpleDataRecordSet<InventoryItem,Inventory>
Collection.size()
public Object[] toArray()
toArray
in interface Collection<InventoryItem>
toArray
in class SimpleDataRecordSet<InventoryItem,Inventory>
Collection.toArray()
public <T> T[] toArray(T[] a)
toArray
in interface Collection<InventoryItem>
toArray
in class SimpleDataRecordSet<InventoryItem,Inventory>
java.util.Collection#toArray(T[])
public String toString()
toString
in class SimpleDataRecord<SimpleDataRecordSet<InventoryItem,Inventory>>
Object.toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |