com.sun.xml.internal.xsom.XSParticle Java Examples

The following examples show how to use com.sun.xml.internal.xsom.XSParticle. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultParticleBinder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void particle( XSParticle p ) {
    XSTerm t = p.getTerm();

    if(marked(p)) {
        BIProperty cust = BIProperty.getCustomization(p);
        CPropertyInfo prop = cust.createElementOrReferenceProperty(
            getLabel(p), false, p, RawTypeSetBuilder.build(p,insideOptionalParticle));
        getCurrentBean().addProperty(prop);
    } else {
        // repeated model groups should have been marked already
        assert !p.isRepeated();

        boolean oldIOP = insideOptionalParticle;
        insideOptionalParticle |= BigInteger.ZERO.equals(p.getMinOccurs());
        // this is an unmarked particle
        t.visit(this);
        insideOptionalParticle = oldIOP;
    }
}
 
Example #2
Source File: ChoiceContentComplexTypeBuilder.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public boolean isApplicable(XSComplexType ct) {
    if( !bgmBuilder.getGlobalBinding().isChoiceContentPropertyEnabled() )
        return false;

    if( ct.getBaseType()!=schemas.getAnyType() )
        // My reading of the spec is that if a complex type is
        // derived from another complex type by extension,
        // its top level model group is always a sequence
        // that combines the base type content model and
        // the extension defined in the new complex type.
        return false;

    XSParticle p = ct.getContentType().asParticle();
    if(p==null)
        return false;

    XSModelGroup mg = getTopLevelModelGroup(p);

    if( mg.getCompositor()!=XSModelGroup.CHOICE )
        return false;

    if( p.isRepeated() )
        return false;

    return true;
}
 
Example #3
Source File: DefaultParticleBinder.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void particle( XSParticle p ) {
    XSTerm t = p.getTerm();

    if(marked(p)) {
        BIProperty cust = BIProperty.getCustomization(p);
        CPropertyInfo prop = cust.createElementOrReferenceProperty(
            getLabel(p), false, p, RawTypeSetBuilder.build(p,insideOptionalParticle));
        getCurrentBean().addProperty(prop);
    } else {
        // repeated model groups should have been marked already
        assert !p.isRepeated();

        boolean oldIOP = insideOptionalParticle;
        insideOptionalParticle |= BigInteger.ZERO.equals(p.getMinOccurs());
        // this is an unmarked particle
        t.visit(this);
        insideOptionalParticle = oldIOP;
    }
}
 
Example #4
Source File: ExpressionParticleBinder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds a {@link XSParticle} that can serve as the representative property of
 * the given {@link ConnectedComponent}.
 *
 * The representative property is used for reporting an error location and
 * taking {@link BIProperty} customization. Right now, the algorithm is just pick
 * the first one with {@link BIProperty}, but one can think of a better algorithm,
 * such as taking a choice of (A|B) if CC={A,B}.
 */
private XSParticle findSourceParticle(ConnectedComponent cc) {
    XSParticle first = null;

    for (Element e : cc) {
        GElement ge = (GElement)e;
        for (XSParticle p : ge.particles) {
            if(first==null)
                first = p;
            if(getLocalPropCustomization(p)!=null)
                return p;
        }
        // if there are multiple property customizations,
        // all but one will be left unused, which will be detected as an error
        // later, so no need to check that now.
    }

    // if no customization was found, just use the first one.
    return first;
}
 
Example #5
Source File: ExpressionParticleBinder.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds a {@link XSParticle} that can serve as the representative property of
 * the given {@link ConnectedComponent}.
 *
 * The representative property is used for reporting an error location and
 * taking {@link BIProperty} customization. Right now, the algorithm is just pick
 * the first one with {@link BIProperty}, but one can think of a better algorithm,
 * such as taking a choice of (A|B) if CC={A,B}.
 */
private XSParticle findSourceParticle(ConnectedComponent cc) {
    XSParticle first = null;

    for (Element e : cc) {
        GElement ge = (GElement)e;
        for (XSParticle p : ge.particles) {
            if(first==null)
                first = p;
            if(getLocalPropCustomization(p)!=null)
                return p;
        }
        // if there are multiple property customizations,
        // all but one will be left unused, which will be detected as an error
        // later, so no need to check that now.
    }

    // if no customization was found, just use the first one.
    return first;
}
 
