1
2
3
4
5
6
7
8
9 package org.jomc.model;
10
11 import javax.annotation.Generated;
12 import javax.xml.bind.annotation.XmlAccessType;
13 import javax.xml.bind.annotation.XmlAccessorType;
14 import javax.xml.bind.annotation.XmlAttribute;
15 import javax.xml.bind.annotation.XmlType;
16 import javax.xml.bind.annotation.XmlValue;
17 import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
18 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 @XmlAccessorType(XmlAccessType.FIELD)
48 @XmlType(name = "Text", namespace = "http://jomc.org/model", propOrder = {
49 "value"
50 })
51 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
52 public class Text implements Cloneable
53 {
54
55 @XmlValue
56 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
57 protected String value;
58 @XmlAttribute(name = "language", required = true)
59 @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
60 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
61 protected String language;
62 @XmlAttribute(name = "type")
63 @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
64 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
65 protected String type;
66
67
68
69
70
71 public Text() {
72
73 super();
74 }
75
76
77
78
79
80
81
82
83
84
85 public Text(final Text o) {
86
87 super();
88 if (o == null) {
89 throw new NullPointerException("Cannot create a copy of 'Text' from 'null'.");
90 }
91
92 this.value = ((o.value == null)?null:o.getValue());
93
94 this.language = ((o.language == null)?null:o.getLanguage());
95
96 this.type = ((o.type == null)?null:o.getType());
97 }
98
99
100
101
102
103
104
105
106
107 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
108 public String getValue() {
109 return value;
110 }
111
112
113
114
115
116
117
118
119
120 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
121 public void setValue(String value) {
122 this.value = value;
123 }
124
125
126
127
128
129
130
131
132
133 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
134 public String getLanguage() {
135 return language;
136 }
137
138
139
140
141
142
143
144
145
146 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
147 public void setLanguage(String value) {
148 this.language = value;
149 }
150
151
152
153
154
155
156
157
158
159 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
160 public String getType() {
161 if (type == null) {
162 return "text/plain";
163 } else {
164 return type;
165 }
166 }
167
168
169
170
171
172
173
174
175
176 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
177 public void setType(String value) {
178 this.type = value;
179 }
180
181
182
183
184
185
186
187
188 @Override
189 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
190 public Text clone() {
191 try {
192 {
193
194 final Text clone = ((Text) super.clone());
195
196 clone.value = ((this.value == null)?null:this.getValue());
197
198 clone.language = ((this.language == null)?null:this.getLanguage());
199
200 clone.type = ((this.type == null)?null:this.getType());
201 return clone;
202 }
203 } catch (CloneNotSupportedException e) {
204
205 throw new AssertionError(e);
206 }
207 }
208
209
210
211
212
213
214
215
216
217
218
219
220 public javax.activation.MimeType getMimeType() throws ModelObjectException
221 {
222 try
223 {
224 return new javax.activation.MimeType( this.getType() );
225 }
226 catch ( final javax.activation.MimeTypeParseException e )
227 {
228 throw new ModelObjectException( getMessage( "mimeTypeParseException", this.getType(),
229 getMessage( e ) ), e );
230
231 }
232 }
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247 public String getJavadocComment( final String lineSeparator, final String indentation ) throws ModelObjectException
248 {
249 if ( lineSeparator == null )
250 {
251 throw new NullPointerException( "lineSeparator" );
252 }
253 if ( indentation == null )
254 {
255 throw new NullPointerException( "indentation" );
256 }
257
258 java.io.BufferedReader reader = null;
259
260 try
261 {
262 String javadocComment = null;
263
264 if ( this.getValue() != null )
265 {
266 reader = new java.io.BufferedReader( new java.io.StringReader( this.getValue() ) );
267 final StringBuilder builder = new StringBuilder( this.getValue().length() );
268 final boolean escapeHtml = !this.getMimeType().match( "text/html" );
269
270 String line;
271 while ( ( line = reader.readLine() ) != null )
272 {
273 if ( escapeHtml )
274 {
275 builder.append( lineSeparator ).append( indentation ).append( " * " ).
276 append( line.replace( "&", "&" ).replace( "<", "<" ).replace( ">", ">" ).
277 replace( "\"", """ ).replace( "*", "∗" ) );
278
279 }
280 else
281 {
282 builder.append( lineSeparator ).append( indentation ).append( " * " ).append( line );
283 }
284 }
285
286 if ( builder.length() > 0 )
287 {
288 javadocComment =
289 builder.substring( lineSeparator.length() + indentation.length() + " * ".length() );
290
291 }
292
293 reader.close();
294 reader = null;
295 }
296
297 return javadocComment;
298 }
299 catch ( final javax.activation.MimeTypeParseException e )
300 {
301 throw new AssertionError( e );
302 }
303 catch ( final java.io.IOException e )
304 {
305 throw new AssertionError( e );
306 }
307 finally
308 {
309 try
310 {
311 if ( reader != null )
312 {
313 reader.close();
314 }
315 }
316 catch ( final java.io.IOException e )
317 {
318 throw new AssertionError( e );
319 }
320 }
321 }
322
323 private static String getMessage( final Throwable t )
324 {
325 return t != null
326 ? t.getMessage() != null && t.getMessage().trim().length() > 0
327 ? t.getMessage()
328 : getMessage( t.getCause() )
329 : null;
330
331 }
332
333 private static String getMessage( final String key, final Object... arguments )
334 {
335 return java.text.MessageFormat.format( java.util.ResourceBundle.getBundle(
336 Text.class.getName().replace( '.', '/' ), java.util.Locale.getDefault() ).
337 getString( key ), arguments );
338
339 }
340
341 }