Package org.h2.value

Class ValueUuid

  • All Implemented Interfaces:
    HasSQL, Typed

    public final class ValueUuid
    extends Value
    Implementation of the UUID data type.
    • Field Detail

      • PRECISION

        static final int PRECISION
        The precision of this value in number of bytes.
        See Also:
        Constant Field Values
      • DISPLAY_SIZE

        static final int DISPLAY_SIZE
        The display size of the textual representation of a UUID. Example: cd38d882-7ada-4589-b5fb-7da0ca559d9a
        See Also:
        Constant Field Values
      • high

        private final long high
      • low

        private final long low
    • Constructor Detail

      • ValueUuid

        private ValueUuid​(long high,
                          long low)
    • Method Detail

      • hashCode

        public int hashCode()
        Specified by:
        hashCode in class Value
      • getNewRandom

        public static ValueUuid getNewRandom()
        Create a new UUID using the pseudo random number generator.
        Returns:
        the new UUID
      • get

        public static ValueUuid get​(byte[] binary)
        Get or create a UUID for the given 16 bytes.
        Parameters:
        binary - the byte array
        Returns:
        the UUID
      • get

        public static ValueUuid get​(long high,
                                    long low)
        Get or create a UUID for the given high and low order values.
        Parameters:
        high - the most significant bits
        low - the least significant bits
        Returns:
        the UUID
      • get

        public static ValueUuid get​(java.util.UUID uuid)
        Get or create a UUID for the given Java UUID.
        Parameters:
        uuid - Java UUID
        Returns:
        the UUID
      • get

        public static ValueUuid get​(java.lang.String s)
        Get or create a UUID for the given text representation.
        Parameters:
        s - the text representation of the UUID
        Returns:
        the UUID
      • getSQL

        public java.lang.StringBuilder getSQL​(java.lang.StringBuilder builder,
                                              int sqlFlags)
        Description copied from interface: HasSQL
        Appends the SQL statement of this object to the specified builder.
        Parameters:
        builder - string builder
        sqlFlags - formatting flags
        Returns:
        the specified string builder
      • getType

        public TypeInfo getType()
        Description copied from interface: Typed
        Returns the data type.
        Specified by:
        getType in interface Typed
        Specified by:
        getType in class Value
        Returns:
        the data type
      • getMemory

        public int getMemory()
        Description copied from class: Value
        Get the memory used by this object.
        Overrides:
        getMemory in class Value
        Returns:
        the memory used in bytes
      • getValueType

        public int getValueType()
        Description copied from class: Value
        Get the value type.
        Specified by:
        getValueType in class Value
        Returns:
        the value type
      • getString

        public java.lang.String getString()
        Description copied from class: Value
        Get the value as a string.
        Specified by:
        getString in class Value
        Returns:
        the string
      • getBytes

        public byte[] getBytes()
        Overrides:
        getBytes in class Value
      • addString

        private java.lang.StringBuilder addString​(java.lang.StringBuilder builder)
      • compareTypeSafe

        public int compareTypeSafe​(Value o,
                                   CompareMode mode,
                                   CastDataProvider provider)
        Description copied from class: Value
        Compare this value against another value given that the values are of the same data type.
        Specified by:
        compareTypeSafe in class Value
        Parameters:
        o - the other value
        mode - the compare mode
        provider - the cast information provider
        Returns:
        0 if both values are equal, -1 if the other value is smaller, and 1 otherwise
      • equals

        public boolean equals​(java.lang.Object other)
        Description copied from class: Value
        Check if the two values have the same hash code. No data conversion is made; this method returns false if the other object is not of the same class. For some values, compareTo may return 0 even if equals return false. Example: ValueDecimal 0.0 and 0.00.
        Specified by:
        equals in class Value
        Parameters:
        other - the other value
        Returns:
        true if they are equal
      • getUuid

        public java.util.UUID getUuid()
        Returns the UUID.
        Returns:
        the UUID
      • getHigh

        public long getHigh()
        Get the most significant 64 bits of this UUID.
        Returns:
        the high order bits
      • getLow

        public long getLow()
        Get the least significant 64 bits of this UUID.
        Returns:
        the low order bits
      • charLength

        public long charLength()
        Description copied from class: Value
        Returns length of this value in characters.
        Overrides:
        charLength in class Value
        Returns:
        length of this value in characters
      • octetLength

        public long octetLength()
        Description copied from class: Value
        Returns length of this value in bytes.
        Overrides:
        octetLength in class Value
        Returns:
        length of this value in bytes