Java源码示例:com.sun.xml.internal.bind.v2.model.core.NonElement

示例1
public ClassInfoImpl<T,C,F,M> getBaseClass() {
    if (!baseClassComputed) {
        // compute the base class
        C s = nav().getSuperClass(clazz);
        if(s==null || s==nav().asDecl(Object.class)) {
            baseClass = null;
        } else {
            NonElement<T,C> b = builder.getClassInfo(s, true, this);
            if(b instanceof ClassInfoImpl) {
                baseClass = (ClassInfoImpl<T,C,F,M>) b;
                baseClass.hasSubClasses = true;
            } else {
                baseClass = null;
            }
        }
        baseClassComputed = true;
    }
    return baseClass;
}
 
示例2
public ClassInfoImpl<T,C,F,M> getBaseClass() {
    if (!baseClassComputed) {
        // compute the base class
        C s = nav().getSuperClass(clazz);
        if(s==null || s==nav().asDecl(Object.class)) {
            baseClass = null;
        } else {
            NonElement<T,C> b = builder.getClassInfo(s, true, this);
            if(b instanceof ClassInfoImpl) {
                baseClass = (ClassInfoImpl<T,C,F,M>) b;
                baseClass.hasSubClasses = true;
            } else {
                baseClass = null;
            }
        }
        baseClassComputed = true;
    }
    return baseClass;
}
 
示例3
/**
 * Process the given PropertyInfo looking for references to namespaces that
 * are foreign to the given namespace.  Any foreign namespace references
 * found are added to the given namespaces dependency list and an &lt;import>
 * is generated for it.
 *
 * @param p the PropertyInfo
 */
private void processForeignNamespaces(PropertyInfo<T, C> p, int processingDepth) {
    for (TypeInfo<T, C> t : p.ref()) {
        if ((t instanceof ClassInfo) && (processingDepth > 0)) {
            java.util.List<PropertyInfo> l = ((ClassInfo) t).getProperties();
            for (PropertyInfo subp : l) {
                processForeignNamespaces(subp, --processingDepth);
            }
        }
        if (t instanceof Element) {
            addDependencyTo(((Element) t).getElementName());
        }
        if (t instanceof NonElement) {
            addDependencyTo(((NonElement) t).getTypeName());
        }
    }
}
 
示例4
public void link() {
    super.link();

    if (!(NonElement.ANYTYPE_NAME.equals(type.getTypeName()) || type.isSimpleType() || id()==ID.IDREF)) {
            parent.builder.reportError(new IllegalAnnotationException(
            Messages.SIMPLE_TYPE_IS_REQUIRED.format(),
            seed
        ));
    }

    if(!isCollection() && seed.hasAnnotation(XmlList.class)) {
        parent.builder.reportError(new IllegalAnnotationException(
            Messages.XMLLIST_ON_SINGLE_PROPERTY.format(), this
        ));
    }
}
 
示例5
/**
 * Have the builder recognize the type (if it hasn't done so yet),
 * and returns a {@link NonElement} that represents it.
 *
 * @return
 *      always non-null.
 */
public NonElement<T,C> getTypeInfo(T t,Locatable upstream) {
    NonElement<T,C> r = typeInfoSet.getTypeInfo(t);
    if(r!=null)     return r;

    if(nav.isArray(t)) { // no need for checking byte[], because above typeInfoset.getTypeInfo() would return non-null
        ArrayInfoImpl<T,C,F,M> ai =
            createArrayInfo(upstream, t);
        addTypeName(ai);
        typeInfoSet.add(ai);
        return ai;
    }

    C c = nav.asDecl(t);
    assert c!=null : t.toString()+" must be a leaf, but we failed to recognize it.";
    return getClassInfo(c,upstream);
}
 
示例6
/**
 * Process the given PropertyInfo looking for references to namespaces that
 * are foreign to the given namespace.  Any foreign namespace references
 * found are added to the given namespaces dependency list and an &lt;import>
 * is generated for it.
 *
 * @param p the PropertyInfo
 */
