Class Misc


  • class Misc
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.security.SecureRandom sRandom  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Misc()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String extractHost​(java.net.URI uri)  
      (package private) static java.lang.String extractHostFromAuthorityPart​(java.lang.String authority)  
      (package private) static java.lang.String extractHostFromEntireUri​(java.lang.String uri)  
      static byte[] getBytesUTF8​(java.lang.String string)
      Get a UTF-8 byte array representation of the given string.
      static java.lang.reflect.Constructor<?> getConstructor​(java.lang.String className, java.lang.Class<?>[] parameterTypes)  
      static java.lang.reflect.Method getMethod​(java.lang.String className, java.lang.String methodName, java.lang.Class<?>[] parameterTypes)  
      static java.lang.Object invoke​(java.lang.reflect.Method method, java.lang.Object object, java.lang.Object... parameters)  
      private static void join​(java.lang.StringBuilder builder, java.util.Collection<?> values, java.lang.String delimiter)  
      static java.lang.String join​(java.util.Collection<?> values, java.lang.String delimiter)  
      static int max​(int[] values)
      Find the maximum value from the given array.
      static int min​(int[] values)
      Find the minimum value from the given array.
      static java.lang.Object newInstance​(java.lang.reflect.Constructor<?> constructor, java.lang.Object... parameters)  
      static byte[] nextBytes​(byte[] buffer)
      Fill the given buffer with random bytes.
      static byte[] nextBytes​(int nBytes)
      Create a buffer of the given size filled with random bytes.
      static java.lang.String readLine​(java.io.InputStream in, java.lang.String charset)
      Read a line from the given stream.
      static java.lang.String toOpcodeName​(int opcode)
      Convert a WebSocket opcode into a string representation.
      static java.lang.String toStringUTF8​(byte[] bytes)
      Convert a UTF-8 byte array into a string.
      static java.lang.String toStringUTF8​(byte[] bytes, int offset, int length)
      Convert a UTF-8 byte array into a string.
      • Methods inherited from class java.lang.Object

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

      • sRandom

        private static final java.security.SecureRandom sRandom
    • Constructor Detail

      • Misc

        private Misc()
    • Method Detail

      • getBytesUTF8

        public static byte[] getBytesUTF8​(java.lang.String string)
        Get a UTF-8 byte array representation of the given string.
      • toStringUTF8

        public static java.lang.String toStringUTF8​(byte[] bytes)
        Convert a UTF-8 byte array into a string.
      • toStringUTF8

        public static java.lang.String toStringUTF8​(byte[] bytes,
                                                    int offset,
                                                    int length)
        Convert a UTF-8 byte array into a string.
      • nextBytes

        public static byte[] nextBytes​(byte[] buffer)
        Fill the given buffer with random bytes.
      • nextBytes

        public static byte[] nextBytes​(int nBytes)
        Create a buffer of the given size filled with random bytes.
      • toOpcodeName

        public static java.lang.String toOpcodeName​(int opcode)
        Convert a WebSocket opcode into a string representation.
      • readLine

        public static java.lang.String readLine​(java.io.InputStream in,
                                                java.lang.String charset)
                                         throws java.io.IOException
        Read a line from the given stream.
        Throws:
        java.io.IOException
      • min

        public static int min​(int[] values)
        Find the minimum value from the given array.
      • max

        public static int max​(int[] values)
        Find the maximum value from the given array.
      • join

        public static java.lang.String join​(java.util.Collection<?> values,
                                            java.lang.String delimiter)
      • join

        private static void join​(java.lang.StringBuilder builder,
                                 java.util.Collection<?> values,
                                 java.lang.String delimiter)
      • extractHost

        public static java.lang.String extractHost​(java.net.URI uri)
      • extractHostFromAuthorityPart

        static java.lang.String extractHostFromAuthorityPart​(java.lang.String authority)
      • extractHostFromEntireUri

        static java.lang.String extractHostFromEntireUri​(java.lang.String uri)
      • getConstructor

        public static java.lang.reflect.Constructor<?> getConstructor​(java.lang.String className,
                                                                      java.lang.Class<?>[] parameterTypes)
      • newInstance

        public static java.lang.Object newInstance​(java.lang.reflect.Constructor<?> constructor,
                                                   java.lang.Object... parameters)
      • getMethod

        public static java.lang.reflect.Method getMethod​(java.lang.String className,
                                                         java.lang.String methodName,
                                                         java.lang.Class<?>[] parameterTypes)
      • invoke

        public static java.lang.Object invoke​(java.lang.reflect.Method method,
                                              java.lang.Object object,
                                              java.lang.Object... parameters)