Package com.thingworx.types
Class InfoTable
java.lang.Object
com.thingworx.types.InfoTable
- All Implemented Interfaces:
IDiffableObject
,Cloneable
- Direct Known Subclasses:
ConfigurationTable
@ThingworxExtensionApiClass(since={6,6},
canInstantiate=true)
public class InfoTable
extends Object
implements Cloneable, IDiffableObject
An InfoTable is the aggregate base type within ThingWorx. InfoTables have a
DataShapeDefinition
that describes the
names, base types, and additional information about each field within the table.
Data within an InfoTable is contained in rows. Each row can have one or more fields, described by the table's DataShapeDefinition.
ValueCollection
s
are used to represent the rows within the table.
InfoTables are often serialized to JSON and this class contains helper functions, such as toJSON and fromJSON to simplify that process.-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
addField
(FieldDefinition field) void
AddField
(org.json.JSONObject jsonObject)
Adds a field to this InfoTable given a field definition as aJSONObject
int
addRow
(ValueCollection row) void
AddRow
(org.json.JSONObject jsonObject)
Adds a row to this InfoTable given the values as aJSONObject
int
int
addRowsFrom
(InfoTable table, Boolean clone)
Adds the rows from an InfoTable to this InfoTable given: the InfoTable to be copied from and a Boolean indicating whether the copied values should be references or cloned values.clone()
int
delete
(ValueCollection values)
Creates an
based on the givenAndFilterCollection
and deletes all rows falling within the parameters of that filterValueCollection
int
deleteRowsToNewTable
(IFilter filters) void
filter
(ValueCollection values) void
filterRows
(IFilter filters) filterRowsToNewTable
(IFilter filters) FilterToNewTable
(org.json.JSONObject jsonObject)
Finds rows in this InfoTable with values that match the values given as a
and returns them as a new InfoTableJSONObject
find
(ValueCollection values)
Finds and returns a row from this InfoTable that matches the values of all fields given as a (
)ValueCollection
find
(ValueCollection values, String[] columns)
Finds and returns a row in this InfoTable given the fields to search as a String Array and the values to match as a (
)ValueCollection
int
findIndex
(ValueCollection values)
Finds and returns the index of a row from this InfoTable that matches the values of all fields given as a (
)ValueCollection
static InfoTable
fromJSON
(org.json.JSONObject jsonObject) Deprecated.static InfoTable
fromJSONWithoutDefaults
(org.json.JSONObject jsonObject) Deprecated.
Returns a
from this InfoTable'sFieldDefinition
, given the name of the field as a StringDataShapeDefinition
int
Returns the number of fields in this InfoTable's DataShape as an intgetIndex()
Returns the number of rows in this InfoTable as an Integer
Returns the first value of the first field in the first row of this InfoTablegetRow
(int index)
Returns the number of rows in this InfoTable as an IntegergetRows()
getRowValue
(String name)
Returns a value as an
from the first row of this InfoTable, given a field name as a StringIPrimitiveType
Verifies a field exists in this InfoTable's DataShape given the field name as a Stringvoid
void
boolean
isEmpty()
Returns a boolean indicating whether this InfoTable has a size of zeroboolean
void
Moves to the first row of this InfoTable.nextRow()
void
void
void
void
RemoveField
(String field)
Removes a field from this InfoTable given the field name as a Stringvoid
removeRow
(int row) void
reverse()
void
void
setDataShape
(DataShapeDefinition fields) void
setRow
(int index, ValueCollection row)
Sets a single row in this InfoTable given a
as a row and the index of the row to be replacedValueCollection
void
setRows
(ValueCollectionList rows)
Sets the rows in this InfoTable given a
No deserialisation needed here as we are replacing all the data from the table and replacing it with new dataValueCollectionList
void
sortRowsToNewTable
(ISort sorters) org.json.JSONObject
toJSON()
Deprecated.no replacementvoid
topN
(int maxItems) topNToNewTable
(int maxItems) updateRowsToNewTable
(IFilter filters, ValueCollection values)
-
Field Details
-
ROWS_ELEMENT_NAME
- See Also:
-
-
Constructor Details
-
InfoTable
Constructs a new InfoTable -
InfoTable
- Parameters:
fields
- DataShapeDefinition containing the fields you would like in your InfoTable
-
-
Method Details
-
getDataShape
- Returns:
- DataShapeDefinition
-
setDataShape
- Parameters:
fields
- DataShapeDefinition containing the fields you would like in your InfoTable
-
getPublicDataShape
- Returns:
- DataShapeDefinition
-
getFieldCount
Returns the number of fields in this InfoTable's DataShape as an int- Returns:
- int number of fields
-
getRows
- Returns:
- ValueCollectionList
-
setRows
Sets the rows in this InfoTable given a
No deserialisation needed here as we are replacing all the data from the table and replacing it with new dataValueCollectionList
- Parameters:
rows
- ValueCollectionList containing the rows you want to add to this InfoTable
-
setRow
Sets a single row in this InfoTable given a
as a row and the index of the row to be replacedValueCollection
- Parameters:
index
- int of the row to be replacedrow
- ValueCollection containing the new row
-
isEmpty
Returns a boolean indicating whether this InfoTable has a size of zero- Returns:
- boolean True: if InfoTable size is 0, False: if InfoTable size is not 0
-
addField
- Parameters:
field
- FieldDefinition containing the field to be added to the InfoTable's DataShape- Returns:
- int number of fields in this InfoTable's DataShape
-
addRow
- Parameters:
row
- ValueCollection containing the values for the row- Returns:
- int size of this InfoTable's ValueCollectionList
-
addRowBeginning
- Parameters:
row
- ValueCollection containing the values for the row- Returns:
- int size of this InfoTable's ValueCollectionList
-
addRowsFrom
Adds the rows from an InfoTable to this InfoTable given: the InfoTable to be copied from and a Boolean indicating whether the copied values should be references or cloned values.- Parameters:
table
- InfoTable containing the rows to be added to this InfoTableclone
- Boolean True: if the values in the row should be copies. False: if the values in the row should be references.- Returns:
- int size of this InfoTable's ValueCollectionList
-
AddField
@ThingworxExtensionApiMethod(since={6,6}) public void AddField(org.json.JSONObject jsonObject) throws Exception
Adds a field to this InfoTable given a field definition as aJSONObject
- Parameters:
jsonObject
- The field definition of the new field as a JSONObject- Throws:
Exception
- If an error occurs
-
AddRow
@ThingworxExtensionApiMethod(since={6,6}) public void AddRow(org.json.JSONObject jsonObject) throws Exception
Adds a row to this InfoTable given the values as aJSONObject
- Parameters:
jsonObject
- The values of the row as a JSONObject- Throws:
Exception
- If an error occurs
-
removeRow
- Parameters:
row
- int Index of the ValueCollection to be removed from the ValueCollectionList- Throws:
Exception
- If an error occurs
-
removeAllRows
-
RemoveField
Removes a field from this InfoTable given the field name as a String- Parameters:
field
- The name of the field to be removed- Throws:
Exception
- If an error occurs
-
FilterToNewTable
@ThingworxExtensionApiMethod(since={6,6}) public InfoTable FilterToNewTable(org.json.JSONObject jsonObject) throws Exception
Finds rows in this InfoTable with values that match the values given as a
and returns them as a new InfoTableJSONObject
- Parameters:
jsonObject
- The values to be matched as a JSONObject- Returns:
- InfoTable Containing the rows with matching values
- Throws:
Exception
- If an error occurs
-
getRowCount
Returns the number of rows in this InfoTable as an Integer- Returns:
- Integer The number rows (ValueCollections) in this InfoTable
-
getLength
Returns the number of rows in this InfoTable as an Integer- Returns:
- Integer The number rows (ValueCollections) in this InfoTable
-
hasField
Verifies a field exists in this InfoTable's DataShape given the field name as a String- Parameters:
name
- String containing the name of the field to verify- Returns:
- Boolean True: if field exists in DataShape, False: if field does not exist in DataShape
-
getField
Returns a
from this InfoTable'sFieldDefinition
, given the name of the field as a StringDataShapeDefinition
- Parameters:
name
- String containing the name of the field- Returns:
- FieldDefinition from this InfoTable's DataShape or null if not found
-
currentRow
- Returns:
- ValueCollection of current row
-
nextRow
- Returns:
- ValueCollection of the row after the current row
-
getIndex
-
indexOn
@ThingworxExtensionApiMethod(since={6,6}) public void indexOn(String fieldName, boolean isUnique) throws Exception - Throws:
Exception
- If an error occurs
-
indexOn
@ThingworxExtensionApiMethod(since={6,6}) public void indexOn(ArrayList<String> fieldNames, boolean isUnique) throws Exception - Throws:
Exception
- If an error occurs
-
getRow
- Parameters:
index
- Location of the row (ValueCollection) in the ValueCollectionList- Returns:
- ValueCollection of the row specified or null if index is out of range
-
getLastRow
- Returns:
- ValueCollection of the last row
-
getRowValue
Returns a value as an
from the first row of this InfoTable, given a field name as a StringIPrimitiveType
- Parameters:
name
- The name of the field containing the wanted value- Returns:
- IPrimitiveType value from the first row of this InfoTable given the field name or null if the field does not exist
-
getReturnValue
Returns the first value of the first field in the first row of this InfoTable- Returns:
- Object value of the first field of the first row or null if either are empty
-
getFirstRow
- Returns:
- ValueCollection The first row of this InfoTable
-
moveToFirst
Moves to the first row of this InfoTable. i.e. Sets the current row of this InfoTable's
to 0 if there are rows present and -1 if there are notValueCollectionList
-
find
Finds and returns a row from this InfoTable that matches the values of all fields given as a (
)ValueCollection
- Parameters:
values
- ValueCollection containing the values that match all fields in the row- Returns:
- ValueCollection The row in this InfoTable that matches the values given or null if not found
-
find
@ThingworxExtensionApiMethod(since={6,6}) public ValueCollection find(ValueCollection values, String[] columns)
Finds and returns a row in this InfoTable given the fields to search as a String Array and the values to match as a (
)ValueCollection
- Parameters:
values
- ValueCollection of the values to matchcolumns
- String Array containing the fields to be searched- Returns:
- ValueCollection containing the matching row in this InfoTable or null if not found
-
find
- Parameters:
filter
- IFilter containing the parameters of the search- Returns:
- ValueCollection a row matching the given parameters in the IFilter or null if not found
-
findIndex
Finds and returns the index of a row from this InfoTable that matches the values of all fields given as a (
)ValueCollection
- Parameters:
values
- ValueCollection containing the values that match all fields in the row- Returns:
- int Index of the row in this InfoTable that matches the values given or null if not found
-
filter
- Parameters:
values
- ValueCollection containing the values to filter by
-
delete
Creates an
based on the givenAndFilterCollection
and deletes all rows falling within the parameters of that filterValueCollection
- Parameters:
values
- ValueCollection containing the values used to generate the filter- Returns:
- int Number of rows deleted
-
delete
-
filterRows
-
quickSort
@ThingworxExtensionApiMethod(since={6,6}) public void quickSort(String fieldName, Boolean isAscending) throws Exception - Throws:
Exception
- If an error occurs
-
quickSort
- Throws:
Exception
- If an error occurs
-
sortRows
-
topN
-
clone
-
cloneStructure
-
filterRowsToNewTable
-
deleteRowsToNewTable
-
updateRowsToNewTable
@ThingworxExtensionApiMethod(since={6,6}) public InfoTable updateRowsToNewTable(IFilter filters, ValueCollection values) -
sortRowsToNewTable
-
topNToNewTable
-
reverse
-
reverseRowJsons
-
isType
-
fromJSON
@Deprecated @ThingworxExtensionApiMethod(since={6,6}, deprecatedSince={8,4}) public static InfoTable fromJSON(org.json.JSONObject jsonObject) throws Exception Deprecated.- Throws:
Exception
- If an error occurs
-
fromJSONWithoutDefaults
@Deprecated @ThingworxExtensionApiMethod(since={8,3}, deprecatedSince={8,4}) public static InfoTable fromJSONWithoutDefaults(org.json.JSONObject jsonObject) throws Exception Deprecated.- Throws:
Exception
- If an error occurs
-
toJSON
@Deprecated @ThingworxExtensionApiMethod(since={6,6}, deprecatedSince={8,4}) public org.json.JSONObject toJSON() throws ExceptionDeprecated.no replacement
Returns a JSON representation of this InfoTable.- Returns:
- a JSON object
- Throws:
Exception
- if an error occurs
-