FileDocCategorySizeDatePackage
CurrencyType.javaAPI DocHibernate 3.2.53489Wed Sep 14 14:54:50 BST 2005org.hibernate.type

CurrencyType

public class CurrencyType extends ImmutableType implements LiteralType
currency: A type that maps an SQL VARCHAR to a java.util.Currency
see
java.util.Currency
author
Gavin King

Fields Summary
public static final Class
CURRENCY_CLASS
private static final Method
CURRENCY_GET_INSTANCE
private static final Method
CURRENCY_GET_CODE
Constructors Summary
Methods Summary
public java.lang.ObjectfromStringValue(java.lang.String xml)

		try {
			return CURRENCY_GET_INSTANCE.invoke( null, new Object[] {xml} );
		}
		catch (Exception e) {
			throw new HibernateException("Could not resolve currency code: " + xml);
		}
	
public java.lang.Objectget(java.sql.ResultSet rs, java.lang.String name)

see
org.hibernate.type.NullableType#get(ResultSet, String)

		Class clazz;
		try {
			clazz = Class.forName("java.util.Currency");
		}
		catch (ClassNotFoundException cnfe) {
			clazz = null;
		}
		if (clazz==null) {
			CURRENCY_CLASS = null;
			CURRENCY_GET_INSTANCE = null;
			CURRENCY_GET_CODE = null;
		}
		else {
			CURRENCY_CLASS = clazz;
			try {
				CURRENCY_GET_INSTANCE = clazz.getMethod("getInstance", new Class[] { String.class } );
				CURRENCY_GET_CODE = clazz.getMethod("getCurrencyCode", new Class[0] );
			}
			catch (Exception e) {
				throw new AssertionFailure("Exception in static initializer of CurrencyType", e);
			}
		}
	
		String code = (String) Hibernate.STRING.nullSafeGet(rs, name);
		try {
			return code==null ? null : 
					CURRENCY_GET_INSTANCE.invoke(null, new Object[] { code } );
		}
		catch (Exception e) {
			throw new HibernateException("Could not resolve currency code: " + code);
		}
	
public java.lang.StringgetName()

see
org.hibernate.type.Type#getName()

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

see
org.hibernate.type.Type#getReturnedClass()

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

see
org.hibernate.type.LiteralType#objectToSQLString(Object, Dialect)

		String code;
		try {
			code = (String) CURRENCY_GET_CODE.invoke(value, null);
		}
		catch (Exception e) {
			throw new HibernateException("Could not get Currency code", e);
		}
		return ( (LiteralType) Hibernate.STRING ).objectToSQLString(code, dialect);
	
public voidset(java.sql.PreparedStatement st, java.lang.Object value, int index)

see
org.hibernate.type.NullableType#set(PreparedStatement, Object, int)

		Object code;
		try {
			code = CURRENCY_GET_CODE.invoke(value, null);
		}
		catch (Exception e) {
			throw new HibernateException("Could not get Currency code", e);
		}
		Hibernate.STRING.set(st, code, index);
	
public intsqlType()

see
org.hibernate.type.NullableType#sqlType()

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

		try {
			return (String) CURRENCY_GET_CODE.invoke(value, null);
		}
		catch (Exception e) {
			throw new HibernateException("Could not get Currency code", e);
		}