Class LocalStorage
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<java.lang.String,java.lang.String>
com.infinitekind.tiksync.SyncRecord
com.infinitekind.moneydance.model.LocalStorage
- All Implemented Interfaces:
com.infinitekind.tiksync.SyncFolder,com.infinitekind.tiksync.SyncStorage,java.io.Serializable,java.lang.Cloneable,java.util.Map<java.lang.String,java.lang.String>
public abstract class LocalStorage
extends com.infinitekind.tiksync.SyncRecord
implements com.infinitekind.tiksync.SyncStorage
Created by sreilly - 01/08/2014 09:27
- See Also:
- Serialized Form
-
Nested Class Summary
-
Field Summary
Fields Modifier and Type Field Description protected com.infinitekind.tiksync.SyncRecordauthenticationCache -
Constructor Summary
Constructors Constructor Description LocalStorage() -
Method Summary
Modifier and Type Method Description voidcacheAuthentication(java.lang.String key, java.lang.String authVal)Used by OnlineService to cache authenticationvoidclearAuthenticationCache(java.lang.String prefix)Remove any stored passwords for the given service whose key begins with the given prefixabstract voiddelete(java.lang.String filename)Deletes a local data file or folder.abstract booleanexists(java.lang.String filename)Returns true iff a file exists at the given path in the safe storage.java.lang.StringgetCachedAuthentication(java.lang.String key)Used by local modules to retrieve cached authentication and other secure informationabstract booleanisFolder(java.lang.String filename)Returns true iff a file at the given path exists and is a folder.static java.lang.StringjoinPath(java.lang.String folder, java.lang.String file)abstract java.util.List<java.lang.String>listFiles(java.lang.String folderPath)Returns a list of files under the given folder path.abstract java.util.List<java.lang.String>listSubfolders(java.lang.String folderPath)Returns a list of folders under the given folder path.abstract voidmoveFile(java.lang.String fromFile, java.lang.String toFileOrFolder)Move or rename the given fromFile to the given file or folder.abstract java.io.InputStreamopenFileForReading(java.lang.String filename)Reads from a local data file, decrypting as it goes.abstract java.io.OutputStreamopenFileForWriting(java.lang.String filename)Returns a stream for writing to a local data file, encrypting as it goes.abstract longreadFile(java.lang.String filename, java.io.OutputStream sinkStream)Reads from a local data file, decrypting as it goes.abstract booleansave()Saves the key-value data to local storageabstract voidwriteFile(java.lang.String filename, java.io.InputStream dataToWrite)Writes to a local data file, encrypting as it goes.abstract voidwriteToFileAtomically(byte[] bytesToWrite, java.lang.String destinationFilename)Encrypts and writes to a local data file atomically.Methods inherited from class com.infinitekind.tiksync.SyncRecord
clone, createFrom, createFrom, getBoolean, getDouble, getInt, getIntArray, getLabel, getLong, getStr, getString, getStringList, getSublist, getSubset, printHumanReadableContents, put, put, put, put, put, put, put, put, put, put, put, readSet, readSet, removeSubset, setLabel, toMultilineHumanReadableString, toString, unescapeAndDecodeUTF8, writeSet, writeToBytes, writeToStringMethods inherited from class java.util.HashMap
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Field Details
-
authenticationCache
protected com.infinitekind.tiksync.SyncRecord authenticationCache
-
-
Constructor Details
-
LocalStorage
public LocalStorage()
-
-
Method Details
-
save
public abstract boolean save()Saves the key-value data to local storage -
exists
public abstract boolean exists(java.lang.String filename) throws java.lang.ExceptionReturns true iff a file exists at the given path in the safe storage. If filename is a relative path (which it should be) it will be based on the safe root of the data folder.- Specified by:
existsin interfacecom.infinitekind.tiksync.SyncFolder- Specified by:
existsin interfacecom.infinitekind.tiksync.SyncStorage- Throws:
java.lang.Exception
-
isFolder
public abstract boolean isFolder(java.lang.String filename) throws java.lang.ExceptionReturns true iff a file at the given path exists and is a folder. If filename is a relative path (which it should be) it will be based on the safe root of the data folder.- Specified by:
isFolderin interfacecom.infinitekind.tiksync.SyncStorage- Throws:
java.lang.Exception
-
listFiles
public abstract java.util.List<java.lang.String> listFiles(java.lang.String folderPath)Returns a list of files under the given folder path. If folderPath is a relative path (which it should be) it will be based on the safe root of the data folder.- Specified by:
listFilesin interfacecom.infinitekind.tiksync.SyncFolder- Specified by:
listFilesin interfacecom.infinitekind.tiksync.SyncStorage
-
listSubfolders
public abstract java.util.List<java.lang.String> listSubfolders(java.lang.String folderPath)Returns a list of folders under the given folder path. If folderPath is a relative path (which it should be) it will be based on the safe root of the data folder.- Specified by:
listSubfoldersin interfacecom.infinitekind.tiksync.SyncFolder- Specified by:
listSubfoldersin interfacecom.infinitekind.tiksync.SyncStorage
-
openFileForReading
public abstract java.io.InputStream openFileForReading(java.lang.String filename) throws java.lang.ExceptionReads from a local data file, decrypting as it goes. If filename is a relative path (which it should be) it will be based on the safe root of the data folder.- Specified by:
openFileForReadingin interfacecom.infinitekind.tiksync.SyncStorage- Throws:
java.lang.Exception
-
openFileForWriting
public abstract java.io.OutputStream openFileForWriting(java.lang.String filename) throws java.lang.ExceptionReturns a stream for writing to a local data file, encrypting as it goes. If filename is a relative path (which it should be) it will be based on the safe root of the data folder.- Specified by:
openFileForWritingin interfacecom.infinitekind.tiksync.SyncStorage- Throws:
java.lang.Exception
-
writeFile
public abstract void writeFile(java.lang.String filename, java.io.InputStream dataToWrite) throws java.lang.ExceptionWrites to a local data file, encrypting as it goes. The data to write is read from the given input stream. If filename is a relative path (which it should be) it will be based on the safe root of the data folder.- Specified by:
writeFilein interfacecom.infinitekind.tiksync.SyncFolder- Specified by:
writeFilein interfacecom.infinitekind.tiksync.SyncStorage- Throws:
java.lang.Exception
-
readFile
public abstract long readFile(java.lang.String filename, java.io.OutputStream sinkStream) throws java.lang.ExceptionReads from a local data file, decrypting as it goes. The data is read from the given local file, decrypted, and then written to the given output stream. If filename is a relative path (which it should be) it will be based on the safe root of the data folder. Returns the number of (decrypted) bytes read and copied.- Specified by:
readFilein interfacecom.infinitekind.tiksync.SyncStorage- Throws:
java.lang.Exception
-
delete
public abstract void delete(java.lang.String filename) throws java.lang.ExceptionDeletes a local data file or folder. If filename is a relative path (which it should be) it will be based on the safe root of the data folder.- Specified by:
deletein interfacecom.infinitekind.tiksync.SyncFolder- Specified by:
deletein interfacecom.infinitekind.tiksync.SyncStorage- Throws:
java.lang.Exception
-
moveFile
public abstract void moveFile(java.lang.String fromFile, java.lang.String toFileOrFolder) throws java.io.IOExceptionMove or rename the given fromFile to the given file or folder.- Specified by:
moveFilein interfacecom.infinitekind.tiksync.SyncStorage- Throws:
java.io.IOException
-
writeToFileAtomically
public abstract void writeToFileAtomically(byte[] bytesToWrite, java.lang.String destinationFilename) throws java.lang.ExceptionEncrypts and writes to a local data file atomically. The given data is saved to the file atomically. That is, it does everything possible to ensure the write will succeed before actually changing the target file. Any IO exceptions should be thrown before the target file is touched. If filename is a relative path (which it should be) it will be based on the safe root of the data folder.- Specified by:
writeToFileAtomicallyin interfacecom.infinitekind.tiksync.SyncStorage- Throws:
java.lang.Exception
-
cacheAuthentication
public void cacheAuthentication(java.lang.String key, java.lang.String authVal)Used by OnlineService to cache authentication -
getCachedAuthentication
public java.lang.String getCachedAuthentication(java.lang.String key)Used by local modules to retrieve cached authentication and other secure information -
clearAuthenticationCache
public void clearAuthenticationCache(java.lang.String prefix)Remove any stored passwords for the given service whose key begins with the given prefix -
joinPath
public static java.lang.String joinPath(java.lang.String folder, java.lang.String file)
-