com.ardikars.jxpacket.common.util.PacketIterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jxpacket-common Show documentation
Show all versions of jxpacket-common Show documentation
Jxpacket is a network packet crafting library for java.
/**
* Copyright (C) 2017-2018 Ardika Rommy Sanjaya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package com.ardikars.jxpacket.common.util;
import com.ardikars.jxpacket.common.Packet;
import java.util.Iterator;
import java.util.NoSuchElementException;
/**
* A {@link Packet} iterator implementation.
*/
public 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.getPayload();
return previous;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy