src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/xmlschema/ct/MultiWildcardComplexTypeBuilder.java

Wed, 27 Apr 2016 01:27:09 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:27:09 +0800
changeset 0
373ffda63c9a
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/jaxws/
changeset: 657:d47a47f961ee
tag: jdk8u25-b17

     1 /*
     2  * Copyright (c) 1997, 2011, 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
    23  * questions.
    24  */
    26 package com.sun.tools.internal.xjc.reader.xmlschema.ct;
    28 import com.sun.tools.internal.xjc.model.CBuiltinLeafInfo;
    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.BIProperty;
    33 import static com.sun.tools.internal.xjc.reader.xmlschema.ct.ComplexTypeBindingMode.FALLBACK_CONTENT;
    34 import com.sun.xml.internal.xsom.XSComplexType;
    35 import com.sun.xml.internal.xsom.XSContentType;
    36 import com.sun.xml.internal.xsom.XSParticle;
    37 import com.sun.xml.internal.xsom.XSType;
    39 /**
    40  * @author Kohsuke Kawaguchi
    41  */
    42 final class MultiWildcardComplexTypeBuilder extends CTBuilder {
    44     public boolean isApplicable(XSComplexType ct) {
    45         if (!bgmBuilder.model.options.contentForWildcard) {
    46             return false;
    47         }
    48         XSType bt = ct.getBaseType();
    49         if (bt ==schemas.getAnyType() && ct.getContentType() != null) {
    50             XSParticle part = ct.getContentType().asParticle();
    51             if ((part != null) && (part.getTerm().isModelGroup())) {
    52                 XSParticle[] parts = part.getTerm().asModelGroup().getChildren();
    53                 int wildcardCount = 0;
    54                 int i = 0;
    55                 while ((i < parts.length) && (wildcardCount <= 1)) {
    56                     if (parts[i].getTerm().isWildcard()) {
    57                         wildcardCount += 1;
    58                     }
    59                     i++;
    60                 }
    61                 return (wildcardCount > 1);
    62             }
    63         }
    64         return false;
    65     }
    67     public void build(XSComplexType ct) {
    68         XSContentType contentType = ct.getContentType();
    70         builder.recordBindingMode(ct, FALLBACK_CONTENT);
    71         BIProperty prop = BIProperty.getCustomization(ct);
    73         CPropertyInfo p;
    75         if(contentType.asEmpty()!=null) {
    76             p = prop.createValueProperty("Content",false,ct,CBuiltinLeafInfo.STRING,null);
    77         } else {
    78             RawTypeSet ts = RawTypeSetBuilder.build(contentType.asParticle(),false);
    79             p = prop.createReferenceProperty("Content", false, ct, ts, true, false, true, false);
    80         }
    82         selector.getCurrentBean().addProperty(p);
    84         // adds attributes and we are through.
    85         green.attContainer(ct);
    86     }
    88 }

mercurial