com.lightstreamer.javameclient.midp
Class UpdateInfo

java.lang.Object
  extended by com.lightstreamer.javameclient.midp.UpdateInfo

public class UpdateInfo
extends java.lang.Object

Provides information about an update for a subscribed item. The new and previous values for the subscribed fields are reported.
If the table subscription configuration enables the "COMMAND logic", then the old field values are referred to the same key.
Both names and positional information can be used to identify the specific fields, unless a SimpleTableInfo was used to describe the related table; in that case, only positional information can be used.


Method Summary
 java.lang.String getItemName()
          Gets the name of the item involved in the current update, if available.
 int getItemPos()
          Gets positional information for the item involved in the current update.
 java.lang.String getNewValue(int fieldPos)
          Gets the value for a field as it is after the reception of this update.
 java.lang.String getNewValue(java.lang.String fieldName)
          Gets the value for a field as it is after the reception of this update.
 int getNumFields()
          Gets the total number of fields contained in the subscriprion schema.
 java.lang.String getOldValue(int fieldPos)
          Gets the value for a field as it was before the reception of this update.
 java.lang.String getOldValue(java.lang.String fieldName)
          Gets the value for a field as it was before the reception of this update.
 boolean isSnapshot()
          Asks whether the current update pertains to the item snapshot.
 boolean isValueChanged(int fieldPos)
          Asks whether the value for a field has changed after the reception of this update.
 boolean isValueChanged(java.lang.String fieldName)
          Asks whether the value for a field has changed after the reception of this update.
 java.lang.String toString()
          Returns a string representation of the update.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getItemPos

public int getItemPos()
Gets positional information for the item involved in the current update.

Returns:
the 1-based position of the item in the Group of items in the related table.

getItemName

public java.lang.String getItemName()
Gets the name of the item involved in the current update, if available.

Returns:
the item name, or null if a SimpleTableInfo was used to describe the related table.

isValueChanged

public boolean isValueChanged(int fieldPos)
Asks whether the value for a field has changed after the reception of this update. For the first update for the item, it always returns true.
If the "COMMAND logic" behaviour is enabled, then the change is meant as relative to the same key; as a consequence, on ADD commands the method always returns true; moreover, on DELETE commands the method returns true for all fields, but for the "key" field.

Parameters:
fieldPos - the 1-based field position within the Schema of fields in the related table.
Returns:
true iif the updated value is different than the previous one, according to the above specifications.
Throws:
java.lang.IllegalArgumentException - if the specified field position does not represent a subscribed field.

isValueChanged

public boolean isValueChanged(java.lang.String fieldName)
Asks whether the value for a field has changed after the reception of this update. For the first update for the item, it always returns true.
If the "COMMAND logic" behaviour is enabled, then the change is meant as relative to the same key; as a consequence, on ADD commands the method always returns true; moreover, on DELETE commands the method returns true for all fields, but for the "key" field.

Parameters:
fieldName - a field name.
Returns:
true iif the updated value is different than the previous one, according to the above specifications.
Throws:
java.lang.IllegalArgumentException - if the specified field name does not represent a subscribed field; also thrown if a SimpleTableInfo was used to describe the related table.

getNewValue

public java.lang.String getNewValue(int fieldPos)
Gets the value for a field as it is after the reception of this update.
If the "COMMAND logic" behaviour is enabled and the event carries a DELETE command, then all fields, but for the "key" and "command" fields, have a null new value.

Parameters:
fieldPos - a 1-based field position within the Schema of fields in the related table.
Returns:
the field value, according to the above specifications; null is a legal value too.
Throws:
java.lang.IllegalArgumentException - if the specified field position does not represent a subscribed field.

getNewValue

public java.lang.String getNewValue(java.lang.String fieldName)
Gets the value for a field as it is after the reception of this update.
If the "COMMAND logic" behaviour is enabled and the event carries a DELETE command, then all fields, but for the "key" and "command" fields, have a null new value.

Parameters:
fieldName - a field name.
Returns:
the field value, according to the above specifications; null is a legal value too.
Throws:
java.lang.IllegalArgumentException - if the specified field name does not represent a subscribed field; also thrown if a SimpleTableInfo was used to describe the related table.

getOldValue

public java.lang.String getOldValue(int fieldPos)
Gets the value for a field as it was before the reception of this update. If the current update is the first one, then all old values are null.
If the "COMMAND logic" behaviour is enabled, then the value is meant as relative to the same key; as a consequence, on ADD commands all old values are null.

Parameters:
fieldPos - a 1-based field position within the Schema of fields in the related table.
Returns:
the previous field value, according to the above specifications; null is a legal value too.
Throws:
java.lang.IllegalArgumentException - if the specified field position does not represent a subscribed field.

getOldValue

public java.lang.String getOldValue(java.lang.String fieldName)
Gets the value for a field as it was before the reception of this update. If the current update is the first one, then all old values are null.
If the "COMMAND logic" behaviour is enabled, then the value is meant as relative to the same key; as a consequence, on ADD commands all old values are null.

Parameters:
fieldName - a field name.
Returns:
the previous field value, according to the above specifications; null is a legal value too.
Throws:
java.lang.IllegalArgumentException - if the specified field name does not represent a subscribed field; also thrown if a SimpleTableInfo was used to describe the related table.

getNumFields

public int getNumFields()
Gets the total number of fields contained in the subscriprion schema. In case a SimpleTableInfo was used to describe the related table, this number might not be known at subscription time.

Returns:
the number of fields.

isSnapshot

public boolean isSnapshot()
Asks whether the current update pertains to the item snapshot.

Returns:
true iif the update is from the initial snapshot.

toString

public java.lang.String toString()
Returns a string representation of the update. Field values are written in sequence, separated by commas, while field names are not shown. Unchanged fields are written in parenthesis.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the update.