Class FRAG2.FragEntry

  • Enclosing class:
    FRAG2

    protected static class FRAG2.FragEntry
    extends java.lang.Object
    Class represents an entry for a message. Each entry holds an array of byte arrays sorted once all the byte buffer entries have been filled the fragmentation is considered complete.
    All methods are unsynchronized, use getLock() to obtain a lock for concurrent access.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.concurrent.locks.Lock lock  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected FragEntry​(int tot_frags)
      Creates a new entry
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected Message assembleMessage()
      Assembles all the fragments into one buffer.
      boolean isComplete()
      returns true if this fragmentation is complete ie, all fragmentations have been received for this buffer
      void lock()
      Use to synchronize on FragEntry
      void set​(int frag_id, Message frag)
      adds on fragmentation buffer to the message
      java.lang.String toString()  
      void unlock()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • lock

        protected final java.util.concurrent.locks.Lock lock
    • Constructor Detail

      • FragEntry

        protected FragEntry​(int tot_frags)
        Creates a new entry
        Parameters:
        tot_frags - the number of fragments to expect for this message
    • Method Detail

      • lock

        public void lock()
        Use to synchronize on FragEntry
      • unlock

        public void unlock()
      • set

        public void set​(int frag_id,
                        Message frag)
        adds on fragmentation buffer to the message
        Parameters:
        frag_id - the number of the fragment being added 0..(tot_num_of_frags - 1)
        frag - the byte buffer containing the data for this fragmentation, should not be null
      • isComplete

        public boolean isComplete()
        returns true if this fragmentation is complete ie, all fragmentations have been received for this buffer
      • assembleMessage

        protected Message assembleMessage()
        Assembles all the fragments into one buffer. Takes all Messages, and combines their buffers into one buffer. This method does not check if the fragmentation is complete (use isComplete() to verify before calling this method)
        Returns:
        the complete message in one buffer
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object