com.planet_ink.coffee_mud.Libraries.interfaces
Interface CatalogLibrary

All Superinterfaces:
java.lang.Cloneable, CMLibrary, CMObject, java.lang.Comparable<CMObject>
All Known Implementing Classes:
CMCatalog

public interface CatalogLibrary
extends CMLibrary

The Catalog Library maintains the prototypes of various Items and Mobs who are keyed by their Name. They can belong to categories to help organize them, but that doesn't change the key requirements. Individual mobs and items are flagged as actually BEING an instance of a cataloged prototype, and thus will change to reflect prototype changes when they are able. In addition to all this, certain statistics and information about catalog usage is maintained by the system.


Nested Class Summary
static interface CatalogLibrary.CataData
          CataData is the metadata about each entry in the catalog.
static class CatalogLibrary.CatalogKind
          An enumeration for the two general catalog object kinds.
static interface CatalogLibrary.RoomContent
          An interface for getting a manipulable list of the content of a room.
 
Method Summary
 void addCatalog(Physical PA)
          Creates a new catalog item or mob from the given item or mob in no catagory.
 void addCatalog(java.lang.String catagory, Physical PA)
          Creates a new catalog item or mob from the given item or mob in the given catagory.
 void bumpDeathPickup(Physical P)
          When a cataloged mob dies, or a cataloged item is picked up, this method is called to bump the metadata stats on the object.
 void changeCatalogUsage(Physical P, boolean add)
          Adds or clears the catalog flag on the item or mob instance given to this method, and adds (or removes) it as an instance from the catadata for its prototype.
 java.lang.StringBuffer checkCatalogIntegrity(Physical P)
          Given an item or mob that might be in the catalog, this method confirms that fact.
 void delCatalog(Physical P)
          Completely removes the given item or mob from the catalog, deleting it from the database, and unsetting the cataloged flag from every instance in the world, though it does not save the items..
 CatalogLibrary.CataData getCatalogData(Physical P)
          Returns the cataloged metadata for the mob or item of the same type and with the same name as the given object.
 Item getCatalogItem(java.lang.String name)
          Returns the cataloged prototype item of the given name.
 CatalogLibrary.CataData getCatalogItemData(java.lang.String name)
          Returns the cataloged metadata for the item of the given name
 java.lang.String[] getCatalogItemNames()
          Creates a list of all the item keys (names) of all the items in the catalog, regardless of catagory.
 java.lang.String[] getCatalogItemNames(java.lang.String catagory)
          Creates a list of all the item keys (names) of all the items in the catalog in the given catagory.
 Item[] getCatalogItems()
          Creates a list of all the prototype catalog items.
 MOB getCatalogMob(java.lang.String name)
          Returns the cataloged prototype mob of the given name.
 CatalogLibrary.CataData getCatalogMobData(java.lang.String name)
          Returns the cataloged metadata for the mob of the given name
 java.lang.String[] getCatalogMobNames()
          Creates a list of all the mob keys (names) of all the mobs in the catalog, regardless of catagory.
 java.lang.String[] getCatalogMobNames(java.lang.String catagory)
          Creates a list of all the mob keys (names) of all the mobs in the catalog in the given catagory.
 MOB[] getCatalogMobs()
          Creates a list of all the prototype catalog mobs.
 Physical getCatalogObj(Physical P)
          Returns the cataloged prototype mob or item of the same type and with the same name as the given object.
 CMFile.CMVFSDir getCatalogRoot(CMFile.CMVFSDir resourcesRoot)
          In order to make the catalog appear in the vfs directory paths, this method is called to get the root directory of the catalog, which automatically turns all the catalog entries into directories and files.
 Item getDropItem(MOB M, boolean live)
          The catalog has the ability to provide random items from the catalog as either random equipment on a live mob, or a random drop from a dead one.
 java.lang.String[] getItemCatalogCatagories()
          Creates a list of all the catagories that items have been placed in.
 java.lang.String[] getMobCatalogCatagories()
          Creates a list of all the catagories that mobs have been placed in.
 boolean isCatalogObj(Environmental E)
          Returns whether there exists an item/mob in the catalog of the same type and name/key as the given item or mob.
 boolean isCatalogObj(java.lang.String name)
          Returns whether there exists an item or mob in the catalog of the given name/key.
 void newInstance(Physical P)
          Registers the given cataloged item or mob as being an instance, for metadata collection purposes only.
 java.util.List<CatalogLibrary.RoomContent> roomContent(Room R)
          Returns the coded contents of a room, as it presently exists.
 CatalogLibrary.CataData sampleCataData(java.lang.String xml)
          Builds catalog metadata, optionally building it from an xml doc of saved metadata.
 void setCategory(Physical P, java.lang.String catagory)
          Changes the catagory of the catalog item with the given physical objects name to the given catagory.
 void submitToCatalog(Physical P)
          If the given item or mob is not yet in the catalog prototype library, this method will mark it as uncataloged (as is correct for a prototype), and add it to the items or mobs list, depending on which is appropriate.
 void updateCatalog(Physical modelP)
          When the properties of a cataloged item or mob change, this method is called to propagate those changes into the catalog prototype, and then to all the known instances of the cataloged item.
 void updateCatalogCategory(Physical modelP, java.lang.String newCat)
          Updates the catagory assigned to the given prototype mob or item to the given catagory.
 void updateCatalogIntegrity(Physical P)
          Confirms this mob or item instance against the catalog prototype.
 void updateRoomContent(java.lang.String roomID, java.util.List<CatalogLibrary.RoomContent> content)
          Updates the database entries of the given room id and the adjusted content objects.
 
