com.sun.tools.internal.xjc.model.CAdapter Java Examples

The following examples show how to use com.sun.tools.internal.xjc.model.CAdapter. 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: TypeAndAnnotationImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void annotate(JAnnotatable programElement) {
    if(typeUse.getAdapterUse()==null && !typeUse.isCollection())
        return; // nothing

    CAdapter adapterUse = typeUse.getAdapterUse();
    if(adapterUse!=null) {
        // ugly, ugly hack
        if(adapterUse.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            programElement.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            programElement.annotate2(XmlJavaTypeAdapterWriter.class).value(
                adapterUse.adapterType.toType(outline,EXPOSED));
        }
    }
    if(typeUse.isCollection())
        programElement.annotate(XmlList.class);
}
 
Example #2
Source File: BIConversion.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public TypeUse getTypeUse(XSSimpleType owner) {
    if(typeUse!=null)
        return typeUse;

    JCodeModel cm = getCodeModel();

    JDefinedClass a;
    try {
        a = cm._class(adapter);
        a.hide();   // we assume this is given by the user
        a._extends(cm.ref(XmlAdapter.class).narrow(String.class).narrow(
                cm.ref(type)));
    } catch (JClassAlreadyExistsException e) {
        a = e.getExistingClass();
    }

    // TODO: it's not correct to say that it adapts from String,
    // but OTOH I don't think we can compute that.
    typeUse = TypeUseFactory.adapt(
            CBuiltinLeafInfo.STRING,
            new CAdapter(a));

    return typeUse;
}
 
Example #3
Source File: TypeAndAnnotationImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void annotate(JAnnotatable programElement) {
    if(typeUse.getAdapterUse()==null && !typeUse.isCollection())
        return; // nothing

    CAdapter adapterUse = typeUse.getAdapterUse();
    if(adapterUse!=null) {
        // ugly, ugly hack
        if(adapterUse.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            programElement.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            programElement.annotate2(XmlJavaTypeAdapterWriter.class).value(
                adapterUse.adapterType.toType(outline,EXPOSED));
        }
    }
    if(typeUse.isCollection())
        programElement.annotate(XmlList.class);
}
 
Example #4
Source File: TypeAndAnnotationImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public JType getTypeClass() {
    CAdapter a = typeUse.getAdapterUse();
    NType nt;
    if(a!=null)
        nt = a.customType;
    else
        nt = typeUse.getInfo().getType();

    JType jt = nt.toType(outline,EXPOSED);

    JPrimitiveType prim = jt.boxify().getPrimitiveType();
    if(!typeUse.isCollection() && prim!=null)
        jt = prim;

    if(typeUse.isCollection())
        jt = jt.array();

    return jt;
}
 
Example #5
Source File: TypeAndAnnotationImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public JType getTypeClass() {
    CAdapter a = typeUse.getAdapterUse();
    NType nt;
    if(a!=null)
        nt = a.customType;
    else
        nt = typeUse.getInfo().getType();

    JType jt = nt.toType(outline,EXPOSED);

    JPrimitiveType prim = jt.boxify().getPrimitiveType();
    if(!typeUse.isCollection() && prim!=null)
        jt = prim;

    if(typeUse.isCollection())
        jt = jt.array();

    return jt;
}
 
Example #6
Source File: TypeAndAnnotationImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void annotate(JAnnotatable programElement) {
    if(typeUse.getAdapterUse()==null && !typeUse.isCollection())
        return; // nothing

    CAdapter adapterUse = typeUse.getAdapterUse();
    if(adapterUse!=null) {
        // ugly, ugly hack
        if(adapterUse.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            programElement.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            programElement.annotate2(XmlJavaTypeAdapterWriter.class).value(
                adapterUse.adapterType.toType(outline,EXPOSED));
        }
    }
    if(typeUse.isCollection())
        programElement.annotate(XmlList.class);
}
 
