public class BridgeNDArray extends DefaultArrayDescription implements NDArray
NDArray
implementation based on an
implementation of the ArrayImpl
interface.
The idea is that all the implementation work common to any
underlying implementation of array functionality is contained in this
class, while the details specific to different underlying array types
can be contained in different implementations of the ArrayImpl
interface. In particular, this class does extensive validation on
method parameters and takes care of throwing the right exceptions
so that the burden of worrying about invalid parameters is removed
from the ArrayImpl implementations.
This exemplifies the Bridge Pattern.
Modifier and Type | Class and Description |
---|---|
protected class |
BridgeNDArray.BridgeNDArrayHdxFacade |
arrayDims, arrayHandler, arrayIsRandom, arrayIsReadable, arrayIsWritable, arrayNdim, arrayNpix, arrayOrder, arrayOrigin, arrayShape, arrayType
Constructor and Description |
---|
BridgeNDArray(ArrayImpl impl)
Constructs a non-persistent BridgeNDArray (one without a URL)
from an ArrayImpl.
|
BridgeNDArray(ArrayImpl impl,
URL url)
Constructs a BridgeNDArray from an ArrayImpl with a given URL.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Declares that this NDArray will not be required for further use;
in particular that no further invocations will be made of the
getAccess method.
|
ArrayAccess |
getAccess()
Returns an object which can read and/or write the pixels of this
NDArray.
|
HdxFacade |
getHdxFacade(HdxResourceType hdxType)
Obtains a
HdxFacade which can
represent this object. |
ArrayImpl |
getImpl()
Returns the
ArrayImpl object supplying the implementation
for this BridgeNDArray . |
URL |
getURL()
Returns the URL of this NDArray, or null if it does not have one.
|
boolean |
multipleAccess()
Indicates whether multiple calls to the getAccess method may be
made.
|
String |
toString() |
getBadHandler, getShape, getType, isRandom, isReadable, isWritable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getBadHandler, getShape, getType, isRandom, isReadable, isWritable
public BridgeNDArray(ArrayImpl impl, URL url)
impl
- an ArrayImpl on which this BridgeNDArray will be basedurl
- the URL at which this NDArray can be found. It is only
used to dispense via the getURL method. May be null
if the NDArray represented by impl is not persistentpublic BridgeNDArray(ArrayImpl impl)
impl
- an ArrayImpl on which this BridgeNDArray will be basedpublic URL getURL()
NDArray
public boolean multipleAccess()
NDArray
ArrayDescription.isRandom()
method returns true, but may do so even for non-random arrays.multipleAccess
in interface NDArray
public ArrayAccess getAccess() throws IOException
NDArray
Each call to this method returns a new and independent
ArrayAccess object. However it may or may not be possible to
call it more than once; the NDArray.multipleAccess()
method
indicates whether this is the case.
getAccess
in interface NDArray
IOException
- if there is some I/O errorpublic void close() throws IOException
NDArray
This method should be invoked on an NDArray when it is no longer required for pixel access. This allows reclamation of non-memory resources, and in the case of writable arrays it may also be required to ensure that data is flushed from buffers back to the actual pixel array.
An array should not however be closed if some other object might
still require pixel access to it via a retained reference.
The general rule is that an application
which obtains a new NDArray from a URL should arrange for
close
to be called
on it at the end of its lifetime, but that utility routines which
perform operations on an NDArray should not close it after use
(though they should close any ArrayAccess
objects
which they take out).
Note that closing an NDArray will normally result in closing any
arrays which it wraps.
Multiple calls of this method may harmlessly be made.
close
in interface NDArray
IOException
- if some I/O error occurredpublic ArrayImpl getImpl()
ArrayImpl
object supplying the implementation
for this BridgeNDArray
.BridgeNDArray
public HdxFacade getHdxFacade(HdxResourceType hdxType)
HdxFacade
which can
represent this object.getHdxFacade
in interface NDArray
hdxType
- the registered type which indicates which Hdx
type this facade is representing as a DOM element. This may
not be null
nor HdxResourceType.NONE
.Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.