public class NotificationBuffer extends java.lang.Object implements Notifiable
Example:
Siena siena;
Filter f;
// ...
// siena = new ...
// f = new Filter();
// f.addConstraint ...
// ...
NotificationBuffer queue = new NotificationBuffer();
siena.subscribe(f, queue);
Notification n = queue.getNotification(-1); // infinite timeout
System.out.println(n.toString());
Notice that NotificationBuffer
handles notifications and
sequences (of notifications) separately.
Notification
,
Notifiable
Constructor and Description |
---|
NotificationBuffer()
constructs an empty NotificationBuffer with unlimited capacity
this NotificationBuffer will grow dynamically to store any number of
notifications and sequences.
|
NotificationBuffer(int dimension)
constructs an empty NotificationBuffer with limited capacity
this NotificationBuffer will hold up to dimension
notifications and dimension sequences.
|
Modifier and Type | Method and Description |
---|---|
Notification |
getNotification()
attempts to extract a notification (non-blocking)
attempts to extract a notification.
|
Notification |
getNotification(long timeout)
attempts to extract a notification (blocking)
attempts to extract a notification.
|
Notification[] |
getSequence() |
Notification[] |
getSequence(long timeout)
attempts to extract a sequence of notification (non-blocking)
attempts to extract a sequence of notifications.
|
int |
notificationsCount()
number of available notifications
|
void |
notify(Notification n)
sends a
Notification to this Notifable
Since version 1.0.1 of the Siena API it is safe to modify the
Notification object received through this method. |
void |
notify(Notification[] s)
sends a sequence of
Notification s to this
Notifable
Since version 1.0.1 of the Siena API it is safe to modify the
Notification objects received through this method. |
int |
sequencesCount()
the number of available sequences of notifications
|
public NotificationBuffer()
public NotificationBuffer(int dimension)
dimension
- maximum capacity. Must be > 0public int notificationsCount()
public int sequencesCount()
public void notify(Notification n)
Notifiable
Notification
to this Notifable
Since version 1.0.1 of the Siena API it is safe to modify the
Notification object received through this method. Note that:
notify
in interface Notifiable
n
- notification passed to the notifiableSiena.subscribe(Filter,Notifiable)
public void notify(Notification[] s)
Notifiable
Notification
s to this
Notifable
Since version 1.0.1 of the Siena API it is safe to modify the
Notification objects received through this method. Please
read the notes in the above documentation of Notifiable.notify(Notification)
, which apply to this method as well.notify
in interface Notifiable
s
- sequence of notifications passed to the notifiableSiena.subscribe(Pattern,Notifiable)
public Notification getNotification()
null
if none is available.null
public Notification getNotification(long timeout) throws java.lang.InterruptedException
null
in case the timeout expired.null
java.lang.InterruptedException
public Notification[] getSequence() throws java.lang.InterruptedException
java.lang.InterruptedException
public Notification[] getSequence(long timeout) throws java.lang.InterruptedException
null
in case the timeout expired.null
java.lang.InterruptedException
Copyright © 2005-2011 Antonio Carzaniga.
This documentation is maintained by Antonio Carzaniga