org.jcoderz.commons.util
Class StringUserTypeBase

java.lang.Object
  extended by org.jcoderz.commons.util.UserTypeBase
      extended by org.jcoderz.commons.util.StringUserTypeBase
All Implemented Interfaces:
Serializable, UserType

public abstract class StringUserTypeBase
extends UserTypeBase

This class is used by the Hibernate binding for RestrictedStrings. A subclass has to implement the fromString method for the particular RestrictedString. Be aware that VARCHAR is restricted to 1000 Unicode characters!

Author:
thomas.bodemer
See Also:
Serialized Form

Constructor Summary
StringUserTypeBase()
           
 
Method Summary
abstract  Object fromString(String value)
          Implement this method for the particular RestrictedString.
abstract  Object getEmptyOrNull()
          Implement this method for the particular RestrictedString.
 Object nullSafeGet(ResultSet resultSet, String[] types, Object owner)
          
 void nullSafeSet(PreparedStatement statement, Object value, int index)
          
 int[] sqlTypes()
          
 
Methods inherited from class org.jcoderz.commons.util.UserTypeBase
assemble, deepCopy, disassemble, equals, hashCode, isMutable, replace, returnedClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringUserTypeBase

public StringUserTypeBase()
Method Detail

nullSafeGet

public Object nullSafeGet(ResultSet resultSet,
                          String[] types,
                          Object owner)
                   throws HibernateException,
                          SQLException

Specified by:
nullSafeGet in interface UserType
Specified by:
nullSafeGet in class UserTypeBase
Throws:
HibernateException
SQLException

getEmptyOrNull

public abstract Object getEmptyOrNull()
Implement this method for the particular RestrictedString.

Returns:
either null or fromString("") if the StrongType permits this.

fromString

public abstract Object fromString(String value)
Implement this method for the particular RestrictedString.

Parameters:
value - the String representation of the mapped class
Returns:
the instance of the mapped class

nullSafeSet

public void nullSafeSet(PreparedStatement statement,
                        Object value,
                        int index)
                 throws HibernateException,
                        SQLException

Specified by:
nullSafeSet in interface UserType
Specified by:
nullSafeSet in class UserTypeBase
Throws:
HibernateException
SQLException

sqlTypes

public int[] sqlTypes()

Specified by:
sqlTypes in interface UserType
Specified by:
sqlTypes in class UserTypeBase


Copyright 2007 The jCoderZ Project.