1
|
package eu.etaxonomy.cdm.remote.editor;
|
2
|
|
3
|
import java.beans.PropertyEditorSupport;
|
4
|
|
5
|
import eu.etaxonomy.cdm.remote.dto.oaipmh.MetadataPrefix;
|
6
|
import eu.etaxonomy.cdm.remote.exception.CannotDisseminateFormatException;
|
7
|
|
8
|
public class MetadataPrefixEditor extends PropertyEditorSupport {
|
9
|
|
10
|
public void setAsText(String text) {
|
11
|
if(text == null) {
|
12
|
throw new IllegalArgumentException("null is not an acceptable metadata format");
|
13
|
} else {
|
14
|
MetadataPrefix metadatPrefix = MetadataPrefix.value(text);
|
15
|
if(metadatPrefix != null){
|
16
|
setValue(metadatPrefix);
|
17
|
|
18
|
// if(text.equals("rdf")) {
|
19
|
// setValue(MetadataPrefix.RDF);
|
20
|
// } else if(text.equals("oai_dc")) {
|
21
|
// setValue(MetadataPrefix.OAI_DC);
|
22
|
} else {
|
23
|
throw new CannotDisseminateFormatException(text + " is not an acceptable metadata format");
|
24
|
}
|
25
|
}
|
26
|
}
|
27
|
|
28
|
public String getAsText() {
|
29
|
if(getValue() == null) {
|
30
|
return null;
|
31
|
} else {
|
32
|
return ((MetadataPrefix)getValue()).name();
|
33
|
}
|
34
|
}
|
35
|
}
|