Java源码示例:com.sun.xml.internal.xsom.XSComponent

示例1
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());
}
 
示例2
public CClassInfo(Model model,JCodeModel cm, String fullName, Locator location, QName typeName, QName elementName, XSComponent source, CCustomizations customizations) {
    super(model,source,location,customizations);
    this.model = model;
    int idx = fullName.indexOf('.');
    if(idx<0) {
        this.parent = model.getPackage(cm.rootPackage());
        this.shortName = model.allocator.assignClassName(parent,fullName);
    } else {
        this.parent = model.getPackage(cm._package(fullName.substring(0,idx)));
        this.shortName = model.allocator.assignClassName(parent,fullName.substring(idx+1));
    }
    this.typeName = typeName;
    this.elementName = elementName;

    model.add(this);
}
 
示例3
private void check(BIDeclaration decl, XSComponent c) {
    if( !decl.isAcknowledged() ) {
        getErrorReporter().error(
            decl.getLocation(),
            Messages.ERR_UNACKNOWLEDGED_CUSTOMIZATION,
            decl.getName().getLocalPart()
            );
        getErrorReporter().error(
            c.getLocator(),
            Messages.ERR_UNACKNOWLEDGED_CUSTOMIZATION_LOCATION);
        // mark it as acknowledged to avoid
        // duplicated error messages.
        decl.markAsAcknowledged();
    }
    for (BIDeclaration d : decl.getChildren())
        check(d,c);
}
 
示例4
public Iterator<XSComponent> select(Iterator<? extends XSComponent> contextNode) {
    Iterator<XSComponent> nodeSet = (Iterator)contextNode;

    int len = steps.length;
    for( int i=0; i<len; i++ ) {
        if(i!=0 && i!=len-1 && !steps[i-1].axis.isModelGroup() && steps[i].axis.isModelGroup()) {
            // expand the current nodeset by adding abbreviatable complex type and model groups.
            // note that such expansion is not allowed to occure in in between model group axes.

            // TODO: this step is not needed if the next step is known not to react to
            // complex type nor model groups, such as, say Axis.FACET
            nodeSet = new Iterators.Unique<XSComponent>(
                new Iterators.Map<XSComponent,XSComponent>(nodeSet) {
                    protected Iterator<XSComponent> apply(XSComponent u) {
                        return new Iterators.Union<XSComponent>(
                            Iterators.singleton(u),
                            Axis.INTERMEDIATE_SKIP.iterator(u) );
                    }
                }
            );
        }
        nodeSet = steps[i].evaluate(nodeSet);
    }

    return nodeSet;
}
 
示例5
public CValuePropertyInfo createValueProperty(String defaultName,boolean forConstant,
    XSComponent source,TypeUse tu, QName typeName) {

    markAsAcknowledged();
    constantPropertyErrorCheck();

    String name = getPropertyName(forConstant);
    if(name==null) {
        name = defaultName;
        if(tu.isCollection() && getBuilder().getGlobalBinding().isSimpleMode())
            name = JJavaName.getPluralForm(name);
    }

    CValuePropertyInfo prop = wrapUp(new CValuePropertyInfo(name, source, getCustomizations(source), source.getLocator(), tu, typeName), source);
    BIInlineBinaryData.handle(source, prop);
    return prop;
}
 
示例6
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());
}
 
示例7
public Iterator<XSComponent> select(Iterator<? extends XSComponent> contextNode) {
    Iterator<XSComponent> nodeSet = (Iterator)contextNode;

    int len = steps.length;
    for( int i=0; i<len; i++ ) {
        if(i!=0 && i!=len-1 && !steps[i-1].axis.isModelGroup() && steps[i].axis.isModelGroup()) {
            // expand the current nodeset by adding abbreviatable complex type and model groups.
            // note that such expansion is not allowed to occure in in between model group axes.

            // TODO: this step is not needed if the next step is known not to react to
            // complex type nor model groups, such as, say Axis.FACET
            nodeSet = new Iterators.Unique<XSComponent>(
                new Iterators.Map<XSComponent,XSComponent>(nodeSet) {
                    protected Iterator<XSComponent> apply(XSComponent u) {
                        return new Iterators.Union<XSComponent>(
                            Iterators.singleton(u),
                            Axis.INTERMEDIATE_SKIP.iterator(u) );
                    }
                }
            );
        }
        nodeSet = steps[i].evaluate(nodeSet);
    }

    return nodeSet;
}
 
示例8
/**
 * Evaluate this step against the current node set
 * and returns matched nodes.
 */