private void processForeignNamespaces(PropertyInfo<T, C> p, int processingDepth) {
    for (TypeInfo<T, C> t : p.ref()) {
        if ((t instanceof ClassInfo) && (processingDepth > 0)) {
            java.util.List<PropertyInfo> l = ((ClassInfo) t).getProperties();
            for (PropertyInfo subp : l) {
                processForeignNamespaces(subp, --processingDepth);
            }
        }
        if (t instanceof Element) {
            addDependencyTo(((Element) t).getElementName());
        }
        if (t instanceof NonElement) {
            addDependencyTo(((NonElement) t).getTypeName());
        }
    }
}
 
示例7
private synchronized XmlSchemaGenerator<TypeMirror, TypeElement, VariableElement, ExecutableElement> getSchemaGenerator() {
    if(xsdgen==null) {
        xsdgen = new XmlSchemaGenerator<TypeMirror, TypeElement, VariableElement, ExecutableElement>(types.getNavigator(), types);

        for (Map.Entry<QName, Reference> e : additionalElementDecls.entrySet()) {
            Reference value = e.getValue();
            if(value!=null) {
                NonElement<TypeMirror, TypeElement> typeInfo = refMap.get(value);
                if(typeInfo==null)
                    throw new IllegalArgumentException(e.getValue()+" was not specified to JavaCompiler.bind");
                TypeMirror type = value.type;
                xsdgen.add(e.getKey(), !(type != null && type.getKind().isPrimitive()), typeInfo);
            } else {
                xsdgen.add(e.getKey(),false,null);
            }
        }
    }
    return xsdgen;
}
 
示例8
/**
 * Process the given PropertyInfo looking for references to namespaces that
 * are foreign to the given namespace.  Any foreign namespace references
 * found are added to the given namespaces dependency list and an &lt;import>
 * is generated for it.
 *
 * @param p the PropertyInfo
 */
private void processForeignNamespaces(PropertyInfo<T, C> p, int processingDepth) {
    for (TypeInfo<T, C> t : p.ref()) {
        if ((t instanceof ClassInfo) && (processingDepth > 0)) {
            java.util.List<PropertyInfo> l = ((ClassInfo) t).getProperties();
            for (PropertyInfo subp : l) {
                processForeignNamespaces(subp, --processingDepth);
            }
        }
        if (t instanceof Element) {
            addDependencyTo(((Element) t).getElementName());
        }
        if (t instanceof NonElement) {
            addDependencyTo(((NonElement) t).getTypeName());
        }
    }
}
 
示例9
public void link() {
    super.link();

    if (!(NonElement.ANYTYPE_NAME.equals(type.getTypeName()) || type.isSimpleType() || id()==ID.IDREF)) {
            parent.builder.reportError(new IllegalAnnotationException(
            Messages.SIMPLE_TYPE_IS_REQUIRED.format(),
            seed
        ));
    }

    if(!isCollection() && seed.hasAnnotation(XmlList.class)) {
        parent.builder.reportError(new IllegalAnnotationException(
            Messages.XMLLIST_ON_SINGLE_PROPERTY.format(), this
        ));
    }
}
 
示例10
/**
 * Have the builder recognize the type (if it hasn't done so yet),
 * and returns a {@link NonElement} that represents it.
 *
 * @return
 *      always non-null.
 */
public NonElement<T,C> getTypeInfo(T t,Locatable upstream) {
    NonElement<T,C> r = typeInfoSet.getTypeInfo(t);
    if(r!=null)     return r;

    if(nav.isArray(t)) { // no need for checking byte[], because above typeInfoset.getTypeInfo() would return non-null
        ArrayInfoImpl<T,C,F,M> ai =
            createArrayInfo(upstream, t);
        addTypeName(ai);
        typeInfoSet.add(ai);
        return ai;
    }

    C c = nav.asDecl(t);
    assert c!=null : t.toString()+" must be a leaf, but we failed to recognize it.";
    return getClassInfo(c,upstream);
}
 
