FileDocCategorySizeDatePackage
MonetoryAmountUserType.javaAPI DocHibernate 3.2.53290Mon Mar 28 21:17:50 BST 2005org.hibernate.test.cut

MonetoryAmountUserType

public class MonetoryAmountUserType extends Object implements org.hibernate.usertype.CompositeUserType
author
Gavin King

Fields Summary
Constructors Summary
Methods Summary
public java.lang.Objectassemble(java.io.Serializable cached, org.hibernate.engine.SessionImplementor session, java.lang.Object owner)

		return deepCopy(cached);
	
public java.lang.ObjectdeepCopy(java.lang.Object value)

		MonetoryAmount ma = (MonetoryAmount) value;
		return new MonetoryAmount( ma.getAmount(), ma.getCurrency() );
	
public java.io.Serializabledisassemble(java.lang.Object value, org.hibernate.engine.SessionImplementor session)

		return (Serializable) deepCopy(value);
	
public booleanequals(java.lang.Object x, java.lang.Object y)

		if (x==y) return true;
		if (x==null || y==null) return false;
		MonetoryAmount mx = (MonetoryAmount) x;
		MonetoryAmount my = (MonetoryAmount) y;
		return mx.getAmount().equals( my.getAmount() ) &&
			mx.getCurrency().equals( my.getCurrency() );
	
public java.lang.String[]getPropertyNames()

		return new String[] { "amount", "currency" };
	
public org.hibernate.type.Type[]getPropertyTypes()

		return new Type[] { Hibernate.BIG_DECIMAL, Hibernate.CURRENCY };
	
public java.lang.ObjectgetPropertyValue(java.lang.Object component, int property)

		MonetoryAmount ma = (MonetoryAmount) component;
		return property==0 ? (Object) ma.getAmount() : (Object) ma.getCurrency();
	
public inthashCode(java.lang.Object x)

		return ( (MonetoryAmount) x ).getAmount().hashCode();
	
public booleanisMutable()

		return true;
	
public java.lang.ObjectnullSafeGet(java.sql.ResultSet rs, java.lang.String[] names, org.hibernate.engine.SessionImplementor session, java.lang.Object owner)

		BigDecimal amt = (BigDecimal) Hibernate.BIG_DECIMAL.nullSafeGet( rs, names[0] );
		Currency cur = (Currency) Hibernate.CURRENCY.nullSafeGet( rs, names[1] );
		if (amt==null) return null;
		return new MonetoryAmount(amt, cur);
	
public voidnullSafeSet(java.sql.PreparedStatement st, java.lang.Object value, int index, org.hibernate.engine.SessionImplementor session)

		MonetoryAmount ma = (MonetoryAmount) value;
		BigDecimal amt = ma == null ? null : ma.getAmount();
		Currency cur = ma == null ? null : ma.getCurrency();
		Hibernate.BIG_DECIMAL.nullSafeSet(st, amt, index);
		Hibernate.CURRENCY.nullSafeSet(st, cur, index+1);
	
public java.lang.Objectreplace(java.lang.Object original, java.lang.Object target, org.hibernate.engine.SessionImplementor session, java.lang.Object owner)

		return deepCopy(original); //TODO: improve
	
public java.lang.ClassreturnedClass()

		return MonetoryAmount.class;
	
public voidsetPropertyValue(java.lang.Object component, int property, java.lang.Object value)

		MonetoryAmount ma = (MonetoryAmount) component;
		if ( property==0 ) {
			ma.setAmount( (BigDecimal) value );
		}
		else {
			ma.setCurrency( (Currency) value );
		}