Package com.thingworx.types
Class InfoTable
- java.lang.Object
-
- com.thingworx.types.InfoTable
-
- All Implemented Interfaces:
IDiffableObject
,java.lang.Cloneable
- Direct Known Subclasses:
ConfigurationTable
@ThingworxExtensionApiClass(since={6,6}, canInstantiate=true) public class InfoTable extends java.lang.Object implements java.lang.Cloneable, IDiffableObject
An InfoTable is the aggregate base type within ThingWorx. InfoTables have a
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.DataShapeDefinition
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.ValueCollection
s
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ROWS_ELEMENT_NAME
-
Constructor Summary
Constructors Constructor Description InfoTable()
Constructs a new InfoTableInfoTable(DataShapeDefinition fields)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description int
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
addRowBeginning(ValueCollection row)
int
addRowsFrom(InfoTable table, java.lang.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.InfoTable
clone()
InfoTable
cloneStructure()
ValueCollection
currentRow()
int
delete(ValueCollection values)
Creates an
based on the givenAndFilterCollection
and deletes all rows falling within the parameters of that filterValueCollection
int
delete(IFilter filter)
InfoTable
deleteRowsToNewTable(IFilter filters)
void
filter(ValueCollection values)
void
filterRows(IFilter filters)
InfoTable
filterRowsToNewTable(IFilter filters)
InfoTable
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
ValueCollection
find(ValueCollection values)
Finds and returns a row from this InfoTable that matches the values of all fields given as a (
)ValueCollection
ValueCollection
find(ValueCollection values, java.lang.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
ValueCollection
find(IFilter filter)
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.DataShapeDefinition
getDataShape()
FieldDefinition
getField(java.lang.String name)
Returns a
from this InfoTable'sFieldDefinition
, given the name of the field as a StringDataShapeDefinition
int
getFieldCount()
Returns the number of fields in this InfoTable's DataShape as an intValueCollection
getFirstRow()
InfoTableRowIndex
getIndex()
ValueCollection
getLastRow()
java.lang.Integer
getLength()
Returns the number of rows in this InfoTable as an IntegerDataShapeDefinition
getPublicDataShape()
java.lang.Object
getReturnValue()
Returns the first value of the first field in the first row of this InfoTableValueCollection
getRow(int index)
java.lang.Integer
getRowCount()
Returns the number of rows in this InfoTable as an IntegerValueCollectionList
getRows()
IPrimitiveType
getRowValue(java.lang.String name)
Returns a value as an
from the first row of this InfoTable, given a field name as a StringIPrimitiveType
java.lang.Boolean
hasField(java.lang.String name)
Verifies a field exists in this InfoTable's DataShape given the field name as a Stringvoid
indexOn(java.lang.String fieldName, boolean isUnique)
void
indexOn(java.util.ArrayList<java.lang.String> fieldNames, boolean isUnique)
boolean
isEmpty()
Returns a boolean indicating whether this InfoTable has a size of zeroboolean
isType(BaseTypes type)
void
moveToFirst()
Moves to the first row of this InfoTable.ValueCollection
nextRow()
void
quickSort(java.lang.String fieldName)
void
quickSort(java.lang.String fieldName, java.lang.Boolean isAscending)
void
removeAllRows()
void
RemoveField(java.lang.String field)
Removes a field from this InfoTable given the field name as a Stringvoid
removeRow(int row)
void
reverse()
void
reverseRowJsons()
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
sortRows(ISort sorters)
InfoTable
sortRowsToNewTable(ISort sorters)
org.json.JSONObject
toJSON()
Deprecated.no replacementvoid
topN(int maxItems)
InfoTable
topNToNewTable(int maxItems)
InfoTable
updateRowsToNewTable(IFilter filters, ValueCollection values)
-
-
-
Field Detail
-
ROWS_ELEMENT_NAME
public static final java.lang.String ROWS_ELEMENT_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
InfoTable
@ThingworxExtensionApiMethod(since={6,6}) public InfoTable()
Constructs a new InfoTable
-
InfoTable
@ThingworxExtensionApiMethod(since={6,6}) public InfoTable(DataShapeDefinition fields)
- Parameters:
fields
- DataShapeDefinition containing the fields you would like in your InfoTable
-
-
Method Detail
-
getDataShape
@ThingworxExtensionApiMethod(since={6,6}) public DataShapeDefinition getDataShape()
- Returns:
- DataShapeDefinition
-
setDataShape
@ThingworxExtensionApiMethod(since={6,6}) public void setDataShape(DataShapeDefinition fields)
- Parameters:
fields
- DataShapeDefinition containing the fields you would like in your InfoTable
-
getPublicDataShape
@ThingworxExtensionApiMethod(since={6,6}) public DataShapeDefinition getPublicDataShape()
- Returns:
- DataShapeDefinition
-
getFieldCount
@ThingworxExtensionApiMethod(since={6,6}) public int getFieldCount()
Returns the number of fields in this InfoTable's DataShape as an int- Returns:
- int number of fields
-
getRows
@ThingworxExtensionApiMethod(since={6,6}) public ValueCollectionList getRows()
- Returns:
- ValueCollectionList
-
setRows
@ThingworxExtensionApiMethod(since={6,6}) public 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
- Parameters:
rows
- ValueCollectionList containing the rows you want to add to this InfoTable
-
setRow
@ThingworxExtensionApiMethod(since={6,6}) public 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
- Parameters:
index
- int of the row to be replacedrow
- ValueCollection containing the new row
-
isEmpty
@ThingworxExtensionApiMethod(since={6,6}) public boolean 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
@ThingworxExtensionApiMethod(since={6,6}) public int addField(FieldDefinition field)
- 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
@ThingworxExtensionApiMethod(since={6,6}) public int addRow(ValueCollection row)
- Parameters:
row
- ValueCollection containing the values for the row- Returns:
- int size of this InfoTable's ValueCollectionList
-
addRowBeginning
@ThingworxExtensionApiMethod(since={6,6}) public int addRowBeginning(ValueCollection row)
- Parameters:
row
- ValueCollection containing the values for the row- Returns:
- int size of this InfoTable's ValueCollectionList
-
addRowsFrom
@ThingworxExtensionApiMethod(since={6,6}) public int addRowsFrom(InfoTable table, java.lang.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.- 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 java.lang.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:
java.lang.Exception
- If an error occurs
-
AddRow
@ThingworxExtensionApiMethod(since={6,6}) public void AddRow(org.json.JSONObject jsonObject) throws java.lang.Exception
Adds a row to this InfoTable given the values as aJSONObject
- Parameters:
jsonObject
- The values of the row as a JSONObject- Throws:
java.lang.Exception
- If an error occurs
-
removeRow
@ThingworxExtensionApiMethod(since={6,6}) public void removeRow(int row) throws java.lang.Exception
- Parameters:
row
- int Index of the ValueCollection to be removed from the ValueCollectionList- Throws:
java.lang.Exception
- If an error occurs
-
removeAllRows
@ThingworxExtensionApiMethod(since={6,6}) public void removeAllRows()
-
RemoveField
@ThingworxExtensionApiMethod(since={6,6}) public void RemoveField(java.lang.String field) throws java.lang.Exception
Removes a field from this InfoTable given the field name as a String- Parameters:
field
- The name of the field to be removed- Throws:
java.lang.Exception
- If an error occurs
-
FilterToNewTable
@ThingworxExtensionApiMethod(since={6,6}) public InfoTable FilterToNewTable(org.json.JSONObject jsonObject) throws java.lang.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:
java.lang.Exception
- If an error occurs
-
getRowCount
@ThingworxExtensionApiMethod(since={6,6}) public java.lang.Integer getRowCount()
Returns the number of rows in this InfoTable as an Integer- Returns:
- Integer The number rows (ValueCollections) in this InfoTable
-
getLength
@ThingworxExtensionApiMethod(since={6,6}) public java.lang.Integer getLength()
Returns the number of rows in this InfoTable as an Integer- Returns:
- Integer The number rows (ValueCollections) in this InfoTable
-
hasField
@ThingworxExtensionApiMethod(since={6,6}) public java.lang.Boolean hasField(java.lang.String name)
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
@ThingworxExtensionApiMethod(since={6,6}) public FieldDefinition getField(java.lang.String name)
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
@ThingworxExtensionApiMethod(since={6,6}) public ValueCollection currentRow()
- Returns:
- ValueCollection of current row
-
nextRow
@ThingworxExtensionApiMethod(since={6,6}) public ValueCollection nextRow()
- Returns:
- ValueCollection of the row after the current row
-
getIndex
@ThingworxExtensionApiMethod(since={6,6}) public InfoTableRowIndex getIndex()
-
indexOn
@ThingworxExtensionApiMethod(since={6,6}) public void indexOn(java.lang.String fieldName, boolean isUnique) throws java.lang.Exception
- Throws:
java.lang.Exception
- If an error occurs
-
indexOn
@ThingworxExtensionApiMethod(since={6,6}) public void indexOn(java.util.ArrayList<java.lang.String> fieldNames, boolean isUnique) throws java.lang.Exception
- Throws:
java.lang.Exception
- If an error occurs
-
getRow
@ThingworxExtensionApiMethod(since={6,6}) public ValueCollection getRow(int index)
- 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
@ThingworxExtensionApiMethod(since={6,6}) public ValueCollection getLastRow()
- Returns:
- ValueCollection of the last row
-
getRowValue
@ThingworxExtensionApiMethod(since={6,6}) public IPrimitiveType getRowValue(java.lang.String name)
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
@ThingworxExtensionApiMethod(since={6,6}) public java.lang.Object 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
@ThingworxExtensionApiMethod(since={6,6}) public ValueCollection getFirstRow()
- Returns:
- ValueCollection The first row of this InfoTable
-
moveToFirst
@ThingworxExtensionApiMethod(since={6,6}) public void 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
@ThingworxExtensionApiMethod(since={6,6}) public ValueCollection find(ValueCollection values)
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, java.lang.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
@ThingworxExtensionApiMethod(since={6,6}) public ValueCollection find(IFilter filter)
- 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
@ThingworxExtensionApiMethod(since={6,6}) public 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
- 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
@ThingworxExtensionApiMethod(since={6,6}) public void filter(ValueCollection values)
- Parameters:
values
- ValueCollection containing the values to filter by
-
delete
@ThingworxExtensionApiMethod(since={6,6}) public int delete(ValueCollection values)
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
@ThingworxExtensionApiMethod(since={6,6}) public int delete(IFilter filter)
-
filterRows
@ThingworxExtensionApiMethod(since={6,6}) public void filterRows(IFilter filters)
-
quickSort
@ThingworxExtensionApiMethod(since={6,6}) public void quickSort(java.lang.String fieldName, java.lang.Boolean isAscending) throws java.lang.Exception
- Throws:
java.lang.Exception
- If an error occurs
-
quickSort
@ThingworxExtensionApiMethod(since={6,6}) public void quickSort(java.lang.String fieldName) throws java.lang.Exception
- Throws:
java.lang.Exception
- If an error occurs
-
sortRows
@ThingworxExtensionApiMethod(since={6,6}) public void sortRows(ISort sorters)
-
topN
@ThingworxExtensionApiMethod(since={6,6}) public void topN(int maxItems)
-
clone
@ThingworxExtensionApiMethod(since={6,6}) public InfoTable clone()
- Overrides:
clone
in classjava.lang.Object
-
cloneStructure
@ThingworxExtensionApiMethod(since={6,6}) public InfoTable cloneStructure()
-
filterRowsToNewTable
@ThingworxExtensionApiMethod(since={6,6}) public InfoTable filterRowsToNewTable(IFilter filters)
-
deleteRowsToNewTable
@ThingworxExtensionApiMethod(since={6,6}) public InfoTable deleteRowsToNewTable(IFilter filters)
-
updateRowsToNewTable
@ThingworxExtensionApiMethod(since={6,6}) public InfoTable updateRowsToNewTable(IFilter filters, ValueCollection values)
-
sortRowsToNewTable
@ThingworxExtensionApiMethod(since={6,6}) public InfoTable sortRowsToNewTable(ISort sorters)
-
topNToNewTable
@ThingworxExtensionApiMethod(since={6,6}) public InfoTable topNToNewTable(int maxItems)
-
reverse
@ThingworxExtensionApiMethod(since={6,6}) public void reverse()
-
reverseRowJsons
@ThingworxExtensionApiMethod(since={6,6}) public void reverseRowJsons()
-
isType
@ThingworxExtensionApiMethod(since={6,6}) public boolean isType(BaseTypes type)
-
fromJSON
@Deprecated @ThingworxExtensionApiMethod(since={6,6}, deprecatedSince={8,4}) public static InfoTable fromJSON(org.json.JSONObject jsonObject) throws java.lang.Exception
Deprecated.- Throws:
java.lang.Exception
- If an error occurs
-
fromJSONWithoutDefaults
@Deprecated @ThingworxExtensionApiMethod(since={8,3}, deprecatedSince={8,4}) public static InfoTable fromJSONWithoutDefaults(org.json.JSONObject jsonObject) throws java.lang.Exception
Deprecated.- Throws:
java.lang.Exception
- If an error occurs
-
toJSON
@Deprecated @ThingworxExtensionApiMethod(since={6,6}, deprecatedSince={8,4}) public org.json.JSONObject toJSON() throws java.lang.Exception
Deprecated.no replacement
Returns a JSON representation of this InfoTable.- Returns:
- a JSON object
- Throws:
java.lang.Exception
- if an error occurs
-
-