com.sap.mw.jco

Class JCO.Table

java.lang.Object
  extended bycom.sap.mw.jco.JCO.MetaData
      extended bycom.sap.mw.jco.JCO.Record
          extended bycom.sap.mw.jco.JCO.Table
All Implemented Interfaces:
Cloneable, IMetaData, Serializable
Enclosing class:
JCO

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

Class that encapsulates a database table

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class com.sap.mw.jco.JCO.Record
JCO.Record.Type1Record, JCO.Record.XMLReader, JCO.Record.XMLWriter
 
Nested classes inherited from class com.sap.mw.jco.JCO.MetaData
JCO.MetaData.Type1Data
 
Field Summary
protected static byte OP_APPEND
           
protected static byte OP_CLEAR
           
protected static byte OP_DELETE
           
protected static byte OP_INSERT
           
protected static byte OP_NOOP
           
protected static int OP_OPCODE_MASK
           
protected static int OP_SHIFT
           
protected static byte OP_UPDATE
           
protected static int OP_VALUE_MASK
           
 
Fields inherited from class com.sap.mw.jco.JCO.Record
data, delta, modified, num_rows, odata, opcode, PARAMETER, rec_type, REQUEST, RESPONSE, row, row_length, SEGMENT, STRUCTURE, TABLE, type1_record
 
Fields inherited from class com.sap.mw.jco.JCO.MetaData
blength, boffset, decimals, defaults, description, extended_field_meta_data, flags, hash_of_indices, last_active_timestamp, length, name, num_fields, num_odata, offset, oindex, PRINT_HEADER_ALL, PRINT_HEADER_DECIMALS, PRINT_HEADER_DEFAULT, PRINT_HEADER_INTERNAL_LENGTH, PRINT_HEADER_INTERNAL_OFFSET, PRINT_HEADER_LENGTH, PRINT_HEADER_NAME, PRINT_HEADER_OFFSET, PRINT_HEADER_TYPE, rec_name, tab_length, tab_meta, type, type_handle, type_name, type1_data, unicode_type
 
Fields inherited from interface com.sap.mw.jco.IMetaData
EXPORT_PARAMETER, IMPORT_PARAMETER, INACTIVE_PARAMETER, NESTED_TYPE1_STRUCTURE, 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
protected JCO.Table(JCO.Structure value)
          Creates an new instance of a table which has the same layout as the structure 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(String name)
          Creates an instance of the table
 
Method Summary
 void addInfo(String name, int type, int length, int offset, int decimals, String sdefault, String description, int flags, Object tab_meta, com.sap.mw.jco.IExtendedFieldMetaData extended)
          Adds a new field descriptor to the meta data object.
protected  void appendDelta(byte opcode, int opvalue)
          Appends an opcode for delta management
 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
protected  void copyContent(JCO.Record rsrc, JCO.Record rdest)
          Deprecated. Only for internal use. This method can be removed or modified without notice.
 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.
protected  void copyRaw(JCO.Structure src)
          Deprecated. Only for internal use. This method can be removed or modified without notice.
protected static void copyRaw(JCO.Structure src, JCO.Table dest)
          Deprecated. Only for internal use. This method can be removed or modified without notice.
protected static void copyRaw(JCO.Table src, int srcrow, JCO.Table dest, int destrow)
          Deprecated. Only for internal use. This method can be removed or modified without notice.
 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.
 void ensureBufferCapacity(int required_rows)
          Checks the size of the buffer and allocates new memory if necessary and initialize the rows.
 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.
protected  void setModified(int row)
          Sets the updated flag for the current 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
checkIfInitialized, checkRowCapacity, clone, createConversionException, createConversionException, encodeGENERIC, ensureBufferCapacity, equals, fields, finalize, fromXML, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBinaryStream, getBinaryStream, getByte, getByte, getByteArray, getByteArray, getChar, getChar, getCharacterStream, getCharacterStream, getCharArray, getCharArray, getClassNameOfValue, getClassNameOfValue, getDataBuffer, getDataBufferOffset, getDataBufferRowLength, getDate, getDate, getDouble, getDouble, getField, getField, getFloat, getFloat, getHTMLString, getInt, getInt, getLong, getLong, getShort, getShort, getString, getString, getStructure, getStructure, getTable, getTable, getTime, getTime, getValue, getValue, hashCode, initializeRow, internalSize, printHTML, printHTML, printHTML, readXML, readXML, setDefault, 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, 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, copy, getCapacity, getDataBufferLength, getDecimals, getDecimals, getDefault, getDefault, getDescription, getDescription, getExtendedFieldMetaData, getExtendedFieldMetaData, getFieldCount, getFlags, getFlags, getInternalLength, getInternalLength, getLength, getLength, getLineTypeName, getMetaData, getMetaData, getMetaData, getName, getName, getNumFields, getObjectId, getOffset, getOffset, getTabLength, getTabName, getTabName, getType, getType, getTypeAsString, getTypeAsString, getUnicodeType, getUnicodeTypeAsString, hasField, indexOf, isActive, isActive, isException, isException, isExport, isExport, isImport, isImport, isInitialized, isInitialized, isNestedType1Structure, isNestedType1Structure, isNestedType1Structure, isOptional, isOptional, isStructure, isStructure, isTable, isTable, printHTML, printHTML, setDataBufferLength, setDataBufferOffset, setExtendedFieldMetaData, setExtendedFieldMetaData, setFlags, setName, setNestedType1Structure, setTabLength, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