public final Iterator<T> evaluate(Iterator<XSComponent> nodeSet) {
    // list up the whole thing
    Iterator<T> r = new Iterators.Map<T,XSComponent>(nodeSet) {
        protected Iterator<? extends T> apply(XSComponent contextNode) {
            return filter(axis.iterator(contextNode));
        }
    };

    // avoid duplicates
    r = new Iterators.Unique<T>(r);

    if(predicate>=0) {
        T item=null;
        for( int i=predicate; i>0; i-- ) {
            if(!r.hasNext())
                return Iterators.empty();
            item = r.next();
        }
        return new Iterators.Singleton<T>(item);
    }

    return r;
}
 
示例9
private CCustomizations getCustomizations( XSAttributeUse src ) {
    // customizations for an attribute use should include those defined in the local attribute.
    // this is so that the schema like:
    //
    // <xs:attribute name="foo" type="xs:int">
    //   <xs:annotation><xs:appinfo>
    //     <hyperjaxb:... />
    //
    // would be picked up
    if(src.getDecl().isLocal())
        return getCustomizations(src,src.getDecl());
    else
        return getCustomizations((XSComponent)src);
}
 
示例10
private static BIProperty getDefault( BGMBuilder builder, XSComponent c ) {
    while(c!=null) {
        c = c.apply(defaultCustomizationFinder);
        if(c!=null) {
            BIProperty prop = builder.getBindInfo(c).get(BIProperty.class);
            if(prop!=null)  return prop;
        }
    }

    // default to the global one
    return builder.getGlobalBinding().getDefaultProperty();
}
 
示例11
public XSComponent selectSingle(String scd, NamespaceContext nsContext) {
    try {
        return SCD.create(scd,nsContext).selectSingle(this);
    } catch (ParseException e) {
        throw new IllegalArgumentException(e);
    }
}
 
示例12
/**
 * Default implementation that simply delegate sto {@link #iterator(XSComponent)}
 */
public Iterator<T> iterator(Iterator<? extends XSComponent> contextNodes) {
    return new Iterators.Map<T,XSComponent>(contextNodes) {
        protected Iterator<? extends T> apply(XSComponent u) {
            return iterator(u);
        }
    };
}
 
示例13
public XSComponent selectSingle(String scd, NamespaceContext nsContext) {
    try {
        return SCD.create(scd,nsContext).selectSingle(this);
    } catch (ParseException e) {
        throw new IllegalArgumentException(e);
    }
}
 
示例14
public Iterator<XSComponent> elementDecl(XSElementDecl decl) {
    XSComplexType ct = decl.getType().asComplexType();
    if(ct==null)
        return empty();
    else {
        // also pick up model groups inside this complex type
        return new Iterators.Union<XSComponent>(singleton(ct),complexType(ct));
    }
}
 
示例15
public Iterator<XSSchema> iterator(Iterator<? extends XSComponent> contextNodes) {
    return new Iterators.Adapter<XSSchema,XSComponent>(contextNodes) {
        protected XSSchema filter(XSComponent u) {
            return u.getOwnerSchema();
        }
    };
}
 
示例16
/**
 * Checks if the given component is bound to a class.
 */
public final CElement isBound( XSElementDecl x, XSComponent referer ) {
    CElementInfo r = boundElements.get(x);
    if(r!=null)
        return r;
    return bindToType(x,referer);
}
 
示例17
private void checkExpectedContentTypes(XSComponent c) {
    if(c.getForeignAttribute(WellKnownNamespace.XML_MIME_URI, Const.EXPECTED_CONTENT_TYPES)==null)
        return; // no such attribute
    if(c instanceof XSParticle)
        return; // particles get the same foreign attributes as local element decls,
                // so we need to skip them

    if(!stb.isAcknowledgedXmimeContentTypes(c)) {
        // this is not used
        getErrorReporter().warning(c.getLocator(),Messages.WARN_UNUSED_EXPECTED_CONTENT_TYPES);
    }
}
 
示例18
/**
 * If the component maps to a property, forwards to purple, otherwise to green.
 *
 * If the component is mapped to a type, this method needs to return true.
 * See the chart at the class javadoc.
 */
public void ying( XSComponent sc, @Nullable XSComponent referer ) {
    if(sc.apply(toPurple)==true || getClassSelector().bindToType(sc,referer)!=null)
        sc.visit(purple);
    else
        sc.visit(green);
}
 
示例19
public Iterator<XSSchema> iterator(Iterator<? extends XSComponent> contextNodes) {
    return new Iterators.Adapter<XSSchema,XSComponent>(contextNodes) {
        protected XSSchema filter(XSComponent u) {
            return u.getOwnerSchema();
        }
    };
}
 
