Package org.pcap4j.packet
Class UnknownPacket
- java.lang.Object
-
- org.pcap4j.packet.AbstractPacket
-
- org.pcap4j.packet.UnknownPacket
-
public final class UnknownPacket extends AbstractPacket
- Since:
- pcap4j 0.9.1
- Author:
- Kaito Yamada
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
UnknownPacket.Builder
-
Nested classes/interfaces inherited from class org.pcap4j.packet.AbstractPacket
AbstractPacket.AbstractBuilder, AbstractPacket.AbstractHeader
-
Nested classes/interfaces inherited from interface org.pcap4j.packet.Packet
Packet.Header
-
-
Method Summary
Modifier and Type Method Description protected java.lang.String
buildString()
This method builds the valuetoString()
will return by concatenating the header's string representation and the payload's string representation.protected int
calcHashCode()
This method calculates the valuehashCode()
will return using the header's hash code and the payload's hash code.boolean
equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one.UnknownPacket.Builder
getBuilder()
Returns a new Builder object populated with this object's fields' values.byte[]
getRawData()
Returns this packet's raw data.int
length()
Returns the packet length in bytes.protected java.lang.String
modifier()
static UnknownPacket
newPacket(byte[] rawData, int offset, int length)
A static factory method.-
Methods inherited from class org.pcap4j.packet.AbstractPacket
buildHexString, buildRawData, calcLength, getHeader, getPayload, hashCode, toHexString, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.pcap4j.packet.Packet
contains, get, getOuterOf, iterator
-
-
-
-
Method Detail
-
newPacket
public static UnknownPacket newPacket(byte[] rawData, int offset, int length)
A static factory method. This method validates the arguments byByteArrays.validateBounds(byte[], int, int)
, which may throw exceptions undocumented here.- Parameters:
rawData
- rawDataoffset
- offsetlength
- length- Returns:
- a new UnknownPacket object.
-
getBuilder
public UnknownPacket.Builder getBuilder()
Description copied from interface:Packet
Returns a new Builder object populated with this object's fields' values.- Specified by:
getBuilder
in interfacePacket
- Specified by:
getBuilder
in classAbstractPacket
- Returns:
- a new Builder object populated with this object's fields values
-
modifier
protected java.lang.String modifier()
-
length
public int length()
Description copied from class:AbstractPacket
Returns the packet length in bytes. This method callscalcLength()
and caches the return value when it is called for the first time, and then, this method returns the cached value from the second time.- Specified by:
length
in interfacePacket
- Overrides:
length
in classAbstractPacket
- Returns:
- the length of the byte stream of the packet represented by this object in bytes
-
getRawData
public byte[] getRawData()
Description copied from class:AbstractPacket
Returns this packet's raw data. This method callsbuildRawData()
and caches the return value when it is called for the first time, and then, this method returns the cached value from the second time. More correctly, this method returns a copy of the cached value, so that the cache can't be changed.- Specified by:
getRawData
in interfacePacket
- Overrides:
getRawData
in classAbstractPacket
- Returns:
- this packet's raw data, namely the byte stream which is actually sent through real network
-
buildString
protected java.lang.String buildString()
Description copied from class:AbstractPacket
This method builds the valuetoString()
will return by concatenating the header's string representation and the payload's string representation. If you write this subclass which represents a packet with extra parts (e.g. a trailer), you need to override this method.- Overrides:
buildString
in classAbstractPacket
- Returns:
- a string representation of this object
-
equals
public boolean equals(java.lang.Object obj)
Description copied from class:AbstractPacket
Indicates whether some other object is "equal to" this one. This method firstly compares this packet's header using the header's equals(Object) method, then compares this packet's payload using the payload's equals(Object) method. If you write this subclass with fields which represent somethings other than header or payload, you need to override this method.- Overrides:
equals
in classAbstractPacket
-
calcHashCode
protected int calcHashCode()
Description copied from class:AbstractPacket
This method calculates the valuehashCode()
will return using the header's hash code and the payload's hash code. If you write this subclass which represents a packet with extra parts (e.g. a trailer), you need to override this method.- Overrides:
calcHashCode
in classAbstractPacket
- Returns:
- a calculated hash code value for the object
-
-