Package dap4.dap4lib.cdm
Class CDMUtil
- java.lang.Object
-
- dap4.dap4lib.cdm.CDMUtil
-
public abstract class CDMUtil extends Object
CDM related Constants and utilities common to client and server code
-
-
Constructor Summary
Constructors Constructor Description CDMUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Index
cdmIndexToIndex(Index cdmidx)
static int[]
computeEffectiveShape(List<DapDimension> dimset)
Compute the shape inferred from a set of slices.static boolean
containsVLEN(List<Dimension> dimset)
Test if any dimension is variable lengthstatic Object
convertVector(DapType dsttype, DapType srctype, Object src)
Convert an array of one type of values to another typestatic List<Range>
createCDMRanges(List<Slice> slices)
static List<Slice>
createSlices(List<Range> rangelist)
Convert a list of ucar.ma2.Range to a list of Slice More or less the inverst of create CDMRangesstatic List<Range>
dimsetToRanges(List<DapDimension> dimset)
static String
getChecksumString(byte[] checksum)
static boolean
hasVLEN(List<Range> ranges)
static boolean
hasVLEN(Variable v)
Test if any dimension is variable lengthstatic Index
indexToCcMIndex(Index d4)
static List<Slice>
indexToSlices(Index indices)
Convert DataIndex to list of slicesstatic boolean
isWhole(List<Range> rangelist, List<DapDimension> dimset, int start, int stop)
Test a Listagainst a List to see if the range list represents the whole set of dimensions within the specified indices. static boolean
isWhole(List<Range> rangelist, List<Slice> slices)
Test a Listagainst a List to see if the range list is whole wrt the slices static boolean
isWhole(List<Range> rangelist, Variable var)
Test a Listagainst the CDM variable's dimensions to see if the range list is whole wrt the dimensions static List<Slice>
shapeToSlices(int[] shape)
static Index
slicesToIndex(List<Slice> slices)
If a set of slices refers to a single position, then return the corresponding Index.static Variable
unwrap(Variable var)
NetcdfDataset can end up wrapping a variable in multiple wrapping classes (e.g.static NetcdfFile
unwrapfile(NetcdfFile file)
NetcdfDataset can wrap a NetcdfFile.
-
-
-
Field Detail
-
SCALAR
public static final Index SCALAR
-
-
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 Listagainst 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.Rangedimset
- the set of DapDimensionsstart
- start looking herestop
- 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 Listagainst a List to see if the range list is whole wrt the slices - Parameters:
rangelist
- the set of ucar.ma2.Rangeslices
- 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 Listagainst the CDM variable's dimensions to see if the range list is whole wrt the dimensions - Parameters:
rangelist
- the set of ucar.ma2.Rangevar
- the cdm var- Returns:
- true if rangelist is whole wrt slices; false otherwise.
- Throws:
DapException
-
createCDMRanges
public static List<Range> createCDMRanges(List<Slice> slices) throws DapException
- 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(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 typesrctype
- source typesrc
- array of values to convert- Returns:
- resulting array of converted values as an object
-
getChecksumString
public static String getChecksumString(byte[] checksum)
-
dimsetToRanges
public static List<Range> dimsetToRanges(List<DapDimension> dimset) throws DapException
- Throws:
DapException
-
shapeToSlices
public static List<Slice> shapeToSlices(int[] shape) throws DapException
- Throws:
DapException
-
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
-
-