|
Smack | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface PacketFilter
Defines a way to filter packets for particular attributes. Packet filters are used when constructing packet listeners or collectors -- the filter defines what packets match the criteria of the collector or listener for further packet processing.
Several pre-defined filters are defined. These filters can be logically combined
for more complex packet 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 packets with a specific ID.
// Use an anonymous inner class to define a packet filter that returns // all packets that have a packet ID of "RS145". PacketFilter myFilter = new PacketFilter() { public boolean accept(Packet packet) { return "RS145".equals(packet.getPacketID()); } }; // Create a new packet collector using the filter we created. PacketCollector myCollector = packetReader.createPacketCollector(myFilter);
PacketCollector
,
PacketListener
Method Summary | |
---|---|
boolean |
accept(Packet packet)
Tests whether or not the specified packet should pass the filter. |
Method Detail |
---|
boolean accept(Packet packet)
packet
- the packet to test.
|
Smack | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |