public class NdxIO extends Object
This factory delegates the actual Ndx I/O to external NdxHandler objects; the URL is passed to each one in turn until one recognises the URL as one it can deal with, at which point the rest of the work is handed off to that object.
By default, if the corresponding classes are present, the following NdxHandlers are installed:
Consult the documentation of these classes to find out about the format of URLs understood by each.Constructor and Description |
---|
NdxIO()
Constructs an NdxIO with a default list of handlers.
|
Modifier and Type | Method and Description |
---|---|
List |
getHandlers()
Gets the list of handlers which actually do the URL->Ndx
construction.
|
boolean |
makeBlankNdx(String location,
Ndx template)
Constructs a new Ndx containing writable and uninitialised
data arrays at a given location.
|
boolean |
makeBlankNdx(URL url,
Ndx template)
Constructs a new Ndx containing writable and uninitialised
array components at the given URL with characteristics
matching those of a given template Ndx.
|
Ndx |
makeNdx(String location,
AccessMode mode)
Constructs a readable Ndx from a location representing an existing
resource.
|
Ndx |
makeNdx(URL url,
AccessMode mode)
Constructs a readable Ndx from a URL representing an exisiting
resource.
|
void |
outputNdx(String location,
Ndx ndx)
Writes a new resource at a given location containing an Ndx with
data copied from an existing Ndx.
|
void |
outputNdx(URL url,
Ndx ndx)
Writes a new resource at a given URL containing an Ndx with data
copied from an existing Ndx.
|
void |
setHandlers(NdxHandler[] handlers)
Sets the list of handlers which actually do the URL->Ndx
construction.
|
public List getHandlers()
NdxIO
.NdxHandler
objects used
for turning URLs into Ndxspublic void setHandlers(NdxHandler[] handlers)
handlers
- an array of NdxHandler objects used for
turning URLs into Ndxspublic Ndx makeNdx(URL url, AccessMode mode) throws IOException
url
- a URL pointing to a resource representing an Ndxmode
- read/write/update access mode for component arraysIOException
- if there is any I/O errorpublic boolean makeBlankNdx(URL url, Ndx template) throws IOException
makeNdx(java.net.URL, uk.ac.starlink.array.AccessMode)
and write values to the array components so that it has valid
array components.
The classes DefaultMutableNdx
and
DummyNDArray
may be useful in
constructing a suitable template Ndx object.
The method will return true if the Ndx was created successfully, and false if none of the available handlers is able to handle the URL. An IOException will result if one of the handlers is willing to handle the URL but encounters some problem when attempting to write the new resource.
url
- a URL at which the new NDX should be writtentemplate
- a template Ndx object from which non-array data
should be initialised - all scalar components
will be copied from it, and new blank writable
array components matching the ones in it will be
createdurl
IOException
- if there is any I/O errorpublic void outputNdx(URL url, Ndx ndx) throws IOException
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 connectionndx
- an existing Ndx object whose data will be copied
to url
IOException
- if an I/O error occursUnsupportedOperationException
- no handler exists for this URLpublic Ndx makeNdx(String location, AccessMode mode) throws IOException
makeNdx(URL,AccessMode)
.location
- the location of the resource. If it cannot be
parsed as a URL it will be treated as a filenamemode
- read/write/update access mode for component arraysIOException
- if there is any I/O errorFileNotFoundException
- if the location doesn't look like a
file or URLpublic boolean makeBlankNdx(String location, Ndx template) throws IOException
makeBlankNdx(URL,Ndx)
.location
- the location of the new resource. If it cannot
be parsed as a URL it will be treated as a filenametemplate
- a template Ndx object on which to base the new oneIOException
- if there is any I/O errorpublic void outputNdx(String location, Ndx ndx) throws IOException
outputNdx(URL,Ndx)
.location
- the location of the resource. If it cannot be
parsed as a URL it will be treated as a filenamendx
- an existing Ndx object whose data will be copiedIOException
- if there is any I/O errorFileNotFoundException
- if the location doesn't look like a
file or URLCopyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.