OP_NOOP

protected static final byte OP_NOOP
See Also:
Constant Field Values

OP_APPEND

protected static final byte OP_APPEND
See Also:
Constant Field Values

OP_INSERT

protected static final byte OP_INSERT
See Also:
Constant Field Values

OP_DELETE

protected static final byte OP_DELETE
See Also:
Constant Field Values

OP_UPDATE

protected static final byte OP_UPDATE
See Also:
Constant Field Values

OP_CLEAR

protected static final byte OP_CLEAR
See Also:
Constant Field Values

OP_SHIFT

protected static final int OP_SHIFT
See Also:
Constant Field Values

OP_OPCODE_MASK

protected static final int OP_OPCODE_MASK
See Also:
Constant Field Values

OP_VALUE_MASK

protected static final int OP_VALUE_MASK
See Also:
Constant Field Values
Constructor Detail

JCO.Table

public JCO.Table(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

JCO.Table

protected JCO.Table(JCO.Structure value)
Creates an new instance of a table which has the same layout as the structure argument. In addition the first row of the table will be filled with the contents of the structure.

Parameters:
value - the initial value of the table
Method Detail

copyContent

protected void copyContent(JCO.Record rsrc,
                           JCO.Record rdest)
Deprecated. Only for internal use. This method can be removed or modified without notice.

Copies the data from src to dest table

Overrides:
copyContent in class JCO.Record
Parameters:
rsrc - the source record

copyRaw

protected static void copyRaw(JCO.Structure src,
                              JCO.Table dest)
Deprecated. Only for internal use. This method can be removed or modified without notice.

Copies the data from the source structure directly into the current row of the specified destination table. Warning No checks whatsoever are made.

Parameters:
src - the JCO.Structure whose content will be copied into the current row of the destination table

copyRaw

protected static void copyRaw(JCO.Table src,
                              int srcrow,
                              JCO.Table dest,
                              int destrow)
Deprecated. Only for internal use. This method can be removed or modified without notice.

Copies the data from the source table row directly into the given row of the specified destination table. Warning No checks whatsoever are made.

Parameters:
src - the JCO.Table whose content will be copied into the current row of the destination table

copyRaw

protected void copyRaw(JCO.Structure src)
Deprecated. Only for internal use. This method can be removed or modified without notice.

Copies the data from the structure directly in to the current row. Warning No checks whatsoever are made.

Parameters:
src - the JCO.Structure whose content will be copied into the current row

addInfo

public void addInfo(String name,
                    int type,
                    int length,
                    int offset,
                    int decimals,
                    String sdefault,
                    String description,
                    int flags,
                    Object tab_meta,
                    com.sap.mw.jco.IExtendedFieldMetaData extended)
Adds a new field descriptor to the meta data object. Only allowed, if the table is empty. Otherwise an exception (group JCO_ERROR_NOT_SUPPORTED) will be thrown.
Generally, it is better to create first a metadata object and then the table
IMetaData tableMD = new JCO.MetaData("table name"); tableMD.addInfo(...); ... tableMD.addInfo(...); JCO.Table table = new JCO.Table(tableMD); It is possible to create more than one table instances from one metadata object.

Specified by:
addInfo in interface IMetaData
Overrides:
addInfo in class JCO.Record
Parameters:
name - Field name for identifying this data field
type - Data field type
length - Data field internal length in bytes
offset - Data field offset in the internal JCO data buffer (with -1 JCo compute the offset automatically)
decimals - Data field number of decimals (only necessary for the data types JCO.TYPE_BCD and JCO.TYPE_FLOAT)
sdefault - Data Field default value
description - Description of data field
flags - additional attribute of the field. Has to be 0
tab_meta - Meta-data if the field is a complex field, i.e. structure or table, null otherwise
extended - extended meta data for this field or null if none available.

ensureBufferCapacity

public void ensureBufferCapacity(int required_rows)
Checks the size of the buffer and allocates new memory if necessary and initialize the rows. Initialize all added rows.


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.


setModified

protected void setModified(int row)
Sets the updated flag for the current row

Overrides:
setModified in class JCO.Record
Parameters:
row - the index of the row that has been modified

appendDelta

protected void appendDelta(byte opcode,
                           int opvalue)
Appends an opcode for delta management

Parameters:
opcode - the opcode for the operation
opvalue - the value for this operation

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.

Returns:
true if the table is empty, false otherwise.
Since:
JCo 2.0

isFirstRow

public final 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.
Since:
JCo 2.0

isLastRow

public final 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.
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:
pos - the position to set the row pointer 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


Copyright 2006 SAP AG Complete Copyright Notice