Example #7
Source File: BIConversion.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public TypeUse getTypeUse(XSSimpleType owner) {
    if(typeUse!=null)
        return typeUse;

    JCodeModel cm = getCodeModel();

    JDefinedClass a;
    try {
        a = cm._class(adapter);
        a.hide();   // we assume this is given by the user
        a._extends(cm.ref(XmlAdapter.class).narrow(String.class).narrow(
                cm.ref(type)));
    } catch (JClassAlreadyExistsException e) {
        a = e.getExistingClass();
    }

    // TODO: it's not correct to say that it adapts from String,
    // but OTOH I don't think we can compute that.
    typeUse = TypeUseFactory.adapt(
            CBuiltinLeafInfo.STRING,
            new CAdapter(a));

    return typeUse;
}
 
Example #8
Source File: BIConversion.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public TypeUse getTypeUse(XSSimpleType owner) {
    if(typeUse!=null)
        return typeUse;

    JCodeModel cm = getCodeModel();

    JDefinedClass a;
    try {
        a = cm._class(adapter);
        a.hide();   // we assume this is given by the user
        a._extends(cm.ref(XmlAdapter.class).narrow(String.class).narrow(
                cm.ref(type)));
    } catch (JClassAlreadyExistsException e) {
        a = e.getExistingClass();
    }

    // TODO: it's not correct to say that it adapts from String,
    // but OTOH I don't think we can compute that.
    typeUse = TypeUseFactory.adapt(
            CBuiltinLeafInfo.STRING,
            new CAdapter(a));

    return typeUse;
}
 
Example #9
Source File: TypeAndAnnotationImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void annotate(JAnnotatable programElement) {
    if(typeUse.getAdapterUse()==null && !typeUse.isCollection())
        return; // nothing

    CAdapter adapterUse = typeUse.getAdapterUse();
    if(adapterUse!=null) {
        // ugly, ugly hack
        if(adapterUse.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            programElement.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            programElement.annotate2(XmlJavaTypeAdapterWriter.class).value(
                adapterUse.adapterType.toType(outline,EXPOSED));
        }
    }
    if(typeUse.isCollection())
        programElement.annotate(XmlList.class);
}
 
Example #10
Source File: TypeAndAnnotationImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public JType getTypeClass() {
    CAdapter a = typeUse.getAdapterUse();
    NType nt;
    if(a!=null)
        nt = a.customType;
    else
        nt = typeUse.getInfo().getType();

    JType jt = nt.toType(outline,EXPOSED);

    JPrimitiveType prim = jt.boxify().getPrimitiveType();
    if(!typeUse.isCollection() && prim!=null)
        jt = prim;

    if(typeUse.isCollection())
        jt = jt.array();

    return jt;
}
 
Example #11
Source File: BIConversion.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public TypeUse getTypeUse(XSSimpleType owner) {
    if(typeUse!=null)
        return typeUse;

    JCodeModel cm = getCodeModel();

    JDefinedClass a;
    try {
        a = cm._class(adapter);
        a.hide();   // we assume this is given by the user
        a._extends(cm.ref(XmlAdapter.class).narrow(String.class).narrow(
                cm.ref(type)));
    } catch (JClassAlreadyExistsException e) {
        a = e.getExistingClass();
    }

    // TODO: it's not correct to say that it adapts from String,
    // but OTOH I don't think we can compute that.
    typeUse = TypeUseFactory.adapt(
            CBuiltinLeafInfo.STRING,
            new CAdapter(a));

    return typeUse;
}
 
Example #12
Source File: TypeAndAnnotationImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public JType getTypeClass() {
    CAdapter a = typeUse.getAdapterUse();
    NType nt;
    if(a!=null)
        nt = a.customType;
    else
        nt = typeUse.getInfo().getType();

    JType jt = nt.toType(outline,EXPOSED);

    JPrimitiveType prim = jt.boxify().getPrimitiveType();
    if(!typeUse.isCollection() && prim!=null)
        jt = prim;

    if(typeUse.isCollection())
        jt = jt.array();

    return jt;
}
 
