Package ucar.nc2.dods

Class DODSNetcdfFile

    • 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,
                              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​(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
        Description copied from class: NetcdfFile
        Close all resources (files, sockets, etc) associated with this file. If the underlying file was acquired, it will be released, otherwise closed. if isClosed() already, nothing will happen
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Specified by:
        close in interface FileCacheable
        Overrides:
        close in class NetcdfFile
        Throws:
        IOException - if error when closing
      • reGroup

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

        protected static Attribute combineAxesAttrs​(Attribute axis1,
                                                    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​(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​(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 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 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
      • readToByteChannel

        public long readToByteChannel​(Variable v,
                                      Section section,
                                      WritableByteChannel channel)
                               throws IOException,
                                      InvalidRangeException
        Description copied from class: NetcdfFile
        Read data from a top level Variable and send data to a WritableByteChannel. Experimental.
        Overrides:
        readToByteChannel in class NetcdfFile
        Parameters:
        v - a top-level Variable
        section - the section of data 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 data to this WritableByteChannel
        Returns:
        the number of bytes written to the channel
        Throws:
        IOException - if read error
        InvalidRangeException - if invalid section
      • getFileTypeId

        public String getFileTypeId()
        Description copied from class: NetcdfFile
        Get the file type id for the underlying data source.
        Overrides:
        getFileTypeId in class NetcdfFile
        Returns:
        registered id of the file type
        See Also:
        "https://www.unidata.ucar.edu/software/netcdf-java/formats/FileTypes.html"
      • getFileTypeDescription

        public String getFileTypeDescription()
        Description copied from class: NetcdfFile
        Get a human-readable description for this file type.
        Overrides:
        getFileTypeDescription in class NetcdfFile
        Returns:
        description of the file type
        See Also:
        "https://www.unidata.ucar.edu/software/netcdf-java/formats/FileTypes.html"