Project

General

Profile

Download (2.48 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

    
10
package eu.etaxonomy.cdm.io.common.mapping.out;
11

    
12
import java.sql.Types;
13

    
14
import org.apache.logging.log4j.LogManager;
15
import org.apache.logging.log4j.Logger;
16

    
17

    
18
/**
19
 * Mapper mapping a boolean CDM to a boolean export DB value.
20
 *
21
 * @author a.mueller
22
 * @since 12.05.2009
23
 */
24
public class DbBooleanMapper
25
        extends DbSingleAttributeExportMapperBase
26
        implements IDbExportMapper {
27

    
28
    @SuppressWarnings("unused")
29
	private static final Logger logger = LogManager.getLogger();
30

    
31
	public static DbBooleanMapper NewInstance(String cdmAttributeString, String dbAttributeString){
32
		return new DbBooleanMapper(cdmAttributeString, dbAttributeString, null, false);
33
	}
34

    
35
	public static DbBooleanMapper NewInstance(String cdmAttributeString, String dbAttributeString, Boolean defaultValue){
36
		return new DbBooleanMapper(cdmAttributeString, dbAttributeString, defaultValue, false);
37
	}
38

    
39
	public static DbBooleanMapper NewFalseInstance(String cdmAttributeString, String dbAttributeString){
40
		return new DbBooleanMapper(cdmAttributeString, dbAttributeString, false, false);
41
	}
42

    
43
	/**
44
     * @param cdmAttributeString source attribute (CDM)
45
     * @param dbAttributString target attribute (export DB)
46
     * @param defaultValue default value if source value is <code>null</code>
47
     * @param obligatory if the source attribute is obligatory, but value may be <code>null</code>
48
     */
49
	public static DbBooleanMapper NewInstance(String cdmAttributeString, String dbAttributeString, Boolean defaultValue, Boolean obligatory){
50
		return new DbBooleanMapper(cdmAttributeString, dbAttributeString, defaultValue, obligatory);
51
	}
52

    
53
    /**
54
     * @param cdmAttributeString source attribute (CDM)
55
     * @param dbAttributString target attribute (export DB)
56
     * @param defaultValue default value if source value is <code>null</code>
57
     * @param obligatory if the source attribute is obligatory, but value may be <code>null</code>
58
     */
59
	private DbBooleanMapper(String cdmAttributeString, String dbAttributeString, Boolean defaultValue, Boolean obligatory) {
60
		super(cdmAttributeString, dbAttributeString, defaultValue, obligatory, false);
61
	}
62

    
63
	@Override
64
	protected int getSqlType() {
65
		return Types.BOOLEAN;
66
	}
67

    
68
	@Override
69
	public Class<?> getTypeClass() {
70
		return Boolean.class;
71
	}
72
}
(6-6/44)