Example #6
Source File: MultiplicityCounter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public Multiplicity modelGroup(XSModelGroup group) {
    boolean isChoice = group.getCompositor() == XSModelGroup.CHOICE;

    Multiplicity r = ZERO;

    for( XSParticle p : group.getChildren()) {
        Multiplicity m = particle(p);

        if(r==null) {
            r=m;
            continue;
        }
        if(isChoice) {
            r = Multiplicity.choice(r,m);
        } else {
            r = Multiplicity.group(r,m);
        }
    }
    return r;
}
 
Example #7
Source File: BIProperty.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private CCustomizations getCustomizations( XSParticle src ) {
    // customizations for a particle  should include those defined in the term unless it's global
    // this is so that the schema like:
    //
    // <xs:sequence>
    //   <xs:element name="foo" type="xs:int">
    //     <xs:annotation><xs:appinfo>
    //       <hyperjaxb:... />
    //
    // would be picked up
    if(src.getTerm().isElementDecl()) {
        XSElementDecl xed = src.getTerm().asElementDecl();
        if(xed.isGlobal())
            return getCustomizations((XSComponent)src);
    }

    return getCustomizations(src,src.getTerm());
}
 
Example #8
Source File: MultiWildcardComplexTypeBuilder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public boolean isApplicable(XSComplexType ct) {
    if (!bgmBuilder.model.options.contentForWildcard) {
        return false;
    }
    XSType bt = ct.getBaseType();
    if (bt ==schemas.getAnyType() && ct.getContentType() != null) {
        XSParticle part = ct.getContentType().asParticle();
        if ((part != null) && (part.getTerm().isModelGroup())) {
            XSParticle[] parts = part.getTerm().asModelGroup().getChildren();
            int wildcardCount = 0;
            int i = 0;
            while ((i < parts.length) && (wildcardCount <= 1)) {
                if (parts[i].getTerm().isWildcard()) {
                    wildcardCount += 1;
                }
                i++;
            }
            return (wildcardCount > 1);
        }
    }
    return false;
}
 
Example #9
Source File: BIProperty.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private CCustomizations getCustomizations( XSParticle src ) {
    // customizations for a particle  should include those defined in the term unless it's global
    // this is so that the schema like:
    //
    // <xs:sequence>
    //   <xs:element name="foo" type="xs:int">
    //     <xs:annotation><xs:appinfo>
    //       <hyperjaxb:... />
    //
    // would be picked up
    if(src.getTerm().isElementDecl()) {
        XSElementDecl xed = src.getTerm().asElementDecl();
        if(xed.isGlobal())
            return getCustomizations((XSComponent)src);
    }

    return getCustomizations(src,src.getTerm());
}
 
Example #10
Source File: AbstractMappingImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private boolean containingChoice(CClassInfo typeBean) {
    XSComponent component = typeBean.getSchemaComponent();
    if (component instanceof XSComplexType) {
        XSContentType contentType = ((XSComplexType) component).getContentType();
        XSParticle particle = contentType.asParticle();
        if (particle != null) {
            XSTerm term = particle.getTerm();
            XSModelGroup modelGroup = term.asModelGroup();
            if (modelGroup != null) {
                return (modelGroup.getCompositor() == XSModelGroup.Compositor.CHOICE);
            }
        }
    }

    return false;
}
 
Example #11
Source File: DefaultParticleBinder.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void build( XSParticle p, Collection<XSParticle> forcedProps ) {
    Checker checker = checkCollision(p,forcedProps);

    if(checker.hasNameCollision()) {
        CReferencePropertyInfo prop = new CReferencePropertyInfo(
            getCurrentBean().getBaseClass()==null?"Content":"Rest",
            true, false, false, p,
            builder.getBindInfo(p).toCustomizationList(),
            p.getLocator(), false, false, false);
        RawTypeSetBuilder.build(p,false).addTo(prop);
        prop.javadoc = Messages.format( Messages.MSG_FALLBACK_JAVADOC,
                checker.getCollisionInfo().toString() );

        getCurrentBean().addProperty(prop);
    } else {
        new Builder(checker.markedParticles).particle(p);
    }
}
 
Example #12
Source File: BGMBuilder.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets the {@link BIDom} object that applies to the given particle.
 */
