1
|
package eu.etaxonomy.cdm.remote.editor;
|
2
|
|
3
|
import java.beans.PropertyEditorSupport;
|
4
|
|
5
|
import eu.etaxonomy.cdm.remote.dto.oaipmh.SetSpec;
|
6
|
|
7
|
public class SetSpecEditor extends PropertyEditorSupport {
|
8
|
|
9
|
public void setAsText(String text) {
|
10
|
if(text == null) {
|
11
|
throw new IllegalArgumentException("null is not an acceptable set spec");
|
12
|
} else {
|
13
|
boolean matched = false;
|
14
|
for(SetSpec setSpec : SetSpec.values()) {
|
15
|
if(setSpec.name().equals(text)) {
|
16
|
setValue(setSpec);
|
17
|
break;
|
18
|
}
|
19
|
}
|
20
|
if(!matched) {
|
21
|
throw new IllegalArgumentException(text + " is not an acceptable set spec");
|
22
|
}
|
23
|
}
|
24
|
}
|
25
|
|
26
|
public String getAsText() {
|
27
|
if(getValue() == null) {
|
28
|
return null;
|
29
|
} else {
|
30
|
return ((SetSpec)getValue()).name();
|
31
|
}
|
32
|
}
|
33
|
}
|