Package uk.ac.bristol.star.cdf
Class Shaper
- java.lang.Object
-
- uk.ac.bristol.star.cdf.Shaper
-
public abstract class Shaper extends java.lang.Object
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 Modifier Constructor Description protected
Shaper(int[] dimSizes, boolean[] dimVarys)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static 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[]
getDimSizes()
Returns the dimensions of the notional array.boolean[]
getDimVarys()
Returns the dimension variances of the array.abstract int
getRawItemCount()
Returns the number of array elements in the raw value array.abstract java.lang.Class<?>
getShapeClass()
Returns the data type of the result of theshape
method.abstract int
getShapedItemCount()
Returns the number of array elements in the shaped value array.abstract java.lang.Object
shape(java.lang.Object rawValue, boolean rowMajor)
Takes a raw value array and turns it into an object of the notional shape for this shaper.
-
-
-
Method Detail
-
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
public abstract java.lang.Class<?> getShapeClass()
Returns the data type of the result of theshape
method.- Returns:
- shaped value class
-
shape
public abstract java.lang.Object shape(java.lang.Object rawValue, boolean rowMajor)
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
-
-