net.smartlab.web
Class StringEnumeration

java.lang.Object
  extended by net.smartlab.web.StringEnumeration
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable, org.hibernate.usertype.UserType
Direct Known Subclasses:
PropertiesEnumeration

public abstract class StringEnumeration
extends java.lang.Object
implements java.io.Serializable, org.hibernate.usertype.UserType, java.lang.Comparable

This class allows to use string to define enumeration elements identifier but needs the definition of two constructors. Implementors of this class need to define two constructors: one without parameters which simply calls super() and an additional one taking two strings and calling super(String, String).

Author:
rlogiacco
See Also:
Serialized Form

Field Summary
protected  java.lang.String code
          TODO documentation
 
Constructor Summary
protected StringEnumeration()
          Default constructor used for internal purposes only.
protected StringEnumeration(java.lang.String code, java.lang.String display)
          Constructs an available choice on a unique identifier and a brief, human understandable, description.
 
Method Summary
 java.lang.Object assemble(java.io.Serializable arg0, java.lang.Object arg1)
           
 int compareTo(java.lang.Object obj)
           
abstract  StringEnumeration decode(java.lang.String code)
          Decodes a unique code into an instance of this class.
 java.lang.Object deepCopy(java.lang.Object value)
           
 java.io.Serializable disassemble(java.lang.Object arg0)
           
 boolean equals(java.lang.Object other)
           
 boolean equals(java.lang.Object src, java.lang.Object dst)
           
 java.lang.String getCode()
          Returns the enumeration element code.
 java.lang.String getDisplay()
          Returns the enumeration element display name.
 int hashCode()
           
 int hashCode(java.lang.Object obj)
           
 boolean isMutable()
           
 java.lang.Object nullSafeGet(java.sql.ResultSet rows, java.lang.String[] names, java.lang.Object owner)
           
 void nullSafeSet(java.sql.PreparedStatement statement, java.lang.Object value, int index)
           
 java.lang.Object replace(java.lang.Object arg0, java.lang.Object arg1, java.lang.Object arg2)
           
 java.lang.Class returnedClass()
           
 int[] sqlTypes()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code

protected java.lang.String code
TODO documentation

Constructor Detail

StringEnumeration

protected StringEnumeration()
Default constructor used for internal purposes only.


StringEnumeration

protected StringEnumeration(java.lang.String code,
                            java.lang.String display)
Constructs an available choice on a unique identifier and a brief, human understandable, description.

Parameters:
id - the unique identifier for this choice.
display - a short, human understandable, description of the choice.
Method Detail

getCode

public java.lang.String getCode()
Returns the enumeration element code.

Returns:
the enumeration element code.

getDisplay

public java.lang.String getDisplay()
Returns the enumeration element display name.

Returns:
the enumeration element display name.

decode

public abstract StringEnumeration decode(java.lang.String code)
Decodes a unique code into an instance of this class. This method can not return null values, instead it should define a default value.

Parameters:
code - the code to decode.
Returns:
an instance of this class.

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

sqlTypes

public int[] sqlTypes()
Specified by:
sqlTypes in interface org.hibernate.usertype.UserType
See Also:
UserType.sqlTypes()

returnedClass

public java.lang.Class returnedClass()
Specified by:
returnedClass in interface org.hibernate.usertype.UserType
See Also:
UserType.returnedClass()

equals

public boolean equals(java.lang.Object src,
                      java.lang.Object dst)
               throws org.hibernate.HibernateException
Specified by:
equals in interface org.hibernate.usertype.UserType
Throws:
org.hibernate.HibernateException
See Also:
UserType.equals(java.lang.Object, java.lang.Object)

nullSafeGet

public java.lang.Object nullSafeGet(java.sql.ResultSet rows,
                                    java.lang.String[] names,
                                    java.lang.Object owner)
                             throws org.hibernate.HibernateException,
                                    java.sql.SQLException
Specified by:
nullSafeGet in interface org.hibernate.usertype.UserType
Throws:
org.hibernate.HibernateException
java.sql.SQLException
See Also:
UserType.nullSafeGet(java.sql.ResultSet, java.lang.String[], java.lang.Object)

nullSafeSet

public void nullSafeSet(java.sql.PreparedStatement statement,
                        java.lang.Object value,
                        int index)
                 throws org.hibernate.HibernateException,
                        java.sql.SQLException
Specified by:
nullSafeSet in interface org.hibernate.usertype.UserType
Throws:
org.hibernate.HibernateException
java.sql.SQLException
See Also:
UserType.nullSafeSet(java.sql.PreparedStatement, java.lang.Object, int)

deepCopy

public java.lang.Object deepCopy(java.lang.Object value)
                          throws org.hibernate.HibernateException
Specified by:
deepCopy in interface org.hibernate.usertype.UserType
Throws:
org.hibernate.HibernateException
See Also:
UserType.deepCopy(java.lang.Object)

isMutable

public boolean isMutable()
Specified by:
isMutable in interface org.hibernate.usertype.UserType
See Also:
UserType.isMutable()

assemble

public java.lang.Object assemble(java.io.Serializable arg0,
                                 java.lang.Object arg1)
                          throws org.hibernate.HibernateException
Specified by:
assemble in interface org.hibernate.usertype.UserType
Throws:
org.hibernate.HibernateException
See Also:
TODO implement

disassemble

public java.io.Serializable disassemble(java.lang.Object arg0)
                                 throws org.hibernate.HibernateException
Specified by:
disassemble in interface org.hibernate.usertype.UserType
Throws:
org.hibernate.HibernateException
See Also:
TODO implement

hashCode

public int hashCode(java.lang.Object obj)
             throws org.hibernate.HibernateException
Specified by:
hashCode in interface org.hibernate.usertype.UserType
Throws:
org.hibernate.HibernateException
See Also:
UserType.hashCode(java.lang.Object)

replace

public java.lang.Object replace(java.lang.Object arg0,
                                java.lang.Object arg1,
                                java.lang.Object arg2)
                         throws org.hibernate.HibernateException
Specified by:
replace in interface org.hibernate.usertype.UserType
Throws:
org.hibernate.HibernateException
See Also:
TODO implement

compareTo

public int compareTo(java.lang.Object obj)
Specified by:
compareTo in interface java.lang.Comparable
See Also:
java.lang.Comparable#compareTo(T)


Copyright © 2004-2009 The SmartWeb Team. All Rights Reserved.