Package ucar.nc2.dods

Class DODSNetcdfFile

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

    @NotThreadSafe
    public class DODSNetcdfFile
    extends ucar.nc2.NetcdfFile
    Access to DODS datasets through the Netcdf API.
    See Also:
    NetcdfFile
    • Nested Class Summary

      • Nested classes/interfaces inherited from class ucar.nc2.NetcdfFile

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

      Constructors 
      Constructor Description
      DODSNetcdfFile​(String datasetURL)
      Open a DODS file.
      DODSNetcdfFile​(String datasetURL, ucar.nc2.util.CancelTask cancelTask)
      Open a DODS file, allow user control over preloading string arrays and making structure data available through netcdf API.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static String canonicalURL​(String urlName)
      Create the canonical form of the URL.
      void close()  
      protected static ucar.nc2.Attribute combineAxesAttrs​(ucar.nc2.Attribute axis1, ucar.nc2.Attribute axis2)
      Safely combine the multiple axis attributes without duplication
      static int convertToDODSType​(ucar.ma2.DataType dataType)
      Get the DODS data class corresponding to the Netcdf data type.
      static ucar.ma2.DataType convertToNCType​(int dodsDataType, boolean isUnsigned)
      Get the Netcdf data type corresponding to the DODS data type.
      static ucar.ma2.DataType convertToNCType​(BaseType dtype, boolean isUnsigned)
      Get the Netcdf data type corresponding to the DODS BaseType class.
      void getDetailInfo​(Formatter f)  
      static String getDODSConstraintName​(ucar.nc2.Variable var)
      Return a variable name suitable for use in a DAP constraint expression.
      String getFileTypeDescription()  
      String getFileTypeId()  
      static boolean isUnsigned​(BaseType dtype)
      Get whether this is an unsigned type.
      protected int[] makeShape​(DArray dodsArray)  
      protected ucar.ma2.Array readData​(ucar.nc2.Variable v, ucar.ma2.Section section)  
      ucar.ma2.Array readSection​(String variableSection)  
      long readToByteChannel​(ucar.nc2.Variable v, ucar.ma2.Section section, WritableByteChannel channel)  
      ucar.ma2.Array readWithCE​(ucar.nc2.Variable v, String CE)  
      protected void reGroup()
      Go thru the variables/structure-variables and their attributes and move to the proper groups.
      protected void reGroupVariable​(ucar.nc2.Group rootgroup, DODSVariable dodsv)
      Deprecated.
      static void setAllowCompression​(boolean b)
      Set whether to allow messages to be compressed.
      static void setAllowDeflate​(boolean b)
      Deprecated.
      use setAllowCompression
      static void setAllowSessions​(boolean b)
      Set whether to allow sessions by allowing cookies.
      static void setCoordinateVariablePreloadSize​(int size)
      If preloading, set maximum size of coordinate variables to be preloaded.
      static void setDebugFlags​(ucar.nc2.util.DebugFlags debugFlag)
      Debugging flags.
      static void setPreload​(boolean b)
      Set whether small variables are preloaded; only turn off for debugging.
      • 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, getDimensions, getFileTypeVersion, getGlobalAttributes, getId, getIosp, getLastModified, getLocation, 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, readArrays, readAttributeDouble, readAttributeInteger, readToOutputStream, registerIOProvider, registerIOProvider, registerIOProvider, registerIOProviderPreferred, release, removeDimension, removeRecordStructure, removeVariable, sendIospMessage, setCacheName, setFileCache, setId, setImmutable, setLocation, setProperty, setRootGroup, setTitle, showCached, showProxies, syncExtend, toBuilder, toNcml, toString, toStringDebug, writeCDL, writeCDL, writeCDL, writeNcml, writeNcml
    • Field Detail

      • debugCE

        public static boolean debugCE
      • debugServerCall

        public static boolean debugServerCall
      • debugOpenResult

        public static boolean debugOpenResult
      • debugDataResult

        public static boolean debugDataResult
      • debugCharArray

        public static boolean debugCharArray
      • debugConvertData

        public static boolean debugConvertData
      • debugConstruct

        public static boolean debugConstruct
      • debugPreload

        public static boolean debugPreload
      • debugTime

        public static boolean debugTime
      • showNCfile

        public static boolean showNCfile
      • debugAttributes

        public static boolean debugAttributes
      • debugCached

        public static boolean debugCached
      • debugOpenTime

        public static boolean debugOpenTime
    • Constructor Detail

      • DODSNetcdfFile

        public DODSNetcdfFile​(String datasetURL)
                       throws IOException
        Open a DODS file.
        Parameters:
        datasetURL - URL of the file. This should start with the protocol "dods:" It may also start with protocol "http:".
        Throws:
        IOException - on io error
        MalformedURLException
      • DODSNetcdfFile

        public DODSNetcdfFile​(String datasetURL,
                              ucar.nc2.util.CancelTask cancelTask)
                       throws IOException
        Open a DODS file, allow user control over preloading string arrays and making structure data available through netcdf API.
        Parameters:
        datasetURL - URL of the file. This should start with the protocol "dods:" or "http:".
        cancelTask - check if task is cancelled. may be null.
        Throws:
        IOException - on io error
        MalformedURLException
    • Method Detail

      • setAllowSessions

        public static void setAllowSessions​(boolean b)
        Set whether to allow sessions by allowing cookies. This only affects requests to the TDS. Setting this to true can eliminate consistency problems for datasets that are being updated.
        Parameters:
        b - true or false. default is false.
      • setAllowDeflate

        public static void setAllowDeflate​(boolean b)
        Deprecated.
        use setAllowCompression
        Set whether to allow messages to be compressed.
        Parameters:
        b - true or false.
      • setAllowCompression

        public static void setAllowCompression​(boolean b)
        Set whether to allow messages to be compressed.
        Parameters:
        b - true or false.
      • setDebugFlags

        public static void setDebugFlags​(ucar.nc2.util.DebugFlags debugFlag)
        Debugging flags. This is a way to decouple setting flags from particular implementations.
        Parameters:
        debugFlag - set of debug flags.
      • setPreload

        public static void setPreload​(boolean b)
        Set whether small variables are preloaded; only turn off for debugging.
        Parameters:
        b - true if small variables are preloaded (default true)
      • setCoordinateVariablePreloadSize

        public static void setCoordinateVariablePreloadSize​(int size)
        If preloading, set maximum size of coordinate variables to be preloaded.
        Parameters:
        size - maximum size of coordinate variables to be preloaded.
      • canonicalURL

        public static String canonicalURL​(String urlName)
        Create the canonical form of the URL. If the urlName starts with "http:" or "https:", change it to start with "dods:", otherwise leave it alone.
        Parameters:
        urlName - the url string
        Returns:
        canonical form
      • close

        public void close()
                   throws IOException
        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
      • reGroup

        protected void reGroup()
                        throws DAP2Exception
        Go thru the variables/structure-variables and their attributes and move to the proper groups.
        Throws:
        DAP2Exception
      • reGroupVariable

        @Deprecated
        protected void reGroupVariable​(ucar.nc2.Group rootgroup,
                                       DODSVariable dodsv)
        Deprecated.
      • combineAxesAttrs

        protected static ucar.nc2.Attribute combineAxesAttrs​(ucar.nc2.Attribute axis1,
                                                             ucar.nc2.Attribute axis2)
        Safely combine the multiple axis attributes without duplication
        Parameters:
        axis1 - axis attribute 1
        axis2 - axis attribute 2
        Returns:
        the combined axis attribute
      • makeShape

        protected int[] makeShape​(DArray dodsArray)
      • getDODSConstraintName

        public static String getDODSConstraintName​(ucar.nc2.Variable var)
        Return a variable name suitable for use in a DAP constraint expression. [Original code seemed wrong because structures can be nested and hence would have to use the full name just like non-structures]
        Parameters:
        var - The variable whose name will appear in the CE
        Returns:
        The name in a form suitable for use in a cE
      • convertToDODSType

        public static int convertToDODSType​(ucar.ma2.DataType dataType)
        Get the DODS data class corresponding to the Netcdf data type. This is the inverse of convertToNCType().
        Parameters:
        dataType - Netcdf data type.
        Returns:
        the corresponding DODS type enum, from opendap.dap.Attribute.XXXX.
      • convertToNCType

        public static ucar.ma2.DataType convertToNCType​(int dodsDataType,
                                                        boolean isUnsigned)
        Get the Netcdf data type corresponding to the DODS data type. This is the inverse of convertToDODSType().
        Parameters:
        dodsDataType - DODS type enum, from dods.dap.Attribute.XXXX.
        Returns:
        the corresponding netcdf DataType.
        See Also:
        isUnsigned(opendap.dap.BaseType)
      • convertToNCType

        public static ucar.ma2.DataType convertToNCType​(BaseType dtype,
                                                        boolean isUnsigned)
        Get the Netcdf data type corresponding to the DODS BaseType class. This is the inverse of convertToDODSType().
        Parameters:
        dtype - DODS BaseType.
        Returns:
        the corresponding netcdf DataType.
        See Also:
        isUnsigned(opendap.dap.BaseType)
      • isUnsigned

        public static boolean isUnsigned​(BaseType dtype)
        Get whether this is an unsigned type.
        Parameters:
        dtype - DODS BaseType.
        Returns:
        true if unsigned
      • 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 v,
                                          ucar.ma2.Section section)
                                   throws IOException,
                                          ucar.ma2.InvalidRangeException
        Overrides:
        readData in class ucar.nc2.NetcdfFile
        Throws:
        IOException
        ucar.ma2.InvalidRangeException
      • readToByteChannel

        public long readToByteChannel​(ucar.nc2.Variable v,
                                      ucar.ma2.Section section,
                                      WritableByteChannel channel)
                               throws IOException,
                                      ucar.ma2.InvalidRangeException
        Overrides:
        readToByteChannel in class ucar.nc2.NetcdfFile
        Throws:
        IOException
        ucar.ma2.InvalidRangeException
      • getDetailInfo

        public void getDetailInfo​(Formatter f)
        Overrides:
        getDetailInfo in class ucar.nc2.NetcdfFile
      • getFileTypeId

        public String getFileTypeId()
        Overrides:
        getFileTypeId in class ucar.nc2.NetcdfFile
      • getFileTypeDescription

        public String getFileTypeDescription()
        Overrides:
        getFileTypeDescription in class ucar.nc2.NetcdfFile