1 /*
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
212 else
213 declaredType = implType.boxify().dotclass();
214 JExpression scopeClass = scope==null?JExpr._null():scope.dotclass();
215
216 // build up the return extpression
217 JInvocation exp = JExpr._new(exposedElementType);
218 if(!ei.hasClass()) {
219 exp.arg(getQNameInvocation(ei));
220 exp.arg(declaredType);
221 exp.arg(scopeClass);
222 }
223 if(implType==exposedType)
224 exp.arg($value);
225 else
226 exp.arg(JExpr.cast(implType,$value));
227
228 m.body()._return( exp );
229
230 m.javadoc()
231 .append("Create an instance of ")
232 .append(exposedElementType)
233 .append("}");
234
235 XmlElementDeclWriter xemw = m.annotate2(XmlElementDeclWriter.class);
236 xemw.namespace(namespaceURI).name(localPart);
237 if(scope!=null)
238 xemw.scope(scope);
239
240 if(ei.getSubstitutionHead()!=null) {
241 QName n = ei.getSubstitutionHead().getElementName();
242 xemw.substitutionHeadNamespace(n.getNamespaceURI());
243 xemw.substitutionHeadName(n.getLocalPart());
244 }
245
246 if(ei.getDefaultValue()!=null)
247 xemw.defaultValue(ei.getDefaultValue());
248
249 if(ei.getProperty().inlineBinaryData())
250 m.annotate(XmlInlineBinaryData.class);
251
252 // if the element is adapter, put that annotation on the factory method
253 outline.generateAdapterIfNecessary(ei.getProperty(),m);
|
1 /*
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
212 else
213 declaredType = implType.boxify().dotclass();
214 JExpression scopeClass = scope==null?JExpr._null():scope.dotclass();
215
216 // build up the return extpression
217 JInvocation exp = JExpr._new(exposedElementType);
218 if(!ei.hasClass()) {
219 exp.arg(getQNameInvocation(ei));
220 exp.arg(declaredType);
221 exp.arg(scopeClass);
222 }
223 if(implType==exposedType)
224 exp.arg($value);
225 else
226 exp.arg(JExpr.cast(implType,$value));
227
228 m.body()._return( exp );
229
230 m.javadoc()
231 .append("Create an instance of ")
232 .append(exposedElementType);
233 m.javadoc().addParam($value)
234 .append("Java instance representing xml element's value.");
235 m.javadoc().addReturn()
236 .append("the new instance of ")
237 .append(exposedElementType);
238
239 XmlElementDeclWriter xemw = m.annotate2(XmlElementDeclWriter.class);
240 xemw.namespace(namespaceURI).name(localPart);
241 if(scope!=null)
242 xemw.scope(scope);
243
244 if(ei.getSubstitutionHead()!=null) {
245 QName n = ei.getSubstitutionHead().getElementName();
246 xemw.substitutionHeadNamespace(n.getNamespaceURI());
247 xemw.substitutionHeadName(n.getLocalPart());
248 }
249
250 if(ei.getDefaultValue()!=null)
251 xemw.defaultValue(ei.getDefaultValue());
252
253 if(ei.getProperty().inlineBinaryData())
254 m.annotate(XmlInlineBinaryData.class);
255
256 // if the element is adapter, put that annotation on the factory method
257 outline.generateAdapterIfNecessary(ei.getProperty(),m);
|