Example #13
Source File: TypeAndAnnotationImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public JType getTypeClass() {
    CAdapter a = typeUse.getAdapterUse();
    NType nt;
    if(a!=null)
        nt = a.customType;
    else
        nt = typeUse.getInfo().getType();

    JType jt = nt.toType(outline,EXPOSED);

    JPrimitiveType prim = jt.boxify().getPrimitiveType();
    if(!typeUse.isCollection() && prim!=null)
        jt = prim;

    if(typeUse.isCollection())
        jt = jt.array();

    return jt;
}
 
Example #14
Source File: TypeAndAnnotationImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public JType getTypeClass() {
    CAdapter a = typeUse.getAdapterUse();
    NType nt;
    if(a!=null)
        nt = a.customType;
    else
        nt = typeUse.getInfo().getType();

    JType jt = nt.toType(outline,EXPOSED);

    JPrimitiveType prim = jt.boxify().getPrimitiveType();
    if(!typeUse.isCollection() && prim!=null)
        jt = prim;

    if(typeUse.isCollection())
        jt = jt.array();

    return jt;
}
 
Example #15
Source File: BIConversion.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public TypeUse getTypeUse(XSSimpleType owner) {
    if(typeUse!=null)
        return typeUse;

    JCodeModel cm = getCodeModel();

    JDefinedClass a;
    try {
        a = cm._class(adapter);
        a.hide();   // we assume this is given by the user
        a._extends(cm.ref(XmlAdapter.class).narrow(String.class).narrow(
                cm.ref(type)));
    } catch (JClassAlreadyExistsException e) {
        a = e.getExistingClass();
    }

    // TODO: it's not correct to say that it adapts from String,
    // but OTOH I don't think we can compute that.
    typeUse = TypeUseFactory.adapt(
            CBuiltinLeafInfo.STRING,
            new CAdapter(a));

    return typeUse;
}
 
Example #16
Source File: TypeAndAnnotationImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public JType getTypeClass() {
    CAdapter a = typeUse.getAdapterUse();
    NType nt;
    if(a!=null)
        nt = a.customType;
    else
        nt = typeUse.getInfo().getType();

    JType jt = nt.toType(outline,EXPOSED);

    JPrimitiveType prim = jt.boxify().getPrimitiveType();
    if(!typeUse.isCollection() && prim!=null)
        jt = prim;

    if(typeUse.isCollection())
        jt = jt.array();

    return jt;
}
 
Example #17
Source File: TypeAndAnnotationImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void annotate(JAnnotatable programElement) {
    if(typeUse.getAdapterUse()==null && !typeUse.isCollection())
        return; // nothing

    CAdapter adapterUse = typeUse.getAdapterUse();
    if(adapterUse!=null) {
        // ugly, ugly hack
        if(adapterUse.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            programElement.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            programElement.annotate2(XmlJavaTypeAdapterWriter.class).value(
                adapterUse.adapterType.toType(outline,EXPOSED));
        }
    }
    if(typeUse.isCollection())
        programElement.annotate(XmlList.class);
}
 
Example #18
Source File: TypeAndAnnotationImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void annotate(JAnnotatable programElement) {
    if(typeUse.getAdapterUse()==null && !typeUse.isCollection())
        return; // nothing

    CAdapter adapterUse = typeUse.getAdapterUse();
    if(adapterUse!=null) {
        // ugly, ugly hack
        if(adapterUse.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            programElement.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            programElement.annotate2(XmlJavaTypeAdapterWriter.class).value(
                adapterUse.adapterType.toType(outline,EXPOSED));
        }
    }
    if(typeUse.isCollection())
        programElement.annotate(XmlList.class);
}
 
Example #19
Source File: BIConversion.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public TypeUse getTypeUse(XSSimpleType owner) {
    if(typeUse!=null)
        return typeUse;

    JCodeModel cm = getCodeModel();

    JDefinedClass a;
    try {
        a = cm._class(adapter);
        a.hide();   // we assume this is given by the user
        a._extends(cm.ref(XmlAdapter.class).narrow(String.class).narrow(
                cm.ref(type)));
    } catch (JClassAlreadyExistsException e) {
        a = e.getExistingClass();
    }

    // TODO: it's not correct to say that it adapts from String,
    // but OTOH I don't think we can compute that.
    typeUse = TypeUseFactory.adapt(
            CBuiltinLeafInfo.STRING,
            new CAdapter(a));

    return typeUse;
}
 
