Package dap4.cdm.nc2

Class DapNetcdfFile

  • All Implemented Interfaces:
    Closeable, AutoCloseable, ucar.nc2.util.cache.FileCacheable

    public class DapNetcdfFile
    extends ucar.nc2.NetcdfFile
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected static class  DapNetcdfFile.NullCancelTask  
      • Nested classes/interfaces inherited from class ucar.nc2.NetcdfFile

        ucar.nc2.NetcdfFile.Builder<T extends ucar.nc2.NetcdfFile.Builder<T>>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean allowCompression  
      protected Map<ucar.nc2.Variable,​ucar.ma2.Array> arraymap
      Originally, the array for a variable was stored using var.setCacheData().
      protected ucar.nc2.util.CancelTask cancel  
      protected boolean closed  
      protected dap4.core.data.DSP dsp  
      protected String dsplocation  
      protected static dap4.core.data.DSPRegistry dspregistry
      Define a map of known DSP classes.
      protected String location  
      protected static DapNetcdfFile.NullCancelTask nullcancel  
      protected dap4.dap4lib.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 connection
      DapNetcdfFile​(String location, ucar.nc2.util.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.
      dap4.core.data.DSP getDSP()  
      String getLocation()  
      boolean isconstrainable()  
      List<ucar.ma2.Array> readArrays​(List<ucar.nc2.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 ucar.ma2.Array readData​(ucar.nc2.Variable cdmvar, ucar.ma2.Section section)
      Primary read entry point.
      ucar.ma2.Array readSection​(String variableSection)  
      long readToByteChannel​(ucar.nc2.Variable v, ucar.ma2.Section section, WritableByteChannel channel)
      Read databuffer from a top level Variable and send databuffer to a WritableByteChannel.
      • 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

      • dspregistry

        protected static dap4.core.data.DSPRegistry dspregistry
        Define a map of known DSP classes.
      • allowCompression

        protected boolean allowCompression
      • closed

        protected boolean closed
      • location

        protected String location
      • dsplocation

        protected String dsplocation
      • xuri

        protected dap4.dap4lib.XURI xuri
      • dsp

        protected dap4.core.data.DSP dsp
      • cancel

        protected ucar.nc2.util.CancelTask cancel
      • arraymap

        protected Map<ucar.nc2.Variable,​ucar.ma2.Array> arraymap
        Originally, the array for a variable was stored using var.setCacheData(). However, that is illegal for Structures and Sequences, so (for now) we maintain a map variable->array.
    • Constructor Detail

      • DapNetcdfFile

        public DapNetcdfFile​(String location,
                             ucar.nc2.util.CancelTask cancelTask)
                      throws IOException
        Open a Dap4 connection or file via a D4DSP.
        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.
        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 interface AutoCloseable
        Specified by:
        close in interface Closeable
        Specified by:
        close in interface ucar.nc2.util.cache.FileCacheable
        Overrides:
        close in class ucar.nc2.NetcdfFile
        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()
        Specified by:
        getLocation in interface ucar.nc2.util.cache.FileCacheable
        Overrides:
        getLocation in class ucar.nc2.NetcdfFile
      • getDSP

        public dap4.core.data.DSP getDSP()
      • readArrays

        public List<ucar.ma2.Array> readArrays​(List<ucar.nc2.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 class ucar.nc2.NetcdfFile
        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​(ucar.nc2.Variable v,
                                      ucar.ma2.Section section,
                                      WritableByteChannel channel)
                               throws IOException,
                                      ucar.ma2.InvalidRangeException
        Read databuffer from a top level Variable and send databuffer to a WritableByteChannel. Experimental.
        Overrides:
        readToByteChannel in class ucar.nc2.NetcdfFile
        Parameters:
        v - a top-level Variable
        section - 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 error
        ucar.ma2.InvalidRangeException - if invalid section
      • readSection

        public ucar.ma2.Array readSection​(String variableSection)
                                   throws IOException,
                                          ucar.ma2.InvalidRangeException
        Overrides:
        readSection in class ucar.nc2.NetcdfFile
        Throws:
        IOException
        ucar.ma2.InvalidRangeException
      • readData

        protected ucar.ma2.Array readData​(ucar.nc2.Variable cdmvar,
                                          ucar.ma2.Section section)
                                   throws IOException,
                                          ucar.ma2.InvalidRangeException
        Primary read entry point. This is the primary implementor of Variable.read.
        Overrides:
        readData in class ucar.nc2.NetcdfFile
        Parameters:
        cdmvar - A top-level variable
        section - 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 error
        ucar.ma2.InvalidRangeException - if invalid section