All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pcap.codec.PacketIterator Maven / Gradle / Ivy

There is a newer version: 1.5.1
Show newest version
/** This code is licenced under the GPL version 2. */
package pcap.codec;

import java.util.Iterator;
import java.util.NoSuchElementException;
import pcap.common.annotation.Inclubating;

/** @author Ardika Rommy Sanjaya */
@Inclubating
class PacketIterator implements Iterator {

  private Packet next;

  public PacketIterator(final Packet packet) {
    this.next = packet;
  }

  @Override
  public boolean hasNext() {
    return next != null;
  }

  @Override
  public Packet next() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    Packet previous = next;
    next = next.payload();
    return previous;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy