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
|
import eu.etaxonomy.cdm.io.common.DbExportStateBase;
|
18
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
19
|
|
20
|
/**
|
21
|
* Mapper that inserts <code>null</code> to the target field.
|
22
|
*
|
23
|
* @see DbExportIgnoreMapper
|
24
|
* @see DbExportNotYetImplementedMapper
|
25
|
*
|
26
|
* @author a.mueller
|
27
|
* @since 12.05.2009
|
28
|
*/
|
29
|
public class DbNullMapper
|
30
|
extends DbSingleAttributeExportMapperBase<DbExportStateBase<?, IExportTransformer>> {
|
31
|
|
32
|
@SuppressWarnings("unused")
|
33
|
private static final Logger logger = LogManager.getLogger();
|
34
|
|
35
|
private int sqlType;
|
36
|
|
37
|
public static DbNullMapper NewInstance(String dbIdAttributeString, int sqlType){
|
38
|
return new DbNullMapper(dbIdAttributeString, sqlType);
|
39
|
}
|
40
|
|
41
|
public static DbNullMapper NewIntegerInstance(String dbIdAttributeString){
|
42
|
return new DbNullMapper(dbIdAttributeString, Types.INTEGER);
|
43
|
}
|
44
|
|
45
|
public static DbNullMapper NewStringInstance(String dbIdAttributeString){
|
46
|
return new DbNullMapper(dbIdAttributeString, Types.NVARCHAR);
|
47
|
}
|
48
|
|
49
|
protected DbNullMapper(String dbAttributeString, int sqlType) {
|
50
|
super(null, dbAttributeString, null);
|
51
|
this.sqlType = sqlType;
|
52
|
}
|
53
|
|
54
|
@Override
|
55
|
public Class<?> getTypeClass() {
|
56
|
return Integer.class;
|
57
|
}
|
58
|
|
59
|
@Override
|
60
|
protected Object getValue(CdmBase cdmBase) {
|
61
|
return null;
|
62
|
}
|
63
|
|
64
|
@Override
|
65
|
protected int getSqlType() {
|
66
|
return this.sqlType;
|
67
|
}
|
68
|
}
|