public class NDArrayFactory extends Object
This factory delegates the actual NDArray creation to external ArrayBuilder objects; the URL is passed to each one in turn until one can make an NDArray object from it, which object is returned to the caller.
By default, if the corresponding classes are present, the following ArrayBuilders are installed:
Consult the documentation of these classes to find out about the format of URLs understood by each.Constructor and Description |
---|
NDArrayFactory()
Constructs an NDArrayFactory with a default list of builders.
|
Modifier and Type | Method and Description |
---|---|
List |
getBuilders()
Gets the list of builders which actually do the URL->NDArray
construction.
|
NDArray |
makeNDArray(String location,
AccessMode mode)
Constructs a readable NDArray from a location representing an
existing resource.
|
NDArray |
makeNDArray(URL url,
AccessMode mode)
Constructs a readable NDArray from a URL representing an exisiting
resource.
|
NDArray |
makeNewNDArray(String location,
NDArray template)
Constructs a new NDArray to which data can be written given a location
and another template NDArray.
|
NDArray |
makeNewNDArray(String location,
NDShape shape,
Type type,
BadHandler bh)
Constructs a new NDArray to which data can be written given a location
and the array characteristics.
|
NDArray |
makeNewNDArray(URL url,
NDArray template)
Constructs a new NDArray to which data can be written given a URL
and another template NDArray.
|
NDArray |
makeNewNDArray(URL url,
NDShape shape,
Type type,
BadHandler bh)
Constructs a new NDArray to which data can be written given a URL
and the array characteristics.
|
void |
setBuilders(ArrayBuilder[] builders)
Sets the list of builders which actually do the URL->NDArray
construction Builders earlier in the list are given a chance
to handle a URL before ones later in the list.
|
public NDArrayFactory()
public List getBuilders()
ArrayBuilder
objects used
for turning URLs into NDArrayspublic void setBuilders(ArrayBuilder[] builders)
builders
- an array of ArrayBuilder objects used for
turning URLs into NDArrayspublic NDArray makeNDArray(URL url, AccessMode mode) throws IOException
url
- a URL pointing to a resource holding array datamode
- the mode with which it should be accessedIOException
- if there is any I/O errorpublic NDArray makeNewNDArray(URL url, NDShape shape, Type type, BadHandler bh) throws IOException
The bh
parameter indicates a requested bad value handling
scheme, but does not guarantee that it will be used, since not all
storage formats are capable of storing bad values in arbitrary
ways. According to the resource type, bad value handling will
be provided on a best-efforts basis.
If bh
is null, the implementation will choose a bad value
handling policy of its own.
url
- a URL pointing to a writable resource. This may be
a suitable file:
-protocol URL or one
with some other protocol which can provide an
output-capable connectionshape
- the shape of the new arraytype
- a Type object indicating the type of data in the arraybh
- the requested bad value handling policy - see above.IOException
- if an I/O error occursIllegalArgumentException
- if the type of bh
does not
match type
public NDArray makeNewNDArray(URL url, NDArray template) throws IOException
makeNewNDArray(URL,NDShape,Type,BadHandler)
with the shape
, type
and bh
parameters copied from the template
NDArray.url
- a URL pointing to a writable resource. This may be
a suitable file:
-protocol URL or one
with some other protocol which can provide an
output-capable connectiontemplate
- an NDArray whose characteristics are to be
copied when the new one is createdIOException
- if an I/O error occurspublic NDArray makeNDArray(String location, AccessMode mode) throws IOException
makeNDArray(URL,AccessMode)
.location
- the location of the resource. If it cannot be
parsed as a URL, it will be treated as a filenamemode
- the mode with which it should be accessedlocation
, or null if one could not be foundIOException
- if there is any I/O errorpublic NDArray makeNewNDArray(String location, NDShape shape, Type type, BadHandler bh) throws IOException
makeNewNDArray(URL,NDShape,Type,BadHandler)
location
- the location of the resource. If it cannot be
parsed as a URL, it will be treated as a filenameshape
- the shape of the new arraytype
- a Type object indicating the type of data in the arraybh
- requested bad value handling policyIOException
- if an I/O error occurspublic NDArray makeNewNDArray(String location, NDArray template) throws IOException
makeNewNDArray(URL,NDArray)
.location
- the location of the resource. If it cannot be
parsed as a URL, it will be treated as a filenametemplate
- an NDArray whose characteristics are to be
copied when the new one is createdIOException
- if an I/O error occursCopyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.