Blackberry JAVA DEVELOPMENT ENVIRONMENT - - CRYPTOGRAPHIC SMART CARD DRIVER - DEVELOPMENT GUIDE Průvodce řešením problémů Strana 81

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 286
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 80
81
4: Managing data
Notify the system when a SyncCollection changes
Task Steps
Use a collection listener to
notify the system when a
SyncCollection changes.
The system invokes CollectionEventSource.addCollectionListener() to create a
CollectionListener for each SyncCollection that the application makes available for wireless
backup.
1. Create a private vector object to store the collection of SyncCollection listeners for the application.
private Vector _listeners;
_listeners = new CloneableVector();
2. Implement the CollectionListener() method, making sure that the method adds a
CollectionListener to the vector object.
public void addCollectionListener(Object listener)
{
_listeners = ListenerUtilities.fastAddListener( _listeners, listener );
}
Remove a collection listener. When the system no longer requires a CollectionListener, it invokes removeCollectionListener.
> Implement the removeCollectionListener()method, using the
ListenerUtilities.removeListener() method to remove a CollectionListener from the
collection of
SyncCollection listeners for the application.
public void removeCollectionListener(Object listener)
{_listeners = ListenerUtilities.removeListener( _listeners, listener );
}
Notify the system when an
element is added to a
SyncCollection.
>Invoke CollectionListener.elementAdded():
for( int i=0; i<_listeners.size(); i++ )
{
CollectionListener cl = (CollectionListener)_listeners.elementAt( i );
cl.elementAdded( this, object );
}
return true;
}
Notify the system when an
element is removed from a
SyncCollection.
>Invoke CollectionListener.elementRemoved().
Notify the system when an
element in a SyncCollection
is replaced.
>Invoke CollectionListener.elementUpdated().
Zobrazit stránku 80
1 2 ... 76 77 78 79 80 81 82 83 84 85 86 ... 285 286

Komentáře k této Příručce

Žádné komentáře