Object
AbstractResource
AbstractGridCoverageResource
- All Implemented Interfaces:
DataSet
,GridCoverageResource
,Resource
public abstract class AbstractGridCoverageResource
extends AbstractResource
implements GridCoverageResource
Default implementations of several methods for classes that want to implement the
GridCoverageResource
interface.
Subclasses should override the following methods:
GridCoverageResource.getGridGeometry()
(mandatory)GridCoverageResource.getSampleDimensions()
(mandatory)
read(…)
method in subclasses:
canNotRead(String, GridGeometry, Throwable)
for reporting a failure to read operation.logReadOperation(Object, GridGeometry, long)
for logging a notice about a read operation.
- Since:
- 1.2
-
Field Summary
Fields inherited from class AbstractResource
listeners
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractGridCoverageResource
(StoreListeners parentListeners, boolean hidden) Creates a new resource which can send notifications to the given set of listeners.protected
Creates a new resource, potentially as a child of another resource. -
Method Summary
Modifier and TypeMethodDescriptionprotected DataStoreException
canNotRead
(String filename, GridGeometry request, Throwable cause) Creates an exception for a failure to load data.protected Metadata
Invoked in a synchronized block the first time thatgetMetadata()
is invoked.Returns the envelope of the grid geometry if known.protected void
logReadOperation
(Object file, GridGeometry domain, long startTime) Logs the execution of aGridCoverageResource.read(GridGeometry, int...)
operation.Methods inherited from class AbstractResource
addListener, clearCache, getIdentifier, getMetadata, getSynchronizationLock, removeListener
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface GridCoverageResource
getGridGeometry, getLoadingStrategy, getResolutions, getSampleDimensions, read, setLoadingStrategy, subset
Methods inherited from interface Resource
addListener, getIdentifier, getMetadata, removeListener
-
Constructor Details
-
AbstractGridCoverageResource
Creates a new resource, potentially as a child of another resource. The parent resource is typically, but not necessarily, anAggregate
.- Parameters:
parent
- the parent resource, ornull
if none.- Since:
- 1.4
-
AbstractGridCoverageResource
Creates a new resource which can send notifications to the given set of listeners. Ifhidden
isfalse
(the recommended value), then this resource will have its own set of listeners with this resource declared as the source of events. It will be possible to add and remove listeners independently from the set of parent listeners. Conversely ifhidden
istrue
, then the given listeners will be used directly and this resource will not appear as the source of any event.In any cases, the listeners of all parents (ultimately the data store that created this resource) will always be notified, either directly if
hidden
istrue
or indirectly ifhidden
isfalse
.- Parameters:
parentListeners
- listeners of the parent resource, ornull
if none. This is usually the listeners of theDataStore
that created this resource.hidden
-false
if this resource shall use its ownStoreListeners
with the specified parent, ortrue
for usingparentListeners
directly.
-
-
Method Details
-
getEnvelope
Returns the envelope of the grid geometry if known. The envelope is absent if the grid geometry does not provide this information.- Specified by:
getEnvelope
in interfaceDataSet
- Overrides:
getEnvelope
in classAbstractResource
- Returns:
- the grid geometry envelope.
- Throws:
DataStoreException
- if an error occurred while computing the grid geometry.- See Also:
-
createMetadata
Invoked in a synchronized block the first time thatgetMetadata()
is invoked. The default implementation populates metadata based on information provided bygetIdentifier()
,getEnvelope()
,getGridGeometry()
andgetSampleDimensions()
. Subclasses should override if they can provide more information. The default value can be completed by casting toDefaultMetadata
.- Overrides:
createMetadata
in classAbstractResource
- Returns:
- the newly created metadata, or
null
if unknown. - Throws:
DataStoreException
- if an error occurred while reading metadata from this resource.
-
canNotRead
Creates an exception for a failure to load data. The exception sub-type is inferred from the arguments. If the failure is caused by an envelope outside the resource domain, then that envelope will be inferred from therequest
argument.- Parameters:
filename
- some identification (typically a file name) of the data that cannot be read.request
- the requested domain, ornull
if unspecified.cause
- the cause of the failure, ornull
if none.- Returns:
- the exception to throw.
- See Also:
-
logReadOperation
Logs the execution of aGridCoverageResource.read(GridGeometry, int...)
operation. The log level will beLevel.FINE
if the operation was quick enough, orPerformanceLevel.SLOWNESS
or higher level otherwise.- Parameters:
file
- the file that was opened, ornull
forStoreListeners.getSourceName()
.domain
- domain of the created grid coverage.startTime
- value ofSystem.nanoTime()
when the loading process started.
-