com.sap.ip.me.api.smartsync
Interface Field

All Known Subinterfaces:
CharacterField, DateField, DecimalField, NumericField, TimeField

public interface Field

A Field represents a specific field with its meta info - FieldDescriptor. A Row has an array of Field objects that holds the every values set into it. The Field defines the accessor methods to every field value in a Row as well as some getter methods to the attributes of a Field.

Field object instance can be retrieved from its corresponding Row object, by passing the appropriate FieldDescriptor as the parameter. Field object is bound to an appropriate FieldDescriptor value inside.

Usage Examples:

Getting a Field instance from an existing Row:

   //retrieving a field instance from a Row using the FieldDescriptor
   Field delvDateField = existingRow.getField(delvDateFieldDescriptor);

   //retrieving the Row's key field
   Field keyField = existingRow.getKeyField();
 

Accessing the Field value:

   DateField
   Getting the value of the DateField.
   java.sql.Date fieldValue = delvDateField.getSqlDate();
   Setting a new field value to the date field
   delvDateField.setValue(java.sql.Date.valueOf("2003-11-22"));
   

TimeField Getting the value of the TimeField. java.sql.Time fieldValue = timeDateField.getSqlTime(); Setting a new field value to the Time field timeDateField.setValue(java.sql.Time.valueOf("12:00:00"));

CharacterField Getting the value of the CharacterField. String fieldValue = characterField.getCharacters(); Setting a new field value to the Character field fieldValue.setValue("new Value");

DecimalField Getting the value of the DecimalField. BigDecimal fieldValue = decimalField.getBigDecimal(); Setting a new field value to the Decimal field. fieldValue.setValue(new BigDecimal("123456789"));

NumericField Getting the value of the NumericField. BigInteger fieldValue = NumericField.getBigInteger(); Setting a new field value to the Numeric Field. fieldValue.setValue(new BigInteger("123456789"));

The value can also be retrieved by the getValue method which can be cast to the appropriate object type. java.sql.Date fieldValue = (java.sql.Date)fieldObject.getValue();

Retrieving the other grouped Fields:

   e.g. delvDate and delvTime fields are grouped together in the metadata
   grouptype for date and time is T
   Field[] groupMates = delvDateField.getGroupFields(FieldGroupType.T);
   Field delvTimeField = groupMates[0];

   Or using the specific type
   DateField delvDateField = parentRow.getDateField(delvDateFieldDescriptor);
   TimeField delvTimeField = delvDateField.getPairedTimeField();
 

Field interface (in com.sap.ip.me.api.smartsync) is to be used with either nulls or type-specific initial values, both of which correspond (i.e. are mapped) to the type-specific initial values in ABAP. ME 2.1 supported nulls only, and with 2.5 client applications can use type-specific initial values by switching on the "use initial value" flag in the MCD editor (transaction MI_MSD). When the flag is switched on, the Field interface and its type-specific sub-interfaces will return the following initial values instead of nulls when either no value has been set on newly created SyncBO/Row or when the origin of the data is an ABAP initial value from the backend system:


Note that for type D, the initial value is null regardless of the flag set in the MCD. This means that applications should expect a null to be returned from Fields of type D, and should set nulls when '00000000' needs to be set in the backend system.

Copyright: Copyright (c) 2002

Company: SAP AG

Since:
2.5
Version:
2.5

Method Summary
 FieldDescriptor getFieldDescriptor()
          Returns The FieldDescriptor of the Field object.
 Field[] getGroupFields(FieldGroupType fieldGroupType)
          Returns an array of other Field objects that are in the same specified group type.
 Row getRow()
          Returns the row attribute of the Field object to which this Field instance belongs.
 java.lang.Object getValue()
          Gets the value attribute of the Field object
 void modifyValue(java.lang.Object fieldValue)
          Modifies the field value.
 void setValue(java.lang.Object fieldValue)
          Deprecated. use modifyValue(Object) instead for better performance.
 

Method Detail

getValue

public java.lang.Object getValue()
Gets the value attribute of the Field object

Returns:
The value in the Object format

setValue

public void setValue(java.lang.Object fieldValue)
              throws ModificationNotAllowedException,
                     PersistenceException
Deprecated. use modifyValue(Object) instead for better performance.

Sets the value attribute of the Field object

Parameters:
fieldValue - The new value
Throws:
ModificationNotAllowedException - thrown if the operation is not complying with the rules set in the metadata definition.
PersistenceException - thrown if any persistent layer exception occurred during the retrieval

getRow

public Row getRow()
Returns the row attribute of the Field object to which this Field instance belongs.

Returns:
The row value

getGroupFields

public Field[] getGroupFields(FieldGroupType fieldGroupType)
Returns an array of other Field objects that are in the same specified group type. This Field instance is NOT an element of this array.

Parameters:
fieldGroupType - the type of Field grouping
Returns:
an array of other Field objects that are in the same specified group type; the current Field is NOT an element of the array
See Also:
FieldGroupType

getFieldDescriptor

public FieldDescriptor getFieldDescriptor()
Returns The FieldDescriptor of the Field object.

Returns:
FieldDescriptor of the Field object.
See Also:
FieldDescriptor

modifyValue

public void modifyValue(java.lang.Object fieldValue)
                 throws ModificationNotAllowedException
Modifies the field value. The difference between setValue(Object) and this method is that this method does the modification only transient on this object. To persist the change you need to call SyncBo.modifyRow(Row) with the Row of this Field as parameter.

Parameters:
fieldValue - the new field value
Throws:
ModificationNotAllowedException - if the modification is not allowed
Since:
MI 2.5 SP13


Copyright © 2005 SAP AG. All Rights Reserved.