| 1 |
|
package org.itracker.persistence.dao; |
| 2 |
|
|
| 3 |
|
import java.io.Serializable; |
| 4 |
|
import java.sql.PreparedStatement; |
| 5 |
|
import java.sql.ResultSet; |
| 6 |
|
import java.sql.SQLException; |
| 7 |
|
import java.sql.Types; |
| 8 |
|
|
| 9 |
|
import org.hibernate.HibernateException; |
| 10 |
|
import org.hibernate.usertype.UserType; |
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
@author |
| 21 |
|
|
|
|
|
| 0% |
Uncovered Elements: 43 (43) |
Complexity: 16 |
Complexity Density: 0.84 |
|
| 22 |
|
public final class IntBooleanType implements UserType { |
| 23 |
|
|
| 24 |
|
private static final int[] SQL_TYPES = { Types.INTEGER }; |
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 29 |
0
|
public IntBooleanType() {... |
| 30 |
|
} |
| 31 |
|
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 32 |
0
|
public void nullSafeSet(PreparedStatement statement, Object value, int index)... |
| 33 |
|
throws HibernateException, SQLException { |
| 34 |
0
|
if (value == null) { |
| 35 |
0
|
statement.setNull(index, Types.INTEGER); |
| 36 |
|
} else { |
| 37 |
0
|
final int intValue = ((Boolean) value).booleanValue() ? 1 : 0; |
| 38 |
0
|
statement.setInt(index, intValue); |
| 39 |
|
} |
| 40 |
|
} |
| 41 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 42 |
0
|
public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner)... |
| 43 |
|
throws HibernateException, SQLException { |
| 44 |
0
|
final int value = resultSet.getInt(names[0]); |
| 45 |
0
|
return resultSet.wasNull() ? null : (value == 1); |
| 46 |
|
} |
| 47 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 1 |
|
| 48 |
0
|
public int hashCode(Object x) throws HibernateException {... |
| 49 |
|
|
| 50 |
0
|
assert (x != null); |
| 51 |
|
|
| 52 |
0
|
return x.hashCode(); |
| 53 |
|
} |
| 54 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 55 |
0
|
public Serializable disassemble(Object value) throws HibernateException {... |
| 56 |
0
|
return (Serializable) value; |
| 57 |
|
} |
| 58 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 59 |
0
|
public Object deepCopy(Object value) throws HibernateException {... |
| 60 |
0
|
return value; |
| 61 |
|
} |
| 62 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 63 |
0
|
public int[] sqlTypes() {... |
| 64 |
0
|
return SQL_TYPES; |
| 65 |
|
} |
| 66 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 67 |
0
|
public Class<Boolean> returnedClass() {... |
| 68 |
0
|
return Boolean.class; |
| 69 |
|
} |
| 70 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 71 |
0
|
public Object replace(Object original, Object target, Object owner) throws HibernateException {... |
| 72 |
0
|
return original; |
| 73 |
|
} |
| 74 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 75 |
0
|
public boolean isMutable() {... |
| 76 |
0
|
return false; |
| 77 |
|
} |
| 78 |
|
|
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 4 |
Complexity Density: 0.8 |
|
| 82 |
0
|
public boolean equals(Object x, Object y) throws HibernateException {... |
| 83 |
0
|
if (x == y) { |
| 84 |
0
|
return true; |
| 85 |
|
} |
| 86 |
|
|
| 87 |
0
|
if (x == null || y == null) { |
| 88 |
0
|
return false; |
| 89 |
|
} |
| 90 |
0
|
return x.equals(y); |
| 91 |
|
} |
| 92 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 93 |
0
|
public Object assemble(Serializable cached, Object owner) throws HibernateException {... |
| 94 |
0
|
return cached; |
| 95 |
|
} |
| 96 |
|
|
| 97 |
|
} |