Package uk.ac.bristol.star.cdf
Class Shaper
java.lang.Object
uk.ac.bristol.star.cdf.Shaper
Takes care of turning raw variable record values into shaped
record values. The raw values are those stored in the CDF data stream,
and the shaped ones are those notionally corresponding to record values.
- Since:
- 20 Jun 2013
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Shaper
createShaper
(DataType dataType, int[] dimSizes, boolean[] dimVarys, boolean rowMajor) Returns an appropriate shaper instance.abstract int
getArrayIndex
(int[] coords) Returns the index into the raw value array at which the value for the given element of the notional array can be found.int[]
Returns the dimensions of the notional array.boolean[]
Returns the dimension variances of the array.abstract int
Returns the number of array elements in the raw value array.abstract Class
<?> Returns the data type of the result of theshape
method.abstract int
Returns the number of array elements in the shaped value array.abstract Object
Takes a raw value array and turns it into an object of the notional shape for this shaper.
-
Constructor Details
-
Shaper
protected Shaper(int[] dimSizes, boolean[] dimVarys) Constructor.- Parameters:
dimSizes
- dimensionality of shaped arraydimVarys
- for each dimension, true for varying, false for fixed
-
-
Method Details
-
getRawItemCount
public abstract int getRawItemCount()Returns the number of array elements in the raw value array.- Returns:
- raw value array size
-
getShapedItemCount
public abstract int getShapedItemCount()Returns the number of array elements in the shaped value array.- Returns:
- shaped value array size
-
getDimSizes
public int[] getDimSizes()Returns the dimensions of the notional array.- Returns:
- dimension sizes array
-
getDimVarys
public boolean[] getDimVarys()Returns the dimension variances of the array.- Returns:
- for each dimension, true if the data varies, false if fixed
-
getShapeClass
Returns the data type of the result of theshape
method.- Returns:
- shaped value class
-
shape
Takes a raw value array and turns it into an object of the notional shape for this shaper. The returned object is new; it is not rawValue.- Parameters:
rawValue
- input raw value array- Returns:
- rowMajor required majority for result; true for row major, false for column major
-
getArrayIndex
public abstract int getArrayIndex(int[] coords) Returns the index into the raw value array at which the value for the given element of the notional array can be found.- Parameters:
coords
- coordinate array, same length as dimensionality- Returns:
- index into raw value array
-
createShaper
public static Shaper createShaper(DataType dataType, int[] dimSizes, boolean[] dimVarys, boolean rowMajor) Returns an appropriate shaper instance.- Parameters:
dataType
- data typedimSizes
- dimensions of notional shaped arraydimVarys
- variances of shaped arrayrowMajor
- majority of raw data array; true for row major, false for column major
-