Package jahuwaldt.js.datareader
Class ArrayParam<Q extends javax.measure.quantity.Quantity>
- java.lang.Object
-
- jahuwaldt.js.datareader.DataParam
-
- jahuwaldt.js.datareader.UnitParameter<Q,ArrayParam>
-
- jahuwaldt.js.datareader.ArrayParam<Q>
-
- Type Parameters:
Q
- The Quantity or unit type of this array of values.
- All Implemented Interfaces:
DataElement
,java.lang.Comparable<DataElement>
,javolution.lang.Immutable
,javolution.lang.ValueType
public final class ArrayParam<Q extends javax.measure.quantity.Quantity> extends UnitParameter<Q,ArrayParam>
An array of parameter values in acase
or run.Modified by: Joseph A. Huwaldt
- Version:
- March 18, 2017
- Author:
- Joseph A. Huwaldt, Date: March 5, 2003
-
-
Field Summary
-
Fields inherited from interface jahuwaldt.js.datareader.DataElement
RESOURCES
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <R extends javax.measure.quantity.Quantity>
ArrayParam<R>changeTo(javax.measure.unit.Unit<R> unit)
Returns the parameter that has the same values as this parameter but with the units changed (without converting the values).ArrayParam<Q>
copy()
Returns a copy of this ArrayParam instanceallocated
by the calling thread (possibly on the stack).boolean
equals(java.lang.Object obj)
Compares the specified object with this parameter for strict equality same value, same units, same name, same user data.double
getValue(int idx)
Return the value of an element in the array in the current units.Float64Vector
getValues()
Return the list of values as a Float64Vector, in current units.double
getValueSI(int idx)
Return the value of an element in the array in reference SI units.Float64Vector
getValuesSI()
Return the list of values as a Float64Vector, in reference SI units.int
hashCode()
Returns the hash code for thisArrayParam
.static ArrayParam
newInstance(java.lang.CharSequence name)
Returns a new, preallocated or recycledArrayParam
instance (on the stack when executing in aStackContext
) with the specified name, no units, and no values (zero size).static void
recycle(ArrayParam instance)
Recycles a parameter instance immediately (on the stack when executing in a StackContext).int
size()
Return the number of elements in this array.ArrayParam<Q>
sort()
Method that sorts the values in this array in ascending numerical order.ArrayParam<Q>
to(javax.measure.unit.Unit<Q> unit)
Returns the equivalent to this parameter but stated in the specified unit.static <Q extends javax.measure.quantity.Quantity>
ArrayParam<Q>valueOf(java.lang.CharSequence name, javax.measure.unit.Unit<Q> unit, double[] values)
Construct an array with the specified name, array of values and units (name and units may not be null).static <Q extends javax.measure.quantity.Quantity>
ArrayParam<Q>valueOf(java.lang.CharSequence name, javax.measure.unit.Unit<Q> unit, int size)
Construct an array with the specified name and units with the array values all set to zero.static <Q extends javax.measure.quantity.Quantity>
ArrayParam<Q>valueOf(java.lang.CharSequence name, javax.measure.unit.Unit<Q> unit, java.util.List<java.lang.Double> values)
Construct an array with the specified name, list of values and units (name and units may not be null).-
Methods inherited from class jahuwaldt.js.datareader.UnitParameter
getUnit
-
Methods inherited from class jahuwaldt.js.datareader.DataParam
compareTo, getName, getUserObject, setName, setUserObject, toString, toText
-
-
-
-
Method Detail
-
recycle
public static void recycle(ArrayParam instance)
Recycles a parameter instance immediately (on the stack when executing in a StackContext).- Parameters:
instance
- The instance to be recycled.
-
valueOf
public static <Q extends javax.measure.quantity.Quantity> ArrayParam<Q> valueOf(java.lang.CharSequence name, javax.measure.unit.Unit<Q> unit, int size)
Construct an array with the specified name and units with the array values all set to zero. The name and the units may not be null.- Type Parameters:
Q
- The quantity or unit type of this array of values.- Parameters:
name
- The name of this array of parameters.unit
- The units to assume for each value in the array.size
- The size or number of elements in this array.- Returns:
- An array with the specified name and units with the array values all set to zero.
-
valueOf
public static <Q extends javax.measure.quantity.Quantity> ArrayParam<Q> valueOf(java.lang.CharSequence name, javax.measure.unit.Unit<Q> unit, double[] values)
Construct an array with the specified name, array of values and units (name and units may not be null).- Type Parameters:
Q
- The quantity or unit type of this array of values.- Parameters:
name
- The name of this array of parameters.unit
- The units to assume for each value in the array.values
- The Java array of values to be stored in this ArrayParam object.- Returns:
- An array with the specified name, array of values and units.
-
valueOf
public static <Q extends javax.measure.quantity.Quantity> ArrayParam<Q> valueOf(java.lang.CharSequence name, javax.measure.unit.Unit<Q> unit, java.util.List<java.lang.Double> values)
Construct an array with the specified name, list of values and units (name and units may not be null).- Type Parameters:
Q
- The quantity or unit type of this array of values.- Parameters:
name
- The name of this array of parameters.unit
- The units to assume for each value in the array.values
- The list of values to be stored in this array.- Returns:
- An array with the specified name, list of values and units.
-
size
public int size()
Return the number of elements in this array.- Returns:
- The number of elements in this array.
-
getValueSI
public double getValueSI(int idx)
Return the value of an element in the array in reference SI units.- Parameters:
idx
- Index to the element in the array to be returned.- Returns:
- The value of an element in the array in reference SI units.
- Throws:
java.lang.IndexOutOfBoundsException
- if (index < 0) || (index > size()-1)
-
getValue
public double getValue(int idx)
Return the value of an element in the array in the current units.- Parameters:
idx
- Index to the point in the array to be returned.- Returns:
- The value of an element in the array in the current units.
- Throws:
java.lang.IndexOutOfBoundsException
- if (index < 0) || (index > size()-1)
-
getValuesSI
public Float64Vector getValuesSI()
Return the list of values as a Float64Vector, in reference SI units.- Returns:
- The list of values as a Float64Vector, in reference SI units.
-
getValues
public Float64Vector getValues()
Return the list of values as a Float64Vector, in current units.- Returns:
- The list of values as a Float64Vector, in current units.
-
to
public ArrayParam<Q> to(javax.measure.unit.Unit<Q> unit) throws javax.measure.converter.ConversionException
Returns the equivalent to this parameter but stated in the specified unit. The values are converted to the new units.- Specified by:
to
in classUnitParameter<Q extends javax.measure.quantity.Quantity,ArrayParam>
- Parameters:
unit
- the unit of the parameter to be returned.- Returns:
- an equivalent to this parameter but stated in the specified unit.
- Throws:
javax.measure.converter.ConversionException
- if the current model does not allows for conversion to the specified unit.
-
changeTo
public <R extends javax.measure.quantity.Quantity> ArrayParam<R> changeTo(javax.measure.unit.Unit<R> unit) throws javax.measure.converter.ConversionException
Returns the parameter that has the same values as this parameter but with the units changed (without converting the values).- Specified by:
changeTo
in classUnitParameter<Q extends javax.measure.quantity.Quantity,ArrayParam>
- Type Parameters:
R
- The Quantity or unit type of the new unit.- Parameters:
unit
- the unit of the parameter to be returned.- Returns:
- an equivalent to this parameter but stated in the specified unit.
- Throws:
javax.measure.converter.ConversionException
- if the current model does not allows for conversion to the specified unit.
-
copy
public ArrayParam<Q> copy()
Returns a copy of this ArrayParam instanceallocated
by the calling thread (possibly on the stack).- Returns:
- an identical and independent copy of this parameter.
-
sort
public ArrayParam<Q> sort()
Method that sorts the values in this array in ascending numerical order. And returns the values as a new array.- Returns:
- A new ArrayParam with the values sorted in ascending numerical order.
-
equals
public boolean equals(java.lang.Object obj)
Compares the specified object with this parameter for strict equality same value, same units, same name, same user data.- Overrides:
equals
in classUnitParameter<Q extends javax.measure.quantity.Quantity,ArrayParam>
- Parameters:
obj
- the object to compare with.- Returns:
true
if this parameter is identical to that parameter;false
otherwise.
-
hashCode
public int hashCode()
Returns the hash code for thisArrayParam
.- Overrides:
hashCode
in classUnitParameter<Q extends javax.measure.quantity.Quantity,ArrayParam>
- Returns:
- the hash code value.
-
newInstance
public static ArrayParam newInstance(java.lang.CharSequence name)
Returns a new, preallocated or recycledArrayParam
instance (on the stack when executing in aStackContext
) with the specified name, no units, and no values (zero size).- Parameters:
name
- The name to be assigned to this parameter (may not benull
).- Returns:
- A new ArrayParam instance with the given name and not data (zero size).
-
-