1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package de.smartics.properties.spi.core.metadata.projectdoc;
17
18 import java.util.Locale;
19
20 import org.jdom.Document;
21 import org.jdom.Element;
22 import org.jdom.Namespace;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25
26 import de.smartics.properties.api.core.domain.PropertiesContext;
27 import de.smartics.properties.api.core.domain.PropertyDescriptor;
28 import de.smartics.properties.api.core.domain.PropertySetProjectdoc;
29 import de.smartics.properties.spi.core.metadata.projectdoc.ProjectdocAnnotationCollector.Defaults;
30
31
32
33
34 public final class PropertySetProjectdocParser extends ProjectdocMetaDataParser
35 {
36
37
38
39
40
41
42
43 private static final Logger LOG = LoggerFactory
44 .getLogger(PropertySetProjectdocParser.class);
45
46
47
48
49 protected static final Namespace NS =
50 Namespace
51 .getNamespace("http://www.smartics.de/schema/projectdoc/doctype/property-set/1");
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66 public PropertySetProjectdocParser(final PropertiesContext context)
67 throws NullPointerException
68 {
69 super(context);
70 }
71
72
73
74
75
76
77
78
79
80 public PropertySetProjectdocParser(final PropertiesContext context,
81 final Defaults defaults) throws NullPointerException
82 {
83 super(context, defaults);
84 }
85
86
87
88
89
90
91
92
93
94
95
96 @Override
97 protected String calcPath(final PropertyDescriptor descriptor,
98 final Locale locale)
99 {
100 return context.createMetaInfPathPropertySet(descriptor, locale);
101 }
102
103 @Override
104 public PropertySetProjectdoc parse(final PropertyDescriptor descriptor,
105 final Locale locale)
106 {
107 try
108 {
109 final PropertySetProjectdoc projectdoc = new PropertySetProjectdoc();
110 parseBase(descriptor, locale, projectdoc);
111 return projectdoc;
112 }
113 catch (final MetaDataException e)
114 {
115 LOG.warn("Cannot parse property set document for property '{}': {}",
116 descriptor, e);
117 return null;
118 }
119 }
120
121 @Override
122 protected void parseAdditional(final ParserContext context)
123 {
124 final PropertySetProjectdoc projectdoc =
125 (PropertySetProjectdoc) context.getMetaData();
126
127 addPropertySetComment(projectdoc, context);
128 }
129
130 private void addPropertySetComment(final PropertySetProjectdoc projectdoc,
131 final ParserContext context)
132 {
133 final Document document = context.getDocument();
134 final Element rootNode = document.getRootElement();
135
136 final String specification =
137 rootNode.getChildTextNormalize("specification", NS);
138
139 projectdoc.setComment(specification);
140 }
141
142 @Override
143 protected Namespace getNs()
144 {
145 return NS;
146 }
147
148
149
150 }