|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.starlink.ndx.NdxIO
public class NdxIO
Performs I/O between Ndx objects and resources named by URLs. Methods are available to construct a readable Ndx from a URL pointing to an existing resource, or to construct a new Ndx located at a given URL and populate it from the content of an existing Ndx.
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 Summary | |
---|---|
NdxIO()
Constructs an NdxIO with a default list of handlers. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NdxIO()
Method Detail |
---|
public List getHandlers()
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 arrays
IOException
- 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
created
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 occurs
UnsupportedOperationException
- 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 arrays
IOException
- if there is any I/O error
FileNotFoundException
- 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 one
IOException
- 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 copied
IOException
- if there is any I/O error
FileNotFoundException
- if the location doesn't look like a
file or URL
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |