com.sap.mw.jco
Class JCO.Table

java.lang.Object
  |
  +--com.sap.mw.jco.JCO.MetaData
        |
        +--com.sap.mw.jco.JCO.Record
              |
              +--com.sap.mw.jco.JCO.Table
All Implemented Interfaces:
java.lang.Cloneable, IMetaData, java.io.Serializable
Enclosing class:
JCO

public static class JCO.Table
extends JCO.Record
implements java.lang.Cloneable, java.io.Serializable

Class that encapsulates a database table

See Also:
Serialized Form

Fields inherited from interface com.sap.mw.jco.IMetaData
EXPORT_PARAMETER, IMPORT_PARAMETER, INACTIVE_PARAMETER, OPTIONAL_PARAMETER, TYPE_BCD, TYPE_BYTE, TYPE_CHAR, TYPE_DATE, TYPE_EXCEPTION, TYPE_FLOAT, TYPE_INT, TYPE_INT1, TYPE_INT2, TYPE_INVALID, TYPE_ITAB, TYPE_NUM, TYPE_STRING, TYPE_STRUCTURE, TYPE_TABLE, TYPE_TIME, TYPE_XSTRING, UNINITIALIZED, UNINITIALIZED_PARAMETER
 
Constructor Summary
JCO.Table(IMetaData meta_data)
          Creates an instance of the table with a column layout as specified by the IMetaData argument
JCO.Table(JCO.Table value)
          Creates an new instance of a table which has the same layout and contents as the table argument
JCO.Table(java.lang.String name)
          Creates an instance of the table
 
Method Summary
 void appendRow()
          Appends a new row at the end of the table and moves the row pointer such that it points to the newly appended row.
 void appendRows(int num_rows)
          Appends the specified number of empty rows at the end of the table.
 void clear()
          Clears the table, i.e. deletes all rows
 int copyFrom(JCO.Record source)
          Appends the matching fields from the source record at the end of this table Data fields are considered to be equivalent if the name and type of two fields match.
 void deleteAllRows()
          Deletes all rows of table
 void deleteRow()
          Deletes the current row
Note:The row pointer will be left untouched unless it would point to a row that would have become invalid due to the deletion operation.
 void deleteRow(int pos)
          Deletes the row at the specified position.
Note:The row pointer will be left untouched unless it would point to a row that would have become invalid due to deletion.
 void firstRow()
          Moves the row pointer to the first row.
 int getNumColumns()
          Returns the number of columns in the table This is just a convenience function and returns the same value as getFieldCount().
 int getNumRows()
          Returns the number of rows
 int getRow()
          Returns the current row number.
 void insertRow(int pos)
          Inserts a new empty row before the specified position
 boolean isEmpty()
          Checks whether the table is empty.
 boolean isFirstRow()
          Retrieves whether the row pointer is on the first row of this table.
 boolean isLastRow()
          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 previousRow()
          Moves the row pointer to the previous row.
 void setRow(int pos)
          Sets the row pointer to the specified position.
 void trimToRows()
          Trims the capacity of this table to be the table's current number of rows.
 
Methods inherited from class com.sap.mw.jco.JCO.Record
addInfo, clone, equals, fields, fromXML, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBinaryStream, getBinaryStream, getByteArray, getByteArray, getChar, getChar, getCharacterStream, getCharacterStream, getClassNameOfValue, getClassNameOfValue, getDate, getDate, getDouble, getDouble, getField, getField, getInt, getInt, getLong, getLong, getShort, getShort, getString, getString, getStructure, getStructure, getTable, getTable, getTime, getTime, getValue, getValue, hashCode, readXML, readXML, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, toString, toXML, toXML, toXML, writeHTML, writeHTML, writeXML, writeXML, writeXML, writeXML
 
