Project

General

Profile

Download (3.81 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.model.description;
11

    
12
import org.apache.log4j.Logger;
13
import org.hibernate.annotations.Cascade;
14
import org.hibernate.annotations.CascadeType;
15

    
16
import eu.etaxonomy.cdm.model.common.Language;
17
import eu.etaxonomy.cdm.model.common.LanguageString;
18

    
19
import java.util.*;
20
import javax.persistence.*;
21

    
22
/**
23
 * This class represents information pieces expressed in categorical type of
24
 * data (in opposition to {@link QuantitativeData quantitative data} on one side and to literal data on
25
 * the other side). Only {@link TaxonDescription taxon descriptions} and
26
 * {@link SpecimenDescription specimen descriptions} may contain categorical data.<BR>
27
 * The "color of petals" {@link Feature feature} for instance can be described with
28
 * {@link State state terms} such as "blue" or "white". If the color of petals of a
29
 * particular tree is described as "mostly blue" and "exceptionally white" two
30
 * {@link StateData state data} instances must be assigned to an instance of the
31
 * present class: the first one with the state "blue" and the {@link Modifier modifier}
32
 * "mostly" and the second one with the state "white" and the modifier "exceptionally".  
33
 * <P>
34
 * This class corresponds partially to CodedDescriptionType according to
35
 * the SDD schema.
36
 * 
37
 * @author m.doering
38
 * @version 1.0
39
 * @created 08-Nov-2007 13:06:15
40
 */
41
@Entity
42
public class CategoricalData extends DescriptionElementBase {
43
	static Logger logger = Logger.getLogger(CategoricalData.class);
44

    
45
	
46
	//whether the sequence of ordered states is important
47
	private boolean orderRelevant;
48
	private List<State> states = new ArrayList();
49

    
50
	
51
	/** 
52
	 * Class constructor: creates a new empty categorical data instance.
53
	 */
54
	protected CategoricalData() {
55
		super(null);
56
	}
57
	
58
	/** 
59
	 * Creates a new empty categorical data instance.
60
	 */
61
	public static CategoricalData NewInstance(){
62
		return new CategoricalData();
63
	}
64
	
65
	/** 
66
	 * Returns the (ordered) list of {@link State states} describing the {@link Feature feature}
67
	 * corresponding to <i>this</i> categorical data.
68
	 */
69
	@ManyToMany
70
	@Cascade({CascadeType.SAVE_UPDATE})
71
	public List<State> getStates(){
72
		return this.states;
73
	}
74
	/**
75
	 * @see	#getStates() 
76
	 */
77
	private void setStates(List<State> states){
78
		this.states = states;
79
	}
80
	/**
81
	 * Adds a {@link State state} to the list of {@link #getStates() states}
82
	 * describing the {@link Feature feature} corresponding to <i>this</i> categorical data.
83
	 * 
84
	 * @param state	the state to be added to <i>this</i> categorical data
85
	 * @see    	   	#getStates()
86
	 */
87
	public void addState(State state){
88
		this.states.add(state);
89
	}
90
	/** 
91
	 * Removes one element from the set of {@link #getStates() states}
92
	 * describing the {@link Feature feature} corresponding to <i>this</i> categorical data.
93
	 *
94
	 * @param  state	the state which should be removed
95
	 * @see     		#getStates()
96
	 * @see     		#addState(State)
97
	 */
98
	public void removeState(State state){
99
		this.states.remove(state);
100
	}
101

    
102
	/**
103
	 * Returns the boolean value of the flag indicating whether the {@link StateData state data}
104
	 * belonging to <i>this</i> categorical data should be treated as an
105
	 * {@link List "ordered" list} (true) according to the {@link State states} or as an
106
	 * {@link Set "unordered" set} (false). The use of this flag depends mostly
107
	 * on the {@link Feature feature} of <i>this</i> categorical data.
108
	 *  
109
	 * @return  the boolean value of the orderRelevant flag
110
	 */
111
	public boolean getOrderRelevant(){
112
		return this.orderRelevant;
113
	}
114
	/**
115
	 * @see	#getOrderRelevant() 
116
	 */
117
	public void setOrderRelevant(boolean orderRelevant){
118
		this.orderRelevant = orderRelevant;
119
	}
120

    
121
}
(2-2/30)