01: /*
02: * Copyright 2007 Bastian Schenke Licensed under the Apache License, Version 2.0 (the "License");
03: * you may not use this file except in compliance with the License.
04: * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
05: * Unless required by applicable law or agreed to in writing, software distributed under the
06: * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
07: * either express or implied. See the License for the specific language governing permissions
08: * and limitations under the License.
09: */
10: package nz.org.take.r2ml;
11:
12: import java.util.HashMap;
13: import java.util.Map;
14:
15: import de.tu_cottbus.r2ml.RuleText;
16:
17: /**
18: * @author Bastian Schenke (bastian.schenke@googlemail.com)
19: *
20: */
21: public class RuleTextHandler implements XmlTypeHandler {
22:
23: /**
24: * Maps a RuleText to a MapEntry for use as an annotation.
25: *
26: * @param obj
27: * a RuleText
28: * @return a Map<String, String> containing all informations given by the RuleText element
29: *
30: * @see nz.org.take.r2ml.XmlTypeHandler#importObject(java.lang.Object,
31: * nz.org.take.r2ml.R2MLDriver)
32: */
33: public Object importObject(Object obj) throws R2MLException {
34: RuleText text = (RuleText) obj;
35: Map<String, String> annotations = new HashMap<String, String>();
36: if (text.getValue() != null)
37: annotations.put(RULE_TEXT_KEY, text.getValue());
38: if (text.getTextFormat() != null)
39: annotations.put(RULE_TEXT_FORMAT_KEY, text.getTextFormat());
40: if (text.getRuleDiagram() != null)
41: annotations.put(RULE_TEXT_DIAGRAM_KEY, text
42: .getRuleDiagram());
43: if (text.getRuleVocabularyDiagram() != null)
44: annotations.put(RULE_TEXT_VOCABULARY_DIAGRAM_KEY, text
45: .getRuleVocabularyDiagram());
46: return annotations;
47: }
48:
49: }
|