Java Code Examples for com.sun.xml.internal.bind.v2.model.core.ID#IDREF

The following examples show how to use com.sun.xml.internal.bind.v2.model.core.ID#IDREF . 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: SingleTypePropertyInfoImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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
        ));
    }
}
 
Example 2
Source File: TransducedAccessor.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets the {@link TransducedAccessor} appropriately configured for
 * the given property.
 *
 * <p>
 * This allows the implementation to use an optimized code.
 */
public static <T> TransducedAccessor<T> get(JAXBContextImpl context, RuntimeNonElementRef ref) {
    Transducer xducer = RuntimeModelBuilder.createTransducer(ref);
    RuntimePropertyInfo prop = ref.getSource();

    if(prop.isCollection()) {
        return new ListTransducedAccessorImpl(xducer,prop.getAccessor(),
                Lister.create(Utils.REFLECTION_NAVIGATOR.erasure(prop.getRawType()), prop.id(), prop.getAdapter()));
    }

    if(prop.id()==ID.IDREF)
        return new IDREFTransducedAccessorImpl(prop.getAccessor());

    if(xducer.isDefault() && context != null && !context.fastBoot) {
        TransducedAccessor xa = OptimizedTransducedAccessorFactory.get(prop);
        if(xa!=null)    return xa;
    }

    if(xducer.useNamespace())
        return new CompositeContextDependentTransducedAccessorImpl( context, xducer, prop.getAccessor() );
    else
        return new CompositeTransducedAccessorImpl( context, xducer, prop.getAccessor() );
}
 
Example 3
Source File: SingleTypePropertyInfoImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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
        ));
    }
}
 
Example 4
Source File: PropertyFactory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Look for the case that can be optimized as a leaf,
 * which is a kind of type whose XML representation is just PCDATA.
 */
static boolean isLeaf(RuntimePropertyInfo info) {
    Collection<? extends RuntimeTypeInfo> types = info.ref();
    if(types.size()!=1)     return false;

    RuntimeTypeInfo rti = types.iterator().next();
    if(!(rti instanceof RuntimeNonElement)) return false;

    if(info.id()==ID.IDREF)
        // IDREF is always handled as leaf -- Transducer maps IDREF String back to an object
        return true;

    if(((RuntimeNonElement)rti).getTransducer()==null)
        // Transducer!=null means definitely binds to PCDATA.
        // even if transducer==null, a referene might be IDREF,
        // in which case it will still produce PCDATA in this reference.
        return false;

    if(!info.getIndividualType().equals(rti.getType()))
        return false;

    return true;
}
 
Example 5
Source File: SingleTypePropertyInfoImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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
        ));
    }
}
 
Example 6
Source File: SingleTypePropertyInfoImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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
        ));
    }
}
 
Example 7
Source File: PropertyFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Look for the case that can be optimized as a leaf,
 * which is a kind of type whose XML representation is just PCDATA.
 */
static boolean isLeaf(RuntimePropertyInfo info) {
    Collection<? extends RuntimeTypeInfo> types = info.ref();
    if(types.size()!=1)     return false;

    RuntimeTypeInfo rti = types.iterator().next();
    if(!(rti instanceof RuntimeNonElement)) return false;

    if(info.id()==ID.IDREF)
        // IDREF is always handled as leaf -- Transducer maps IDREF String back to an object
        return true;

    if(((RuntimeNonElement)rti).getTransducer()==null)
        // Transducer!=null means definitely binds to PCDATA.
        // even if transducer==null, a referene might be IDREF,
        // in which case it will still produce PCDATA in this reference.
        return false;

    if(!info.getIndividualType().equals(rti.getType()))
        return false;

    return true;
}
 
Example 8
Source File: Lister.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets a reference to the appropriate {@link Lister} object
 * if the field is a multi-value field. Otherwise null.
 *
 * @param fieldType
 *      the type of the field that stores the collection
 * @param idness
 *      ID-ness of the property.
 * @param adapter
 *      adapter to be used for individual items. can be null.
 */
