Project

General

Profile

Download (1.46 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 org.apache.logging.log4j.LogManager;
13
import org.apache.logging.log4j.Logger;
14

    
15
import eu.etaxonomy.cdm.io.common.DbExportStateBase;
16
import eu.etaxonomy.cdm.model.common.CdmBase;
17

    
18
/**
19
 * Maps to a constant value.
20
 *
21
 * TODO deduplicate with {@link DbFixedIntegerMapper} and {@link DbFixedStringMapper}.
22
 *
23
 * @author a.mueller
24
 * @since 12.05.2009
25
 */
26
public class DbConstantMapper
27
        extends DbSingleAttributeExportMapperBase<DbExportStateBase<?, IExportTransformer>>{
28

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

    
32
	private int sqlType;
33
	private Object value;
34

    
35
	public static DbConstantMapper NewInstance(String dbIdAttributeString, int sqlType, Object value){
36
		return new DbConstantMapper(dbIdAttributeString, sqlType, value);
37
	}
38

    
39
	protected DbConstantMapper(String dbAttributeString, int sqlType, Object value) {
40
		super(null, dbAttributeString, null);
41
		this.sqlType = sqlType;
42
		this.value = value;
43
	}
44

    
45
	@Override
46
	public Class<?> getTypeClass() {
47
		return Integer.class;
48
	}
49

    
50
	@Override
51
	protected Object getValue(CdmBase cdmBase) {
52
		return value;
53
	}
54

    
55
	@Override
56
	protected int getSqlType() {
57
		return this.sqlType;
58
	}
59
}
(8-8/44)