Class SqlJetUtility


  • public final class SqlJetUtility
    extends java.lang.Object
    • Constructor Detail

      • SqlJetUtility

        public SqlJetUtility()
    • Method Detail

      • log

        public static void log​(java.util.logging.Logger logger,
                               java.lang.String format,
                               java.lang.Object... args)
        Parameters:
        logger -
        format -
        args -
      • wrapPtr

        public static final ISqlJetMemoryPointer wrapPtr​(byte[] bs)
        Parameters:
        bs -
        Returns:
      • getSysProp

        public static java.lang.String getSysProp​(java.lang.String propName,
                                                  java.lang.String defValue)
                                           throws SqlJetError
        Throws:
        SqlJetError
      • getIntSysProp

        public static int getIntSysProp​(java.lang.String propName,
                                        int defValue)
                                 throws SqlJetError
        Throws:
        SqlJetError
      • getBoolSysProp

        public static boolean getBoolSysProp​(java.lang.String propName,
                                             boolean defValue)
        Parameters:
        string -
        b -
        Returns:
      • getEnumSysProp

        public static <T extends java.lang.Enum<T>> T getEnumSysProp​(java.lang.String propName,
                                                                     T defValue)
        Type Parameters:
        T -
        Parameters:
        propName -
        defValue -
        Returns:
      • get2byte

        public static final int get2byte​(ISqlJetMemoryPointer x)
        Read a two-byte big-endian integer values.
      • get2byte

        public static final int get2byte​(ISqlJetMemoryPointer x,
                                         int off)
        Read a two-byte big-endian integer values.
      • put2byte

        public static final void put2byte​(ISqlJetMemoryPointer p,
                                          int v)
        Write a two-byte big-endian integer values.
      • put2byte

        public static final void put2byte​(ISqlJetMemoryPointer p,
                                          int off,
                                          int v)
        Write a two-byte big-endian integer values.
      • put4byte

        public static final ISqlJetMemoryPointer put4byte​(int v)
        Write a four-byte big-endian integer value.
      • get4byte

        public static final int get4byte​(ISqlJetMemoryPointer p)
        Read a four-byte big-endian integer value.
      • get4byte

        public static final int get4byte​(ISqlJetMemoryPointer p,
                                         int pos)
        Read a four-byte big-endian integer value.
      • put4byte

        public static final void put4byte​(ISqlJetMemoryPointer p,
                                          int pos,
                                          long v)
        Write a four-byte big-endian integer value.
      • put4byte

        public static final void put4byte​(ISqlJetMemoryPointer p,
                                          long v)
        Write a four-byte big-endian integer value.
      • memcpy

        public static final void memcpy​(byte[] dest,
                                        byte[] src,
                                        int length)
        Parameters:
        dest -
        src -
        length -
      • memcpy

        public static final void memcpy​(byte[] dest,
                                        int dstPos,
                                        byte[] src,
                                        int srcPos,
                                        int length)
      • memset

        public static final void memset​(ISqlJetMemoryPointer data,
                                        int from,
                                        byte value,
                                        int count)
        Parameters:
        data -
        from -
        value -
        count -
      • memset

        public static final void memset​(ISqlJetMemoryPointer data,
                                        byte value,
                                        int count)
        Parameters:
        data -
        value -
        count -
      • memset

        public static final void memset​(ISqlJetMemoryPointer data,
                                        byte value)
        Parameters:
        data -
        value -
      • strlen

        public static int strlen​(byte[] s,
                                 int from)
        Parameters:
        s -
        from -
        Returns:
      • bitSetTest

        public static boolean bitSetTest​(java.util.BitSet bitSet,
                                         int index)
        Check to see if the i-th bit is set. Return true or false. If p is NULL (if the bitmap has not been created) or if i is out of range, then return false.
        Parameters:
        bitSet -
        index -
        Returns:
      • memcmp

        public static final int memcmp​(byte[] a1,
                                       byte[] a2,
                                       int count)
        Parameters:
        magic -
        journalMagic -
        i -
        Returns:
      • memcmp

        public static final int memcmp​(byte[] a1,
                                       int from1,
                                       byte[] a2,
                                       int from2,
                                       int count)
      • addZeroByteEnd

        public static byte[] addZeroByteEnd​(byte[] b)
        Parameters:
        b -
        Returns:
      • getBytes

        public static byte[] getBytes​(java.lang.String string)
        Parameters:
        sqliteFileHeader -
        Returns:
      • putVarint

        public static int putVarint​(ISqlJetMemoryPointer p,
                                    long v)
        Write a 64-bit variable-length integer to memory starting at p[0]. The length of data write will be between 1 and 9 bytes. The number of bytes written is returned. A variable-length integer consists of the lower 7 bits of each byte for all bytes that have the 8th bit set and one byte with the 8th bit clear. Except, if we get to the 9th byte, it stores the full 8 bits and is the last byte.
      • putVarint32

        public static int putVarint32​(ISqlJetMemoryPointer p,
                                      int v)
        This routine is a faster version of sqlite3PutVarint() that only works for 32-bit positive integers and which is optimized for the common case of small integers. A MACRO version, putVarint32, is provided which inlines the single-byte case. All code should use the MACRO version as this function assumes the single-byte case has already been handled.
      • getVarint

        public static byte getVarint​(ISqlJetMemoryPointer p,
                                     long[] v)
        Read a 64-bit variable-length integer from memory starting at p[0]. Return the number of bytes read. The value is stored in *v.
      • getVarint32

        public static byte getVarint32​(ISqlJetMemoryPointer p,
                                       int[] v)
        Read a 32-bit variable-length integer from memory starting at p[0]. Return the number of bytes read. The value is stored in *v. A MACRO version, getVarint32, is provided which inlines the single-byte case. All code should use the MACRO version as this function assumes the single-byte case has already been handled.
        Throws:
        SqlJetExceptionRemove
      • sqlite3VarintLen

        public static int sqlite3VarintLen​(long v)
        Return the number of bytes that will be needed to store the given 64-bit integer.
      • mutex_held

        public static final boolean mutex_held​(ISqlJetMutex mutex)
        Parameters:
        mutex -
        Returns:
      • strlen30

        public static int strlen30​(ISqlJetMemoryPointer z)
        Compute a string length that is limited to what can be stored in lower 30 bits of a 32-bit signed integer.
        Parameters:
        z -
        Returns:
      • getUnsignedByte

        public static final int getUnsignedByte​(ISqlJetMemoryPointer byteBuffer,
                                                int index)
        Get unsigned byte from byte buffer
        Parameters:
        byteBuffer -
        index -
        Returns:
      • putUnsignedByte

        public static final ISqlJetMemoryPointer putUnsignedByte​(ISqlJetMemoryPointer byteBuffer,
                                                                 int index,
                                                                 int value)
        Put unsigned byte to byte buffer
        Parameters:
        byteBuffer -
        index -
        value -
        Returns:
      • toString

        public static java.lang.String toString​(ISqlJetMemoryPointer buf)
        Convert byte buffer to string.
        Parameters:
        buf -
        Returns:
      • trim

        public static final java.lang.String trim​(java.lang.String s)
        Parameters:
        s -
        Returns:
      • varintLen

        public static int varintLen​(long v)
        Return the number of bytes that will be needed to store the given 64-bit integer.
      • toUnsigned

        public static final short toUnsigned​(byte value)
      • fromUnsigned

        public static final byte fromUnsigned​(short value)
      • toUnsigned

        public static final int toUnsigned​(short value)
      • fromUnsigned

        public static final short fromUnsigned​(int value)
      • toUnsigned

        public static long toUnsigned​(int value)
      • fromUnsigned

        public static final int fromUnsigned​(long value)
      • get4byteUnsigned

        public static final long get4byteUnsigned​(byte[] p)
        Read a four-byte big-endian integer value.
      • get4byteUnsigned

        public static final long get4byteUnsigned​(byte[] p,
                                                  int pos)
        Read a four-byte big-endian integer value.
      • put4byteUnsigned

        public static final ISqlJetMemoryPointer put4byteUnsigned​(long v)
        Write a four-byte big-endian integer value.
      • put4byteUnsigned

        public static final void put4byteUnsigned​(byte[] p,
                                                  int pos,
                                                  long v)
        Write a four-byte big-endian integer value.
      • get4byteUnsigned

        public static final long get4byteUnsigned​(ISqlJetMemoryPointer p)
        Read a four-byte big-endian integer value.
      • get4byteUnsigned

        public static final long get4byteUnsigned​(ISqlJetMemoryPointer p,
                                                  int pos)
        Read a four-byte big-endian integer value.
      • put4byteUnsigned

        public static final void put4byteUnsigned​(ISqlJetMemoryPointer p,
                                                  int pos,
                                                  long v)
        Write a four-byte big-endian integer value.
      • put4byteUnsigned

        public static final void put4byteUnsigned​(ISqlJetMemoryPointer p,
                                                  long v)
        Write a four-byte big-endian integer value.
      • atoi64

        public static final java.lang.Long atoi64​(java.lang.String str)
        Parameters:
        str -
        Returns:
      • absolute

        public static final long absolute​(long i)
        Returns absolute value of argument
        Parameters:
        i -
        Returns:
      • addArrays

        public static final java.lang.Object[] addArrays​(java.lang.Object[] array1,
                                                         java.lang.Object[] array2)
        Parameters:
        key -
        dataRowId -
        Returns:
      • insertArray

        public static final java.lang.Object[] insertArray​(java.lang.Object[] intoArray,
                                                           java.lang.Object[] insertArray,
                                                           int pos)
      • of

        public static final <E extends java.lang.Enum<E>> java.util.EnumSet<E> of​(E e1,
                                                                                  E... e)
      • of

        public static final <E extends java.lang.Enum<E>> java.util.EnumSet<E> of​(E e)
      • of

        public static final <E extends java.lang.Enum<E>> java.util.EnumSet<E> of​(E e1,
                                                                                  E e2)
      • of

        public static final <E extends java.lang.Enum<E>> java.util.EnumSet<E> of​(E e1,
                                                                                  E e2,
                                                                                  E e3)
      • noneOf

        public static final <E extends java.lang.Enum<E>> java.util.EnumSet<E> noneOf​(java.lang.Class<E> elementType)
      • adjustNumberTypes

        public static final java.lang.Object[] adjustNumberTypes​(java.lang.Object[] key)
        Parameters:
        key -
        Returns:
      • adjustNumberType

        public static final java.lang.Object adjustNumberType​(java.lang.Object value)
      • readByteBuffer

        public static byte[] readByteBuffer​(ISqlJetMemoryPointer buffer)
        Parameters:
        buffer -
        Returns:
      • copyArray

        public static java.lang.Object[] copyArray​(java.lang.Object[] array)
        Parameters:
        firstKey -
        Returns:
      • isNumber

        public static boolean isNumber​(java.lang.String s,
                                       boolean[] realnum)
        Return TRUE if z is a pure numeric string. Return FALSE and leave realnum unchanged if the string contains any character which is not part of a number. If the string is pure numeric, set realnum to TRUE if the string contains the '.' character or an "E+000" style exponentiation suffix. Otherwise set realnum to FALSE. Note that just becaue realnum is false does not mean that the number can be successfully converted into an integer - it might be too big. An empty string is considered non-numeric.
        Parameters:
        s -
        realnum -
        Returns:
      • doubleToInt64

        public static java.lang.Long doubleToInt64​(java.lang.Double r)
        Parameters:
        r -
        Returns:
      • fromByteBuffer

        public static ISqlJetMemoryPointer fromByteBuffer​(java.nio.ByteBuffer b)
        Parameters:
        value -
        Returns: