Class UniqueValue


  • class UniqueValue
    extends java.lang.Object
    This is a utility class that generates unique values. The generated String contains only US-ASCII characters and hence is safe for use in RFC822 headers.

    This is a package private class.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.concurrent.atomic.AtomicInteger id
      A global unique number, to ensure uniqueness of generated strings.
    • Constructor Summary

      Constructors 
      Constructor Description
      UniqueValue()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getUniqueBoundaryValue()
      Get a unique value for use in a multipart boundary string.
      static java.lang.String getUniqueMessageIDValue​(Session ssn)
      Get a unique value for use in a Message-ID.
      • Methods inherited from class java.lang.Object

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

      • id

        private static java.util.concurrent.atomic.AtomicInteger id
        A global unique number, to ensure uniqueness of generated strings.
    • Constructor Detail

      • UniqueValue

        UniqueValue()
    • Method Detail

      • getUniqueBoundaryValue

        public static java.lang.String getUniqueBoundaryValue()
        Get a unique value for use in a multipart boundary string. This implementation generates it by concatenating a global part number, a newly created object's hashCode(), and the current time (in milliseconds).
      • getUniqueMessageIDValue

        public static java.lang.String getUniqueMessageIDValue​(Session ssn)
        Get a unique value for use in a Message-ID. This implementation generates it by concatenating a newly created object's hashCode(), a global ID (incremented on every use), the current time (in milliseconds), and the host name from this user's local address generated by InternetAddress.getLocalAddress(). (The host name defaults to "localhost" if getLocalAddress() returns null.)
        Parameters:
        ssn - Session object used to get the local address
        See Also:
        InternetAddress