Package com.mckoi.database
Class TStringType
- java.lang.Object
-
- com.mckoi.database.TType
-
- com.mckoi.database.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
-
-
Field Summary
-
Fields inherited from class com.mckoi.database.TType
ARRAY_TYPE, BINARY_TYPE, BOOLEAN_TYPE, DATE_TYPE, NULL_TYPE, NUMERIC_TYPE, QUERY_PLAN_TYPE, STRING_TYPE
-
-
Constructor Summary
Constructors Constructor Description TStringType(int sql_type, int max_size, java.lang.String locale_str)Constructor without strength and decomposition that sets to default levels.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.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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcalculateApproximateMemoryUse(java.lang.Object ob)Calculates the approximate memory usage of an object of this type in bytes.booleancomparableTypes(TType type)For strings, the locale must be the same for the types to be comparable.intcompareObs(java.lang.Object ob1, java.lang.Object ob2)Compares two objects that are logically comparable under this type.intgetDecomposition()Returns the decomposition of this string type as defined in java.text.Collator.java.util.LocalegetLocale()Returns the locale of the string.java.lang.StringgetLocaleString()Returns the locale information as a formatted string.intgetMaximumSize()Returns the maximum size of the string (-1 is don't care).intgetStrength()Returns the strength of this string type as defined in java.text.Collator.java.lang.ClassjavaClass()Returns the Java Class that is used to represent this type of object.-
Methods inherited from class com.mckoi.database.TType
asEncodedString, asEncodedString, asSQLString, binaryType, booleanType, castObjectToTType, dateType, decodeString, decodeTypes, fromClass, getSQLType, getWidestType, javaObjectType, numericType, stringType
-
-
-
-
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:
comparableTypesin classTType
-
compareObs
public int compareObs(java.lang.Object ob1, java.lang.Object ob2)Description copied from class:TTypeCompares 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:
compareObsin classTType
-
calculateApproximateMemoryUse
public int calculateApproximateMemoryUse(java.lang.Object ob)
Description copied from class:TTypeCalculates the approximate memory usage of an object of this type in bytes.- Specified by:
calculateApproximateMemoryUsein classTType
-
-