Class ExtendedDataTypeFloat<U extends Unit<U>,T extends AbstractFloatScalar<U,T>,O extends AbstractFloatVector<U,T,O>,G extends GtuDataInterface>
- java.lang.Object
-
- org.opentrafficsim.kpi.sampling.data.ExtendedDataType<T,O,float[],G>
-
- org.opentrafficsim.kpi.sampling.data.ExtendedDataTypeFloat<U,T,O,G>
-
- Type Parameters:
U- unitT- type in vectorO- vector typeG- gtu data type
- All Implemented Interfaces:
Identifiable
- Direct Known Subclasses:
ExtendedDataTypeDuration,ExtendedDataTypeLength,ExtendedDataTypeSpeed
public abstract class ExtendedDataTypeFloat<U extends Unit<U>,T extends AbstractFloatScalar<U,T>,O extends AbstractFloatVector<U,T,O>,G extends GtuDataInterface> extends ExtendedDataType<T,O,float[],G>
Class to facilitate JUNITS types in extended data.Copyright (c) 2013-2022 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.- Version:
- $Revision$, $LastChangedDate$, by $Author$, initial version 21 mrt. 2017
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
-
Constructor Summary
Constructors Constructor Description ExtendedDataTypeFloat(String id, Class<T> type)Constructor setting the id.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Oconvert(float[] storage)Convert float array to typed array.Oconvert(float[] storage, int size)Convert storage type to output type.protected abstract TconvertValue(float value)Convert float to typed value.StringformatValue(String format, T value)Formats the value into a string.TgetOutputValue(O output, int i)Returns a specific output value.TgetStorageValue(float[] storage, int i)Returns a specific storage value.float[]initializeStorage()Returns an initial storage object.float[]setValue(float[] storage, int i, T value)Returns an updated list/array/vector of the storage type, including a new value at given index.-
Methods inherited from class org.opentrafficsim.kpi.sampling.data.ExtendedDataType
equals, getId, getType, getValue, hashCode, interpolate, parseValue
-
-
-
-
Method Detail
-
setValue
public final float[] setValue(float[] storage, int i, T value)Returns an updated list/array/vector of the storage type, including a new value at given index.- Specified by:
setValuein classExtendedDataType<T extends AbstractFloatScalar<U,T>,O extends AbstractFloatVector<U,T,O>,float[],G extends GtuDataInterface>- Parameters:
storage- S; storagei- int; index to store next valuevalue- T; value to add- Returns:
- updated list/array/vector of the storage type, including a new value at given index
-
initializeStorage
public final float[] initializeStorage()
Returns an initial storage object.- Specified by:
initializeStoragein classExtendedDataType<T extends AbstractFloatScalar<U,T>,O extends AbstractFloatVector<U,T,O>,float[],G extends GtuDataInterface>- Returns:
- initial storage object.
-
formatValue
public final String formatValue(String format, T value)
Formats the value into a string. If the value is numeric, the default implementation is:String.format(format, value.si);
- Specified by:
formatValuein classExtendedDataType<T extends AbstractFloatScalar<U,T>,O extends AbstractFloatVector<U,T,O>,float[],G extends GtuDataInterface>- Parameters:
format- String; formatvalue- T; value- Returns:
- formatted value
-
getOutputValue
public final T getOutputValue(O output, int i) throws SamplingException
Returns a specific output value. This is used to store extended data types as generic file, i.e. text file.- Specified by:
getOutputValuein classExtendedDataType<T extends AbstractFloatScalar<U,T>,O extends AbstractFloatVector<U,T,O>,float[],G extends GtuDataInterface>- Parameters:
output- O; outputi- int; index of value to return- Returns:
- the i'th output value
- Throws:
SamplingException- wheniis out of bounds.
-
getStorageValue
public T getStorageValue(float[] storage, int i) throws SamplingException
Returns a specific storage value. This is used to bypass conversion to the output type when trajectories are cut.- Specified by:
getStorageValuein classExtendedDataType<T extends AbstractFloatScalar<U,T>,O extends AbstractFloatVector<U,T,O>,float[],G extends GtuDataInterface>- Parameters:
storage- S; storagei- int; index of value to return- Returns:
- the i'th output value
- Throws:
SamplingException- wheniis out of bounds.
-
convertValue
protected abstract T convertValue(float value)
Convert float to typed value.- Parameters:
value- float; float value- Returns:
- typed value
-
convert
public O convert(float[] storage, int size)
Convert storage type to output type.- Specified by:
convertin classExtendedDataType<T extends AbstractFloatScalar<U,T>,O extends AbstractFloatVector<U,T,O>,float[],G extends GtuDataInterface>- Parameters:
storage- S; stored datasize- int; size of trajectory- Returns:
- converted output
-
convert
protected abstract O convert(float[] storage) throws ValueRuntimeException
Convert float array to typed array.- Parameters:
storage- float[]; float array storage- Returns:
- typed array
- Throws:
ValueRuntimeException- when float array cannot be converted
-
-