public static <BeanT,PropT,ItemT,PackT>
    Lister<BeanT,PropT,ItemT,PackT> create(Type fieldType,ID idness, Adapter<Type,Class> adapter) {

    Class rawType = (Class) Utils.REFLECTION_NAVIGATOR.erasure(fieldType);
    Class itemType;

    Lister l;
    if( rawType.isArray() ) {
        itemType = rawType.getComponentType();
        l = getArrayLister(itemType);
    } else
    if( Collection.class.isAssignableFrom(rawType) ) {
        Type bt = Utils.REFLECTION_NAVIGATOR.getBaseClass(fieldType,Collection.class);
        if(bt instanceof ParameterizedType)
            itemType = (Class) Utils.REFLECTION_NAVIGATOR.erasure(((ParameterizedType)bt).getActualTypeArguments()[0]);
        else
            itemType = Object.class;
        l = new CollectionLister(getImplClass(rawType));
    } else
        return null;

    if(idness==ID.IDREF)
        l = new IDREFS(l,itemType);

    if(adapter!=null)
        l = new AdaptedLister(l,adapter.adapterType);

    return l;
}
 
Example 9
Source File: ElementInfoImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private ID calcId() {
    // TODO: share code with PropertyInfoImpl
    if(reader().hasMethodAnnotation(XmlID.class,method)) {
        return ID.ID;
    } else
    if(reader().hasMethodAnnotation(XmlIDREF.class,method)) {
        return ID.IDREF;
    } else {
        return ID.NONE;
    }
}
 
Example 10
Source File: PropertyInfoImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Called after all the {@link TypeInfo}s are collected into the governing {@link TypeInfoSet}.
 *
 * Derived class can do additional actions to complete the model.
 */
protected void link() {
    if(id==ID.IDREF) {
        // make sure that the refereced type has ID
        for (TypeInfo<T,C> ti : ref()) {
            if(!ti.canBeReferencedByIDREF())
                parent.builder.reportError(new IllegalAnnotationException(
                Messages.INVALID_IDREF.format(
                    parent.builder.nav.getTypeName(ti.getType())), this ));
        }
    }
}
 
Example 11
Source File: ElementInfoImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private ID calcId() {
    // TODO: share code with PropertyInfoImpl
    if(reader().hasMethodAnnotation(XmlID.class,method)) {
        return ID.ID;
    } else
    if(reader().hasMethodAnnotation(XmlIDREF.class,method)) {
        return ID.IDREF;
    } else {
        return ID.NONE;
    }
}
 
Example 12
Source File: PropertyInfoImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Called after all the {@link TypeInfo}s are collected into the governing {@link TypeInfoSet}.
 *
 * Derived class can do additional actions to complete the model.
 */
protected void link() {
    if(id==ID.IDREF) {
        // make sure that the refereced type has ID
        for (TypeInfo<T,C> ti : ref()) {
            if(!ti.canBeReferencedByIDREF())
                parent.builder.reportError(new IllegalAnnotationException(
                Messages.INVALID_IDREF.format(
                    parent.builder.nav.getTypeName(ti.getType())), this ));
        }
    }
}
 
Example 13
Source File: ElementInfoImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private ID calcId() {
    // TODO: share code with PropertyInfoImpl
    if(reader().hasMethodAnnotation(XmlID.class,method)) {
        return ID.ID;
    } else
    if(reader().hasMethodAnnotation(XmlIDREF.class,method)) {
        return ID.IDREF;
    } else {
        return ID.NONE;
    }
}
 
Example 14
Source File: PropertyInfoImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private ID calcId() {
    if(seed.hasAnnotation(XmlID.class)) {
        // check the type
        if(!nav().isSameType(getIndividualType(), nav().ref(String.class)))
            parent.builder.reportError(new IllegalAnnotationException(
                Messages.ID_MUST_BE_STRING.format(getName()), seed )
            );
        return ID.ID;
    } else
    if(seed.hasAnnotation(XmlIDREF.class)) {
        return ID.IDREF;
    } else {
        return ID.NONE;
    }
}
 
Example 15
Source File: PropertyInfoImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Called after all the {@link TypeInfo}s are collected into the governing {@link TypeInfoSet}.
 *
 * Derived class can do additional actions to complete the model.
 */