Methods inherited from class com.sap.mw.jco.JCO.MetaData
addInfo, addInfo, addInfo, addInfo, addInfo, addInfo, addInfo, getCapacity, getDecimals, getDecimals, getDefault, getDefault, getDescription, getDescription, getExtendedFieldMetaData, getExtendedFieldMetaData, getFieldCount, getFlags, getFlags, getInternalLength, getInternalLength, getLength, getLength, getMetaData, getMetaData, getMetaData, getName, getName, getNumFields, getOffset, getOffset, getTabLength, getTabName, getTabName, getType, getType, getTypeAsString, getTypeAsString, hasField, indexOf, isActive, isActive, isException, isException, isExport, isExport, isImport, isImport, isInitialized, isInitialized, isOptional, isOptional, isStructure, isStructure, isTable, isTable, setExtendedFieldMetaData, setExtendedFieldMetaData, setFlags, setTabLength
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JCO.Table

public JCO.Table(java.lang.String name)
Creates an instance of the table
Parameters:
name - the name of the table

JCO.Table

public JCO.Table(IMetaData meta_data)
Creates an instance of the table with a column layout as specified by the IMetaData argument
Parameters:
meta_data - the layout of the table

JCO.Table

public JCO.Table(JCO.Table value)
Creates an new instance of a table which has the same layout and contents as the table argument
Parameters:
value - the initial value of the table
Method Detail

trimToRows

public 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.

copyFrom

public int copyFrom(JCO.Record source)
Appends the matching fields from the source record at the end of this table Data fields are considered to be equivalent if the name and type of two fields match. The data will be copied and converted as best as can, i.e. strings will be cut off if the source field is longer than the destination field, or they will be filled with spaces if the source is shorter than the destination, etc. If a single conversion fails so will the whole copy operation and the record will be left untouched.
Overrides:
copyFrom in class JCO.Record
Parameters:
source - the source record from which to copy the data
Returns:
the number of matching columns
Throws:
JCO.Exception - if something went wrong

isEmpty

public final boolean isEmpty()
Checks whether the table is empty.
Since:
JCo 2.0

isFirstRow

public final boolean isFirstRow()
Retrieves whether the row pointer is on the first row of this table.
Since:
JCo 2.0

isLastRow

public final boolean isLastRow()
Retrieves whether the row pointer is on the last row of this table.
Since:
JCo 2.0

getNumRows

public final int getNumRows()
Returns the number of rows
Returns:
the number of rows

getNumColumns

public final int getNumColumns()
Returns the number of columns in the table This is just a convenience function and returns the same value as getFieldCount().
Returns:
the number of columns in the table
See Also:
JCO.MetaData.getFieldCount()

clear

public void clear()
Clears the table, i.e. deletes all rows
Overrides:
clear in class JCO.Record
Since:
JCo 2.0

deleteAllRows

public void deleteAllRows()
Deletes all rows of table

firstRow

public final void firstRow()
Moves the row pointer to the first row.

lastRow

public final void lastRow()
Moves the row pointer to the last row.

nextRow

public final 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 at the end of record, true otherwise

previousRow

public final 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 at the beginning of record, true otherwise

getRow

public final 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

public void setRow(int pos)
Sets the row pointer to the specified position. The first row is 0, the second 0, and so on. Most likely to be used to loop through table rows, e.g.

  int num_rows = table.getNumRows();
  for (int irow = 0; i < num_rows; irow++) {
      table.setRow(irow);
      ....
  }
  
Parameters:
row - the row to position to

appendRow

public void appendRow()
Appends a new row at the end of the table and moves the row pointer such that it points to the newly appended row.

appendRows

public void appendRows(int num_rows)
Appends the specified number of empty rows at the end of the table. The row pointer will be positioned at the first newly added row.
Parameters:
num_rows - the number of empty rows to append

insertRow

public void insertRow(int pos)
Inserts a new empty row before the specified position
Parameters:
pos - the index of the row before to insert the new row

deleteRow

public void deleteRow()
Deletes the current row
Note:The row pointer will be left untouched unless it would point to a row that would have become invalid due to the deletion operation. In this case the row pointer will be repositioned to the row at (getNumRows() - 1).

deleteRow

public void deleteRow(int pos)
Deletes the row at the specified position.
Note:The row pointer will be left untouched unless it would point to a row that would have become invalid due to deletion. In this case the row pointer will be repositioned to the row at (getNumRows() - 1).
Parameters:
pos - the index of the row to delete