public abstract class AbstractFileStore extends WWObjectImpl implements FileStore
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractFileStore.StoreLocation |
Modifier and Type | Field and Description |
---|---|
protected List<AbstractFileStore.StoreLocation> |
readLocations |
protected AbstractFileStore.StoreLocation |
writeLocation |
Constructor and Description |
---|
AbstractFileStore() |
Modifier and Type | Method and Description |
---|---|
void |
addLocation(int index,
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.
|
void |
addLocation(String newPath,
boolean isInstall)
Adds a location to search when files are requested from the file store.
|
protected static String |
buildLocationPath(String property,
String append,
String wwDir) |
protected void |
buildReadPaths(Node dataFileStoreNode) |
protected void |
buildWritePaths(Node dataFileCacheNode) |
boolean |
containsFile(String fileName)
Indicates whether the file store contains a specified file.
|
protected static String |
determineAllUserLocation() |
protected static String |
determineSingleUserLocation() |
protected void |
doListFileNames(AbstractFileStore.StoreLocation location,
File dir,
FileStoreFilter filter,
boolean recurse,
boolean exitBranchOnFirstMatch,
Collection<String> names) |
protected String[] |
doListFileNames(String pathName,
FileStoreFilter filter,
boolean recurse,
boolean exitBranchOnFirstMatch) |
URL |
findFile(String fileName,
boolean checkClassPath)
Searches the file store for a specified file and returns a reference to it if it is.
|
List<? extends File> |
getLocations()
Returns the locations that the file store will look for files.
|
protected static String |
getUserHomeDir() |
File |
getWriteLocation()
Returns the location that additions to the file store are placed.
|
protected void |
initialize(InputStream xmlConfigStream) |
boolean |
isInstallLocation(String path)
Indicates whether a specified location is considered an installed-data location and therefore not subject to
automatic removal of its contents.
|
String[] |
listAllFileNames(String pathName,
FileStoreFilter filter)
Returns an array of strings naming the files discovered under a specified file store path name.
|
protected boolean |
listFile(AbstractFileStore.StoreLocation location,
File file,
FileStoreFilter filter,
Collection<String> names) |
protected boolean |
listFileName(AbstractFileStore.StoreLocation location,
String fileName,
FileStoreFilter filter,
Collection<String> names) |
String[] |
listFileNames(String pathName,
FileStoreFilter filter)
Returns an array of strings naming the files discovered directly under a specified file store path name.
|
String[] |
listTopFileNames(String pathName,
FileStoreFilter filter)
Returns an array of strings naming the files discovered under a specified file store path name.
|
protected static File |
makeAbsoluteFile(File file,
String fileName) |
protected static String |
makeAbsolutePath(File dir,
String fileName) |
protected static void |
markFileUsed(File file) |
File |
newFile(String fileName)
Creates a new, empty file in the file store.
|
protected static String |
normalizeFileStoreName(String fileName) |
protected static String |
propertyToPath(String propName) |
void |
removeFile(URL url)
Removes a file from the file store using the URL to the cached file.
|
void |
removeLocation(String path)
Remove a specified read location from the file store.
|
protected AbstractFileStore.StoreLocation |
storeLocationFor(String path) |
protected static String |
storePathForFile(AbstractFileStore.StoreLocation location,
File file) |
onMessage, propertyChange
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getContentType, getExpirationTime, removeFile, requestFile, requestFile
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
propertyChange
onMessage
protected final List<AbstractFileStore.StoreLocation> readLocations
protected AbstractFileStore.StoreLocation writeLocation
public void addLocation(int index, String newPath, boolean isInstall)
FileStore
addLocation
in interface FileStore
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.public void addLocation(String newPath, boolean isInstall)
FileStore
addLocation
in interface FileStore
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.protected static String buildLocationPath(String property, String append, String wwDir)
protected void buildReadPaths(Node dataFileStoreNode)
protected void buildWritePaths(Node dataFileCacheNode)
public boolean containsFile(String fileName)
FileStore
containsFile
in interface FileStore
fileName
- the file in question.protected static String determineAllUserLocation()
protected static String determineSingleUserLocation()
protected void doListFileNames(AbstractFileStore.StoreLocation location, File dir, FileStoreFilter filter, boolean recurse, boolean exitBranchOnFirstMatch, Collection<String> names)
protected String[] doListFileNames(String pathName, FileStoreFilter filter, boolean recurse, boolean exitBranchOnFirstMatch)
public URL findFile(String fileName, boolean checkClassPath)
FileStore
findFile
in interface FileStore
fileName
- the name of the file to findcheckClassPath
- if true
, 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 directoriesIllegalArgumentException
- if fileName
is nullpublic List<? extends File> getLocations()
FileStore
getLocations
in interface FileStore
protected static String getUserHomeDir()
public File getWriteLocation()
FileStore
getWriteLocation
in interface FileStore
protected void initialize(InputStream xmlConfigStream)
public boolean isInstallLocation(String path)
FileStore
isInstallLocation
in interface FileStore
path
- the path in question.public String[] listAllFileNames(String pathName, FileStoreFilter filter)
FileStore
listAllFileNames
in interface FileStore
pathName
- relative path in the file store to search, or null to search the entire file store.filter
- a file filter.protected boolean listFile(AbstractFileStore.StoreLocation location, File file, FileStoreFilter filter, Collection<String> names)
protected boolean listFileName(AbstractFileStore.StoreLocation location, String fileName, FileStoreFilter filter, Collection<String> names)
public String[] listFileNames(String pathName, FileStoreFilter filter)
FileStore
listFileNames
in interface FileStore
pathName
- relative path in the file store to search, or null to search the entire file store.filter
- a file filter.public String[] listTopFileNames(String pathName, FileStoreFilter filter)
FileStore
FileStore.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.listTopFileNames
in interface FileStore
pathName
- relative path in the file store to search, or null to search the entire file store.filter
- a file filter.protected static void markFileUsed(File file)
public File newFile(String fileName)
FileStore
newFile
in interface FileStore
fileName
- the name to give the newly created fileIllegalArgumentException
- if fileName
is nullpublic void removeFile(URL url)
FileStore
removeFile
in interface FileStore
url
- the "file:" URL of the file to remove from the file store. Only files in the writable World Wind disk
cache or temp file directory are removed by this method.IllegalArgumentException
- if url
is nullpublic void removeLocation(String path)
FileStore
removeLocation
in interface FileStore
path
- the read location to remove.protected AbstractFileStore.StoreLocation storeLocationFor(String path)
protected static String storePathForFile(AbstractFileStore.StoreLocation location, File file)