Package gov.nasa.worldwind.cache
Class AbstractFileStore
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.cache.AbstractFileStore
-
- All Implemented Interfaces:
AVList,FileStore,MessageListener,WWObject,java.beans.PropertyChangeListener,java.util.EventListener
- Direct Known Subclasses:
BasicDataFileStore
public abstract class AbstractFileStore extends WWObjectImpl implements FileStore
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAbstractFileStore.StoreLocation
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<AbstractFileStore.StoreLocation>readLocationsprotected AbstractFileStore.StoreLocationwriteLocation
-
Constructor Summary
Constructors Constructor Description AbstractFileStore()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLocation(int index, java.lang.String newPath, boolean isInstall)Adds a location to search when files are requested from the file store and specifies its location in the search order.voidaddLocation(java.lang.String newPath, boolean isInstall)Adds a location to search when files are requested from the file store.protected static java.lang.StringbuildLocationPath(java.lang.String property, java.lang.String append, java.lang.String wwDir)protected voidbuildReadPaths(org.w3c.dom.Node dataFileStoreNode)protected voidbuildWritePaths(org.w3c.dom.Node dataFileCacheNode)booleancontainsFile(java.lang.String fileName)Indicates whether the file store contains a specified file.protected static java.lang.StringdetermineAllUserLocation()protected static java.lang.StringdetermineSingleUserLocation()protected voiddoListFileNames(AbstractFileStore.StoreLocation location, java.io.File dir, FileStoreFilter filter, boolean recurse, boolean exitBranchOnFirstMatch, java.util.Collection<java.lang.String> names)protected java.lang.String[]doListFileNames(java.lang.String pathName, FileStoreFilter filter, boolean recurse, boolean exitBranchOnFirstMatch)java.net.URLfindFile(java.lang.String fileName, boolean checkClassPath)Searches the file store for a specified file and returns a reference to it if it is.java.util.List<? extends java.io.File>getLocations()Returns the locations that the file store will look for files.protected static java.lang.StringgetUserHomeDir()java.io.FilegetWriteLocation()Returns the location that additions to the file store are placed.protected voidinitialize(java.io.InputStream xmlConfigStream)booleanisInstallLocation(java.lang.String path)Indicates whether a specified location is considered an installed-data location and therefore not subject to automatic removal of its contents.java.lang.String[]listAllFileNames(java.lang.String pathName, FileStoreFilter filter)Returns an array of strings naming the files discovered under a specified file store path name.protected booleanlistFile(AbstractFileStore.StoreLocation location, java.io.File file, FileStoreFilter filter, java.util.Collection<java.lang.String> names)protected booleanlistFileName(AbstractFileStore.StoreLocation location, java.lang.String fileName, FileStoreFilter filter, java.util.Collection<java.lang.String> names)java.lang.String[]listFileNames(java.lang.String pathName, FileStoreFilter filter)Returns an array of strings naming the files discovered directly under a specified file store path name.java.lang.String[]listTopFileNames(java.lang.String pathName, FileStoreFilter filter)Returns an array of strings naming the files discovered under a specified file store path name.protected static java.io.FilemakeAbsoluteFile(java.io.File file, java.lang.String fileName)protected static java.lang.StringmakeAbsolutePath(java.io.File dir, java.lang.String fileName)protected static voidmarkFileUsed(java.io.File file)java.io.FilenewFile(java.lang.String fileName)Creates a new, empty file in the file store.protected static java.lang.StringnormalizeFileStoreName(java.lang.String fileName)protected static java.lang.StringpropertyToPath(java.lang.String propName)voidremoveFile(java.net.URL url)Removes a file from the file store using the URL to the cached file.voidremoveLocation(java.lang.String path)Remove a specified read location from the file store.protected AbstractFileStore.StoreLocationstoreLocationFor(java.lang.String path)protected static java.lang.StringstorePathForFile(AbstractFileStore.StoreLocation location, java.io.File file)-
Methods inherited from class gov.nasa.worldwind.WWObjectImpl
onMessage, propertyChange
-
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface gov.nasa.worldwind.avlist.AVList
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
-
Methods inherited from interface gov.nasa.worldwind.cache.FileStore
getContentType, getExpirationTime, removeFile, requestFile, requestFile
-
Methods inherited from interface gov.nasa.worldwind.event.MessageListener
onMessage
-
-
-
-
Field Detail
-
readLocations
protected final java.util.List<AbstractFileStore.StoreLocation> readLocations
-
writeLocation
protected AbstractFileStore.StoreLocation writeLocation
-
-
Method Detail
-
initialize
protected void initialize(java.io.InputStream xmlConfigStream)
-
buildReadPaths
protected void buildReadPaths(org.w3c.dom.Node dataFileStoreNode)
-
buildWritePaths
protected void buildWritePaths(org.w3c.dom.Node dataFileCacheNode)
-
buildLocationPath
protected static java.lang.String buildLocationPath(java.lang.String property, java.lang.String append, java.lang.String wwDir)
-
propertyToPath
protected static java.lang.String propertyToPath(java.lang.String propName)
-
determineAllUserLocation
protected static java.lang.String determineAllUserLocation()
-
determineSingleUserLocation
protected static java.lang.String determineSingleUserLocation()
-
getUserHomeDir
protected static java.lang.String getUserHomeDir()
-
getLocations
public java.util.List<? extends java.io.File> getLocations()
Description copied from interface:FileStoreReturns the locations that the file store will look for files.- Specified by:
getLocationsin interfaceFileStore- Returns:
- the list of locations the file store will search when a file is requested.
-
getWriteLocation
public java.io.File getWriteLocation()
Description copied from interface:FileStoreReturns the location that additions to the file store are placed.- Specified by:
getWriteLocationin interfaceFileStore- Returns:
- the location at which new entries are placed.
-
addLocation
public void addLocation(java.lang.String newPath, boolean isInstall)Description copied from interface:FileStoreAdds a location to search when files are requested from the file store.- Specified by:
addLocationin interfaceFileStore- Parameters:
newPath- the location to add. If the location already exists in the list of read locations its entry is removed and a new entry is added to the end of the search list.isInstall- indicates whether the location is an "installed data" location and therefore not subject to automatic removal of its contents.
-
addLocation
public void addLocation(int index, java.lang.String newPath, boolean isInstall)Description copied from interface:FileStoreAdds a location to search when files are requested from the file store and specifies its location in the search order.- Specified by:
addLocationin interfaceFileStore- Parameters:
index- the location in the search list at which to add the new location.newPath- the location to add.isInstall- indicates whether the location is an installed-data location and therefore not subject to automatic removal of its contents.
-
removeLocation
public void removeLocation(java.lang.String path)
Description copied from interface:FileStoreRemove a specified read location from the file store. The current write location cannot be removed.- Specified by:
removeLocationin interfaceFileStore- Parameters:
path- the read location to remove.
-
isInstallLocation
public boolean isInstallLocation(java.lang.String path)
Description copied from interface:FileStoreIndicates whether a specified location is considered an installed-data location and therefore not subject to automatic removal of its contents.- Specified by:
isInstallLocationin interfaceFileStore- Parameters:
path- the path in question.- Returns:
- true if the location is an installed-data location, otherwise false.
-
storeLocationFor
protected AbstractFileStore.StoreLocation storeLocationFor(java.lang.String path)
-
containsFile
public boolean containsFile(java.lang.String fileName)
Description copied from interface:FileStoreIndicates whether the file store contains a specified file.- Specified by:
containsFilein interfaceFileStore- Parameters:
fileName- the file in question.- Returns:
- true if the file store contains the file, false if the file store does not contain the file or the specified path is null.
-
findFile
public java.net.URL findFile(java.lang.String fileName, boolean checkClassPath)Description copied from interface:FileStoreSearches the file store for a specified file and returns a reference to it if it is.- Specified by:
findFilein interfaceFileStore- Parameters:
fileName- the name of the file to findcheckClassPath- iftrue, the class path is first searched for the file, otherwise the class path is not searched unless it's one of the explicit paths in the cache search directories- Returns:
- a handle to the requested file if it exists in the cache, otherwise null
- Throws:
java.lang.IllegalArgumentException- iffileNameis null
-
markFileUsed
protected static void markFileUsed(java.io.File file)
-
newFile
public java.io.File newFile(java.lang.String fileName)
Description copied from interface:FileStoreCreates a new, empty file in the file store.If the file store has no write location, the file is not created and null is returned.
-
removeFile
public void removeFile(java.net.URL url)
Description copied from interface:FileStoreRemoves a file from the file store using the URL to the cached file.- Specified by:
removeFilein interfaceFileStore- Parameters:
url- the "file:" URL of the file to remove from the file store. Only files in the writable WorldWind disk cache or temp file directory are removed by this method.- Throws:
java.lang.IllegalArgumentException- ifurlis null
-
makeAbsoluteFile
protected static java.io.File makeAbsoluteFile(java.io.File file, java.lang.String fileName)
-
makeAbsolutePath
protected static java.lang.String makeAbsolutePath(java.io.File dir, java.lang.String fileName)
-
normalizeFileStoreName
protected static java.lang.String normalizeFileStoreName(java.lang.String fileName)
-
storePathForFile
protected static java.lang.String storePathForFile(AbstractFileStore.StoreLocation location, java.io.File file)
-
listFileNames
public java.lang.String[] listFileNames(java.lang.String pathName, FileStoreFilter filter)Description copied from interface:FileStoreReturns an array of strings naming the files discovered directly under a specified file store path name. If the path name is null, files under the store root are searched. This returns null if the path does not exist in the store. Returned names are relative pointers to a file in the store; they are not necessarily a file system path.- Specified by:
listFileNamesin interfaceFileStore- Parameters:
pathName- relative path in the file store to search, or null to search the entire file store.filter- a file filter.- Returns:
- an array of file store names. Returns null if the path does not exist in the file store.
-
listAllFileNames
public java.lang.String[] listAllFileNames(java.lang.String pathName, FileStoreFilter filter)Description copied from interface:FileStoreReturns an array of strings naming the files discovered under a specified file store path name. If the path name is null, the entire file store will be searched. Otherwise the file store is recursively searched under the specified path name for files accepted by the specified filter, until the entire path tree is exhausted. This returns null if the path does not exist in the store. Returned names are relative pointers to a file in the store; they are not necessarily a file system path.- Specified by:
listAllFileNamesin interfaceFileStore- Parameters:
pathName- relative path in the file store to search, or null to search the entire file store.filter- a file filter.- Returns:
- an array of file store names. Returns null if the path does not exist in the file store.
-
listTopFileNames
public java.lang.String[] listTopFileNames(java.lang.String pathName, FileStoreFilter filter)Description copied from interface:FileStoreReturns an array of strings naming the files discovered under a specified file store path name. If the path name is null, the entire file store will be searched. Otherwise the file store is recursively searched under each branch of the the specified path name until a matching file is found, or that branch is exhausted. UnlikeFileStore.listAllFileNames(String, FileStoreFilter), This has the effect of locating the top file name under each branch. This returns null if the path does not exist in the store. Returned names are relative pointers to a file in the store; they are not necessarily a file system path.- Specified by:
listTopFileNamesin interfaceFileStore- Parameters:
pathName- relative path in the file store to search, or null to search the entire file store.filter- a file filter.- Returns:
- an array of file store names. Returns null if the path does not exist in the file store.
-
doListFileNames
protected java.lang.String[] doListFileNames(java.lang.String pathName, FileStoreFilter filter, boolean recurse, boolean exitBranchOnFirstMatch)
-
doListFileNames
protected void doListFileNames(AbstractFileStore.StoreLocation location, java.io.File dir, FileStoreFilter filter, boolean recurse, boolean exitBranchOnFirstMatch, java.util.Collection<java.lang.String> names)
-
listFile
protected boolean listFile(AbstractFileStore.StoreLocation location, java.io.File file, FileStoreFilter filter, java.util.Collection<java.lang.String> names)
-
listFileName
protected boolean listFileName(AbstractFileStore.StoreLocation location, java.lang.String fileName, FileStoreFilter filter, java.util.Collection<java.lang.String> names)
-
-