- java.lang.Object
-
- org.pcap4j.packet.AbstractPacket
-
- org.pcap4j.packet.SimplePacket
-
- Direct Known Subclasses:
CompressedPacket,EncryptedPacket,FragmentedPacket,UnknownPacket
abstract class SimplePacket extends AbstractPacket
- Since:
- pcap4j 1.4.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSimplePacket.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
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]rawDataprivate static longserialVersionUID
-
Constructor Summary
Constructors Modifier Constructor Description protectedSimplePacket(byte[] rawData, int offset, int length)protectedSimplePacket(SimplePacket.Builder builder)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringbuildString()This method builds the valuetoString()will return by concatenating the header's string representation and the payload's string representation.protected intcalcHashCode()This method calculates the valuehashCode()will return using the header's hash code and the payload's hash code.booleanequals(java.lang.Object obj)Indicates whether some other object is "equal to" this one.byte[]getRawData()Returns this packet's raw data.intlength()Returns the packet length in bytes.protected abstract java.lang.Stringmodifier()-
Methods inherited from class org.pcap4j.packet.AbstractPacket
buildHexString, buildRawData, calcLength, contains, get, getBuilder, getHeader, getOuterOf, getPayload, hashCode, iterator, toHexString, toString
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
rawData
private final byte[] rawData
-
-
Constructor Detail
-
SimplePacket
protected SimplePacket(byte[] rawData, int offset, int length)
-
SimplePacket
protected SimplePacket(SimplePacket.Builder builder)
-
-
Method Detail
-
length
public int length()
Description copied from class:AbstractPacketReturns 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:
lengthin interfacePacket- Overrides:
lengthin 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:AbstractPacketReturns 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:
getRawDatain interfacePacket- Overrides:
getRawDatain 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:AbstractPacketThis 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:
buildStringin classAbstractPacket- Returns:
- a string representation of this object
-
modifier
protected abstract java.lang.String modifier()
-
equals
public boolean equals(java.lang.Object obj)
Description copied from class:AbstractPacketIndicates 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:
equalsin classAbstractPacket
-
calcHashCode
protected int calcHashCode()
Description copied from class:AbstractPacketThis 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:
calcHashCodein classAbstractPacket- Returns:
- a calculated hash code value for the object
-
-