org.starhope.appius.mb
Class Currency

java.lang.Object
  extended by org.starhope.appius.util.SimpleDataRecord<Currency>
      extended by org.starhope.appius.mb.Currency
All Implemented Interfaces:
com.whirlycott.cache.Cacheable, Serializable, Comparable<Currency>, CastsToJSON, CTime, DataRecord, HasSubversionRevision

public class Currency
extends SimpleDataRecord<Currency>
implements CastsToJSON

Author:
brpocock@star-hope.org
See Also:
Serialized Form

Field Summary
private  String code
          The ISO-4217 currency code (three letters); "USD" is U.S.
private static long serialVersionUID
           
private  String symbol
          The display character sequence.
private  String title
          Title
 
Fields inherited from class org.starhope.appius.util.SimpleDataRecord
myLoader, timeLastChanged, timeLastSaved
 
Constructor Summary
Currency()
          WRITEME: Document this constructor brpocock@star-hope.org
Currency(RecordLoader<Currency> loader)
          WRITEME: Document this constructor brpocock@star-hope.org
 
Method Summary
static Currency get_USD()
           This is a quick "semantic sugar" to pick up U.S.
static Currency get(String id)
          Deprecated. Use Nomenclator.getDataRecord(Class, String) instead
static Currency getByCode(String string)
          Deprecated. use Nomenclator.getDataRecord(Class, String)
 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.
 String getCode()
          Get the three-character (ISO-4217) currency code.
static Currency getPeanuts()
          TODO: refer to database, to be paranoid.
 String getSubversionRevision()
           Return the Subversion revision level of this class's source code file, as supplied via the special "$Rev: " sequence.
 String getSymbol()
           
 String getTitle()
           
static Currency getTootTokens()
          TODO: refer to database, to be paranoid.
 void setCode(String newCode)
          Change the currency code for this instance.
 void setSymbol(String newSymbol)
          Set the user-visible displayed symbol of this currency.
 void setTitle(String newTitle)
           
 org.json.JSONObject toJSON()
          WRITEME: Document this method brpocock@star-hope.org
 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, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

code

private String code
The ISO-4217 currency code (three letters); "USD" is U.S. Dollar, and "EUR" is the Euro.


symbol

private String symbol
The display character sequence. For US Dollars, it's " US $ "; for Euros, it's just the Euro sign


title

private String title
Title

Constructor Detail

Currency

public Currency()
WRITEME: Document this constructor brpocock@star-hope.org


Currency

public Currency(RecordLoader<Currency> loader)
WRITEME: Document this constructor brpocock@star-hope.org

Parameters:
loader - WRITEME
Method Detail

get

@Deprecated
public static Currency get(String id)
                    throws RuntimeException,
                           NotFoundException
Deprecated. Use Nomenclator.getDataRecord(Class, String) instead

Parameters:
id - ISO-4217 currency code
Returns:
currency with that database ID
Throws:
NotFoundException - if it's not found in the database
RuntimeException - if something else wonky were to happen

get_USD

public static final Currency get_USD()

This is a quick "semantic sugar" to pick up U.S. Dollars as a currency format, since that's realistically the only one we're dealing with at the moment.

TODO: refer to database, to be paranoid.

Returns:
a Currency object representing U.S. Dollars.

getByCode

@Deprecated
public static Currency getByCode(String string)
                          throws NotFoundException
Deprecated. use Nomenclator.getDataRecord(Class, String)

Parameters:
string - ISO-4217 currency code
Returns:
a Currency object
Throws:
NotFoundException - if it can't be found

getPeanuts

public static final Currency getPeanuts()
TODO: refer to database, to be paranoid.

Returns:
Tootsville™ Peanuts

getTootTokens

public static final Currency getTootTokens()
TODO: refer to database, to be paranoid.

Returns:
Tootsville™ Toot Tokens

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()

getCode

public String getCode()
Get the three-character (ISO-4217) currency code.

Returns:
A string of three uppercase characters

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()

getSymbol

public String getSymbol()
Returns:
A string of 1-5 characters suitable for unambiguous representation of this currency.
See Also:
Returns the currency symbol for user presentation of prices.

getTitle

public String getTitle()
Returns:
the title of the currency

setCode

public void setCode(String newCode)
             throws DataException
Change the currency code for this instance.

Parameters:
newCode - The new currency code to be set (ISO-4217, uppercase, e.g. "USD")
Throws:
DataException - if the specification does not consist of three AppiusCharacter.UPPERCASE_LETTER characters.

setSymbol

public void setSymbol(String newSymbol)
               throws DataException
Set the user-visible displayed symbol of this currency. E.G. for the US Dollar, this is "US $"; Mexican New Peso, "Mx $"; for the Canadian dollar, "CA $"; for the Chinese RMB, it might be "RMB", versus Japanese Yen "Jp ¥"; Euro, just "€" (since there's no confusion with any other country using a similar currency symbol)

Parameters:
newSymbol - The new symbol string to be used for this currency
Throws:
DataException - if the new symbol string is not supplied, or is more than 5 characters long

setTitle

public void setTitle(String newTitle)
Parameters:
newTitle - the title to set

toJSON

public org.json.JSONObject toJSON()
WRITEME: Document this method brpocock@star-hope.org

Specified by:
toJSON in interface CastsToJSON
Returns:
WRITEME

toString

public String toString()
Overrides:
toString in class SimpleDataRecord<Currency>
See Also:
Object.toString()