1 /*
2 * Copyright (c) 1997, 2013, 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
1053 protected void write(ContentModelContainer parent, boolean isOptional, boolean repeated) {
1054 LocalElement e = parent.element();
1055
1056 QName tn = t.getTagName();
1057
1058 PropertyInfo propInfo = t.getSource();
1059 TypeInfo parentInfo = (propInfo == null) ? null : propInfo.parent();
1060
1061 if (canBeDirectElementRef(t, tn, parentInfo)) {
1062 if ((!t.getTarget().isSimpleType()) && (t.getTarget() instanceof ClassInfo) && collisionChecker.findDuplicate((ClassInfo<T, C>) t.getTarget())) {
1063 e.ref(new QName(uri, tn.getLocalPart()));
1064 } else {
1065
1066 QName elemName = null;
1067 if (t.getTarget() instanceof Element) {
1068 Element te = (Element) t.getTarget();
1069 elemName = te.getElementName();
1070 }
1071
1072 Collection<TypeInfo> refs = propInfo.ref();
1073 TypeInfo ti;
1074 if ((refs != null) && (!refs.isEmpty()) && (elemName != null)
1075 && ((ti = refs.iterator().next()) == null || ti instanceof ClassInfoImpl)) {
1076 ClassInfoImpl cImpl = (ClassInfoImpl)ti;
1077 if ((cImpl != null) && (cImpl.getElementName() != null)) {
1078 e.ref(new QName(cImpl.getElementName().getNamespaceURI(), tn.getLocalPart()));
1079 } else {
1080 e.ref(new QName("", tn.getLocalPart()));
1081 }
1082 } else {
1083 e.ref(tn);
1084 }
1085 }
1086 } else {
1087 e.name(tn.getLocalPart());
1088 writeTypeRef(e,t, "type");
1089 elementFormDefault.writeForm(e,tn);
1090 }
1091
1092 if (t.isNillable()) {
1093 e.nillable(true);
1094 }
1095 if(t.getDefaultValue()!=null)
1096 e._default(t.getDefaultValue());
1097 writeOccurs(e,isOptional,repeated);
1098 }
1099 });
1100 }
1101
1102 final Tree choice = Tree.makeGroup(GroupKind.CHOICE, children)
1103 .makeOptional(!ep.isRequired())
1104 .makeRepeated(ep.isCollection()); // see Spec table 8-13
1105
|
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
1053 protected void write(ContentModelContainer parent, boolean isOptional, boolean repeated) {
1054 LocalElement e = parent.element();
1055
1056 QName tn = t.getTagName();
1057
1058 PropertyInfo propInfo = t.getSource();
1059 TypeInfo parentInfo = (propInfo == null) ? null : propInfo.parent();
1060
1061 if (canBeDirectElementRef(t, tn, parentInfo)) {
1062 if ((!t.getTarget().isSimpleType()) && (t.getTarget() instanceof ClassInfo) && collisionChecker.findDuplicate((ClassInfo<T, C>) t.getTarget())) {
1063 e.ref(new QName(uri, tn.getLocalPart()));
1064 } else {
1065
1066 QName elemName = null;
1067 if (t.getTarget() instanceof Element) {
1068 Element te = (Element) t.getTarget();
1069 elemName = te.getElementName();
1070 }
1071
1072 Collection<TypeInfo> refs = propInfo.ref();
1073 if ((refs != null) && (!refs.isEmpty()) && (elemName != null)){
1074 ClassInfoImpl cImpl = null;
1075 for (TypeInfo ref : refs) {
1076 if (ref == null || ref instanceof ClassInfoImpl) {
1077 if (elemName.equals(((ClassInfoImpl)ref).getElementName())) {
1078 cImpl = (ClassInfoImpl) ref;
1079 break;
1080 }
1081 }
1082 }
1083 if (cImpl != null)
1084 e.ref(new QName(cImpl.getElementName().getNamespaceURI(), tn.getLocalPart()));
1085 else
1086 e.ref(new QName("", tn.getLocalPart()));
1087 } else
1088 e.ref(tn);
1089 }
1090 } else {
1091 e.name(tn.getLocalPart());
1092 writeTypeRef(e,t, "type");
1093 elementFormDefault.writeForm(e,tn);
1094 }
1095
1096 if (t.isNillable()) {
1097 e.nillable(true);
1098 }
1099 if(t.getDefaultValue()!=null)
1100 e._default(t.getDefaultValue());
1101 writeOccurs(e,isOptional,repeated);
1102 }
1103 });
1104 }
1105
1106 final Tree choice = Tree.makeGroup(GroupKind.CHOICE, children)
1107 .makeOptional(!ep.isRequired())
1108 .makeRepeated(ep.isCollection()); // see Spec table 8-13
1109
|