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

CharBooleanType

public abstract class CharBooleanType extends BooleanType
Superclass for types that map Java boolean to SQL CHAR(1).
author
Gavin King

Fields Summary
Constructors Summary
Methods Summary
public java.lang.Objectget(java.sql.ResultSet rs, java.lang.String name)

		String code = rs.getString(name);
		if ( code==null || code.length()==0 ) {
			return null;
		}
		else {
			return getTrueString().equalsIgnoreCase( code.trim() ) ? 
					Boolean.TRUE : Boolean.FALSE;
		}
	
protected abstract java.lang.StringgetFalseString()

protected abstract java.lang.StringgetTrueString()

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

		return "'" + toCharacter(value) + "'";
	
public voidset(java.sql.PreparedStatement st, java.lang.Object value, int index)

		st.setString( index, toCharacter(value) );

	
public intsqlType()

		return Types.CHAR;
	
public java.lang.ObjectstringToObject(java.lang.String xml)

		if ( getTrueString().equalsIgnoreCase(xml) ) {
			return Boolean.TRUE;
		}
		else if ( getFalseString().equalsIgnoreCase(xml) ) {
			return Boolean.FALSE;
		}
		else {
			throw new HibernateException("Could not interpret: " + xml);
		}
	
private java.lang.StringtoCharacter(java.lang.Object value)

		return ( (Boolean) value ).booleanValue() ? getTrueString() : getFalseString();