Example #20
Source File: TypeAndAnnotationImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public JType getTypeClass() {
    CAdapter a = typeUse.getAdapterUse();
    NType nt;
    if(a!=null)
        nt = a.customType;
    else
        nt = typeUse.getInfo().getType();

    JType jt = nt.toType(outline,EXPOSED);

    JPrimitiveType prim = jt.boxify().getPrimitiveType();
    if(!typeUse.isCollection() && prim!=null)
        jt = prim;

    if(typeUse.isCollection())
        jt = jt.array();

    return jt;
}
 
Example #21
Source File: TypeAndAnnotationImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void annotate(JAnnotatable programElement) {
    if(typeUse.getAdapterUse()==null && !typeUse.isCollection())
        return; // nothing

    CAdapter adapterUse = typeUse.getAdapterUse();
    if(adapterUse!=null) {
        // ugly, ugly hack
        if(adapterUse.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            programElement.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            programElement.annotate2(XmlJavaTypeAdapterWriter.class).value(
                adapterUse.adapterType.toType(outline,EXPOSED));
        }
    }
    if(typeUse.isCollection())
        programElement.annotate(XmlList.class);
}
 
Example #22
Source File: TypeAndAnnotationImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void annotate(JAnnotatable programElement) {
    if(typeUse.getAdapterUse()==null && !typeUse.isCollection())
        return; // nothing

    CAdapter adapterUse = typeUse.getAdapterUse();
    if(adapterUse!=null) {
        // ugly, ugly hack
        if(adapterUse.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            programElement.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            programElement.annotate2(XmlJavaTypeAdapterWriter.class).value(
                adapterUse.adapterType.toType(outline,EXPOSED));
        }
    }
    if(typeUse.isCollection())
        programElement.annotate(XmlList.class);
}
 
Example #23
Source File: BIConversion.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public TypeUse getTypeUse(XSSimpleType owner) {
    if(typeUse!=null)
        return typeUse;

    JCodeModel cm = getCodeModel();

    JDefinedClass a;
    try {
        a = cm._class(adapter);
        a.hide();   // we assume this is given by the user
        a._extends(cm.ref(XmlAdapter.class).narrow(String.class).narrow(
                cm.ref(type)));
    } catch (JClassAlreadyExistsException e) {
        a = e.getExistingClass();
    }

    // TODO: it's not correct to say that it adapts from String,
    // but OTOH I don't think we can compute that.
    typeUse = TypeUseFactory.adapt(
            CBuiltinLeafInfo.STRING,
            new CAdapter(a));

    return typeUse;
}
 
Example #24
Source File: BIConversion.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public TypeUse getTypeUse(XSSimpleType owner) {
    if(typeUse!=null)
        return typeUse;

    JCodeModel cm = getCodeModel();

    JDefinedClass a;
    try {
        a = cm._class(adapter);
        a.hide();   // we assume this is given by the user
        a._extends(cm.ref(XmlAdapter.class).narrow(String.class).narrow(
                cm.ref(type)));
    } catch (JClassAlreadyExistsException e) {
        a = e.getExistingClass();
    }

    // TODO: it's not correct to say that it adapts from String,
    // but OTOH I don't think we can compute that.
    typeUse = TypeUseFactory.adapt(
            CBuiltinLeafInfo.STRING,
            new CAdapter(a));

    return typeUse;
}
 
Example #25
Source File: ElementMappingImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
protected ElementMappingImpl(JAXBModelImpl parent, CElementInfo elementInfo) {
    super(parent,elementInfo);

    TypeUse t = clazz.getContentType();
    if(clazz.getProperty().isCollection())
        t = TypeUseFactory.makeCollection(t);
    CAdapter a = clazz.getProperty().getAdapter();
    if(a!=null)
        t = TypeUseFactory.adapt(t,a);
    taa = new TypeAndAnnotationImpl(parent.outline,t);
}
 
