Class Utils


  • final class Utils
    extends java.lang.Object
    A set of utility methods.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static byte[] BYTE_ZEROES  
      private static int[] INT_ZEROES  
    • Constructor Summary

      Constructors 
      Constructor Description
      Utils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static java.nio.ByteBuffer asReadOnlyBuffer​(java.nio.ByteBuffer src)  
      (package private) static void closeInput​(java.io.InputStream src)  
      (package private) static void copyBytes​(byte[] dst, int target, byte[] src, int start, int end)  
      (package private) static void copyBytesWithin​(byte[] bytes, int target, int start, int end)  
      (package private) static void fillBytesWithZeroes​(byte[] dest, int start, int end)
      Fills byte array with zeroes.
      (package private) static void fillIntsWithZeroes​(int[] dest, int start, int end)
      Fills int array with zeroes.
      (package private) static void flipBuffer​(java.nio.Buffer buffer)  
      (package private) static int getLogBintness()  
      (package private) static int isDebugMode()  
      (package private) static int isDirect​(java.nio.ByteBuffer src)  
      (package private) static int isReadOnly​(java.nio.ByteBuffer src)  
      (package private) static int readInput​(java.io.InputStream src, byte[] dst, int offset, int length)  
      (package private) static byte[] toUsAsciiBytes​(java.lang.String src)  
      • Methods inherited from class java.lang.Object

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

      • BYTE_ZEROES

        private static final byte[] BYTE_ZEROES
      • INT_ZEROES

        private static final int[] INT_ZEROES
    • Constructor Detail

      • Utils

        Utils()
    • Method Detail

      • fillBytesWithZeroes

        static void fillBytesWithZeroes​(byte[] dest,
                                        int start,
                                        int end)
        Fills byte array with zeroes.

        Current implementation uses System.arraycopy(java.lang.Object, int, java.lang.Object, int, int), so it should be used for length not less than 16.

        Parameters:
        dest - array to fill with zeroes
        offset - the first byte to fill
        length - number of bytes to change
      • fillIntsWithZeroes

        static void fillIntsWithZeroes​(int[] dest,
                                       int start,
                                       int end)
        Fills int array with zeroes.

        Current implementation uses System.arraycopy(java.lang.Object, int, java.lang.Object, int, int), so it should be used for length not less than 16.

        Parameters:
        dest - array to fill with zeroes
        offset - the first item to fill
        length - number of item to change
      • copyBytes

        static void copyBytes​(byte[] dst,
                              int target,
                              byte[] src,
                              int start,
                              int end)
      • copyBytesWithin

        static void copyBytesWithin​(byte[] bytes,
                                    int target,
                                    int start,
                                    int end)
      • readInput

        static int readInput​(java.io.InputStream src,
                             byte[] dst,
                             int offset,
                             int length)
      • closeInput

        static void closeInput​(java.io.InputStream src)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • toUsAsciiBytes

        static byte[] toUsAsciiBytes​(java.lang.String src)
      • asReadOnlyBuffer

        static java.nio.ByteBuffer asReadOnlyBuffer​(java.nio.ByteBuffer src)
      • isReadOnly

        static int isReadOnly​(java.nio.ByteBuffer src)
      • isDirect

        static int isDirect​(java.nio.ByteBuffer src)
      • flipBuffer

        static void flipBuffer​(java.nio.Buffer buffer)
      • isDebugMode

        static int isDebugMode()
      • getLogBintness

        static int getLogBintness()