author | mkos |
Sun, 30 Dec 2012 00:00:00 +0100 | |
changeset 22678 | ac1ea46be942 |
parent 12009 | 4abb694f273a |
permissions | -rw-r--r-- |
12009 | 1 |
/* |
22678
ac1ea46be942
8029237: Update copyright year to match last edit in jaxws repository for 2012
mkos
parents:
12009
diff
changeset
|
2 |
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
12009 | 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 |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package com.sun.tools.internal.xjc.reader.xmlschema.ct; |
|
27 |
||
28 |
import com.sun.tools.internal.xjc.model.CClass; |
|
29 |
import com.sun.tools.internal.xjc.model.CPropertyInfo; |
|
30 |
import com.sun.tools.internal.xjc.reader.RawTypeSet; |
|
31 |
import com.sun.tools.internal.xjc.reader.xmlschema.RawTypeSetBuilder; |
|
32 |
import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIGlobalBinding; |
|
33 |
import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIProperty; |
|
34 |
import com.sun.xml.internal.xsom.XSComplexType; |
|
35 |
import com.sun.xml.internal.xsom.XSContentType; |
|
36 |
import com.sun.xml.internal.xsom.XSType; |
|
37 |
||
38 |
/** |
|
39 |
* @author Kohsuke Kawaguchi |
|
40 |
*/ |
|
41 |
final class MixedExtendedComplexTypeBuilder extends AbstractExtendedComplexTypeBuilder { |
|
42 |
||
43 |
public boolean isApplicable(XSComplexType ct) { |
|
44 |
||
45 |
if (!bgmBuilder.isGenerateMixedExtensions()) return false; |
|
46 |
||
47 |
XSType bt = ct.getBaseType(); |
|
48 |
if (bt.isComplexType() && |
|
49 |
bt.asComplexType().isMixed() && |
|
50 |
ct.isMixed() && |
|
51 |
ct.getDerivationMethod()==XSType.EXTENSION && |
|
52 |
ct.getContentType().asParticle() != null && |
|
53 |
ct.getExplicitContent().asEmpty() == null |
|
54 |
) { |
|
55 |
return true; |
|
56 |
} |
|
57 |
||
58 |
return false; |
|
59 |
} |
|
60 |
||
61 |
public void build(XSComplexType ct) { |
|
62 |
XSComplexType baseType = ct.getBaseType().asComplexType(); |
|
63 |
||
64 |
// build the base class |
|
65 |
CClass baseClass = selector.bindToType(baseType, ct, true); |
|
66 |
assert baseClass != null; // global complex type must map to a class |
|
67 |
||
68 |
if (!checkIfExtensionSafe(baseType, ct)) { |
|
69 |
// error. We can't handle any further extension |
|
70 |
errorReceiver.error(ct.getLocator(), |
|
71 |
Messages.ERR_NO_FURTHER_EXTENSION.format( |
|
72 |
baseType.getName(), ct.getName() ) |
|
73 |
); |
|
74 |
return; |
|
75 |
} |
|
76 |
||
77 |
selector.getCurrentBean().setBaseClass(baseClass); |
|
78 |
builder.recordBindingMode(ct, ComplexTypeBindingMode.FALLBACK_EXTENSION); |
|
79 |
||
80 |
BIProperty prop = BIProperty.getCustomization(ct); |
|
81 |
CPropertyInfo p; |
|
82 |
||
83 |
RawTypeSet ts = RawTypeSetBuilder.build(ct.getContentType().asParticle(), false); |
|
84 |
p = prop.createDummyExtendedMixedReferenceProperty("contentOverrideFor" + ct.getName(), ct, ts); |
|
85 |
||
86 |
selector.getCurrentBean().addProperty(p); |
|
87 |
||
88 |
// adds attributes and we are through. |
|
89 |
green.attContainer(ct); |
|
90 |
} |
|
91 |
||
92 |
} |