Class MoneydanceSyncableItem
java.lang.Object
com.infinitekind.moneydance.model.MoneydanceSyncableItem
- All Implemented Interfaces:
com.infinitekind.tiksync.SyncableItem
- Direct Known Subclasses:
AbstractTxn,Account,AddressBookEntry,Budget,BudgetItem,CurrencySnapshot,CurrencySplit,CurrencyType,OnlineMailList,OnlinePayeeList,OnlinePaymentList,OnlineService,OnlineTxnList,Reminder,ReportSpec
public class MoneydanceSyncableItem
extends java.lang.Object
implements com.infinitekind.tiksync.SyncableItem
Created by sreilly - 2014.07.01 19:45
-
Field Summary
Fields Modifier and Type Field Description protected AccountBookbookprotected com.infinitekind.tiksync.SyncRecordinfostatic java.lang.StringSECURITY_SUBTYPES_ITEM_TYPE -
Constructor Summary
Constructors Constructor Description MoneydanceSyncableItem()MoneydanceSyncableItem(AccountBook book) -
Method Summary
Modifier and Type Method Description voidaddParameters(java.util.Map<java.lang.String,java.lang.String> additionalParams)Add/merge all parameters from the given map that don't already have a key in the internal mapvoidaddTags(java.util.Map<java.lang.String,java.lang.String> newTags)Set the TagSet associated with this object.protected booleanautoSyncsChanges()Return true if any changes to this object are automatically syncedstatic java.util.List<java.lang.String>decodeKeywordList(java.lang.String keywordString)booleandeleteItem()Deletes this item and writes a remove-item entry to the syncing system.booleandoesParameterExist(java.lang.String parameterName)MoneydanceSyncableItemduplicate()Return a clone of this object with the same backing infostatic java.lang.StringencodeKeywordList(java.util.List<java.lang.String> keywords)booleanequals(java.lang.Object obj)AccountgetAccountParameter(java.lang.String acctNumKey, java.lang.String acctIDKey, Account defaultValue)Lookup and return an account that was referenced by this object using one of the given parameter names.AddressBookEntrygetAddress()AddressBookEntrygetAddressParameter(java.lang.String addressNumKey, java.lang.String addressIDKey, AddressBookEntry defaultValue)Lookup and return an address book entry that was referenced by this object using one of the given parameter names.AccountBookgetBook()booleangetBooleanParameter(java.lang.String parameterName, boolean defaultVal)Get the specified parameter as a boolean.CurrencyTypegetCurrencyParameter(java.lang.String parameterName, CurrencyType defaultValue)Lookup and return the currency referenced by this object using the given parameter keyCurrencyTypegetCurrencyParameter(java.lang.String currNumKey, java.lang.String currIDKey, CurrencyType defaultValue)Lookup and return a currency that was referenced by this object using one of the given parameter names.CurrencyTypegetCurrencyParameter(java.lang.String currNumKey, java.lang.String currIDKey, java.lang.String currencyIDString, CurrencyType defaultValue)Lookup and return a currency that was referenced by this object using one of the given parameter names.doublegetDoubleParameter(java.lang.String parameterName, double defaultVal)Get the specified parameter as a double (64 bit) float.intgetIntParameter(java.lang.String parameterName, int defaultVal)Get the specified parameter as an integer.java.util.List<java.lang.String>getKeywords()longgetLongParameter(java.lang.String parameterName, long defaultVal)Get the specified parameter as a long.MoneydanceSyncableItemgetOriginalItem()java.lang.StringgetParameter(java.lang.String parameterName)java.lang.StringgetParameter(java.lang.String parameterName, java.lang.String defaultStr)Get the specified parameter name.intgetParameterCount()Get an enumeration of the keys of this object's parametersjava.util.Set<java.lang.String>getParameterKeys()java.lang.StringgetPreference(java.lang.String key, java.lang.String defaultValue)Returns the String value associated with the given key in the local data file-specific preferencesbooleangetPreferenceBoolean(java.lang.String key, boolean defaultValue)Returns the boolean value associated with the given key in the local data file-specific preferencesdoublegetPreferenceDouble(java.lang.String key, double defaultValue)Returns the double value associated with the given key in the local data file-specific preferencesintgetPreferenceInt(java.lang.String key, int defaultValue)Returns the integer value associated with the given key in the local data file-specific preferencesint[]getPreferenceIntArray(java.lang.String key)Returns an array of integers from in the local data file-specific preferences that were stored using setPreference(String, int[])longgetPreferenceLong(java.lang.String key, long defaultValue)Returns the long value associated with the given key in the local data file-specific preferencesjava.util.List<java.lang.String>getPreferenceStringList(java.lang.String key)Return a list of string values that were stored with setPreference(key, ...) (ie in the local data file-specific preferences)java.util.List<com.infinitekind.tiksync.SyncRecord>getPreferenceSublist(java.lang.String prefix)Returns a list of SyncRecord objects which were stored with setPreference(key, ...) in the local data file-specific preferences.com.infinitekind.tiksync.SyncRecordgetPreferenceSubset(java.lang.String prefix)Returns a new SyncRecord with the key-value pairs for which the keys have the given prefix in the local data file-specific preferences.java.util.List<java.lang.String>getStringListParameter(java.lang.String key)Return a list of string values that were stored with setPreference(key, ...) (ie in the local data file-specific preferences)com.infinitekind.tiksync.SyncRecordgetSyncInfo()save this item to a new SyncRecord and return it.java.lang.StringgetSyncItemType()Subclasses should override this to return a static string identifying their type of objectlonggetSyncTimestamp()The timestamp is handled in the loading/syncing codejava.lang.StringgetUUID()Return the unique identifier for this objectbooleanhasBeenSynced()Returns true if this object has already been recorded as part of this data set.inthashCode()booleanhasKeywordSubstring(java.lang.String matchString, boolean caseSensitive)protected voidinitialize(AccountBook book)protected booleanisInEditingMode()protected booleanisSyncable()protected voiditemWasUpdated()This is called after an item is updated by calling itemWasUpdated(SyncRecord).voiditemWasUpdated(com.infinitekind.tiksync.SyncRecord syncInfo)Is called when this item was synced from the net so that the object can be made aware of new valuesprotected voiditemWillSync()This is called just before an item will be stored and/or synced when itemWillSync(SyncRecord) is called.voiditemWillSync(com.infinitekind.tiksync.SyncRecord syncInfo)Called just before this item is synced to the net so that the object can store its values into the given map.static MoneydanceSyncableItemmakeSyncableItem(AccountBook accountBook, com.infinitekind.tiksync.SyncRecord itemInfo)voidremoveParameter(java.lang.String parameterName)Remove the parameter with the given name.voidsetAccountParameter(java.lang.String acctNumKey, java.lang.String acctIDKey, Account acct)Store a reference to acct in this object using the given keys.voidsetAddress(AddressBookEntry address)voidsetAddressParameter(java.lang.String oldAddressIDKey, java.lang.String addressIDKey, AddressBookEntry address)Store a reference to address in this account using the keys.voidsetCurrencyParameter(java.lang.String parameterName, CurrencyType currency)Store a reference to the given currency in this object using the given parameter key.voidsetCurrencyParameter(java.lang.String currNumKey, java.lang.String currIDKey, CurrencyType curr)Store a reference to currency in this object using the given keys.voidsetCurrencyParameter(java.lang.String currNumKey, java.lang.String currIDKey, java.lang.String currencyIDStringKey, CurrencyType curr)Store a reference to currency in this object using the given keys.protected voidsetDirty()Marks this object as needing saving and puts it in a buffer for objects needing syncingvoidsetEditingMode()Put the object into "editing mode" in which no changes will be automatically saved until you call syncItem() on this.voidsetKeywords(java.util.List<java.lang.String> newKeywords)Store a reference to the given keywords (aka tags) in this object.voidsetParameter(java.lang.String parameterName, boolean parameterValue)Set the given parameter name to the given boolean valuevoidsetParameter(java.lang.String parameterName, double parameterValue)Set the given parameter name to the given double valuevoidsetParameter(java.lang.String parameterName, int parameterValue)Set the given parameter name to the given integer valuevoidsetParameter(java.lang.String parameterName, long parameterValue)Set the given parameter name to the given long valuevoidsetParameter(java.lang.String name, java.lang.String val)voidsetParameter(java.lang.String name, java.util.List value)voidsetParameter(java.lang.String name, java.util.Map value)voidsetParameterNoNotify(java.lang.String parameterName, java.lang.String parameterValue)Set the given parameter name to the given value but don't notify listeners of changes!voidsetPreference(java.lang.String parameterName, boolean parameterValue)Set the given parameter name to the given boolean value, without sending an account-changed event, or recording the account as dirty.voidsetPreference(java.lang.String parameterName, int parameterValue)Set the given parameter name to the given integer value, without sending an account-changed event, or recording the account as dirty.voidsetPreference(java.lang.String parameterName, java.lang.String parameterValue)Set the given preference name to the given value and associate it with this object in _local storage_.booleansyncItem()Call this to tell the storage that this item was changed and needs to be synced Please don't call this when either of the itemWasUpdated(..) methods are invoked unless you enjoy infinite loops as well as wasting bandwidth and disk space.
-
Field Details
-
SECURITY_SUBTYPES_ITEM_TYPE
public static final java.lang.String SECURITY_SUBTYPES_ITEM_TYPE- See Also:
- Constant Field Values
-
info
protected com.infinitekind.tiksync.SyncRecord info -
book
-
-
Constructor Details
-
MoneydanceSyncableItem
-
MoneydanceSyncableItem
public MoneydanceSyncableItem()
-
-
Method Details
-
initialize
-
getBook
-
setEditingMode
public void setEditingMode()Put the object into "editing mode" in which no changes will be automatically saved until you call syncItem() on this. Note that calling duplicate() will put the new duplicate into editing mode automatically -
isInEditingMode
protected boolean isInEditingMode() -
syncItem
public boolean syncItem()Call this to tell the storage that this item was changed and needs to be synced Please don't call this when either of the itemWasUpdated(..) methods are invoked unless you enjoy infinite loops as well as wasting bandwidth and disk space. -
deleteItem
public boolean deleteItem()Deletes this item and writes a remove-item entry to the syncing system. Use with caution! -
autoSyncsChanges
protected boolean autoSyncsChanges()Return true if any changes to this object are automatically synced -
setDirty
protected void setDirty()Marks this object as needing saving and puts it in a buffer for objects needing syncing -
itemWasUpdated
protected void itemWasUpdated()This is called after an item is updated by calling itemWasUpdated(SyncRecord). This can occur from the syncing process or from being loaded locally. Override this method to be notified. -
itemWasUpdated
public final void itemWasUpdated(com.infinitekind.tiksync.SyncRecord syncInfo)Description copied from interface:com.infinitekind.tiksync.SyncableItemIs called when this item was synced from the net so that the object can be made aware of new values- Specified by:
itemWasUpdatedin interfacecom.infinitekind.tiksync.SyncableItem
-
itemWillSync
protected void itemWillSync()This is called just before an item will be stored and/or synced when itemWillSync(SyncRecord) is called. Override this method to be notified or if you'd like to store anything into the info record to be synced. -
itemWillSync
public final void itemWillSync(com.infinitekind.tiksync.SyncRecord syncInfo)Description copied from interface:com.infinitekind.tiksync.SyncableItemCalled just before this item is synced to the net so that the object can store its values into the given map.- Specified by:
itemWillSyncin interfacecom.infinitekind.tiksync.SyncableItem
-
isSyncable
protected boolean isSyncable() -
hasBeenSynced
public boolean hasBeenSynced()Returns true if this object has already been recorded as part of this data set. This can often be used to tell whether we're creating a new object or editing an existing one, for example in a transaction or account editor form.- Since:
- Moneydance build 1511
-
getUUID
public final java.lang.String getUUID()Description copied from interface:com.infinitekind.tiksync.SyncableItemReturn the unique identifier for this object- Specified by:
getUUIDin interfacecom.infinitekind.tiksync.SyncableItem
-
getSyncInfo
public final com.infinitekind.tiksync.SyncRecord getSyncInfo()save this item to a new SyncRecord and return it. This is a shortcut to SyncRecord r = new SyncRecord(); itemWillSync(r); return r; -
getSyncTimestamp
public final long getSyncTimestamp()The timestamp is handled in the loading/syncing code- Specified by:
getSyncTimestampin interfacecom.infinitekind.tiksync.SyncableItem
-
getSyncItemType
public java.lang.String getSyncItemType()Subclasses should override this to return a static string identifying their type of object- Specified by:
getSyncItemTypein interfacecom.infinitekind.tiksync.SyncableItem
-
duplicate
Return a clone of this object with the same backing info -
getOriginalItem
-
doesParameterExist
public final boolean doesParameterExist(java.lang.String parameterName) -
getParameter
public final java.lang.String getParameter(java.lang.String parameterName) -
getParameter
public final java.lang.String getParameter(java.lang.String parameterName, java.lang.String defaultStr)Get the specified parameter name. If the given parameter does not have a value, return the given defaultStr -
getStringListParameter
public java.util.List<java.lang.String> getStringListParameter(java.lang.String key)Return a list of string values that were stored with setPreference(key, ...) (ie in the local data file-specific preferences)- Since:
- build 1570 (Moneydance 2017)
-
getIntParameter
public final int getIntParameter(java.lang.String parameterName, int defaultVal)Get the specified parameter as an integer. If the given parameter does not have a value, or if it is not an integer, return the given defaul value -
getLongParameter
public final long getLongParameter(java.lang.String parameterName, long defaultVal)Get the specified parameter as a long. If the given parameter does not have a value, or if it is not a long, return the given defaul value. This method was created as of build 254. -
getDoubleParameter
public double getDoubleParameter(java.lang.String parameterName, double defaultVal)Get the specified parameter as a double (64 bit) float. If the given parameter does not have a value, or if it is not an double, return the given defaul value -
getBooleanParameter
public final boolean getBooleanParameter(java.lang.String parameterName, boolean defaultVal)Get the specified parameter as a boolean. If the given parameter does not have a value, or if it is not a boolean, return the given default value -
setParameter
public final void setParameter(java.lang.String parameterName, boolean parameterValue)Set the given parameter name to the given boolean value -
setParameter
public final void setParameter(java.lang.String parameterName, int parameterValue)Set the given parameter name to the given integer value -
setParameter
public final void setParameter(java.lang.String parameterName, long parameterValue)Set the given parameter name to the given long value -
setParameter
public final void setParameter(java.lang.String parameterName, double parameterValue)Set the given parameter name to the given double value -
setPreference
public final void setPreference(java.lang.String parameterName, boolean parameterValue)Set the given parameter name to the given boolean value, without sending an account-changed event, or recording the account as dirty. -
setPreference
public final void setPreference(java.lang.String parameterName, int parameterValue)Set the given parameter name to the given integer value, without sending an account-changed event, or recording the account as dirty. -
setPreference
public final void setPreference(java.lang.String parameterName, java.lang.String parameterValue)Set the given preference name to the given value and associate it with this object in _local storage_. This will not be synced and neither will it result in any modification notifications being triggered. -
setParameter
public final void setParameter(java.lang.String name, java.lang.String val) -
addParameters
public void addParameters(java.util.Map<java.lang.String,java.lang.String> additionalParams)Add/merge all parameters from the given map that don't already have a key in the internal map -
addTags
public final void addTags(java.util.Map<java.lang.String,java.lang.String> newTags)Set the TagSet associated with this object. This should only be called when initially constructing this object from old data files. In other words, DON'T USE THIS! -
setParameter
public final void setParameter(java.lang.String name, java.util.Map value) -
setParameter
public final void setParameter(java.lang.String name, java.util.List value) -
getPreferenceSubset
public com.infinitekind.tiksync.SyncRecord getPreferenceSubset(java.lang.String prefix)Returns a new SyncRecord with the key-value pairs for which the keys have the given prefix in the local data file-specific preferences. -
getPreferenceStringList
public java.util.List<java.lang.String> getPreferenceStringList(java.lang.String key)Return a list of string values that were stored with setPreference(key, ...) (ie in the local data file-specific preferences) -
getPreferenceSublist
public java.util.List<com.infinitekind.tiksync.SyncRecord> getPreferenceSublist(java.lang.String prefix)Returns a list of SyncRecord objects which were stored with setPreference(key, ...) in the local data file-specific preferences. -
getPreferenceInt
public int getPreferenceInt(java.lang.String key, int defaultValue)Returns the integer value associated with the given key in the local data file-specific preferences -
getPreferenceIntArray
public int[] getPreferenceIntArray(java.lang.String key)Returns an array of integers from in the local data file-specific preferences that were stored using setPreference(String, int[]) -
getPreferenceLong
public long getPreferenceLong(java.lang.String key, long defaultValue)Returns the long value associated with the given key in the local data file-specific preferences -
getPreferenceDouble
public double getPreferenceDouble(java.lang.String key, double defaultValue)Returns the double value associated with the given key in the local data file-specific preferences -
getPreferenceBoolean
public boolean getPreferenceBoolean(java.lang.String key, boolean defaultValue)Returns the boolean value associated with the given key in the local data file-specific preferences -
getPreference
public java.lang.String getPreference(java.lang.String key, java.lang.String defaultValue)Returns the String value associated with the given key in the local data file-specific preferences -
setParameterNoNotify
public final void setParameterNoNotify(java.lang.String parameterName, java.lang.String parameterValue)Set the given parameter name to the given value but don't notify listeners of changes! -
removeParameter
public final void removeParameter(java.lang.String parameterName)Remove the parameter with the given name. -
getParameterCount
public final int getParameterCount()Get an enumeration of the keys of this object's parameters -
getAccountParameter
public Account getAccountParameter(java.lang.String acctNumKey, java.lang.String acctIDKey, Account defaultValue)Lookup and return an account that was referenced by this object using one of the given parameter names. Priority is given to acctIDKey which should reference the UUID of the account being referenced. If the acctIDKey lookup is not successfull then a lookup is done using the acctNumKey which references the integer account ID that is returned by getAccountNum() on the referenced account. If either acctNumKey or acctIDKey is null then that key is not checked for an account reference. -
setAccountParameter
public void setAccountParameter(java.lang.String acctNumKey, java.lang.String acctIDKey, Account acct)Store a reference to acct in this object using the given keys. The acctNumKey, if non-null, refers to the number returned by acct.getAccountNum(). The acctIDKey, if non-null, refers to the string returned by acct.getUUID() and will generally be more reliable and have a faster lookup time. If not storing references to accounts that have been migrated from before Moneydance 2015 then please only use the acctIDKey to store references. -
getCurrencyParameter
public CurrencyType getCurrencyParameter(java.lang.String parameterName, CurrencyType defaultValue)Lookup and return the currency referenced by this object using the given parameter key- Since:
- build 1800 (Moneydance 2018)
-
setCurrencyParameter
Store a reference to the given currency in this object using the given parameter key.- Since:
- build 1800 (Moneydance 2018)
-
getCurrencyParameter
public CurrencyType getCurrencyParameter(java.lang.String currNumKey, java.lang.String currIDKey, CurrencyType defaultValue)Lookup and return a currency that was referenced by this object using one of the given parameter names. Priority is given to currIDKey which should reference the UUID of the currency being referenced. If the currIDKey lookup is not successfull then a lookup is done using the currNumKey which references the integer account ID that is returned by getID() method on the referenced currency. If either currNumKey or currIDKey is null then that key is not checked for a currency reference. -
getCurrencyParameter
public CurrencyType getCurrencyParameter(java.lang.String currNumKey, java.lang.String currIDKey, java.lang.String currencyIDString, CurrencyType defaultValue)Lookup and return a currency that was referenced by this object using one of the given parameter names. Priority is given to currIDKey which should reference the UUID of the currency being referenced. If the currIDKey lookup is not successfull then a lookup is done using the currNumKey which references the integer account ID that is returned by getID() method on the referenced currency. If no currency has been found then the parameter value associated with the currencyIDString key is checked for a currency ID string (usually the three character ISO currency ID). Any of the parameters currNumKey, currIDKey, or currencyIDString can be null in which case that parameter is not checked for a currency reference.- Since:
- build 1664 (Moneydance 2017.7)
-
setCurrencyParameter
public void setCurrencyParameter(java.lang.String currNumKey, java.lang.String currIDKey, CurrencyType curr)Store a reference to currency in this object using the given keys. The currNumKey, if non-null, refers to the number returned by curr.getID(). The currIDKey, if non-null, refers to the string returned by curr.getUUID() and will generally be more reliable and have a faster lookup time. If not storing references to accounts that have been migrated from before Moneydance 2015 then please only use the acctIDKey to store references. -
setCurrencyParameter
public void setCurrencyParameter(java.lang.String currNumKey, java.lang.String currIDKey, java.lang.String currencyIDStringKey, CurrencyType curr)Store a reference to currency in this object using the given keys. The currNumKey, if non-null, refers to the number returned by curr.getID(). The currIDKey, if non-null, refers to the string returned by curr.getUUID() and will generally be more reliable and have a faster lookup time. If not storing references to accounts that have been migrated from before Moneydance 2015 then please only use the acctIDKey to store references. -
getAddressParameter
public AddressBookEntry getAddressParameter(java.lang.String addressNumKey, java.lang.String addressIDKey, AddressBookEntry defaultValue)Lookup and return an address book entry that was referenced by this object using one of the given parameter names. Priority is given to addressIDKey which should reference the UUID of the address being referenced. If the addressIDKey lookup is not successfull then a lookup is done using the addressNumKey which references the integer address ID that is returned by getID() on the referenced account. If either addressNumKey or addressIDKey is null then that key is not checked for an account reference. -
setAddress
-
getAddress
-
setAddressParameter
public void setAddressParameter(java.lang.String oldAddressIDKey, java.lang.String addressIDKey, AddressBookEntry address)Store a reference to address in this account using the keys. The acctNumKey, if non-null, refers to the number returned by address.getAccountNum(). The acctIDKey, if non-null, refers to the string returned by address.getUUID() and will generally be more reliable and have a faster lookup time. If not storing references to accounts that have been migrated from before Moneydance 2015 then please only use the acctIDKey to store references. -
setKeywords
public void setKeywords(java.util.List<java.lang.String> newKeywords)Store a reference to the given keywords (aka tags) in this object. Note this removes any tab characters -
getKeywords
public java.util.List<java.lang.String> getKeywords() -
hasKeywordSubstring
public boolean hasKeywordSubstring(java.lang.String matchString, boolean caseSensitive) -
encodeKeywordList
public static java.lang.String encodeKeywordList(java.util.List<java.lang.String> keywords) -
decodeKeywordList
public static java.util.List<java.lang.String> decodeKeywordList(java.lang.String keywordString) -
getParameterKeys
public final java.util.Set<java.lang.String> getParameterKeys() -
makeSyncableItem
public static MoneydanceSyncableItem makeSyncableItem(AccountBook accountBook, com.infinitekind.tiksync.SyncRecord itemInfo) -
equals
public boolean equals(java.lang.Object obj)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-