Example #26
Source File: BeanGenerator.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates {@link XmlJavaTypeAdapter} from {@link PropertyInfo} if necessary.
 * Also generates other per-property annotations
 * (such as {@link XmlID}, {@link XmlIDREF}, and {@link XmlMimeType} if necessary.
 */
public final void generateAdapterIfNecessary(CPropertyInfo prop, JAnnotatable field) {
    CAdapter adapter = prop.getAdapter();
    if (adapter != null) {
        if (adapter.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            field.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            XmlJavaTypeAdapterWriter xjtw = field.annotate2(XmlJavaTypeAdapterWriter.class);
            xjtw.value(adapter.adapterType.toType(this, EXPOSED));
        }
    }

    switch (prop.id()) {
        case ID:
            field.annotate(XmlID.class);
            break;
        case IDREF:
            field.annotate(XmlIDREF.class);
            break;
    }

    if (prop.getExpectedMimeType() != null) {
        field.annotate2(XmlMimeTypeWriter.class).value(prop.getExpectedMimeType().toString());
    }
}
 
Example #27
Source File: ElementMappingImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
protected ElementMappingImpl(JAXBModelImpl parent, CElementInfo elementInfo) {
    super(parent,elementInfo);

    TypeUse t = clazz.getContentType();
    if(clazz.getProperty().isCollection())
        t = TypeUseFactory.makeCollection(t);
    CAdapter a = clazz.getProperty().getAdapter();
    if(a!=null)
        t = TypeUseFactory.adapt(t,a);
    taa = new TypeAndAnnotationImpl(parent.outline,t);
}
 
Example #28
Source File: BeanGenerator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates {@link XmlJavaTypeAdapter} from {@link PropertyInfo} if necessary.
 * Also generates other per-property annotations
 * (such as {@link XmlID}, {@link XmlIDREF}, and {@link XmlMimeType} if necessary.
 */
public final void generateAdapterIfNecessary(CPropertyInfo prop, JAnnotatable field) {
    CAdapter adapter = prop.getAdapter();
    if (adapter != null) {
        if (adapter.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            field.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            XmlJavaTypeAdapterWriter xjtw = field.annotate2(XmlJavaTypeAdapterWriter.class);
            xjtw.value(adapter.adapterType.toType(this, EXPOSED));
        }
    }

    switch (prop.id()) {
        case ID:
            field.annotate(XmlID.class);
            break;
        case IDREF:
            field.annotate(XmlIDREF.class);
            break;
    }

    if (prop.getExpectedMimeType() != null) {
        field.annotate2(XmlMimeTypeWriter.class).value(prop.getExpectedMimeType().toString());
    }
}
 
Example #29
Source File: BeanGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates {@link XmlJavaTypeAdapter} from {@link PropertyInfo} if necessary.
 * Also generates other per-property annotations
 * (such as {@link XmlID}, {@link XmlIDREF}, and {@link XmlMimeType} if necessary.
 */
public final void generateAdapterIfNecessary(CPropertyInfo prop, JAnnotatable field) {
    CAdapter adapter = prop.getAdapter();
    if (adapter != null) {
        if (adapter.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            field.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            XmlJavaTypeAdapterWriter xjtw = field.annotate2(XmlJavaTypeAdapterWriter.class);
            xjtw.value(adapter.adapterType.toType(this, EXPOSED));
        }
    }

    switch (prop.id()) {
        case ID:
            field.annotate(XmlID.class);
            break;
        case IDREF:
            field.annotate(XmlIDREF.class);
            break;
    }

    if (prop.getExpectedMimeType() != null) {
        field.annotate2(XmlMimeTypeWriter.class).value(prop.getExpectedMimeType().toString());
    }
}
 
Example #30
Source File: ElementMappingImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
protected ElementMappingImpl(JAXBModelImpl parent, CElementInfo elementInfo) {
    super(parent,elementInfo);

    TypeUse t = clazz.getContentType();
    if(clazz.getProperty().isCollection())
        t = TypeUseFactory.makeCollection(t);
    CAdapter a = clazz.getProperty().getAdapter();
    if(a!=null)
        t = TypeUseFactory.adapt(t,a);
    taa = new TypeAndAnnotationImpl(parent.outline,t);
}