Class TStringType

  • All Implemented Interfaces:
    java.io.Serializable

    public final class TStringType
    extends TType
    An implementation of TType for a String.
    Author:
    Tobias Downer
    See Also:
    Serialized Form
    • Constructor Detail

      • TStringType

        public TStringType​(int sql_type,
                           int max_size,
                           java.util.Locale locale,
                           int strength,
                           int decomposition)
        Constructs a type with the given sql_type value, the maximum size, and the locale of the string. Note that the 'sql_type' MUST be a string SQL type.

        Note that a string type may be constructed with a NULL locale which means strings are compared lexicographically.

      • TStringType

        public TStringType​(int sql_type,
                           int max_size,
                           java.lang.String locale_str,
                           int strength,
                           int decomposition)
        Constructs a type with the given sql_type value, the maximum size, and the locale of the string. Note that the 'sql_type' MUST be a string SQL type.

        Note that a string type may be constructed with a NULL locale which means strings are compared lexicographically. The string locale is formated as [2 char language][2 char country][rest is variant]. For example, US english would be 'enUS', French would be 'fr' and Germany would be 'deDE'.

      • TStringType

        public TStringType​(int sql_type,
                           int max_size,
                           java.lang.String locale_str)
        Constructor without strength and decomposition that sets to default levels.
    • Method Detail

      • getMaximumSize

        public int getMaximumSize()
        Returns the maximum size of the string (-1 is don't care).
      • getStrength

        public int getStrength()
        Returns the strength of this string type as defined in java.text.Collator.
      • getDecomposition

        public int getDecomposition()
        Returns the decomposition of this string type as defined in java.text.Collator.
      • getLocale

        public java.util.Locale getLocale()
        Returns the locale of the string.
      • getLocaleString

        public java.lang.String getLocaleString()
        Returns the locale information as a formatted string.

        Note that a string type may be constructed with a NULL locale which means strings are compared lexicographically. The string locale is formated as [2 char language][2 char country][rest is variant]. For example, US english would be 'enUS', French would be 'fr' and Germany would be 'deDE'.

      • comparableTypes

        public boolean comparableTypes​(TType type)
        For strings, the locale must be the same for the types to be comparable. If the locale is not the same then they are not comparable. Note that strings with a locale of null can be compared with any other locale. So this will only return false if both types have different (but defined) locales.
        Specified by:
        comparableTypes in class TType
      • compareObs

        public int compareObs​(java.lang.Object ob1,
                              java.lang.Object ob2)
        Description copied from class: TType
        Compares two objects that are logically comparable under this type. Returns 0 if the values are equal, >1 if ob1 is greater than ob2, and <1 if ob1 is less than ob2. It is illegal to pass NULL values for ob1 or ob2 into this method.
        Specified by:
        compareObs in class TType
      • calculateApproximateMemoryUse

        public int calculateApproximateMemoryUse​(java.lang.Object ob)
        Description copied from class: TType
        Calculates the approximate memory usage of an object of this type in bytes.
        Specified by:
        calculateApproximateMemoryUse in class TType
      • javaClass

        public java.lang.Class javaClass()
        Description copied from class: TType
        Returns the Java Class that is used to represent this type of object. For example, string types would return String.class.
        Specified by:
        javaClass in class TType