Clover Coverage Report - SmartWeb
Coverage timestamp: Sun Jun 8 2008 21:20:12 CEST
../../../img/srcFileCovDistChart0.png 29% of files have more coverage
20   194   18   1,54
4   71   0,9   13
13     1,38  
1    
5,1% of code in this file is excluded from these metrics.
 
  StringEnumeration       Line # 40 20 18 0% 0.0
 
No Tests
 
1    /*
2    * The SmartWeb Framework
3    * Copyright (C) 2004-2006
4    *
5    * This library is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU Lesser General Public
7    * License as published by the Free Software Foundation; either
8    * version 2.1 of the License, or (at your option) any later version.
9    *
10    * This library is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this library; if not, write to the Free Software
17    * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18    *
19    * For further informations on the SmartWeb Framework please visit
20    *
21    * http://smartweb.sourceforge.net
22    */
23    package net.smartlab.web;
24   
25    import java.io.Serializable;
26    import java.sql.PreparedStatement;
27    import java.sql.ResultSet;
28    import java.sql.SQLException;
29    import java.sql.Types;
30   
31    import org.hibernate.Hibernate;
32    import org.hibernate.HibernateException;
33    import org.hibernate.usertype.UserType;
34   
35    /**
36    * TODO documentation
37    *
38    * @author rlogiacco
39    */
 
40    public abstract class StringEnumeration implements Serializable, UserType, Comparable {
41   
42    private final static long serialVersionUID = -1298346029203487615L;
43   
44    /**
45    * The SQL column type.
46    */
47    private final static int[] TYPES = new int[] {Types.VARCHAR};
48   
49    /**
50    * TODO documentation
51    *
52    * @uml.property name="code"
53    */
54    protected String code;
55   
56   
57    /**
58    * TODO documentation
59    *
60    * @return
61    * @uml.property name="code"
62    */
 
63  0 toggle public String getCode() {
64  0 return code;
65    }
66   
67    /**
68    * TODO documentation
69    *
70    * @return
71    */
72    public abstract String getDisplay();
73   
74    /**
75    * Decodes a unique code into an instance of this class. This method <b>can
76    * not</b> return <code>null</code> values, instead it should define a
77    * <i>default</i> value.
78    *
79    * @param code the code to decode.
80    * @return an instance of this class.
81    */
82    public abstract StringEnumeration decode(String code);
83   
84    /**
85    * @see org.hibernate.usertype.UserType#sqlTypes()
86    */
 
87  0 toggle public int[] sqlTypes() {
88  0 return TYPES;
89    }
90   
91    /**
92    * @see org.hibernate.usertype.UserType#returnedClass()
93    */
 
94  0 toggle public Class returnedClass() {
95  0 return this.getClass();
96    }
97   
98    /**
99    * @see org.hibernate.usertype.UserType#equals(java.lang.Object,
100    * java.lang.Object)
101    */
 
102  0 toggle public boolean equals(Object src, Object dst) throws HibernateException {
103  0 if (src == dst) {
104  0 return true;
105    }
106  0 if (src == null || dst == null) {
107  0 return false;
108    }
109  0 return Hibernate.STRING.isEqual(src, dst);
110    }
111   
112    /**
113    * @see org.hibernate.usertype.UserType#nullSafeGet(java.sql.ResultSet,
114    * java.lang.String[], java.lang.Object)
115    */
 
116  0 toggle public Object nullSafeGet(ResultSet rows, String[] names, Object owner) throws HibernateException, SQLException {
117  0 String code = ((String)Hibernate.STRING.nullSafeGet(rows, names[0]));
118  0 return this.decode(code);
119    }
120   
121    /**
122    * @see org.hibernate.usertype.UserType#nullSafeSet(java.sql.PreparedStatement,
123    * java.lang.Object, int)
124    */
 
125  0 toggle public void nullSafeSet(PreparedStatement statement, Object value, int index) throws HibernateException,
126    SQLException {
127  0 try {
128  0 statement.setString(index, ((StringEnumeration)value).getCode());
129    } catch (ClassCastException cce) {
130    throw new HibernateException(cce);
131    }
132    }
133   
134    /**
135    * @see org.hibernate.usertype.UserType#deepCopy(java.lang.Object)
136    */
 
137  0 toggle public Object deepCopy(Object value) throws HibernateException {
138  0 return value;
139    }
140   
141    /**
142    * @see org.hibernate.usertype.UserType#isMutable()
143    */
 
144  0 toggle public boolean isMutable() {
145  0 return false;
146    }
147   
148    /**
149    * @see org.hibernate.usertype.UserType#assemble(java.io.Serializable,
150    * java.lang.Object) TODO implement
151    */
 
152  0 toggle public Object assemble(Serializable arg0, Object arg1) throws HibernateException {
153    // TODO Auto-generated method stub
154  0 return null;
155    }
156   
157    /**
158    * @see org.hibernate.usertype.UserType#disassemble(java.lang.Object) TODO
159    * implement
160    */
 
161  0 toggle public Serializable disassemble(Object arg0) throws HibernateException {
162    // TODO Auto-generated method stub
163  0 return null;
164    }
165   
166    /**
167    * @see org.hibernate.usertype.UserType#hashCode(java.lang.Object)
168    */
 
169  0 toggle public int hashCode(Object obj) throws HibernateException {
170  0 return ((Enumeration)obj).hashCode();
171    }
172   
173    /**
174    * @see org.hibernate.usertype.UserType#replace(java.lang.Object,
175    * java.lang.Object, java.lang.Object) TODO implement
176    */
 
177  0 toggle public Object replace(Object arg0, Object arg1, Object arg2) throws HibernateException {
178  0 return null;
179    }
180   
181    /**
182    * TODO documentation
183    *
184    * @param obj
185    * @return
186    */
 
187  0 toggle public int compareTo(Object obj) {
188  0 try {
189  0 return this.getCode().compareTo(((StringEnumeration)obj).code);
190    } catch (ClassCastException cce) {
191    return 0;
192    }
193    }
194    }