protected final BIDom getLocalDomCustomization( XSParticle p ) {
    if (p == null) {
        return null;
    }
    BIDom dom = getBindInfo(p).get(BIDom.class);
    if(dom!=null)  return dom;

    // if not, the term might have one.
    dom = getBindInfo(p.getTerm()).get(BIDom.class);
    if(dom!=null)  return dom;

    XSTerm t = p.getTerm();
    // type could also have one, in case of the dom customization
    if(t.isElementDecl())
        return getBindInfo(t.asElementDecl().getType()).get(BIDom.class);
    // similarly the model group in a model group definition may have one.
    if(t.isModelGroupDecl())
        return getBindInfo(t.asModelGroupDecl().getModelGroup()).get(BIDom.class);

    return null;
}
 
Example #13
Source File: MultiWildcardComplexTypeBuilder.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public boolean isApplicable(XSComplexType ct) {
    if (!bgmBuilder.model.options.contentForWildcard) {
        return false;
    }
    XSType bt = ct.getBaseType();
    if (bt ==schemas.getAnyType() && ct.getContentType() != null) {
        XSParticle part = ct.getContentType().asParticle();
        if ((part != null) && (part.getTerm().isModelGroup())) {
            XSParticle[] parts = part.getTerm().asModelGroup().getChildren();
            int wildcardCount = 0;
            int i = 0;
            while ((i < parts.length) && (wildcardCount <= 1)) {
                if (parts[i].getTerm().isWildcard()) {
                    wildcardCount += 1;
                }
                i++;
            }
            return (wildcardCount > 1);
        }
    }
    return false;
}
 
Example #14
Source File: DefaultParticleBinder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void build( XSParticle p, Collection<XSParticle> forcedProps ) {
    Checker checker = checkCollision(p,forcedProps);

    if(checker.hasNameCollision()) {
        CReferencePropertyInfo prop = new CReferencePropertyInfo(
            getCurrentBean().getBaseClass()==null?"Content":"Rest",
            true, false, false, p,
            builder.getBindInfo(p).toCustomizationList(),
            p.getLocator(), false, false, false);
        RawTypeSetBuilder.build(p,false).addTo(prop);
        prop.javadoc = Messages.format( Messages.MSG_FALLBACK_JAVADOC,
                checker.getCollisionInfo().toString() );

        getCurrentBean().addProperty(prop);
    } else {
        new Builder(checker.markedParticles).particle(p);
    }
}
 
Example #15
Source File: DefaultParticleBinder.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void modelGroup( XSModelGroup mg ) {
    boolean oldIOP = insideOptionalParticle;
    insideOptionalParticle |= mg.getCompositor()==XSModelGroup.CHOICE;

    for( XSParticle p : mg.getChildren())
        particle(p);

    insideOptionalParticle = oldIOP;
}
 
Example #16
Source File: DefaultParticleBinder.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Hides the computeLabel method of the outer class
 * and adds caching.
 */
private String computeLabel( XSParticle p ) {
    String label = labelCache.get(p);
    if(label==null)
        labelCache.put( p, label=DefaultParticleBinder.this.computeLabel(p) );
    return label;
}
 
Example #17
Source File: Axis.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void visit(XSModelGroup mg, List<XSComponent> r) {
    // since model groups never form a cycle, no cycle check is needed
    r.add(mg);
    for (XSParticle p : mg) {
        XSModelGroup child = p.getTerm().asModelGroup();
        if(child!=null)
            visit(child,r);
    }
}
 
Example #18
Source File: AbstractAxisImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Iterator<T> modelGroup(XSModelGroup group) {
    // compensate for particles that are ignored in SCD
    return new Iterators.Map<T,XSParticle>(group.iterator()) {
        protected Iterator<? extends T> apply(XSParticle p) {
            return particle(p);
        }
    };
}
 
Example #19
Source File: RefererFinder.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void modelGroup(XSModelGroup group) {
    if(!visited.add(group))  return;

    for (XSParticle p : group.getChildren()) {
        particle(p);
    }
}
 
Example #20
Source File: AbstractExtendedComplexTypeBuilder.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets a {@link NameClass} that represents all the terms in the given content type.
 * If t is not a particle, just return an empty name class.
 */
private NameClass getNameClass(XSContentType t) {
    if(t==null) return NameClass.NULL;
    XSParticle p = t.asParticle();
    if(p==null) return NameClass.NULL;
    else        return p.getTerm().apply(contentModelNameClassBuilder);
}
 
Example #21
Source File: ExpressionParticleBinder.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void build(XSParticle p, Collection<XSParticle> forcedProps) {
    // this class isn't about spec conformance, but
    // for the ease of use.
    // so we don't give a damn about 'forcedProps'.
    // although, for a future note, it's conceivable to expand
    // the binding algorithm to cover this notion.

    Expression tree = ExpressionBuilder.createTree(p);
    Graph g = new Graph(tree);
    for (ConnectedComponent cc : g) {
        buildProperty(cc);
    }
}
 
