Project

General

Profile

Download (2.24 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;
11

    
12
import java.util.ArrayList;
13
import java.util.HashSet;
14
import java.util.List;
15
import java.util.Set;
16

    
17
import org.apache.log4j.Logger;
18

    
19
import eu.etaxonomy.cdm.io.common.mapping.CdmAttributeMapperBase;
20

    
21
/**
22
 * @author a.mueller
23
 * @created 05.08.2008
24
 * @version 1.0
25
 */
26
public abstract class CdmSingleAttributeMapperBase extends CdmAttributeMapperBase{
27
	@SuppressWarnings("unused")
28
	private static final Logger logger = Logger.getLogger(CdmSingleAttributeMapperBase.class);
29
	
30
	private String sourceValue;
31
	private String destinationValue;
32
	protected Object defaultValue;
33

    
34
	protected CdmSingleAttributeMapperBase(String sourceAttributString, String destinationAttributeString){
35
		this(sourceAttributString,destinationAttributeString, null);
36
	}
37

    
38
	protected CdmSingleAttributeMapperBase(String sourceAttributString, String destinationAttributeString, Object defaultValue){
39
		this.sourceValue = sourceAttributString;
40
		this.destinationValue = destinationAttributeString;
41
		this.defaultValue = defaultValue;
42
	}
43

    
44
	
45
	public String getSourceAttribute(){
46
		return sourceValue;
47
	}
48
	
49
	public String getDestinationAttribute(){
50
		return destinationValue;
51
	}
52
	
53
	@Override
54
	public Set<String> getSourceAttributes(){
55
		Set<String>  result = new HashSet<String>();
56
		result.add(sourceValue);
57
		return result;
58
	}
59

    
60
	@Override
61
	public Set<String>  getDestinationAttributes(){
62
		Set<String>  result = new HashSet<String>();
63
		if(destinationValue != null){
64
			result.add(destinationValue);
65
		}
66
		return result;
67
	}
68
	
69
	
70
	@Override
71
	public List<String> getSourceAttributeList(){
72
		List<String>  result = new ArrayList<String>();
73
		result.add(sourceValue);
74
		return result;
75
	}
76

    
77
	@Override
78
	public List<String>  getDestinationAttributeList(){
79
		List<String>  result = new ArrayList<String>();
80
		if(destinationValue != null){
81
			result.add(destinationValue);
82
		}
83
		return result;
84
	}
85
	
86
	public abstract Class getTypeClass();
87
}
(4-4/51)