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 boolean
false
if 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 void
deleteRecursively
(Path root, boolean deleteRoot) Deletes all files and sub-directories in the specified directory.void
Removes aResource
from this store.Methods inherited from class org.apache.sis.internal.storage.folder.Store
accept, close, components, getIdentifier, getMetadata, getOpenParameters, getOriginator, getStructuredView, message, messages
Methods inherited from class org.apache.sis.storage.DataStore
addListener, findResource, getDisplayName, getLocale, getNativeMetadata, getProvider, removeListener, setLocale, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.sis.storage.Aggregate
components
Methods inherited from interface org.apache.sis.storage.Resource
addListener, getIdentifier, getMetadata, removeListener
-
Field Details
-
isReadOnly
private boolean isReadOnlyfalse
if 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 theStore
parent class, theformat
is mandatory for writable stores. This is not verified by this constructor; it should be verified byStoreProvider
instead.- Throws:
DataStoreException
IOException
-
-
Method Details
-
add
Create a new file for the given resource. This implementation uses the provider specified at creation time.- Specified by:
add
in interfaceWritableAggregate
- Parameters:
resource
- the resource to copy in thisAggregate
.- Returns:
- the effectively added resource. May be
resource
itself if it has been added verbatim. - Throws:
DataStoreException
- if the given resource cannot be stored in thisAggregate
.
-
remove
Removes aResource
from 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: theResource
and it's related files will be deleted.- Specified by:
remove
in 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 givenroot
is a file rather than a directory. The root directory is left in place (after being emptied) ifdeleteRoot
isfalse
.- Parameters:
root
- the directory to delete with all sub-directories.deleteRoot
-true
for deleting alsoroot
, orfalse
for leaving it empty.- Throws:
IOException
-