Example #22
Source File: AbstractAxisImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public Iterator<T> complexType(XSComplexType type) {
    // compensate particle
    XSParticle p = type.getContentType().asParticle();
    if(p!=null)
        return particle(p);
    else
        return empty();
}
 
Example #23
Source File: BIProperty.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 *
 * @param defaultName
 *      If the name is not customized, this name will be used
 *      as the default. Note that the name conversion <b>MUST</b>
 *      be applied before this method is called if necessary.
 * @param source
 *      Source schema component from which a field is built.
 */
public CElementPropertyInfo createElementProperty(String defaultName, boolean forConstant, XSParticle source,
                                                  RawTypeSet types) {

    if(!types.refs.isEmpty())
        // if this property is empty, don't acknowleedge the customization
        // this allows pointless property customization to be reported as an error
        markAsAcknowledged();
    constantPropertyErrorCheck();

    String name = getPropertyName(forConstant);
    if(name==null)
        name = defaultName;

    CElementPropertyInfo prop = wrapUp(
        new CElementPropertyInfo(
            name, types.getCollectionMode(),
            types.id(),
            types.getExpectedMimeType(),
            source, getCustomizations(source),
            source.getLocator(), types.isRequired()),
        source);

    types.addTo(prop);

    BIInlineBinaryData.handle(source.getTerm(), prop);
    return prop;
}
 
Example #24
Source File: ParticleBinder.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected final <T extends BIDeclaration> T getLocalCustomization( XSParticle p, Class<T> type ) {
    // check the property customization of this component first
    T cust = builder.getBindInfo(p).get(type);
    if(cust!=null)  return cust;

    // if not, the term might have one.
    cust = builder.getBindInfo(p.getTerm()).get(type);
    if(cust!=null)  return cust;

    return null;
}
 
Example #25
Source File: DefaultParticleBinder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private Checker checkCollision( XSParticle p, Collection<XSParticle> forcedProps ) {
    // scan the tree by a checker.
    Checker checker = new Checker(forcedProps);

    CClassInfo superClass = getCurrentBean().getBaseClass();

    if(superClass!=null)
        checker.readSuperClass(superClass);
    checker.particle(p);

    return checker;
}
 
Example #26
Source File: MultiplicityCounter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public Multiplicity particle( XSParticle p ) {
    Multiplicity m = p.getTerm().apply(this);

    BigInteger max;
    if (m.max==null || (BigInteger.valueOf(XSParticle.UNBOUNDED).equals(p.getMaxOccurs())))
        max=null;
    else
        max=p.getMaxOccurs();

    return Multiplicity.multiply( m, Multiplicity.create(p.getMinOccurs(),max) );
}
 
Example #27
Source File: DefaultParticleBinder.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void modelGroup( XSModelGroup mg ) {
    boolean oldIOP = insideOptionalParticle;
    insideOptionalParticle |= mg.getCompositor()==XSModelGroup.CHOICE;

    for( XSParticle p : mg.getChildren())
        particle(p);

    insideOptionalParticle = oldIOP;
}
 
Example #28
Source File: ParticleBinder.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
protected final <T extends BIDeclaration> T getLocalCustomization( XSParticle p, Class<T> type ) {
    // check the property customization of this component first
    T cust = builder.getBindInfo(p).get(type);
    if(cust!=null)  return cust;

    // if not, the term might have one.
    cust = builder.getBindInfo(p.getTerm()).get(type);
    if(cust!=null)  return cust;

    return null;
}
 
Example #29
Source File: AbstractAxisImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public Iterator<T> modelGroup(XSModelGroup group) {
    // compensate for particles that are ignored in SCD
    return new Iterators.Map<T,XSParticle>(group.iterator()) {
        protected Iterator<? extends T> apply(XSParticle p) {
            return particle(p);
        }
    };
}
 
Example #30
Source File: DefaultParticleBinder.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private Checker checkCollision( XSParticle p, Collection<XSParticle> forcedProps ) {
    // scan the tree by a checker.
    Checker checker = new Checker(forcedProps);

    CClassInfo superClass = getCurrentBean().getBaseClass();

    if(superClass!=null)
        checker.readSuperClass(superClass);
    checker.particle(p);

    return checker;
}