public final class CurrencyType extends MoneydanceSyncableItem
Modifier and Type | Class and Description |
---|---|
static class |
CurrencyType.Type |
Modifier and Type | Field and Description |
---|---|
static int |
CURRTYPE_CURRENCY |
static int |
CURRTYPE_SECURITY |
static java.lang.String |
SYNCABLE_TYPE_VALUE |
static java.lang.String |
TAG_RELATIVE_TO_CURR |
book, info
Constructor and Description |
---|
CurrencyType(CurrencyTable table)
Construct a CurrencyType object.
|
Modifier and Type | Method and Description |
---|---|
CurrencySnapshot |
addSnapshotInt(int date,
double userRate)
Create a new snapshot with the given date and rate and return the
result after adding it to the snapshot list.
|
CurrencySplit |
addStockSplit(long date,
double splitRatio,
int oldShares,
int newShares)
Deprecated.
use the addStockSplit method that takes an int date instead
|
CurrencySplit |
addStockSplitInt(int date,
double splitRatio,
int oldShares,
int newShares)
Add a stock split with the given ratio (which should match the old/new shares)
on the given date (which decimal form is YYYYMMDD)
|
double |
adjustRateForSplitsInt(int date,
double rate)
Given a value for this currency at the specified day, return
the equivalent value in the currency today after adjusting for
splits.
|
double |
adjustRateForSplitsInt(int date,
double rate,
int endDate)
Given a rate for this currency at the specified day, return the
equivalent rate in the currency at endDate after adjusting for splits.
|
long |
adjustValueForSplits(long txnDate,
long val)
Deprecated.
use adjustValueForSplitsInt(int, long) instead
|
long |
adjustValueForSplitsInt(int txnDate,
long val)
Given a number of currency units on the given day, return
the equivalent number of units in todays currency value.
|
long |
adjustValueForSplitsInt(int txnDate,
long val,
int endDate)
Given a number of currency units on the given day, return
the equivalent number of units in the endDate's currency value.
|
int |
compareToCurrency(CurrencyType curr)
Return an integer indicating whether this currency is less than, equal to,
or greater than the given currency when sorting by type, name, and ID.
|
long |
convertValue(long baseCurrencyAmount)
Convert the given
baseCurrencyAmount value to
it's value in this currency. |
static CurrencyType |
currencyFromFields(int id,
java.lang.String idString,
java.lang.String name,
double rate,
int decimalPlaces,
java.lang.String prefix,
java.lang.String suffix,
java.lang.String tickerSymbol,
int effectiveDate,
int currencyType,
CurrencyTable table)
Construct a CurrencyType object.
|
boolean |
deleteItem()
Deletes this item and and all of the snapshots and splits that reference it.
|
java.lang.String |
format(long amt,
char decimalChar)
Format the given value with the format NNNN.NN
|
java.lang.String |
formatFancy(long amt,
char decimalChar)
Format the given value with the format <prefix> N,NNN.NN <suffix>
|
java.lang.String |
formatNoDecimals(long amt)
Format the given value with the format NNNN
|
java.lang.String |
formatSemiFancy(long amt,
char decimalChar)
Format the given value with the format N,NNN.NN
|
CurrencyType.Type |
getCurrencyType() |
double |
getDailyChange() |
long |
getDailyVolume() |
int |
getDecimalPlaces() |
double |
getDoubleValue(long longVal)
Get the 64 bit floating point representation of the given integer amount of this currency
|
int |
getEffectiveDateInt()
Returns the int value (where the decimal form equals YYYYMMDD) representing
the first date that this currency is active.
|
boolean |
getHideInUI()
Get a boolean flag indicating whether or not this currency
should be displayed in user-friendly currency lists.
|
int |
getID() |
java.lang.String |
getIDForScheme(java.lang.String idScheme)
Returns the security/currency ID that was set for this CurrencyType
using the given ID scheme.
|
java.lang.String |
getIDString() |
long |
getLongValue(double doubleVal) |
java.lang.String |
getName() |
java.lang.String |
getPrefix() |
double |
getRawRate()
Get the rate of this currency relative to the base currency.
|
double |
getRawRateByDateInt(int dt)
Get the last known raw rate for this currency at the given time.
|
java.util.List<CurrencySnapshot> |
getSnapshots() |
java.util.List<CurrencySplit> |
getSplits() |
java.lang.String |
getSuffix() |
java.lang.String |
getSyncItemType()
Subclasses should override this to return a static string identifying their type of object
|
CurrencyTable |
getTable()
Returns the currency table that this currency is a part of.
|
java.lang.String |
getTickerSymbol() |
double |
getUserRate()
Get the rate of this currency relative to the base currency
|
double |
getUserRateByDateInt(int dt)
Return the user rate as of the given date.
|
long |
invertValue(long currencyAmount)
Convert the given
currencyAmount value in
this currency to a value in the base currency. |
boolean |
isDirty() |
void |
itemWasUpdated()
This is called after an item is updated by calling itemWasUpdated(SyncRecord).
|
void |
itemWillSync()
This is called just before an item will be stored and/or synced when itemWillSync(SyncRecord)
is called.
|
long |
parse(java.lang.String str,
char decimalChar) |
long |
parse(java.lang.String str,
char decimalChar,
boolean quickDecimal)
Parse the given amount string given the provided decimal character.
|
static long |
parseRaw(java.lang.String str)
Parse a raw currency string, assuming there are enough decimal places.
|
void |
resetDirtyFlags() |
void |
setCurrencyType(CurrencyType.Type newType) |
void |
setDailyChange(double change) |
void |
setDailyVolume(long vol) |
void |
setDecimalPlaces(int newDecimalPlaces) |
void |
setHideInUI(boolean hideInUI)
Set a boolean flag indicating whether or not this currency
should be displayed in user-friendly currency lists.
|
void |
setIDForScheme(java.lang.String idScheme,
java.lang.String newID)
Sets the security/currency ID for the given ID scheme.
|
void |
setIDString(java.lang.String newIDString) |
void |
setName(java.lang.String newName) |
void |
setPrefix(java.lang.String newPrefix) |
void |
setRawRate(double newRate,
boolean adjustRelativeSecurities)
Set the rate *already adjusted* for differences in decimal places for currency.
|
CurrencySnapshot |
setSnapshotInt(int date,
double userRate)
If a snapshot exists for the specified date, set the rate and
return it.
|
CurrencySnapshot |
setSnapshotInt(int date,
double userRate,
CurrencyType relativeCurr)
If a snapshot exists for the specified date, set the rate and
return it.
|
void |
setSuffix(java.lang.String newSuffix) |
void |
setTickerSymbol(java.lang.String newTickerSymbol) |
void |
setUserRate(double newRate)
Set the price or rate for this currency using the normal decimal placement, not the
decimal place adjusted values used when setting raw rates.
|
void |
setUserRate(double newRate,
CurrencyType relativeCurr)
Set the new user (not raw) rate to the given value relative to the given currency.
|
void |
sortSnapshots() |
void |
sortStockSplits() |
java.lang.String |
toString() |
long |
unadjustValueForSplitsInt(int asofDate,
long todayVal,
int today)
Given a number of currency units as of today, return the equivalent number of units in the
asofDate's currency value, which must be a previous date.
|
addParameters, addTags, autoSyncsChanges, decodeKeywordList, doesParameterExist, duplicate, encodeKeywordList, equals, getAccountParameter, getAddress, getAddressParameter, getBook, getBooleanParameter, getCurrencyParameter, getDoubleParameter, getIntParameter, getKeywords, getLongParameter, getParameter, getParameter, getParameterCount, getParameterKeys, getPreference, getPreferenceBoolean, getPreferenceDouble, getPreferenceInt, getPreferenceIntArray, getPreferenceLong, getPreferenceStringList, getPreferenceSublist, getPreferenceSubset, getSyncInfo, getSyncTimestamp, getUUID, hashCode, hasKeywordSubstring, initialize, isInEditingMode, isSyncable, itemWasUpdated, itemWillSync, makeSyncableItem, removeParameter, setAccountParameter, setAddress, setAddressParameter, setCurrencyParameter, setDirty, setEditingMode, setKeywords, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setParameterNoNotify, setPreference, setPreference, setPreference, syncItem
public static final java.lang.String SYNCABLE_TYPE_VALUE
public static final int CURRTYPE_CURRENCY
public static final int CURRTYPE_SECURITY
public static final java.lang.String TAG_RELATIVE_TO_CURR
public CurrencyType(CurrencyTable table)
public void itemWasUpdated()
MoneydanceSyncableItem
itemWasUpdated
in class MoneydanceSyncableItem
public void itemWillSync()
MoneydanceSyncableItem
itemWillSync
in class MoneydanceSyncableItem
public final java.lang.String getSyncItemType()
MoneydanceSyncableItem
getSyncItemType
in interface com.infinitekind.tiksync.SyncableItem
getSyncItemType
in class MoneydanceSyncableItem
public int getID()
public boolean deleteItem()
deleteItem
in class MoneydanceSyncableItem
public final int getEffectiveDateInt()
public final CurrencyType.Type getCurrencyType()
public void setCurrencyType(CurrencyType.Type newType)
public final java.lang.String getIDString()
public final java.lang.String getName()
public final java.lang.String getPrefix()
public final java.lang.String getSuffix()
public final int getDecimalPlaces()
public final java.lang.String getTickerSymbol()
public final void setDecimalPlaces(int newDecimalPlaces)
public CurrencyTable getTable()
public final double getDoubleValue(long longVal)
public final long getLongValue(double doubleVal)
public final void setIDString(java.lang.String newIDString)
public final void setDailyVolume(long vol)
public final long getDailyVolume()
public final void setDailyChange(double change)
public final double getDailyChange()
public final void setTickerSymbol(java.lang.String newTickerSymbol)
public final void setName(java.lang.String newName)
public final double getRawRate()
public void setRawRate(double newRate, boolean adjustRelativeSecurities)
public final void setUserRate(double newRate)
public final void setUserRate(double newRate, CurrencyType relativeCurr)
public final double getUserRate()
public final void setPrefix(java.lang.String newPrefix)
public final void setSuffix(java.lang.String newSuffix)
public final long convertValue(long baseCurrencyAmount)
baseCurrencyAmount
value to
it's value in this currency.public final long invertValue(long currencyAmount)
currencyAmount
value in
this currency to a value in the base currency.public final boolean isDirty()
public final void resetDirtyFlags()
public final CurrencySplit addStockSplit(long date, double splitRatio, int oldShares, int newShares)
public final CurrencySplit addStockSplitInt(int date, double splitRatio, int oldShares, int newShares)
public final long adjustValueForSplits(long txnDate, long val)
public final long adjustValueForSplitsInt(int txnDate, long val)
public final long adjustValueForSplitsInt(int txnDate, long val, int endDate)
public final long unadjustValueForSplitsInt(int asofDate, long todayVal, int today)
asofDate
- The older date.todayVal
- The value as of the today
date.today
- Today's date (or at least a date more current than asofDate
).asofDate
, un-adjusted for any splits.public final double adjustRateForSplitsInt(int date, double rate)
public final double adjustRateForSplitsInt(int date, double rate, int endDate)
public java.util.List<CurrencySplit> getSplits()
public final void sortStockSplits()
public final void sortSnapshots()
public final CurrencySnapshot setSnapshotInt(int date, double userRate)
public final CurrencySnapshot setSnapshotInt(int date, double userRate, CurrencyType relativeCurr)
public final CurrencySnapshot addSnapshotInt(int date, double userRate)
public java.util.List<CurrencySnapshot> getSnapshots()
public final double getRawRateByDateInt(int dt)
public final double getUserRateByDateInt(int dt)
public final void setHideInUI(boolean hideInUI)
public final boolean getHideInUI()
public java.lang.String getIDForScheme(java.lang.String idScheme)
public void setIDForScheme(java.lang.String idScheme, java.lang.String newID)
public final java.lang.String toString()
toString
in class java.lang.Object
public final java.lang.String formatFancy(long amt, char decimalChar)
public final java.lang.String formatSemiFancy(long amt, char decimalChar)
public final java.lang.String formatNoDecimals(long amt)
public final java.lang.String format(long amt, char decimalChar)
public final long parse(java.lang.String str, char decimalChar)
public final long parse(java.lang.String str, char decimalChar, boolean quickDecimal)
public static final long parseRaw(java.lang.String str)
public int compareToCurrency(CurrencyType curr)
public static final CurrencyType currencyFromFields(int id, java.lang.String idString, java.lang.String name, double rate, int decimalPlaces, java.lang.String prefix, java.lang.String suffix, java.lang.String tickerSymbol, int effectiveDate, int currencyType, CurrencyTable table)