Interface JCoTable
- All Superinterfaces:
Cloneable
,Iterable<JCoField>
,JCoRecord
,Serializable
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Appends a new row at the end of the table.void
appendRows
(int numRows) Appends the specified number of empty rows at the end of the table.void
clear()
Clears the table by deleting all rows.void
Deletes all rows of this table.void
Deletes the current row.void
deleteRow
(int pos) Deletes the row at the specified position.void
ensureBufferCapacity
(int minRows) Checks the size of the internal buffer and allocates new memory, if necessary, and initializes the rows.void
firstRow()
Moves the row pointer to the first row.int
Returns the number of columns in this table.int
Returns the number of rows.Returns a JCoRecordFieldIterator.Returns the appropriated metadata object, that was used for the creation of this table.int
getRow()
Returns the current row number.Returns a String containing all fields of the current row concatenated to one single String.void
insertRow
(int pos) Inserts a new empty row before the specified position.boolean
isEmpty()
Checks whether the table is empty.boolean
Retrieves whether the row pointer is on the first row of this table.boolean
Retrieves whether the row pointer is on the last row of this table.void
lastRow()
Moves the row pointer to the last row.boolean
nextRow()
Moves the row pointer to the next row.boolean
Moves the row pointer to the previous row.void
setRow
(int pos) Sets the row pointer to the specified position.void
Allows to set all fields for the current row handed over by one single String containing all field values.void
Trims the capacity of this table to be the table's current number of rows.Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface com.sap.conn.jco.JCoRecord
clone, copyFrom, fromJSON, fromJSON, getAbapObject, getAbapObject, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBinaryStream, getBinaryStream, getByte, getByte, getByteArray, getByteArray, getChar, getChar, getCharacterStream, getCharacterStream, getCharArray, getCharArray, getClassNameOfValue, getDate, getDate, getDouble, getDouble, getField, getField, getFieldCount, getFieldIterator, getFloat, getFloat, getInt, getInt, getLong, getLong, getMetaData, getShort, getShort, getString, getString, getStructure, getStructure, getTable, getTable, getTime, getTime, getValue, getValue, isInitialized, isInitialized, iterator, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, toJSON, toJSON, toXML, toXML, toXML, write, write
-
Method Details
-
getRecordMetaData
JCoRecordMetaData getRecordMetaData()Returns the appropriated metadata object, that was used for the creation of this table.- Returns:
- JCoRecordMetaData instance of the appropriated metadata object
-
ensureBufferCapacity
void ensureBufferCapacity(int minRows) Checks the size of the internal buffer and allocates new memory, if necessary, and initializes the rows.- Parameters:
minRows
- the minimum number of rows to allocate memory for
-
trimToRows
void trimToRows()Trims the capacity of this table to be the table's current number of rows. An application can use this operation to minimize the storage requirements of this table.Note: The reallocation of the internal table buffer increases the temporary memory consumption.
-
isEmpty
boolean isEmpty()Checks whether the table is empty.- Returns:
true
if the table is empty,false
otherwise
-
isFirstRow
boolean isFirstRow()Retrieves whether the row pointer is on the first row of this table.- Returns:
true
if the row pointer is on the first row,false
otherwise
-
isLastRow
boolean isLastRow()Retrieves whether the row pointer is on the last row of this table.- Returns:
true
if the row pointer is on the last row,false
otherwise
-
getNumRows
int getNumRows()Returns the number of rows.- Returns:
- the number of rows
-
getNumColumns
int getNumColumns()Returns the number of columns in this table.
This is just a convenience method and returns the same value asgetFieldCount()
.- Returns:
- the number of columns in this table
- See Also:
-
clear
void clear()Clears the table by deleting all rows. -
deleteAllRows
void deleteAllRows()Deletes all rows of this table.
This is just a convenience method and is the same as calling methodclear()
.- See Also:
-
firstRow
void firstRow()Moves the row pointer to the first row. -
lastRow
void lastRow()Moves the row pointer to the last row. -
nextRow
boolean nextRow()Moves the row pointer to the next row. Used to loop through table rows, e.g.if (table.getNumRows() > 0) { table.firstRow(); do { ... } while (table.nextRow()); }
- Returns:
false
if the row pointer is already positioned on the last row of the table,true
otherwise
-
previousRow
boolean previousRow()Moves the row pointer to the previous row. Used to loop through table rows, e.g.if (table.getNumRows() > 0) { table.lastRow(); do { ... } while (table.previousRow()); }
- Returns:
false
if the row pointer is already positioned on the first row of the table,true
otherwise
-
getRow
int getRow()Returns the current row number.
The first row number is 0, the second is 1, and so on.- Returns:
- the current row number
-
setRow
void setRow(int pos) Sets the row pointer to the specified position.
The first row is at position 0, the second is at position 1, and so on. This method is useful for looping through the table rows, e.g.int numRows = table.getNumRows(); for (int irow = 0; i < numRows; irow++) { table.setRow(irow); ... }
Note: If a negative value is specified, the row pointer is set to position 0, and if the specified value is greater than the number of rows, it is moved to the last row.- Parameters:
pos
- the position to set the row pointer to
-
appendRow
void appendRow()Appends a new row at the end of the table.
The row pointer is positioned on the newly appended row. -
appendRows
void appendRows(int numRows) Appends the specified number of empty rows at the end of the table.
The row pointer is positioned on the first newly appended row.- Parameters:
numRows
- the number of empty rows to append
-
insertRow
void insertRow(int pos) Inserts a new empty row before the specified position.
The row pointer is positioned on the newly inserted row.- Parameters:
pos
- the index of the row, before which the new row shall be inserted
-
deleteRow
void deleteRow()Deletes the current row.Note: The row pointer is left untouched unless it would point to a row that would become invalid due to the deletion operation. In this case the row pointer will be repositioned to the row at
(getNumRows() - 1)
. -
deleteRow
void deleteRow(int pos) Deletes the row at the specified position.Note: The row pointer is left untouched unless it would point to a row that would become invalid due to the deletion operation. In this case the row pointer will be repositioned to the row at
(getNumRows() - 1)
.Example:
If the row pointer points to row 10, it will still point to row 10 after the deletion operation, even if a row with pos < 10 was deleted.- Parameters:
pos
- the index of the row to delete
-
getRecordFieldIterator
JCoRecordFieldIterator getRecordFieldIterator()Returns a JCoRecordFieldIterator.- Returns:
- an iterator over all fields of the current table row
- See Also:
-
getString
String getString()Returns a String containing all fields of the current row concatenated to one single String.Note: The
JCoTable
must be a flat table with only simple char-like fields such as CHAR, NUM, DATE or TIME. The function mimics a 'c-style memcpy'. If the last field is aTYPE_CHAR
, this method trims all trailing blanks from the returned string. In addition to programming convenience it should also improve runtime performance compared to fetching each single field one-by-one.- Returns:
- the value of all fields of the current row concatenated as a String
- Throws:
ConversionException
- if the values could not be converted to a String or theJCoTable
contains fields other than CHAR, NUM, DATE or TIME- Since:
- JCo 3.1.0
-
setString
Allows to set all fields for the current row handed over by one single String containing all field values.Note: The
JCoTable
must be a flat table with only simple char-like fields, such as CHAR, NUM, DATE or TIME. The function mimics a 'c-style memcpy'. In addition to programming convenience, it should also improve runtime performance compared to setting each single field one-by-one. The function will set all fields 'up to', meaning you can provide a much shorter String for only setting the first fields. If the String is bigger than the internal buffer for all fields, the remaining substring will be ignored. DATE and TIME values inside the String can contain '-' or ':' as formatter.- Parameters:
fieldsAsString
- the string to set- Throws:
ConversionException
- if the given String could not be converted to the table's internal representation or theJCoTable
contains fields other than CHAR, NUM, DATE or TIME- Since:
- JCo 3.1.0
-