Class WritableStore
java.lang.Object
org.apache.sis.storage.DataStore
org.apache.sis.internal.storage.folder.Store
org.apache.sis.internal.storage.folder.WritableStore
- All Implemented Interfaces:
AutoCloseable,DirectoryStream.Filter<Path>,UnstructuredAggregate,StoreResource,Aggregate,Resource,WritableAggregate,Localized
Writable version of the store which rely on given datastore provider to create new types.
Note 1: this implementation is experimental.
Note 2: it has not been tested since we do not have writable feature sets yet.
- Since:
- 1.0
- Version:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanfalseif this data store is capable to writeFeatureSet.Fields inherited from class org.apache.sis.internal.storage.folder.Store
children, componentProvider, components, encoding, locale, location, timezone -
Constructor Summary
ConstructorsConstructorDescriptionWritableStore(DataStoreProvider provider, StorageConnector connector, Path path, DataStoreProvider format) Creates a new folder store from the given file, path or URI. -
Method Summary
Modifier and TypeMethodDescriptionCreate a new file for the given resource.(package private) static voiddeleteRecursively(Path root, boolean deleteRoot) Deletes all files and sub-directories in the specified directory.voidRemoves aResourcefrom this store.Methods inherited from class org.apache.sis.internal.storage.folder.Store
accept, close, components, getIdentifier, getMetadata, getOpenParameters, getOriginator, getStructuredView, message, messagesMethods inherited from class org.apache.sis.storage.DataStore
addListener, findResource, getDisplayName, getLocale, getNativeMetadata, getProvider, removeListener, setLocale, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.sis.storage.Aggregate
componentsMethods inherited from interface org.apache.sis.storage.Resource
addListener, getIdentifier, getMetadata, removeListener
-
Field Details
-
isReadOnly
private boolean isReadOnlyfalseif this data store is capable to writeFeatureSet. We currently have no easy way to determine that from the provider only, so this flag may be set after the first attempt to add a new resource.
-
-
Constructor Details
-
WritableStore
WritableStore(DataStoreProvider provider, StorageConnector connector, Path path, DataStoreProvider format) throws DataStoreException, IOException Creates a new folder store from the given file, path or URI. Contrarily to theStoreparent class, theformatis mandatory for writable stores. This is not verified by this constructor; it should be verified byStoreProviderinstead.- Throws:
DataStoreExceptionIOException
-
-
Method Details
-
add
Create a new file for the given resource. This implementation uses the provider specified at creation time.- Specified by:
addin interfaceWritableAggregate- Parameters:
resource- the resource to copy in thisAggregate.- Returns:
- the effectively added resource. May be
resourceitself if it has been added verbatim. - Throws:
DataStoreException- if the given resource cannot be stored in thisAggregate.
-
remove
Removes aResourcefrom this store. The resource must be a part of thisAggregate. For a folder store, this means that the resource must be a direct children of the directory managed by this store. This operation is destructive: theResourceand it's related files will be deleted.- Specified by:
removein interfaceWritableAggregate- Parameters:
resource- child resource to remove from thisAggregate.- Throws:
DataStoreException- if the given resource could not be removed.
-
deleteRecursively
Deletes all files and sub-directories in the specified directory. This method does nothing if the givenrootis a file rather than a directory. The root directory is left in place (after being emptied) ifdeleteRootisfalse.- Parameters:
root- the directory to delete with all sub-directories.deleteRoot-truefor deleting alsoroot, orfalsefor leaving it empty.- Throws:
IOException
-