Class CDMUtil


  • public abstract class CDMUtil
    extends Object
    CDM related Constants and utilities common to client and server code
    • Field Detail

      • SCALAR

        public static final Index SCALAR
    • Constructor Detail

      • CDMUtil

        public CDMUtil()
    • Method Detail

      • createSlices

        public static List<Slice> createSlices​(List<Range> rangelist)
                                        throws DapException
        Convert a list of ucar.ma2.Range to a list of Slice More or less the inverst of create CDMRanges
        Parameters:
        rangelist - the set of ucar.ma2.Range
        Returns:
        the equivalent list of Slice
        Throws:
        DapException
      • isWhole

        public static boolean isWhole​(List<Range> rangelist,
                                      List<DapDimension> dimset,
                                      int start,
                                      int stop)
                               throws DapException
        Test a List against a List to see if the range list represents the whole set of dimensions within the specified indices.
        Parameters:
        rangelist - the set of ucar.ma2.Range
        dimset - the set of DapDimensions
        start - start looking here
        stop - stop looking here
        Returns:
        true if rangelist is whole; false otherwise.
        Throws:
        DapException
      • isWhole

        public static boolean isWhole​(List<Range> rangelist,
                                      List<Slice> slices)
                               throws DapException
        Test a List against a List to see if the range list is whole wrt the slices
        Parameters:
        rangelist - the set of ucar.ma2.Range
        slices - the set of slices
        Returns:
        true if rangelist is whole wrt slices; false otherwise.
        Throws:
        DapException
      • isWhole

        public static boolean isWhole​(List<Range> rangelist,
                                      Variable var)
                               throws DapException
        Test a List against the CDM variable's dimensions to see if the range list is whole wrt the dimensions
        Parameters:
        rangelist - the set of ucar.ma2.Range
        var - the cdm var
        Returns:
        true if rangelist is whole wrt slices; false otherwise.
        Throws:
        DapException
      • unwrap

        public static Variable unwrap​(Variable var)
        NetcdfDataset can end up wrapping a variable in multiple wrapping classes (e.g. VariableDS). Goal of this procedure is to get down to the lowest level Variable instance
        Parameters:
        var - possibly wrapped variable
        Returns:
        the lowest level Variable instance
      • unwrapfile

        public static NetcdfFile unwrapfile​(NetcdfFile file)
        NetcdfDataset can wrap a NetcdfFile. Goal of this procedure is to get down to the lowest level NetcdfFile instance.
        Parameters:
        file - NetcdfFile or NetcdfDataset
        Returns:
        the lowest level NetcdfFile instance
      • hasVLEN

        public static boolean hasVLEN​(List<Range> ranges)
      • hasVLEN

        public static boolean hasVLEN​(Variable v)
        Test if any dimension is variable length
      • containsVLEN

        public static boolean containsVLEN​(List<Dimension> dimset)
        Test if any dimension is variable length
      • computeEffectiveShape

        public static int[] computeEffectiveShape​(List<DapDimension> dimset)
        Compute the shape inferred from a set of slices. 'Effective' means that any trailing vlen will be ignored.
        Parameters:
        dimset - from which to generate shape
        Returns:
        effective shape
      • convertVector

        public static Object convertVector​(DapType dsttype,
                                           DapType srctype,
                                           Object src)
        Convert an array of one type of values to another type
        Parameters:
        dsttype - target type
        srctype - source type
        src - array of values to convert
        Returns:
        resulting array of converted values as an object
      • getChecksumString

        public static String getChecksumString​(byte[] checksum)
      • cdmIndexToIndex

        public static Index cdmIndexToIndex​(Index cdmidx)
      • indexToCcMIndex

        public static Index indexToCcMIndex​(Index d4)
      • indexToSlices

        public static List<Slice> indexToSlices​(Index indices)
                                         throws DapException
        Convert DataIndex to list of slices
        Parameters:
        indices - to convert
        Returns:
        list of corresponding slices
        Throws:
        DapException
      • slicesToIndex

        public static Index slicesToIndex​(List<Slice> slices)
                                   throws DapException
        If a set of slices refers to a single position, then return the corresponding Index. Otherwise, throw Exception.
        Parameters:
        slices -
        Returns:
        Index corresponding to slices
        Throws:
        DapException