Methods inherited from interface com.planet_ink.coffee_mud.Libraries.interfaces.CMLibrary
activate, getServiceClient, L, propertiesLoaded, shutdown
 
Methods inherited from interface com.planet_ink.coffee_mud.core.interfaces.CMObject
copyOf, ID, initializeClass, name, newInstance
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

getCatalogItemNames

java.lang.String[] getCatalogItemNames()
Creates a list of all the item keys (names) of all the items in the catalog, regardless of catagory.

Returns:
a list of all the item keys
See Also:
getCatalogItemNames(String)

getCatalogItemNames

java.lang.String[] getCatalogItemNames(java.lang.String catagory)
Creates a list of all the item keys (names) of all the items in the catalog in the given catagory. Send null to get all items regardless of catagory

Parameters:
catagory - the item catagory to filter by
Returns:
a list of all the item keys
See Also:
getCatalogItemNames()

getCatalogMobNames

java.lang.String[] getCatalogMobNames()
Creates a list of all the mob keys (names) of all the mobs in the catalog, regardless of catagory.

Returns:
a list of all the mob keys
See Also:
getCatalogItemNames(), getCatalogMobNames(String)

getCatalogMobNames

java.lang.String[] getCatalogMobNames(java.lang.String catagory)
Creates a list of all the mob keys (names) of all the mobs in the catalog in the given catagory. Send null to get all mobs regardless of catagory

Parameters:
catagory - the mob catagory to filter by
Returns:
a list of all the mob keys
See Also:
getCatalogMobNames()

getMobCatalogCatagories

java.lang.String[] getMobCatalogCatagories()
Creates a list of all the catagories that mobs have been placed in.

Returns:
a list of all the catagories
See Also:
getItemCatalogCatagories()

getItemCatalogCatagories

java.lang.String[] getItemCatalogCatagories()
Creates a list of all the catagories that items have been placed in.

Returns:
a list of all the catagories
See Also:
getMobCatalogCatagories()

getCatalogItems

Item[] getCatalogItems()
Creates a list of all the prototype catalog items.

Returns:
a list of all the prototype catalog items.
See Also:
getCatalogMobs()

getCatalogMobs

MOB[] getCatalogMobs()
Creates a list of all the prototype catalog mobs.

Returns:
a list of all the prototype catalog mobs.
See Also:
getCatalogItems()

isCatalogObj

boolean isCatalogObj(Environmental E)
Returns whether there exists an item/mob in the catalog of the same type and name/key as the given item or mob.