示例11
/**
 * Have the builder recognize the type (if it hasn't done so yet),
 * and returns a {@link NonElement} that represents it.
 *
 * @return
 *      always non-null.
 */
public NonElement<T,C> getTypeInfo(T t,Locatable upstream) {
    NonElement<T,C> r = typeInfoSet.getTypeInfo(t);
    if(r!=null)     return r;

    if(nav.isArray(t)) { // no need for checking byte[], because above typeInfoset.getTypeInfo() would return non-null
        ArrayInfoImpl<T,C,F,M> ai =
            createArrayInfo(upstream, t);
        addTypeName(ai);
        typeInfoSet.add(ai);
        return ai;
    }

    C c = nav.asDecl(t);
    assert c!=null : t.toString()+" must be a leaf, but we failed to recognize it.";
    return getClassInfo(c,upstream);
}
 
示例12
/**
 * Have the builder recognize the type (if it hasn't done so yet),
 * and returns a {@link NonElement} that represents it.
 *
 * @return
 *      always non-null.
 */
public NonElement<T,C> getTypeInfo(T t,Locatable upstream) {
    NonElement<T,C> r = typeInfoSet.getTypeInfo(t);
    if(r!=null)     return r;

    if(nav.isArray(t)) { // no need for checking byte[], because above typeInfoset.getTypeInfo() would return non-null
        ArrayInfoImpl<T,C,F,M> ai =
            createArrayInfo(upstream, t);
        addTypeName(ai);
        typeInfoSet.add(ai);
        return ai;
    }

    C c = nav.asDecl(t);
    assert c!=null : t.toString()+" must be a leaf, but we failed to recognize it.";
    return getClassInfo(c,upstream);
}
 
示例13
public ClassInfoImpl<T,C,F,M> getBaseClass() {
    if (!baseClassComputed) {
        // compute the base class
        C s = nav().getSuperClass(clazz);
        if(s==null || s==nav().asDecl(Object.class)) {
            baseClass = null;
        } else {
            NonElement<T,C> b = builder.getClassInfo(s, true, this);
            if(b instanceof ClassInfoImpl) {
                baseClass = (ClassInfoImpl<T,C,F,M>) b;
                baseClass.hasSubClasses = true;
            } else {
                baseClass = null;
            }
        }
        baseClassComputed = true;
    }
    return baseClass;
}
 
示例14
/**
 * Have the builder recognize the type (if it hasn't done so yet),
 * and returns a {@link NonElement} that represents it.
 *
 * @return
 *      always non-null.
 */
public NonElement<T,C> getTypeInfo(T t,Locatable upstream) {
    NonElement<T,C> r = typeInfoSet.getTypeInfo(t);
    if(r!=null)     return r;

    if(nav.isArray(t)) { // no need for checking byte[], because above typeInfoset.getTypeInfo() would return non-null
        ArrayInfoImpl<T,C,F,M> ai =
            createArrayInfo(upstream, t);
        addTypeName(ai);
        typeInfoSet.add(ai);
        return ai;
    }

    C c = nav.asDecl(t);
    assert c!=null : t.toString()+" must be a leaf, but we failed to recognize it.";
    return getClassInfo(c,upstream);
}
 
示例15
private synchronized XmlSchemaGenerator<TypeMirror, TypeElement, VariableElement, ExecutableElement> getSchemaGenerator() {
    if(xsdgen==null) {
        xsdgen = new XmlSchemaGenerator<TypeMirror, TypeElement, VariableElement, ExecutableElement>(types.getNavigator(), types);

        for (Map.Entry<QName, Reference> e : additionalElementDecls.entrySet()) {
            Reference value = e.getValue();
            if(value!=null) {
                NonElement<TypeMirror, TypeElement> typeInfo = refMap.get(value);
                if(typeInfo==null)
                    throw new IllegalArgumentException(e.getValue()+" was not specified to JavaCompiler.bind");
                TypeMirror type = value.type;
                xsdgen.add(e.getKey(), !(type != null && type.getKind().isPrimitive()), typeInfo);
            } else {
                xsdgen.add(e.getKey(),false,null);
            }
        }
    }
    return xsdgen;
}
 
