Package dap4.dap4lib.cdm.nc2
Class DapNetcdfFile
- java.lang.Object
-
- ucar.nc2.NetcdfFile
-
- dap4.dap4lib.cdm.nc2.DapNetcdfFile
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,FileCacheable
public class DapNetcdfFile extends NetcdfFile
This class is the work-horse of the client side. It uses a D4DSP instance to obtain access to a DMR and (optionally) a compiled DAP4 data stream. Given that, it constructs a translation to CDM.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
DapNetcdfFile.NullCancelTask
-
Nested classes/interfaces inherited from class ucar.nc2.NetcdfFile
NetcdfFile.Builder<T extends NetcdfFile.Builder<T>>
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
allowCompression
protected Map<Variable,Array>
arraymap
protected CancelTask
cancel
protected CDMCompiler
cdmCompiler
protected ChecksumMode
checksummode
protected boolean
closed
protected DapContext
cxt
protected boolean
daploaded
protected DapDataset
dmr
protected D4DSP
dsp
protected String
dsplocation
protected static DSPRegistry
dspregistry
Define a map of known DSP classes.protected String
location
protected static DapNetcdfFile.NullCancelTask
nullcancel
protected XURI
xuri
-
Fields inherited from class ucar.nc2.NetcdfFile
cache, dimensions, gattributes, id, iosp, IOSP_MESSAGE_ADD_RECORD_STRUCTURE, IOSP_MESSAGE_CONVERT_RECORD_STRUCTURE, IOSP_MESSAGE_GET_NETCDF_FILE_FORMAT, IOSP_MESSAGE_RANDOM_ACCESS_FILE, IOSP_MESSAGE_REMOVE_RECORD_STRUCTURE, rootGroup, title, variables
-
-
Constructor Summary
Constructors Constructor Description DapNetcdfFile(String url)
Open a Dap4 connectionDapNetcdfFile(String location, CancelTask cancelTask)
Open a Dap4 connection or file via a D4DSP.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close all resources (files, sockets, etc) associated with this file.void
ensuredata()
void
ensuredmr()
Do what is necessary to ensure that DMR and DAP compilation will workD4DSP
getDSP()
String
getLocation()
Get the NetcdfFile location.boolean
isconstrainable()
protected void
loadContext()
List<Array>
readArrays(List<Variable> variables)
Do a bulk read on a list of Variables and return a corresponding list of Array that contains the results of a full read on each Variable.protected Array
readData(Variable cdmvar, Section section)
b * Primary read entry point.Array
readSection(String variableSection)
Read a variable using the given section specification.long
readToByteChannel(Variable v, Section section, WritableByteChannel channel)
Read databuffer from a top level Variable and send databuffer to a WritableByteChannel.protected void
verifyChecksums()
-
Methods inherited from class ucar.nc2.NetcdfFile
addAttribute, addAttribute, addDimension, addGroup, addLocalFieldsToBuilder, addStringVariable, addVariable, addVariable, addVariableAttribute, builder, canonicalizeUriString, canOpen, empty, findAttribute, findAttValueIgnoreCase, findDimension, findGlobalAttribute, findGlobalAttributeIgnoreCase, findGroup, findVariable, findVariable, findVariableByAttribute, finish, getCacheName, getDetailInfo, getDetailInfo, getDimensions, getFileTypeDescription, getFileTypeId, getFileTypeVersion, getGlobalAttributes, getId, getIosp, getLastModified, getRootGroup, getStructureIterator, getTitle, getUnlimitedDimension, getVariables, hasUnlimitedDimension, iospDeRegister, iospRegistered, makeFullName, makeFullName, makeFullNameSectionSpec, makeFullNameWithString, makeNameUnescaped, makeRecordStructure, makeValidCDLName, makeValidCdmObjectName, makeValidPathName, makeValidSectionSpecName, open, open, open, open, open, open, openInMemory, openInMemory, openInMemory, openInMemory, reacquire, read, readAttributeDouble, readAttributeInteger, readToOutputStream, registerIOProvider, registerIOProvider, registerIOProvider, registerIOProviderPreferred, release, removeDimension, removeRecordStructure, removeVariable, sendIospMessage, setCacheName, setDebugFlags, setFileCache, setId, setImmutable, setLocation, setProperty, setRootGroup, setTitle, showCached, showProxies, syncExtend, toBuilder, toNcml, toString, toStringDebug, writeCDL, writeCDL, writeCDL, writeNcml, writeNcml
-
-
-
-
Field Detail
-
nullcancel
protected static final DapNetcdfFile.NullCancelTask nullcancel
-
dspregistry
protected static DSPRegistry dspregistry
Define a map of known DSP classes.
-
allowCompression
protected boolean allowCompression
-
closed
protected boolean closed
-
location
protected String location
-
cancel
protected CancelTask cancel
-
dsplocation
protected String dsplocation
-
xuri
protected XURI xuri
-
cxt
protected DapContext cxt
-
dsp
protected D4DSP dsp
-
dmr
protected DapDataset dmr
-
cdmCompiler
protected CDMCompiler cdmCompiler
-
checksummode
protected ChecksumMode checksummode
-
daploaded
protected boolean daploaded
-
-
Constructor Detail
-
DapNetcdfFile
public DapNetcdfFile(String location, CancelTask cancelTask) throws IOException
Open a Dap4 connection or file via a D4DSP. Warning: we do not use a Builder because this object is mutable over time.- Parameters:
location
- URL for the request. Note that if this is intended to send to a file oriented DSP, then if must be converted to an absolute path. Note also that the URL path should not have any .dap or .dmr extension since using those is the purview of this class.cancelTask
- check if task is cancelled; may be null.- Throws:
IOException
-
DapNetcdfFile
public DapNetcdfFile(String url) throws IOException
Open a Dap4 connection- Parameters:
url
- URL for the request.- Throws:
IOException
-
-
Method Detail
-
close
public void close() throws IOException
Close all resources (files, sockets, etc) associated with this file.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceFileCacheable
- Overrides:
close
in classNetcdfFile
- Throws:
IOException
- if error when closing
-
isconstrainable
public boolean isconstrainable()
- Returns:
- true if we can ask the server to do constraint processing
-
getLocation
public String getLocation()
Description copied from class:NetcdfFile
Get the NetcdfFile location. This is a URL, or a file pathname.- Specified by:
getLocation
in interfaceFileCacheable
- Overrides:
getLocation
in classNetcdfFile
- Returns:
- location URL or file pathname.
-
getDSP
public D4DSP getDSP()
-
readArrays
public List<Array> readArrays(List<Variable> variables) throws IOException
Do a bulk read on a list of Variables and return a corresponding list of Array that contains the results of a full read on each Variable. TODO: optimize to make only a single server call and cache the results.- Overrides:
readArrays
in classNetcdfFile
- Parameters:
variables
- List of type Variable- Returns:
- List of Array, one for each Variable in the input.
- Throws:
IOException
- if read error
-
readToByteChannel
public long readToByteChannel(Variable v, Section section, WritableByteChannel channel) throws IOException, InvalidRangeException
Read databuffer from a top level Variable and send databuffer to a WritableByteChannel. Experimental.- Overrides:
readToByteChannel
in classNetcdfFile
- Parameters:
v
- a top-level Variablesection
- the section of databuffer to read. There must be a Range for each Dimension in the variable, in order. Note: no nulls allowed. IOSP may not modify.channel
- write databuffer to this WritableByteChannel- Returns:
- the number of databuffer written to the channel
- Throws:
IOException
- if read errorInvalidRangeException
- if invalid section
-
readSection
public Array readSection(String variableSection) throws IOException, InvalidRangeException
Description copied from class:NetcdfFile
Read a variable using the given section specification. The result is always an array of the type of the innermost variable. Its shape is the accumulation of all the shapes of its parent structures.- Overrides:
readSection
in classNetcdfFile
- Parameters:
variableSection
- the constraint expression.- Returns:
- data requested
- Throws:
IOException
- if errorInvalidRangeException
- if variableSection is invalid- See Also:
- SectionSpecification
-
readData
protected Array readData(Variable cdmvar, Section section) throws IOException, InvalidRangeException
b * Primary read entry point. This is the primary implementor of Variable.read.- Overrides:
readData
in classNetcdfFile
- Parameters:
cdmvar
- A top-level variablesection
- the section of databuffer to read. There must be a Range for each Dimension in the variable, in order. Note: no nulls allowed.- Returns:
- An Array object for accessing the databuffer
- Throws:
IOException
- if read errorInvalidRangeException
- if invalid section
-
loadContext
protected void loadContext()
-
verifyChecksums
protected void verifyChecksums() throws DapException
- Throws:
DapException
-
ensuredmr
public void ensuredmr() throws IOException
Do what is necessary to ensure that DMR and DAP compilation will work- Throws:
IOException
-
ensuredata
public void ensuredata() throws IOException
- Throws:
IOException
-
-