org.starhope.appius.game.intangible
Class ItemTemplate

java.lang.Object
  extended by org.starhope.appius.util.ManagedReferenceHolder
      extended by org.starhope.appius.util.BaseDatum
          extended by org.starhope.appius.game.intangible.ItemTemplate
All Implemented Interfaces:
com.sun.sgs.app.ManagedObject, Externalizable, Serializable, CastsToJSON

public class ItemTemplate
extends BaseDatum

An ItemTemplate represents a "class" of items. Typically, ItemTemplate:s exist in stores; once purchased, they become SpecificItem:s. Potentially, an NPC other than a "store" could have ItemTemplate:s as well, for spawning new SpecificItem:s at need.

Author:
brpocock
See Also:
Serialized Form

Field Summary
private  String description
           
private  Domain domain
           
private  String filename
           
private  ItemType itemType
           
private  String name
           
private  Image portrait
           
private static long serialVersionUID
           
 
Fields inherited from class org.starhope.appius.util.BaseDatum
database_id
 
Constructor Summary
ItemTemplate()
           
 
Method Summary
static ItemTemplate get(org.json.JSONObject object)
           
static ItemTemplate get(String id)
           
 String getDescription()
           
 Domain getDomain()
           
 String getFilename()
           
 ItemType getItemType()
           
 String getName()
           
 Image getPortrait()
           
 void set(org.json.JSONObject o)
          This method will attempt to set the data contents of this object to the values derived from the JSON object being passed-in.
 void setDescription(String description)
           
 void setDomain(Domain domain)
           
 void setFilename(String filename)
           
 void setItemType(ItemType itemType)
           
 void setName(String name)
           
 void setPortrait(Image portrait)
           
 org.json.JSONObject toJSON()
          This returns a copy of the object's data cast into a JSON form.
 SpecificItem toSpecificItem()
           
 
Methods inherited from class org.starhope.appius.util.BaseDatum
changed, commitToDatabase, delete, equals, flush, get, get, getID, getUniqueBoundName, readExternal, refJSON, setID, sqlDateTime, writeExternal
 
Methods inherited from class org.starhope.appius.util.ManagedReferenceHolder
deref, setRef
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

description

private String description

domain

private Domain domain

filename

private String filename

itemType

private ItemType itemType

name

private String name

portrait

private Image portrait
Constructor Detail

ItemTemplate

public ItemTemplate()
Method Detail

get

public static ItemTemplate get(org.json.JSONObject object)
                        throws RuntimeException,
                               NotFoundException,
                               org.json.JSONException
Parameters:
object - the JSON object
Returns:
the ItemTemplate object it refers to
Throws:
org.json.JSONException - if the JSON data is funky
NotFoundException - if the object (or some part of it) can't be found
RuntimeException - if there's something really bad going on

get

public static ItemTemplate get(String id)
                        throws RuntimeException,
                               NotFoundException
Parameters:
id - the database ID
Returns:
the instantiated ItemTemplate object
Throws:
NotFoundException - if the ID isn't found
RuntimeException - if something strange were to happen

getDescription

public String getDescription()
Returns:
the description

getDomain

public Domain getDomain()
Returns:
the domain

getFilename

public String getFilename()
Returns:
the filename

getItemType

public ItemType getItemType()
Returns:
the itemType

getName

public String getName()
Returns:
the name

getPortrait

public Image getPortrait()
Returns:
the portrait

set

public void set(org.json.JSONObject o)
Description copied from interface: CastsToJSON
This method will attempt to set the data contents of this object to the values derived from the JSON object being passed-in. All exceptions are ignored, but any errors in the JSON data could cause the command to fail, completely or partially.

Specified by:
set in interface CastsToJSON
Overrides:
set in class BaseDatum
Parameters:
o - The JSON object containing a the new data for this object.
See Also:
CastsToJSON.set(org.json.JSONObject)

setDescription

public void setDescription(String description)
Parameters:
description - the description to set

setDomain

public void setDomain(Domain domain)
Parameters:
domain - the domain to set

setFilename

public void setFilename(String filename)
                 throws DataException
Parameters:
filename - the filename to set
Throws:
DataException - if the filename is not from 1..50 chars

setItemType

public void setItemType(ItemType itemType)
Parameters:
itemType - the itemType to set

setName

public void setName(String name)
             throws DataException
Parameters:
name - the name to set
Throws:
DataException - if the name is less than 1 or more than 50 chars

setPortrait

public void setPortrait(Image portrait)
Parameters:
portrait - the portrait to set

toJSON

public org.json.JSONObject toJSON()
Description copied from interface: CastsToJSON
This returns a copy of the object's data cast into a JSON form.

Specified by:
toJSON in interface CastsToJSON
Overrides:
toJSON in class BaseDatum
Returns:
The string representing this object in JSON format
See Also:
BaseDatum.toJSON()

toSpecificItem

public SpecificItem toSpecificItem()
Returns:
a specific instance of this type of item