示例16
/**
 * Have the builder recognize the type (if it hasn't done so yet),
 * and returns a {@link NonElement} that represents it.
 *
 * @return
 *      always non-null.
 */
public NonElement<T,C> getTypeInfo(T t,Locatable upstream) {
    NonElement<T,C> r = typeInfoSet.getTypeInfo(t);
    if(r!=null)     return r;

    if(nav.isArray(t)) { // no need for checking byte[], because above typeInfoset.getTypeInfo() would return non-null
        ArrayInfoImpl<T,C,F,M> ai =
            createArrayInfo(upstream, t);
        addTypeName(ai);
        typeInfoSet.add(ai);
        return ai;
    }

    C c = nav.asDecl(t);
    assert c!=null : t.toString()+" must be a leaf, but we failed to recognize it.";
    return getClassInfo(c,upstream);
}
 
示例17
public NonElement<T,C> getTarget() {
    if(type==null) {
        assert parent.builder!=null : "this method must be called during the build stage";
        type = parent.builder.getTypeInfo(getIndividualType(),this);
    }
    return type;
}
 
示例18
/**
 * Checks the uniqueness of the type name.
 */
private void addTypeName(NonElement<T, C> r) {
    QName t = r.getTypeName();
    if(t==null)     return;

    TypeInfo old = typeNames.put(t,r);
    if(old!=null) {
        // collision
        reportError(new IllegalAnnotationException(
                Messages.CONFLICTING_XML_TYPE_MAPPING.format(r.getTypeName()),
                old, r ));
    }
}
 
示例19
public QName getTypeName(TypeReference tr) {
    try {
        NonElement<Type,Class> xt = getXmlType(getTypeInfoSet(),tr);
        if(xt==null)    throw new IllegalArgumentException();
        return xt.getTypeName();
    } catch (IllegalAnnotationsException e) {
        // impossible given that JAXBRIContext has been successfully built in the first place
        throw new AssertionError(e);
    }
}
 
示例20
public QName getTypeName(TypeReference tr) {
    try {
        NonElement<Type,Class> xt = getXmlType(getTypeInfoSet(),tr);
        if(xt==null)    throw new IllegalArgumentException();
        return xt.getTypeName();
    } catch (IllegalAnnotationsException e) {
        // impossible given that JAXBRIContext has been successfully built in the first place
        throw new AssertionError(e);
    }
}
 
示例21
/**
 * Adds an additional element declaration.
 *
 * @param tagName
 *      The name of the element declaration to be added.
 * @param type
 *      The type this element refers to.
 *      Can be null, in which case the element refers to an empty anonymous complex type.
 */
public void add( QName tagName, boolean isNillable, NonElement<T,C> type ) {

    if(type!=null && type.getType()==navigator.ref(CompositeStructure.class))
        return; // this is a special class we introduced for JAX-WS that we *don't* want in the schema


    Namespace n = getNamespace(tagName.getNamespaceURI());
    n.elementDecls.put(tagName.getLocalPart(), n.new ElementWithType(isNillable,type));

    // search for foreign namespace references
    if(type!=null)
        n.addDependencyTo(type.getTypeName());
}
 
示例22
private boolean addAllSubtypes(T type) {
    Navigator<T,C,F,M> nav = nav();

    // this allows the explicitly referenced type to be sucked in to the model
    NonElement<T,C> t = parent.builder.getClassInfo(nav.asDecl(type),this);
    if(!(t instanceof ClassInfo))
        // this is leaf.
        return false;

    boolean result = false;

    ClassInfo<T,C> c = (ClassInfo<T,C>) t;
    if(c.isElement()) {
        types.add(c.asElement());
        result = true;
    }

    // look for other possible types
    for( ClassInfo<T,C> ci : parent.owner.beans().values() ) {
        if(ci.isElement() && nav.isSubClassOf(ci.getType(),type)) {
            types.add(ci.asElement());
            result = true;
        }
    }

    // don't allow local elements to substitute.
    for( ElementInfo<T,C> ei : parent.owner.getElementMappings(null).values()) {
        if(nav.isSubClassOf(ei.getType(),type)) {
            types.add(ei);
            result = true;
        }
    }

    return result;
}
 