示例20
public CReferencePropertyInfo(String name, boolean collection, boolean required, boolean isMixed, XSComponent source,
                              CCustomizations customizations, Locator locator, boolean dummy, boolean content, boolean isMixedExtended) {   // 'dummy' and 'content' here for NHIN fix - a hack in order to be able to handle extended mixed types better
    super(name, (collection||isMixed) && (!dummy), source, customizations, locator);
    this.isMixed = isMixed;
    this.required = required;
    this.dummy = dummy;
    this.content = content;
    this.isMixedExtendedCust = isMixedExtended;
}
 
示例21
public CReferencePropertyInfo(String name, boolean collection, boolean required, boolean isMixed, XSComponent source,
                              CCustomizations customizations, Locator locator, boolean dummy, boolean content, boolean isMixedExtended) {   // 'dummy' and 'content' here for NHIN fix - a hack in order to be able to handle extended mixed types better
    super(name, (collection||isMixed) && (!dummy), source, customizations, locator);
    this.isMixed = isMixed;
    this.required = required;
    this.dummy = dummy;
    this.content = content;
    this.isMixedExtendedCust = isMixedExtended;
}
 
示例22
public Collection<XSComponent> select(String scd, NamespaceContext nsContext) {
    try {
        return SCD.create(scd,nsContext).select(this);
    } catch (ParseException e) {
        throw new IllegalArgumentException(e);
    }
}
 
示例23
public CElementPropertyInfo(String name, CollectionMode collection, ID id, MimeType expectedMimeType, XSComponent source,
                            CCustomizations customizations, Locator locator, boolean required) {
    super(name, collection.col, source, customizations, locator);
    this.required = required;
    this.id = id;
    this.expectedMimeType = expectedMimeType;
    this.isValueList = collection.val;
}
 
示例24
/**
 *
 * @param typeName
 *      XML Schema type name of this property's single value. Optional
 *      for other schema languages. This is used to determine if we should
 *      generate {@link @XmlSchemaType} annotation to improve the roundtrip.
 */
protected CSingleTypePropertyInfo(String name, TypeUse type, QName typeName, XSComponent source, CCustomizations customizations, Locator locator) {
    super(name, type.isCollection(), source, customizations, locator);
    this.type = type;

    if(needsExplicitTypeName(type,typeName))
        schemaType = typeName;
    else
        schemaType = null;
}
 
示例25
public XSComponent selectSingle(String scd, NamespaceContext nsContext) {
    try {
        return SCD.create(scd,nsContext).selectSingle(this);
    } catch (ParseException e) {
        throw new IllegalArgumentException(e);
    }
}
 
示例26
private CCustomizations getCustomizations( XSAttributeUse src ) {
    // customizations for an attribute use should include those defined in the local attribute.
    // this is so that the schema like:
    //
    // <xs:attribute name="foo" type="xs:int">
    //   <xs:annotation><xs:appinfo>
    //     <hyperjaxb:... />
    //
    // would be picked up
    if(src.getDecl().isLocal())
        return getCustomizations(src,src.getDecl());
    else
        return getCustomizations((XSComponent)src);
}
 
示例27
/**
 * Checks if the given component is bound to a class.
 */
public final CElement isBound( XSElementDecl x, XSComponent referer ) {
    CElementInfo r = boundElements.get(x);
    if(r!=null)
        return r;
    return bindToType(x,referer);
}
 
示例28
public CClass bindToType( XSComplexType t, XSComponent referer, boolean cannotBeDelayed ) {
    // this assumption that a complex type always binds to a ClassInfo
    // does not hold for xs:anyType --- our current approach of handling
    // this idiosynchracy is to make sure that xs:anyType doesn't use
    // this codepath.
    return (CClass)_bindToClass(t,referer,cannotBeDelayed);
}
 
示例29
/**
 * Find all types that refer to the given complex type.
 */
public Set<XSComponent> getReferer(XSType c) {
    if(refFinder==null) {
        refFinder = new RefererFinder();
        refFinder.schemaSet(Ring.get(XSSchemaSet.class));
    }
    return refFinder.getReferer(c);
}
 
示例30
private static BIProperty getDefault( BGMBuilder builder, XSComponent c ) {
    while(c!=null) {
        c = c.apply(defaultCustomizationFinder);
        if(c!=null) {
            BIProperty prop = builder.getBindInfo(c).get(BIProperty.class);
            if(prop!=null)  return prop;
        }
    }

    // default to the global one
    return builder.getGlobalBinding().getDefaultProperty();
}