Class ExchangeCodec


  • public abstract class ExchangeCodec
    extends java.lang.Object
    Utility class provides methods to convert exchange code from string to long and vice versa.

    Methods are thread-safe and longToCode(long) caches strings internally to optimise string allocations. From the other side, synchronized methods may be too slow for scenarios, when they are used frequently. Consider using of AlphanumericCodec instance in this case.

    If you not sure a name is less or equal to 10 characters and all of the characters are uppercase, use codeToLongSafely(java.lang.String). It truncates the name if its length is more than 10 characters and converts the name to uppercase. For example, the name "GoldmanSachs" will be converted to "GOLDMANSAC" before encoded.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int MAX_LEN  
      static long NULL  
    • Constructor Summary

      Constructors 
      Constructor Description
      ExchangeCodec()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static long codeToLong​(java.lang.CharSequence code)  
      static long codeToLong​(java.lang.String code)  
      static long codeToLongSafely​(java.lang.CharSequence code)  
      static long codeToLongSafely​(java.lang.String code)  
      static java.lang.String longToCode​(long n)  
      • Methods inherited from class java.lang.Object

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

      • ExchangeCodec

        public ExchangeCodec()
    • Method Detail

      • longToCode

        public static java.lang.String longToCode​(long n)
      • codeToLong

        public static long codeToLong​(java.lang.String code)
      • codeToLong

        public static long codeToLong​(java.lang.CharSequence code)
      • codeToLongSafely

        public static long codeToLongSafely​(java.lang.String code)
      • codeToLongSafely

        public static long codeToLongSafely​(java.lang.CharSequence code)