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.
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,
java.net.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.
|
ArrayImpl |
getImpl()
Returns the ArrayImpl object supplying the implementation
for this BridgeNDArray.
|
java.net.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.
|
java.lang.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, java.net.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 java.net.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 java.io.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.
public void close() throws java.io.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.
public ArrayImpl getImpl()
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2017 Central Laboratory of the Research Councils. All Rights Reserved.