FileDocCategorySizeDatePackage
LocaleType.javaAPI DocHibernate 3.2.52029Wed Aug 10 15:23:56 BST 2005org.hibernate.type

LocaleType

public class LocaleType extends ImmutableType implements LiteralType
locale: A type that maps an SQL VARCHAR to a Java Locale.
author
Gavin King

Fields Summary
Constructors Summary
Methods Summary
public intcompare(java.lang.Object x, java.lang.Object y, org.hibernate.EntityMode entityMode)

		return x.toString().compareTo( y.toString() );
	
public java.lang.ObjectfromStringValue(java.lang.String string)

		if (string == null) {
			return null;
		}
		else {
			StringTokenizer tokens = new StringTokenizer(string, "_");
			String language = tokens.hasMoreTokens() ? tokens.nextToken() : "";
			String country = tokens.hasMoreTokens() ? tokens.nextToken() : "";
			// Need to account for allowable '_' within the variant
			String variant = "";
			String sep = "";
			while ( tokens.hasMoreTokens() ) {
				variant += sep + tokens.nextToken();
				sep = "_";
			}
			return new Locale(language, country, variant);
		}
	
public java.lang.Objectget(java.sql.ResultSet rs, java.lang.String name)

		return fromStringValue( (String) Hibernate.STRING.get(rs, name) );
	
public java.lang.StringgetName()

		return "locale";
	
public java.lang.ClassgetReturnedClass()

		return Locale.class;
	
public java.lang.StringobjectToSQLString(java.lang.Object value, org.hibernate.dialect.Dialect dialect)

		return ( (LiteralType) Hibernate.STRING ).objectToSQLString( value.toString(), dialect );
	
public voidset(java.sql.PreparedStatement st, java.lang.Object value, int index)

		Hibernate.STRING.set(st, value.toString(), index);
	
public intsqlType()

		return Hibernate.STRING.sqlType();
	
public java.lang.StringtoString(java.lang.Object value)

		return value.toString();