Class ProbeResult
- All Implemented Interfaces:
Serializable
DataStore.
ProbeResult may also provide additional information, like file MIME type and the
format version.
Usage
When aDataStores.open(…) method is invoked, SIS will iterate over the list of known
providers and invoke the DataStoreProvider.probeContent(StorageConnector) method for each of them.
The ProbeResult value returned by probeContent(…) tells to SIS whether a particular
DataStoreProvider instance has reasonable chances to be able to handle the given storage.
Whether a storage appears to be supported or not is given by the isSupported() property.
Other properties like getVersion() are sometimes available for both supported and unsupported storages.
For example, a file may be encoded in a known format, but may be using an unsupported version of that format.
Special values
In addition to the supported/unsupported information,ProbeResult defines two constants having
a special meaning: INSUFFICIENT_BYTES and UNDETERMINED, which indicate that the provider does
not have enough information for telling whether the storage can be opened.
In such cases, SIS will revisit those providers only if no better suited provider is found.- Since:
- 0.4
- See Also:
Defined in the sis-storage module
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ProbeResultThe open capability cannot be determined because theByteBuffercontains an insufficient amount of bytes.static final ProbeResultTheDataStoreProviderrecognizes the given storage, but has no additional information.static final ProbeResultThe open capability cannot be determined.static final ProbeResultTheDataStoreProviderdoes not recognize the given storage object, file format or database schema. -
Constructor Summary
ConstructorsConstructorDescriptionProbeResult(boolean isSupported, String mimeType, Version version) Creates a newProbeResultwith the given support status, MIME type and version number. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCompares thisProbeResultwith the given object for equality.Returns the MIME type of the storage file format, ornullif unknown or not applicable.Returns the version of file format or database schema used by the storage, ornullif unknown or not applicable.intReturns a hash code value for this instance.booleanReturnstrueif the storage is supported by theDataStoreProvider.Returns a string representation of thisProbeResultfor debugging purpose.
-
Field Details
-
SUPPORTED
TheDataStoreProviderrecognizes the given storage, but has no additional information. TheisSupported()method returnstrue, but the MIME type and version properties arenull.DataStoreProvider.probeContent(StorageConnector)implementations should consider returning a new instance instead of this constant if they can provide the file MIME type or the format version number. -
UNSUPPORTED_STORAGE
TheDataStoreProviderdoes not recognize the given storage object, file format or database schema. No other information is available: theisSupported()method returnsfalse, and the MIME type and version properties arenull.Examples:
- The storage is a file while the provider expected a database connection (or conversely).
- The file does not contains the expected magic number.
- The database schema does not contain the expected tables.
DataStoreProvider.probeContent(StorageConnector)implementations should consider returning a new instance instead of this constant if theDataStoreProviderrecognizes the given storage, but the data are structured according a file or schema version not yet supported by the current implementation. -
INSUFFICIENT_BYTES
The open capability cannot be determined because theByteBuffercontains an insufficient amount of bytes. This value can be returned byDataStoreProvider.probeContent(StorageConnector)implementations as below:
When searching for a provider capable to read a given file, if at least onepublic ProbeResult probeContent(StorageConnector storage) throws DataStoreException { final ByteBuffer buffer = storage.getStorageAs(ByteBuffer.class); if (buffer == null) { return ProbeResult.UNSUPPORTED_STORAGE; } if (buffer.remaining() < Integer.BYTES) { return ProbeResult.INSUFFICIENT_BYTES; } // Other verifications here. }DataStoreProviderreturnsINSUFFICIENT_BYTES, then:- SIS will continue to search for another provider for which
probeContent(…)declares to support the storage, using only the available bytes. - Only if no such provider can be found, then SIS will fetch more bytes and query again
the providers that returned
INSUFFICIENT_BYTESin the previous iteration.
- SIS will continue to search for another provider for which
-
UNDETERMINED
The open capability cannot be determined. This value may be returned byDataStoreimplementations that could potentially open anything, for example the RAW image format.This is a last resort value!
probeContent(…)implementations are strongly encouraged to return a more accurate enumeration value for allowingDataStores.open(Object)to perform a better choice. Generally, this value should be returned only by the RAW image format.
-
-
Constructor Details
-
ProbeResult
Creates a newProbeResultwith the given support status, MIME type and version number.- Parameters:
isSupported-trueif the storage is supported by theDataStoreProvider.mimeType- the storage MIME type, ornullif unknown or not applicable.version- the version of file format or database schema used by the storage, ornullif unknown or not applicable.
-
-
Method Details
-
isSupported
public boolean isSupported()Returnstrueif the storage is supported by theDataStoreProvider.DataStoreinstances created by that provider are likely (but not guaranteed) to be able to read from - and eventually write to - the given storage.- Returns:
trueif the storage is supported by theDataStoreProvider.
-
getMimeType
Returns the MIME type of the storage file format, ornullif unknown or not applicable. TheDataStoreProvidermay (at implementation choice) inspect the storage content for determining a more accurate MIME type.XML types
A generic MIME type for XML documents is"application/xml". However, many other MIME types exist for XML documents compliant to some particular shema. Those types can be determined by inspecting the namespace of XML root element. The following table gives some example:MIME type examples MIME type Description Namespace "application/gml+xml"Official mime type for OGC GML "http://www.opengis.net/gml/3.2" "application/vnd.eu.europa.ec.inspire.resource+xml"Official mime type for INSPIRE Resources "application/vnd.iso.19139+xml"Unofficial mime type for ISO 19139 metadata "http://www.isotc211.org/2005/gmd" "application/vnd.ogc.wms_xml"Unofficial mime type for OGC WMS "application/vnd.ogc.wfs_xml"Unofficial mime type for OGC WFS "application/vnd.ogc.csw_xml"Unofficial mime type for OGC CSW "http://www.opengis.net/cat/csw/3.0" "application/vnd.google-earth.kml+xml""application/rdf+xml""application/soap+xml"- Returns:
- the storage MIME type, or
nullif unknown or not applicable.
-
getVersion
Returns the version of file format or database schema used by the storage, ornullif unknown or not applicable.- Returns:
- the version of file format or database schema used by the storage,
or
nullif unknown or not applicable.
-
hashCode
public int hashCode()Returns a hash code value for this instance. -
equals
Compares thisProbeResultwith the given object for equality. TwoProbeResults are equal if they are instances of the same class and all their properties are equal. -
toString
Returns a string representation of thisProbeResultfor debugging purpose.
-