public interface PacketFilter
Several simple filters are pre-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 (real code should use PacketIDFilter instead).
// 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,
PacketListenerboolean accept(Packet packet)
packet - the packet to test.