Project

General

Profile

Download (2.1 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.log4j.Logger;
15

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

    
19
/**
20
 * @author a.mueller
21
 * @since 12.05.2009
22
 * @version 1.0
23
 */
24
public class DbSequenceMapper extends DbSingleAttributeExportMapperBase<DbExportStateBase<?, IExportTransformer>> implements IDbExportMapper<DbExportStateBase<?, IExportTransformer>, IExportTransformer>{
25
	@SuppressWarnings("unused")
26
	private static final Logger logger = Logger.getLogger(DbSequenceMapper.class);
27
	private int sqlType = Types.INTEGER; ;
28
	private int sequence;
29
	private int start = 0;
30
	
31
	public static DbSequenceMapper NewInstance(String dbAttributeString){
32
		return new DbSequenceMapper(dbAttributeString, 0);
33
	}
34

    
35
	
36
	public static DbSequenceMapper NewInstance(String dbAttributeString, int start){
37
		return new DbSequenceMapper(dbAttributeString, start);
38
	}
39
	
40
	/**
41
	 * @param dbAttributString
42
	 * @param cdmAttributeString
43
	 */
44
	protected DbSequenceMapper(String dbAttributeString, int start) {
45
		super(null, dbAttributeString, null);
46
		this.start = start;
47
		this.reset();
48
	}
49
	
50
	public void reset(){
51
		this.sequence = this.start;
52
	}
53

    
54

    
55
	/* (non-Javadoc)
56
	 * @see eu.etaxonomy.cdm.io.common.CdmSingleAttributeMapperBase#getTypeClass()
57
	 */
58
	@Override
59
	public Class<?> getTypeClass() {
60
		return Integer.class;
61
	}
62

    
63
	/* (non-Javadoc)
64
	 * @see eu.etaxonomy.cdm.io.berlinModel.out.mapper.DbSingleAttributeExportMapperBase#getValue()
65
	 */
66
	@Override
67
	protected Object getValue(CdmBase cdmBase) {
68
		return this.sequence++;
69
	}
70
	
71
	
72

    
73
	/* (non-Javadoc)
74
	 * @see eu.etaxonomy.cdm.io.berlinModel.out.mapper.DbSingleAttributeExportMapperBase#getValueType()
75
	 */
76
	@Override
77
	protected int getSqlType() {
78
		return this.sqlType;
79
	}
80
	
81
}
(25-25/40)