Project

General

Profile

Download (2.5 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;import org.apache.logging.log4j.Logger;
15

    
16

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

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

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

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

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

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

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

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

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