FileDocCategorySizeDatePackage
TextType.javaAPI DocHibernate 3.2.52106Sat Sep 25 06:22:20 BST 2004org.hibernate.type

TextType

public class TextType extends ImmutableType
text: A type that maps an SQL CLOB to a Java String.
author
Gavin King, Bertrand Renuart

Fields Summary
Constructors Summary
Methods Summary
public java.lang.ObjectfromStringValue(java.lang.String xml)

		return xml;
	
public java.lang.Objectget(java.sql.ResultSet rs, java.lang.String name)


			// Retrieve the value of the designated column in the current row of this
			// ResultSet object as a java.io.Reader object
			Reader charReader = rs.getCharacterStream(name);

			// if the corresponding SQL value is NULL, the reader we got is NULL as well
			if (charReader==null) return null;

			// Fetch Reader content up to the end - and put characters in a StringBuffer
			StringBuffer sb = new StringBuffer();
			try {
				char[] buffer = new char[2048];
				while (true) {
					int amountRead = charReader.read(buffer, 0, buffer.length);
					if ( amountRead == -1 ) break;
					sb.append(buffer, 0, amountRead);
				}
			}
			catch (IOException ioe) {
				throw new HibernateException( "IOException occurred reading text", ioe );
			}
			finally {
				try {
					charReader.close();
				}
				catch (IOException e) {
					throw new HibernateException( "IOException occurred closing stream", e );
				}
			}

			// Return StringBuffer content as a large String
			return sb.toString();
	
public java.lang.StringgetName()

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

		return String.class;
	
public voidset(java.sql.PreparedStatement st, java.lang.Object value, int index)

		String str = (String) value;
		st.setCharacterStream( index, new StringReader(str), str.length() );
	
public intsqlType()

		return Types.CLOB; //or Types.LONGVARCHAR?
	
public java.lang.StringtoString(java.lang.Object val)

		return (String) val;