Parameters:
E - the item or mob
Returns:
true if it's in the catalog, false otherwise
See Also:
isCatalogObj(String)

isCatalogObj

boolean isCatalogObj(java.lang.String name)
Returns whether there exists an item or mob in the catalog of the given name/key. Since the name could be item or mob, preference is given to mobs.

Parameters:
name - the item or mob name
Returns:
true if it's in the catalog, false otherwise
See Also:
isCatalogObj(Environmental)

getCatalogItem

Item getCatalogItem(java.lang.String name)
Returns the cataloged prototype item of the given name.

Parameters:
name - the name to look for.
Returns:
the cataloged prototype item
See Also:
getCatalogItem(String), getCatalogObj(Physical)

getCatalogMob

MOB getCatalogMob(java.lang.String name)
Returns the cataloged prototype mob of the given name.

Parameters:
name - the name to look for.
Returns:
the cataloged prototype mob
See Also:
getCatalogMob(String), getCatalogObj(Physical)

getCatalogObj

Physical getCatalogObj(Physical P)
Returns the cataloged prototype mob or item of the same type and with the same name as the given object.

Parameters:
P - the object type and name to look for
Returns:
the cataloged prototype mob or item
See Also:
getCatalogMob(String), getCatalogItem(String)

getCatalogItemData

CatalogLibrary.CataData getCatalogItemData(java.lang.String name)
Returns the cataloged metadata for the item of the given name

Parameters:
name - the name of the cataloged item.
Returns:
the cataloged metadata for the item
See Also:
CatalogLibrary.CataData, getCatalogMobData(String), getCatalogData(Physical)

getCatalogMobData

CatalogLibrary.CataData getCatalogMobData(java.lang.String name)
Returns the cataloged metadata for the mob of the given name

Parameters:
name - the name of the cataloged mob.
Returns:
the cataloged metadata for the mob
See Also:
CatalogLibrary.CataData, getCatalogItemData(String), getCatalogData(Physical)

getCatalogData

CatalogLibrary.CataData getCatalogData(Physical P)
Returns the cataloged metadata for the mob or item of the same type and with the same name as the given object.

Parameters:
P - the object type and name to look for
Returns:
the cataloged metadata for the mob
See Also:
CatalogLibrary.CataData, getCatalogItemData(String), getCatalogMobData(String)

addCatalog

void addCatalog(java.lang.String catagory,
                Physical PA)
Creates a new catalog item or mob from the given item or mob in the given catagory. The given object is marked as cataloged and a copy if submitted to the database and memory.

Parameters:
catagory - the new catagory, such as null
PA - the item or mob to create in the catalog
See Also:
addCatalog(Physical), delCatalog(Physical), submitToCatalog(Physical)

addCatalog

void addCatalog(Physical PA)
Creates a new catalog item or mob from the given item or mob in no catagory. The given object is marked as cataloged and a copy if submitted to the database and memory.

Parameters:
PA - the item or mob to create in the catalog
See Also:
addCatalog(String, Physical), delCatalog(Physical), submitToCatalog(Physical), updateCatalog(Physical)

submitToCatalog

void submitToCatalog(Physical P)
If the given item or mob is not yet in the catalog prototype library, this method will mark it as uncataloged (as is correct for a prototype), and add it to the items or mobs list, depending on which is appropriate. This method, unlike addCatalog, does not copy the item or add to the database.

Parameters:
P - the item or mob to add to the catalog
See Also:
addCatalog(Physical), delCatalog(Physical), addCatalog(String, Physical)

updateCatalogCategory

void updateCatalogCategory(Physical modelP,
                           java.lang.String newCat)
Updates the catagory assigned to the given prototype mob or item to the given catagory. Catagories do not affect the requirement for a unique name/key for each mob or item. Unlike setCatagory, this method is totally synchronized and also clears the VFSDir cache.

Parameters:
modelP - the prototype mob or item
newCat - the catagory to change it into, or null
See Also:
setCategory(Physical, String)

setCategory

