Package org.apache.sis.internal.storage
Class URIDataStore
java.lang.Object
org.apache.sis.storage.DataStore
org.apache.sis.internal.storage.URIDataStore
- All Implemented Interfaces:
AutoCloseable,ResourceOnFileSystem,StoreResource,Resource,Localized
- Direct Known Subclasses:
PRJDataStore,StaxDataStore,Store,Store,Store
A data store for a storage that may be represented by a
URI.
It is still possible to create a data store with a ReadableByteChannel,
InputStream or Reader, in which case the location will be null.- Since:
- 0.8
- Version:
- 1.2
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final URITheDataStoreProvider.LOCATIONparameter value, ornullif none.private PathThelocationas a path, computed when first needed.private final booleanWhetherlocationAsPathwas initialized at construction time (true) of inferred from thelocationURI at a later time (false). -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedURIDataStore(DataStoreProvider provider, StorageConnector connector) Creates a new data store. -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidaddTitleOrIdentifier(MetadataBuilder builder) Adds the filename (without extension) as the citation title if there are no titles, or as the identifier otherwise.Path[]Returns the location as aPathcomponent or an empty array if none.private StringReturns the filename without path and without file extension, ornullif none.Optional<org.opengis.util.GenericName>Returns an identifier for the root resource of this data store, or an empty value if none.Optional<org.opengis.parameter.ParameterValueGroup>Returns the parameters used to open this data store.final DataStoreReturns the originator of this resource, which is this data store itself.protected final Pathstatic ObjectReturns the location (path, URL, URI, etc.) of the given resource.static org.opengis.parameter.ParameterValueGroupparameters(DataStoreProvider provider, URI location) Creates parameter value group for the current location, if non-null.Methods inherited from class org.apache.sis.storage.DataStore
addListener, close, findResource, getDisplayName, getLocale, getMetadata, 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.Resource
addListener, getMetadata, removeListener
-
Field Details
-
location
TheDataStoreProvider.LOCATIONparameter value, ornullif none. -
locationAsPath
Thelocationas a path, computed when first needed. If the storage given at construction time was aPathor aFileinstance, then this field is initialized in the constructor in order to avoid a "path → URI → path" roundtrip (such roundtrip transforms relative paths into absolute paths).- See Also:
-
locationIsPath
private final boolean locationIsPathWhetherlocationAsPathwas initialized at construction time (true) of inferred from thelocationURI at a later time (false).- See Also:
-
-
Constructor Details
-
URIDataStore
protected URIDataStore(DataStoreProvider provider, StorageConnector connector) throws DataStoreException Creates a new data store. This constructor does not open the file, so subclass constructors can decide whether to open in read-only or read/write mode. It is caller's responsibility to ensure that theOpenOptionare compatible with whether this data store is read-only or read/write.- Parameters:
provider- the factory that created thisURIDataStoreinstance, ornullif unspecified.connector- information about the storage (URL, stream, reader instance, etc).- Throws:
DataStoreException- if an error occurred while creating the data store for the given storage.
-
-
Method Details
-
getOriginator
Returns the originator of this resource, which is this data store itself.- Specified by:
getOriginatorin interfaceStoreResource- Returns:
this.
-
getIdentifier
Returns an identifier for the root resource of this data store, or an empty value if none. The default implementation returns the filename without path and without file extension.- Specified by:
getIdentifierin interfaceResource- Overrides:
getIdentifierin classDataStore- Returns:
- an identifier for the root resource of this data store.
- Throws:
DataStoreException- if an error occurred while fetching the identifier.- See Also:
-
getFilename
Returns the filename without path and without file extension, ornullif none. -
getSpecifiedPath
If the location was specified as aPathorFileinstance, returns that path. Otherwise returnsnull. This method does not try to convert URI toPathbecause this conversion may fail for HTTP and FTP connections.- Returns:
- the path specified at construction time, or
nullif the storage was not specified as a path.
-
getComponentFiles
Returns the location as aPathcomponent or an empty array if none. The default implementation returns the storage specified at construction time if it was aPathorFile, or converts the URI to aPathotherwise.- Specified by:
getComponentFilesin interfaceResourceOnFileSystem- Returns:
- the URI as a path, or an empty array if unknown.
- Throws:
DataStoreException- if the URI cannot be converted to aPath.
-
getOpenParameters
Returns the parameters used to open this data store.- Specified by:
getOpenParametersin classDataStore- Returns:
- parameters used for opening this
DataStore. - See Also:
-
parameters
public static org.opengis.parameter.ParameterValueGroup parameters(DataStoreProvider provider, URI location) Creates parameter value group for the current location, if non-null. This convenience method is used forDataStore.getOpenParameters()implementations in publicDataStorethat cannot extendURIDataStoredirectly, because this class is internal.- Parameters:
provider- the provider of the data store for which to get open parameters.location- file opened by the data store.- Returns:
- parameters to be returned by
DataStore.getOpenParameters().
-
location
Returns the location (path, URL, URI, etc.) of the given resource. The type of the returned object can be any of the types documented inDataStoreProvider.LOCATION. The main ones areURI,Pathand JDBC DataSource.- Parameters:
resource- the resource for which to get the location, ornull.- Returns:
- location of the given resource, or
nullif none. - Throws:
DataStoreException- if an error on the file system prevent the creation of the path.- Since:
- 1.1
-
addTitleOrIdentifier
Adds the filename (without extension) as the citation title if there are no titles, or as the identifier otherwise. This method should be invoked last, afterDataStoreimplementation did its best effort for adding a title. The intent is actually to provide an identifier, but since the title is mandatory in ISO 19115 metadata, providing only an identifier without title would be invalid.- Parameters:
builder- where to add the title or identifier.
-