Project

General

Profile

« Previous | Next » 

Revision f905a388

Added by Andreas Müller almost 2 years ago

cleanup

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/mapping/out/DbNullMapper.java
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
import eu.etaxonomy.cdm.io.common.DbExportStateBase;
17
import eu.etaxonomy.cdm.model.common.CdmBase;
18

  
19
/**
20
 * Mapper that inserts <code>null</code> to the target field.
21
 *
22
 * @see DbExportIgnoreMapper
23
 * @see DbExportNotYetImplementedMapper
24
 *
25
 * @author a.mueller
26
 * @since 12.05.2009
27
 */
28
public class DbNullMapper
29
        extends DbSingleAttributeExportMapperBase<DbExportStateBase<?, IExportTransformer>> {
30

  
31
    @SuppressWarnings("unused")
32
	private static final Logger logger = LogManager.getLogger(DbNullMapper.class);
33

  
34
    private int sqlType;
35

  
36
	public static DbNullMapper NewInstance(String dbIdAttributeString, int sqlType){
37
		return new DbNullMapper(dbIdAttributeString, sqlType);
38
	}
39

  
40
    public static DbNullMapper NewIntegerInstance(String dbIdAttributeString){
41
        return new DbNullMapper(dbIdAttributeString, Types.INTEGER);
42
    }
43

  
44
    public static DbNullMapper NewStringInstance(String dbIdAttributeString){
45
        return new DbNullMapper(dbIdAttributeString, Types.NVARCHAR);
46
    }
47

  
48
	protected DbNullMapper(String dbAttributeString, int sqlType) {
49
		super(null, dbAttributeString, null);
50
		this.sqlType = sqlType;
51
	}
52

  
53
	@Override
54
	public Class<?> getTypeClass() {
55
		return Integer.class;
56
	}
57

  
58
	@Override
59
	protected Object getValue(CdmBase cdmBase) {
60
		return null;
61
	}
62

  
63
	@Override
64
	protected int getSqlType() {
65
		return this.sqlType;
66
	}
67
}
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
}

Also available in: Unified diff