パッケージ org.pcap4j.packet

クラス AbstractPacket

    • コンストラクタの詳細

      • AbstractPacket

        public AbstractPacket()
    • メソッドの詳細

      • getHeader

        public Packet.Header getHeader()
        Returns the Header object representing this packet's header. This subclass have to override this method if the packet represented by the subclass has a header.
        定義:
        getHeader インタフェース内 Packet
        戻り値:
        the Header object representing this packet's header. May be null if the header doesn't exist
      • getPayload

        public Packet getPayload()
        Returns the Packet object representing this packet's payload. This subclass have to override this method if the packet represented by the subclass has a payload.
        定義:
        getPayload インタフェース内 Packet
        戻り値:
        the Packet object representing this packet's payload. May be null if the payload doesn't exist
      • calcLength

        protected int calcLength()
        This method calculates the value length() will return by adding up the header length and the payload length. If you write this subclass which represents a packet with extra parts (e.g. a trailer), you need to override this method.
        戻り値:
        a calculated length
      • length

        public int length()
        Returns the packet length in bytes. This method calls calcLength() 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.
        定義:
        length インタフェース内 Packet
        戻り値:
        the length of the byte stream of the packet represented by this object in bytes
      • buildRawData

        protected byte[] buildRawData()
        This method builds the value getRawData() will return by concatenating the header's raw data and the payload's raw data. If you write this subclass which represents a packet with extra parts (e.g. a trailer), you need to override this method.
        戻り値:
        a raw data built
      • getRawData

        public byte[] getRawData()
        Returns this packet's raw data. This method calls buildRawData() 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.
        定義:
        getRawData インタフェース内 Packet
        戻り値:
        this packet's raw data, namely the byte stream which is actually sent through real network
      • get

        public <T extends Packet> T get​(Class<T> clazz)
        インタフェースからコピーされた説明: Packet
        Traverses this packet and its payload to find an object of the specified packet class and returns the object. If there are more than one objects of the specified class in this object, this method returns the most outer one of them.
        定義:
        get インタフェース内 Packet
        型パラメータ:
        T - packet
        パラメータ:
        clazz - the packet class of the object to get
        戻り値:
        a packet object if found; otherwise null
      • getOuterOf

        public Packet getOuterOf​(Class<? extends Packet> clazz)
        インタフェースからコピーされた説明: Packet
        Returns the outer packet object of a packet object get(clazz) returns.
        定義:
        getOuterOf インタフェース内 Packet
        パラメータ:
        clazz - the packet class of the object whose outer packet object is what you want to get
        戻り値:
        a packet object if found; otherwise null
      • contains

        public <T extends Packet> boolean contains​(Class<T> clazz)
        インタフェースからコピーされた説明: Packet
        Returns true if this packet is or its payload includes an object of specified packet class; false otherwise.
        定義:
        contains インタフェース内 Packet
        型パラメータ:
        T - packet
        パラメータ:
        clazz - the packet class of the object to search for
        戻り値:
        true if this packet is or its payload includes an object of specified packet class; false otherwise
      • getBuilder

        public abstract Packet.Builder getBuilder()
        インタフェースからコピーされた説明: Packet
        Returns a new Builder object populated with this object's fields' values.
        定義:
        getBuilder インタフェース内 Packet
        戻り値:
        a new Builder object populated with this object's fields values
      • buildHexString

        protected String buildHexString()
        This method builds the value toHexString() will return using the return value of getRawData(). Each octet in this return value is separated by a white space. (e.g. 00 01 02 03 aa bb cc)
        戻り値:
        a hex string representation of this object
      • toHexString

        public String toHexString()
        Returns the hex string representation of this object. This method calls buildHexString() 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.
        戻り値:
        a hex string representation of this object
      • buildString

        protected String buildString()
        This method builds the value toString() 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.
        戻り値:
        a string representation of this object
      • toString

        public String toString()
        Returns a string representation of the object. This method calls buildString() 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.
        オーバーライド:
        toString クラス内 Object
      • equals

        public boolean equals​(Object obj)
        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.
        オーバーライド:
        equals クラス内 Object
      • calcHashCode

        protected int calcHashCode()
        This method calculates the value hashCode() 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.
        戻り値:
        a calculated hash code value for the object
      • hashCode

        public int hashCode()
        Returns a hash code value for the object. This method calls calcHashCode() 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.
        オーバーライド:
        hashCode クラス内 Object