示例23
/**
 * Returns a {@link TypeInfo} for the given type.
 *
 * @return
 *      null if the specified type cannot be bound by JAXB, or
 *      not known to this set.
 */
public NonElement<T,C> getTypeInfo( T type ) {
    type = nav.erasure(type);   // replace type variables by their bounds

    LeafInfo<T,C> l = builtins.get(type);
    if(l!=null)     return l;

    if( nav.isArray(type) ) {
        return arrays.get(type);
    }

    C d = nav.asDecl(type);
    if(d==null)     return null;
    return getClassInfo(d);
}
 
示例24
/**
 * Checks the uniqueness of the type name.
 */
private void addTypeName(NonElement<T, C> r) {
    QName t = r.getTypeName();
    if(t==null)     return;

    TypeInfo old = typeNames.put(t,r);
    if(old!=null) {
        // collision
        reportError(new IllegalAnnotationException(
                Messages.CONFLICTING_XML_TYPE_MAPPING.format(r.getTypeName()),
                old, r ));
    }
}
 
示例25
private NonElement<Type,Class> getXmlType(RuntimeTypeInfoSet tis, TypeReference tr) {
    if(tr==null)
        throw new IllegalArgumentException();

    XmlJavaTypeAdapter xjta = tr.get(XmlJavaTypeAdapter.class);
    XmlList xl = tr.get(XmlList.class);

    Ref<Type,Class> ref = new Ref<Type,Class>(annotationReader, tis.getNavigator(), tr.type, xjta, xl );

    return tis.getTypeInfo(ref);
}
 
示例26
private NonElement<TypeMirror, TypeElement> getXmlType(Reference r) {
    if(r==null)
        throw new IllegalArgumentException();

    XmlJavaTypeAdapter xjta = r.annotations.getAnnotation(XmlJavaTypeAdapter.class);
    XmlList xl = r.annotations.getAnnotation(XmlList.class);

    Ref<TypeMirror, TypeElement> ref = new Ref<TypeMirror, TypeElement>(
        reader,types.getNavigator(),r.type,xjta,xl);

    return types.getTypeInfo(ref);
}
 
示例27
public QName getXmlTypeName(Reference javaType) {
    NonElement<TypeMirror, TypeElement> ti = refMap.get(javaType);

    if(ti!=null)
        return ti.getTypeName();

    return null;
}
 
示例28
public QName getTypeName(TypeReference tr) {
    try {
        NonElement<Type,Class> xt = getXmlType(getTypeInfoSet(),tr);
        if(xt==null)    throw new IllegalArgumentException();
        return xt.getTypeName();
    } catch (IllegalAnnotationsException e) {
        // impossible given that JAXBRIContext has been successfully built in the first place
        throw new AssertionError(e);
    }
}
 
示例29
/**
 * This method is used to add a root reference to a model.
 */
public NonElement<T,C> getTypeInfo(Ref<T,C> ref) {
    // TODO: handle XmlValueList
    assert !ref.valueList;
    C c = nav.asDecl(ref.type);
    if(c!=null && reader.getClassAnnotation(XmlRegistry.class,c,null/*TODO: is this right?*/)!=null) {
        if(!registries.containsKey(nav.getPackageName(c)))
            addRegistry(c,null);
        return null;    // TODO: is this correct?
    } else
        return getTypeInfo(ref.type,null);
}
 
示例30
public NonElement<T,C> getTarget() {
    if(type==null) {
        assert parent.builder!=null : "this method must be called during the build stage";
        type = parent.builder.getTypeInfo(getIndividualType(),this);
    }
    return type;
}