net.smartlab.web
Class Enumeration

java.lang.Object
  extended by net.smartlab.web.Enumeration
All Implemented Interfaces:
java.io.Serializable, org.hibernate.usertype.UserType

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

Represents a meta type used to constraint a property to accept only pre-defined admitted values. Whenever a property needs some sort of constraint on assignable values, like person gender or process status, a subclass of Enumeration can be used to enumerate all possible values.

Author:
rlogiacco
See Also:
Serialized Form

Constructor Summary
protected Enumeration()
          Default constructor used for internal purposes only.
protected Enumeration(int id, 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)
           
abstract  Enumeration decode(int id)
          Decodes a unique identifier 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 getDisplay()
          Returns the brief description of the choice.
 int getId()
          Returns the unique identifier for the choice.
 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
 

Constructor Detail

Enumeration

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


Enumeration

protected Enumeration(int id,
                      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

getId

public int getId()
Returns the unique identifier for the choice.

Returns:
the unique identifier for the choice.

getDisplay

public java.lang.String getDisplay()
Returns the brief description of the choice.

Returns:
the brief description of the choice.

decode

public abstract Enumeration decode(int id)
Decodes a unique identifier into an instance of this class. This method can not return null values, instead it should define a default value.

Parameters:
id - the identifier 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()

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)

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)

isMutable

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

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)

returnedClass

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

sqlTypes

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

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:
UserType.assemble(java.io.Serializable, java.lang.Object)

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:
UserType.disassemble(java.lang.Object)

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:
UserType.replace(java.lang.Object, java.lang.Object, java.lang.Object)


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