void setCategory(Physical P,
                 java.lang.String catagory)
Changes the catagory of the catalog item with the given physical objects name to the given catagory. Unlike updateCatalogCatagory, this method is not synchronized and does not clear the VFSDir cache

Parameters:
P - the catalog item to get a key/name from
catagory - the new catagory, such as null
See Also:
updateCatalogCategory(Physical, String)

delCatalog

void delCatalog(Physical P)
Completely removes the given item or mob from the catalog, deleting it from the database, and unsetting the cataloged flag from every instance in the world, though it does not save the items..

Parameters:
P - the item or mob whose name and prototype are removed
See Also:
addCatalog(Physical), updateCatalog(Physical)

updateCatalog

void updateCatalog(Physical modelP)
When the properties of a cataloged item or mob change, this method is called to propagate those changes into the catalog prototype, and then to all the known instances of the cataloged item. Therefore this is a potentially expensive call timewise.

Parameters:
modelP - the updated changed item or mob

checkCatalogIntegrity

java.lang.StringBuffer checkCatalogIntegrity(Physical P)
Given an item or mob that might be in the catalog, this method confirms that fact. It returns null if all is well, and if there are differences between this object and the cataloged one, it returns a string list of the stats that differ.

Parameters:
P - the item or mob to check
Returns:
null or the list of bad stats

updateCatalogIntegrity

void updateCatalogIntegrity(Physical P)
Confirms this mob or item instance against the catalog prototype. If it matches, it does nothing. If it doesn't, the given item or mob loses its catalog flagging.

Parameters:
P - the item or mob to confirm against the catalog prototype

changeCatalogUsage

void changeCatalogUsage(Physical P,
                        boolean add)
Adds or clears the catalog flag on the item or mob instance given to this method, and adds (or removes) it as an instance from the catadata for its prototype.

Parameters:
P - the item or mob to alter
add - true to flag it as cataloged, false to clear its flag.

getDropItem

Item getDropItem(MOB M,
                 boolean live)
The catalog has the ability to provide random items from the catalog as either random equipment on a live mob, or a random drop from a dead one. This method is called to generate just such an item from the available options.

Parameters:
M - the mob to equip
live - true if its for a live mob, false if its for a corpse
Returns:
null or a random item

sampleCataData

CatalogLibrary.CataData sampleCataData(java.lang.String xml)
Builds catalog metadata, optionally building it from an xml doc of saved metadata.

Parameters:
xml - an optional xml doc of metadata data
Returns:
a catadata object
See Also:
CatalogLibrary.CataData

roomContent

java.util.List<CatalogLibrary.RoomContent> roomContent(Room R)
Returns the coded contents of a room, as it presently exists. That's all the mobs and items, including all the shopkeeper shop items. This is used typically for catalogging.

Parameters:
R - the room to retrieve content from
Returns:
the list of items and mobs in the room
See Also:
updateRoomContent(String, List), CatalogLibrary.RoomContent

updateRoomContent

void updateRoomContent(java.lang.String roomID,
                       java.util.List<CatalogLibrary.RoomContent> content)
Updates the database entries of the given room id and the adjusted content objects.

Parameters:
roomID - the roomID of the room being updated
content - the adjusted content of the room
See Also:
roomContent(Room), CatalogLibrary.RoomContent

newInstance

void newInstance(Physical P)
Registers the given cataloged item or mob as being an instance, for metadata collection purposes only.

Parameters:
P - the item or mob to register as being in the world

bumpDeathPickup

void bumpDeathPickup(Physical P)
When a cataloged mob dies, or a cataloged item is picked up, this method is called to bump the metadata stats on the object.

Parameters:
P - the item or mob to bump the stats on

getCatalogRoot

CMFile.CMVFSDir getCatalogRoot(CMFile.CMVFSDir resourcesRoot)
In order to make the catalog appear in the vfs directory paths, this method is called to get the root directory of the catalog, which automatically turns all the catalog entries into directories and files.

Parameters:
resourcesRoot - the vfs dir of the resources directory
Returns:
the vfs dir of the catalog directory