public interface StanzaFilter
Several simple filters are pre-defined. These filters can be logically combined for more complex
stanza filtering by using the AndFilter
and
OrFilter
filters. It's also possible to define
your own filters by implementing this interface. The code example below creates a trivial filter
for stanzas with a specific ID (real code should use StanzaIdFilter
instead).
// Use an anonymous inner class to define a stanza filter that returns // all stanzas that have a stanza ID of "RS145". StanzaFilter myFilter = new StanzaFilter() { public boolean accept(Stanza stanza) { return "RS145".equals(stanza.getStanzaId()); } }; // Create a new stanza collector using the filter we created. StanzaCollector myCollector = connection.createStanzaCollector(myFilter);
StanzaCollector
,
StanzaListener
Modifier and Type | Method and Description |
---|---|
boolean |
accept(Stanza stanza)
Tests whether or not the specified stanza should pass the filter.
|