public class MetricDataset
extends java.lang.Object
MetricValue
values.
A MetricValue
object stores any other object and represents a single data row.
It is also assigned a key in the LinkedHashMap
if the input does not have one.
To represent a single object value, simply add it as is and the method getFirstValue
can be used to retrieve it. If a list is added, getNextValue
can iterate through all
data rows, or getData
will return the whole dataset.The dataset can be retrieved either as an ordered list or as a keyed and ordered set of values.
Modifier | Constructor and Description |
---|---|
protected |
MetricDataset(MetricValue thisDataObj)
Create a new instance of MetricDataset.
|
protected |
MetricDataset(java.lang.String thisValueType,
MetricValue thisDataObj)
Create a new instance of MetricDataset.
|
protected |
MetricDataset(java.lang.String thisName,
java.lang.String thisValueType,
java.util.List<?> thisDataset)
Create a new instance of MetricDataset.
|
protected |
MetricDataset(java.lang.String thisName,
java.lang.String thisValueType,
java.util.Map<java.lang.String,?> thisDataset)
Create a new instance of MetricDataset.
|
protected |
MetricDataset(java.lang.String thisName,
java.lang.String thisValueType,
MetricValue thisDataObj)
Create a new instance of MetricDataset.
|
protected |
MetricDataset(java.lang.String thisName,
java.lang.String thisValueType,
T thisDataset)
Create a new instance of MetricDataset.
|
Modifier and Type | Method and Description |
---|---|
java.util.ArrayList<MetricValue> |
getData()
Get a copy of the whole data list.
|
java.util.ArrayList<java.lang.String> |
getDataKeys()
Get a copy of the ordered list of keys that represent each data value entry.
|
int |
getDatasetSize()
Get the size of the dataset.
|
java.lang.Object |
getFirstValue()
This resets the value iterator to point to the first value in the LinkedHashMap list
and returns that value directly, not the enclosing
MetricValue object. |
java.lang.String |
getName()
Get the id or name of this value structure.
|
java.lang.Object |
getNextValue()
This uses the current iterator to return the next value in the LinkedHashMap list
and returns that value directly, not the enclosing
MetricValue object. |
java.util.HashMap<java.lang.String,java.lang.Object> |
getParams()
Get the additional parameters list.
|
java.lang.Object |
getValue()
Get the actual node value, not the enclosing
MetricValue object. |
java.lang.Object |
getValue(java.lang.String dataKey)
Get the actual node value, not the enclosing
MetricValue object, relating to a specific entry key. |
java.lang.String |
getValueType()
Get the data type.
|
boolean |
hasNextValue()
Return true if the value iterator still has element to return.
|
static boolean |
isDataset(java.lang.Object thisData)
Return true if the data object is already a
MetricDataset type. |
boolean |
isSingleValue()
Return true if the dataset stores a single value only.
|
void |
resetValueIterator()
Reset the value iterator to the start element.
|
void |
setName(java.lang.String thisName)
Set the id or name of this value structure.
|
void |
setParams(java.util.HashMap<java.lang.String,java.lang.Object> theParams)
Set the arbitrary parameters list.
|
static MetricDataset |
toDataset(java.lang.String name,
java.lang.String valueType,
java.util.ArrayList<?> dataPoints)
Create a metric dataset object where each array value is added as a
MetricValue
object to the dataset. |
static MetricDataset |
toDataset(java.lang.String name,
java.lang.String valueType,
java.util.HashMap<java.lang.String,?> dataPoints)
Create a metric dataset object where each array value is added as a
MetricValue
object to the dataset. |
static MetricDataset |
toDataset(java.lang.String name,
java.lang.String valueType,
java.util.Hashtable<java.lang.String,?> dataPoints)
Create a metric dataset object where each array value is added as a
MetricValue
object to the dataset. |
static MetricDataset |
toDataset(java.lang.String name,
java.lang.String valueType,
java.util.LinkedHashMap<?,?> dataPoints)
Create a metric dataset object where each array value is added as a
MetricValue
object to the dataset. |
static MetricDataset |
toDataset(java.lang.String name,
java.lang.String valueType,
MetricValue dataPoints)
Create a metric dataset object where each array value is added as a
MetricValue
object to the dataset. |
static MetricDataset |
toDataset(java.lang.String name,
java.lang.String valueType,
java.lang.String dataPoints)
Create a metric dataset object where each array value is added as a
MetricValue
object to the dataset. |
static <T> MetricDataset |
toDataset(java.lang.String name,
java.lang.String valueType,
T dataPoints)
Create a metric dataset object by calling the constructor with the closest match to the data object passed in.
|
static MetricDataset |
toDataset(java.lang.String name,
java.lang.String valueType,
java.util.Vector<?> dataPoints)
Create a metric dataset object where each array value is added as a
MetricValue
object to the dataset. |
static <T> MetricDataset |
toDataset(java.lang.String valueType,
T dataPoints)
Create a metric dataset object by calling the constructor with the closest match to the data object passed in.
|
static <T> MetricDataset |
toDataset(T dataPoints)
Create a metric dataset object by calling the constructor with the closest match to the data object passed in.
|
java.lang.String |
toString()
Get a String-based representation of this metric value object.
|
protected MetricDataset(MetricValue thisDataObj) throws java.lang.Exception
name
and valueType
to null.thisDataObj
- a single data object that gets added to the dataList
.java.lang.Exception
- any error.protected MetricDataset(java.lang.String thisValueType, MetricValue thisDataObj) throws java.lang.Exception
thisValueType
- the type of data object.thisDataObj
- a single data object that gets added to the dataList
.java.lang.Exception
- any error.protected MetricDataset(java.lang.String thisName, java.lang.String thisValueType, MetricValue thisDataObj) throws java.lang.Exception
thisName
- a unique name or id for the whole dataset. Can be null.thisValueType
- the type of data object.thisDataObj
- a single data object that gets added to the dataList
.java.lang.Exception
- any error.protected MetricDataset(java.lang.String thisName, java.lang.String thisValueType, java.util.Map<java.lang.String,?> thisDataset) throws java.lang.Exception
thisName
- a unique name or id for the dataset. Can be null.thisValueType
- the type of data object.thisDataset
- a list of data objects to evaluate. These can be of any
type, but are converted to MetricValue
before storing in the dataMap
.
As part of the conversion, a unique id is assigned to each point in the dataMap
,
that is different to any original MetricValue name. Note that a HashMap
ordering
is undetermined.java.lang.Exception
- any error.protected MetricDataset(java.lang.String thisName, java.lang.String thisValueType, T thisDataset) throws java.lang.Exception
thisName
- a unique name or id for the dataset. Can be null.thisValueType
- the type of data object.thisDataset
- the dataset representation. This is stored as a single MetricValue
value, where the value itself could be a single object or a list, for example, but
is not changed further inside the MetricValue.java.lang.Exception
- any error.protected MetricDataset(java.lang.String thisName, java.lang.String thisValueType, java.util.List<?> thisDataset) throws java.lang.Exception
thisName
- a unique name or id for the dataset. Can be null.thisValueType
- the type of data object.thisDataset
- a list of data objects to evaluate. These can be of any
type, but are converted to MetricValue
before storing in the dataList
.
As part of the conversion, a unique id is assigned to each point in the dataMap
,
that is different to any original MetricValue name.java.lang.Exception
- any error.public static boolean isDataset(java.lang.Object thisData)
MetricDataset
type.thisData
- the data object to evaluate.public boolean isSingleValue()
public java.lang.String getValueType()
MetricValue
.public int getDatasetSize()
public void resetValueIterator()
public java.lang.Object getFirstValue()
MetricValue
object.
If the dataset is used for storing a single value only, then this method can be used
to retrieve it.MetricValue.getValue()
value for the first list element.public boolean hasNextValue()
public java.lang.Object getNextValue()
MetricValue
object. If
the iterator has not been used, it returns the same result as getFirstData
.MetricValue.getValue()
value for the next list element.public java.lang.Object getValue()
MetricValue
object.ArrayList
of values, or single value using value.getFirstValue()
, or null
for no value.public java.lang.Object getValue(java.lang.String dataKey)
MetricValue
object, relating to a specific entry key.dataKey
- the key in the dataKeys
list.null
for no key or value.public java.util.ArrayList<java.lang.String> getDataKeys()
public java.util.ArrayList<MetricValue> getData()
MetricValue
data values.public void setName(java.lang.String thisName)
thisName
- the value object name.public java.lang.String getName()
public void setParams(java.util.HashMap<java.lang.String,java.lang.Object> theParams)
theParams
- a list of parameters for any use.public java.util.HashMap<java.lang.String,java.lang.Object> getParams()
public java.lang.String toString()
toString
in class java.lang.Object
public static <T> MetricDataset toDataset(T dataPoints) throws java.lang.Exception
dataPoints
is already a MetricDataset
then return it exactly as is, without any changes.String
value can be added as is, or if the value type is char
, then it is converted
to a list of chars.Arrays
of simple types are allowed and are now stored and retrieved as a single object in
the MetricValue
object.ArrayList
's are converted to the internal map structure, unless the data type is also an
ArrayList
, when it will be stored and retrieved as a single object.Map
's are converted to the internal map structure, unless the data type is also the Map
(not the element type), when it will be stored and retrieved as a single object.dataPoints
- the list of data points to add.java.lang.Exception
- any error.public static <T> MetricDataset toDataset(java.lang.String valueType, T dataPoints) throws java.lang.Exception
dataPoints
is already a MetricDataset
then return it exactly as is, without any changes.String
value can be added as is, or if the value type is char
, then it is converted
to a list of chars.Arrays
of simple types are allowed and are now stored and retrieved as a single object in
the MetricValue
object.ArrayList
's are converted to the internal map structure, unless the data type is also an
ArrayList
, when it will be stored and retrieved as a single object.Map
's are converted to the internal map structure, unless the data type is also the Map
(not the element type), when it will be stored and retrieved as a single object.valueType
- the type of data to add. This will also convert a single String
into a list of chars, if the Character
or char
value type is indicated.dataPoints
- the list of data points to add. This can include arrays, or
a String that needs to be converted into chars. A single data point is also
possible that can be added simply as is. This data type overrides the valueType
entry.
A MetricValue
entry is a simply added as is.java.lang.Exception
- any error.public static <T> MetricDataset toDataset(java.lang.String name, java.lang.String valueType, T dataPoints) throws java.lang.Exception
dataPoints
is already a MetricDataset
then return it exactly as is, without any changes.String
value can be added as is, or if the value type is char
, then it is converted
to a list of chars.Arrays
of simple types are allowed and are now stored and retrieved as a single object in
the MetricValue
object.ArrayList
's are converted to the internal map structure, unless the data type is also an
ArrayList
, when it will be stored and retrieved as a single object.Map
's are converted to the internal map structure, unless the data type is also the Map
(not the element type), when it will be stored and retrieved as a single object.name
- a name to give the dataset.valueType
- the type of data to add. This will also convert a single String
into a list of chars, if the Character
or char
value type is indicated.dataPoints
- the list of data points to add.java.lang.Exception
- any error.public static MetricDataset toDataset(java.lang.String name, java.lang.String valueType, MetricValue dataPoints) throws java.lang.Exception
MetricValue
object to the dataset. This is the standard way to store and retrieve the data.name
- a name to give the dataset.valueType
- the type of data to add.dataPoints
- the list of data points to add, as a MetricValue list.java.lang.Exception
- any error.public static MetricDataset toDataset(java.lang.String name, java.lang.String valueType, java.util.ArrayList<?> dataPoints) throws java.lang.Exception
MetricValue
object to the dataset. This is the standard way to store and retrieve the data.name
- a name to give the dataset.valueType
- the type of data to add.dataPoints
- the list of data points to add.java.lang.Exception
- any error.public static MetricDataset toDataset(java.lang.String name, java.lang.String valueType, java.util.Vector<?> dataPoints) throws java.lang.Exception
MetricValue
object to the dataset. This is the standard way to store and retrieve the data.name
- a name to give the dataset.valueType
- the type of data to add.dataPoints
- the list of data points to add.java.lang.Exception
- any error.public static MetricDataset toDataset(java.lang.String name, java.lang.String valueType, java.util.HashMap<java.lang.String,?> dataPoints) throws java.lang.Exception
MetricValue
object to the dataset. This is the standard way to store and retrieve the data.name
- a name to give the dataset.valueType
- the type of data to add.dataPoints
- the list of data points to add.java.lang.Exception
- any error.public static MetricDataset toDataset(java.lang.String name, java.lang.String valueType, java.util.Hashtable<java.lang.String,?> dataPoints) throws java.lang.Exception
MetricValue
object to the dataset. This is the standard way to store and retrieve the data.name
- a name to give the dataset.valueType
- the type of data to add.dataPoints
- the list of data points to add.java.lang.Exception
- any error.public static MetricDataset toDataset(java.lang.String name, java.lang.String valueType, java.util.LinkedHashMap<?,?> dataPoints) throws java.lang.Exception
MetricValue
object to the dataset. This is the standard way to store and retrieve the data.name
- a name to give the dataset.valueType
- the type of data to add.dataPoints
- the list of data points to add.java.lang.Exception
- any error.public static MetricDataset toDataset(java.lang.String name, java.lang.String valueType, java.lang.String dataPoints) throws java.lang.Exception
MetricValue
object to the dataset. This is the standard way to store and retrieve the data.name
- a name to give the dataset.valueType
- the type of data to add. This will also convert a single String
into a list of chars, if the Character
or char
value type is indicated.dataPoints
- the list of data points to add.java.lang.Exception
- any error.