FileDocCategorySizeDatePackage
AbstractCharArrayType.javaAPI DocHibernate 3.2.52763Fri Jun 09 22:24:06 BST 2006org.hibernate.type

AbstractCharArrayType

public abstract class AbstractCharArrayType extends MutableType
Logic to bind stream of char into a VARCHAR
author
Emmanuel Bernard

Fields Summary
Constructors Summary
Methods Summary
protected java.lang.ObjectdeepCopyNotNull(java.lang.Object value)

		char[] chars = toInternalFormat(value);
		char[] result = new char[chars.length];
		System.arraycopy(chars, 0, result, 0, chars.length);
		return toExternalFormat(result);
	
public java.lang.ObjectfromStringValue(java.lang.String xml)

		if (xml == null) return null;
		int length = xml.length();
		char[] chars = new char[length];
		for (int index = 0 ; index < length ; index++ ) {
			chars[index] = xml.charAt( index );
		}
		return toExternalFormat( chars );
	
public java.lang.Objectget(java.sql.ResultSet rs, java.lang.String name)

		Reader stream = rs.getCharacterStream(name);
		if ( stream == null ) return toExternalFormat( null );
		CharArrayWriter writer = new CharArrayWriter();
		for(;;) {
			try {
				int c = stream.read();
				if ( c == -1) return toExternalFormat( writer.toCharArray() );
				writer.write( c );
			}
			catch (IOException e) {
				throw new HibernateException("Unable to read character stream from rs");
			}
		}
	
public abstract java.lang.ClassgetReturnedClass()

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


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

		char[] chars = toInternalFormat( value );
		st.setCharacterStream(index, new CharArrayReader(chars), chars.length);
	
public intsqlType()

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

		if (xml == null) return toExternalFormat( null );
		int length = xml.length();
		char[] chars = new char[length];
		for (int index = 0 ; index < length ; index++ ) {
			chars[index] = xml.charAt( index );
		}
		return toExternalFormat( chars );
	
protected abstract java.lang.ObjecttoExternalFormat(char[] chars)
Convert the char[] into the expected object type

protected abstract char[]toInternalFormat(java.lang.Object chars)
Convert the object into the internal char[] representation

public java.lang.StringtoString(java.lang.Object value)

		if (value == null) return null;
		return new String( toInternalFormat( value ) );