Project

General

Profile

Download (1.92 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
import eu.etaxonomy.cdm.model.common.CdmBase;
18
import eu.etaxonomy.cdm.model.common.ExtensionType;
19

    
20
/**
21
 * @author a.mueller
22
 * @since 10.06.2009
23
 */
24
public class DbIntegerExtensionMapper extends DbExtensionMapper {
25

    
26
	private static final Logger logger = LogManager.getLogger();
27

    
28
	public static DbIntegerExtensionMapper NewInstance(ExtensionType extensionType, String dbAttributeString){
29
		return new DbIntegerExtensionMapper(extensionType, dbAttributeString);
30
	}
31

    
32

    
33
	/**
34
	 * @param dbAttributeString
35
	 * @param cdmAttributeString
36
	 */
37
	private DbIntegerExtensionMapper(ExtensionType extensionType, String dbAttributeString) {
38
		super(extensionType, dbAttributeString);
39
	}
40

    
41
	/* (non-Javadoc)
42
	 * @see eu.etaxonomy.cdm.io.berlinModel.out.mapper.DbAnnotationMapper#getValue(eu.etaxonomy.cdm.model.common.CdmBase)
43
	 */
44
	@Override
45
	protected Object getValue(CdmBase cdmBase) {
46
		String strValue = (String)super.getValue(cdmBase);
47
		Integer intValue;
48
		try {
49
			intValue = (strValue == null) ? null : Integer.valueOf(strValue);
50
		} catch (NumberFormatException e) {
51
			logger.warn("Annotation could not be casted to Integer: " + strValue);
52
			return null;
53
		}
54
		return intValue;
55
	}
56

    
57
	/* (non-Javadoc)
58
	 * @see eu.etaxonomy.cdm.io.berlinModel.out.mapper.DbAnnotationMapper#getSqlType()
59
	 */
60
	@Override
61
	protected int getSqlType() {
62
		return Types.INTEGER;
63
	}
64

    
65
	/* (non-Javadoc)
66
	 * @see eu.etaxonomy.cdm.io.berlinModel.out.mapper.DbAnnotationMapper#getTypeClass()
67
	 */
68
	@Override
69
	public Class<?> getTypeClass() {
70
		return Integer.class;
71
	}
72

    
73

    
74

    
75

    
76

    
77
}
(21-21/44)