public class NumericBooleanType extends BooleanType { /** * {@inheritDoc} * <p/> * This type's name is <tt>numeric_boolean</tt> */ public String getName() { return "numeric_boolean"; } /** * {@inheritDoc} */ public Object get(ResultSet rs, String name) throws SQLException { int value = rs.getInt( name ); if ( rs.wasNull() ) { return getDefaultValue(); } else if ( value == 0 ) { return Boolean.FALSE; } else { return Boolean.TRUE; } } /** * {@inheritDoc} */ public void set(PreparedStatement st, Object value, int index) throws SQLException { if ( value == null ) { st.setNull( index, Types.INTEGER ); } else { boolean bool = ( ( Boolean ) value ).booleanValue(); st.setInt( index, bool ? 1 : 0 ); } } /** * {@inheritDoc} */ public String objectToSQLString(Object value, Dialect dialect) throws Exception { return ( ( Boolean ) value ).booleanValue() ? "1" : "0"; } /** * {@inheritDoc} */ public int sqlType() { return Types.INTEGER;
public class NumericTrueFalseType extends BooleanType { public Object get(ResultSet rs, String name) throws SQLException { int value = rs.getInt( name ); if ( rs.wasNull() ) { return getDefaultValue(); } else if ( value == 0 ) { return Boolean.FALSE; } else { return Boolean.TRUE; } } public void set(PreparedStatement st, Object value, int index) throws SQLException { if ( value == null ) { st.setNull( index, Types.INTEGER ); } else { boolean bool = ( ( Boolean ) value ).booleanValue(); st.setInt( index, bool ? 1 : 0 ); } } public String objectToSQLString(Object value, Dialect dialect) throws Exception { return ( ( Boolean ) value ).booleanValue() ? "1" : "0"; } public int sqlType() { return Types.INTEGER; } public String getName() { return "numeric_boolean";
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/type/NumericBooleanType.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/where/NumericTrueFalseType.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public class NumericBooleanType extends BooleanType {
1
public class NumericTrueFalseType extends BooleanType {
2
	/**
3
	 * {@inheritDoc}
4
	 * <p/>
5
	 * This type's name is <tt>numeric_boolean</tt>
6
	 */
7
	public String getName() {
8
		return "numeric_boolean";
9
	}
10
	/**
11
	 * {@inheritDoc}
12
	 */
2

13
	public Object get(ResultSet rs, String name) throws SQLException {
3
	public Object get(ResultSet rs, String name) throws SQLException {
14
		int value = rs.getInt( name );
4
		int value = rs.getInt( name );
15
		if ( rs.wasNull() ) {
5
		if ( rs.wasNull() ) {
16
			return getDefaultValue();
6
			return getDefaultValue();
17
		}
7
		}
18
		else if ( value == 0 ) {
8
		else if ( value == 0 ) {
19
			return Boolean.FALSE;
9
			return Boolean.FALSE;
20
		}
10
		}
21
		else {
11
		else {
22
			return Boolean.TRUE;
12
			return Boolean.TRUE;
23
		}
13
		}
24
	}
14
	}
25
	/**
26
	 * {@inheritDoc}
27
	 */
15

28
	public void set(PreparedStatement st, Object value, int index) throws SQLException {
16
	public void set(PreparedStatement st, Object value, int index) throws SQLException {
29
		if ( value == null ) {
17
		if ( value == null ) {
30
			st.setNull( index, Types.INTEGER );
18
			st.setNull( index, Types.INTEGER );
31
		}
19
		}
32
		else {
20
		else {
33
			boolean bool = ( ( Boolean ) value ).booleanValue();
21
			boolean bool = ( ( Boolean ) value ).booleanValue();
34
			st.setInt( index, bool ? 1 : 0 );
22
			st.setInt( index, bool ? 1 : 0 );
35
		}
23
		}
36
	}
24
	}
37
	/**
38
	 * {@inheritDoc}
39
	 */
25

40
	public String objectToSQLString(Object value, Dialect dialect) throws Exception {
26
	public String objectToSQLString(Object value, Dialect dialect) throws Exception {
41
		return ( ( Boolean ) value ).booleanValue() ? "1" : "0";
27
		return ( ( Boolean ) value ).booleanValue() ? "1" : "0";
42
	}
43
	/**
44
	 * {@inheritDoc}
45
	 */
28
	}
29

46
	public int sqlType() {
30
	public int sqlType() {
47
		return Types.INTEGER;
31
		return Types.INTEGER;
32
	}
33
	public String getName() {
34
		return "numeric_boolean";
48
	
35
	
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0