protected void link() {
    if(id==ID.IDREF) {
        // make sure that the refereced type has ID
        for (TypeInfo<T,C> ti : ref()) {
            if(!ti.canBeReferencedByIDREF())
                parent.builder.reportError(new IllegalAnnotationException(
                Messages.INVALID_IDREF.format(
                    parent.builder.nav.getTypeName(ti.getType())), this ));
        }
    }
}
 
Example 16
Source File: Lister.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets a reference to the appropriate {@link Lister} object
 * if the field is a multi-value field. Otherwise null.
 *
 * @param fieldType
 *      the type of the field that stores the collection
 * @param idness
 *      ID-ness of the property.
 * @param adapter
 *      adapter to be used for individual items. can be null.
 */
public static <BeanT,PropT,ItemT,PackT>
    Lister<BeanT,PropT,ItemT,PackT> create(Type fieldType,ID idness, Adapter<Type,Class> adapter) {

    Class rawType = (Class) Utils.REFLECTION_NAVIGATOR.erasure(fieldType);
    Class itemType;

    Lister l;
    if( rawType.isArray() ) {
        itemType = rawType.getComponentType();
        l = getArrayLister(itemType);
    } else
    if( Collection.class.isAssignableFrom(rawType) ) {
        Type bt = Utils.REFLECTION_NAVIGATOR.getBaseClass(fieldType,Collection.class);
        if(bt instanceof ParameterizedType)
            itemType = (Class) Utils.REFLECTION_NAVIGATOR.erasure(((ParameterizedType)bt).getActualTypeArguments()[0]);
        else
            itemType = Object.class;
        l = new CollectionLister(getImplClass(rawType));
    } else
        return null;

    if(idness==ID.IDREF)
        l = new IDREFS(l,itemType);

    if(adapter!=null)
        l = new AdaptedLister(l,adapter.adapterType);

    return l;
}
 
Example 17
Source File: PropertyInfoImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private ID calcId() {
    if(seed.hasAnnotation(XmlID.class)) {
        // check the type
        if(!nav().isSameType(getIndividualType(), nav().ref(String.class)))
            parent.builder.reportError(new IllegalAnnotationException(
                Messages.ID_MUST_BE_STRING.format(getName()), seed )
            );
        return ID.ID;
    } else
    if(seed.hasAnnotation(XmlIDREF.class)) {
        return ID.IDREF;
    } else {
        return ID.NONE;
    }
}
 
Example 18
Source File: PropertyInfoImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private ID calcId() {
    if(seed.hasAnnotation(XmlID.class)) {
        // check the type
        if(!nav().isSameType(getIndividualType(), nav().ref(String.class)))
            parent.builder.reportError(new IllegalAnnotationException(
                Messages.ID_MUST_BE_STRING.format(getName()), seed )
            );
        return ID.ID;
    } else
    if(seed.hasAnnotation(XmlIDREF.class)) {
        return ID.IDREF;
    } else {
        return ID.NONE;
    }
}
 
Example 19
Source File: PropertyInfoImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Called after all the {@link TypeInfo}s are collected into the governing {@link TypeInfoSet}.
 *
 * Derived class can do additional actions to complete the model.
 */
protected void link() {
    if(id==ID.IDREF) {
        // make sure that the refereced type has ID
        for (TypeInfo<T,C> ti : ref()) {
            if(!ti.canBeReferencedByIDREF())
                parent.builder.reportError(new IllegalAnnotationException(
                Messages.INVALID_IDREF.format(
                    parent.builder.nav.getTypeName(ti.getType())), this ));
        }
    }
}
 
Example 20
Source File: PropertyInfoImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Called after all the {@link TypeInfo}s are collected into the governing {@link TypeInfoSet}.
 *
 * Derived class can do additional actions to complete the model.
 */
protected void link() {
    if(id==ID.IDREF) {
        // make sure that the refereced type has ID
        for (TypeInfo<T,C> ti : ref()) {
            if(!ti.canBeReferencedByIDREF())
                parent.builder.reportError(new IllegalAnnotationException(
                Messages.INVALID_IDREF.format(
                    parent.builder.nav.getTypeName(ti.getType())), this ));
        }
    }
}