Search in sources :

Example 26 with TypeMappingInfo

use of org.eclipse.persistence.jaxb.TypeMappingInfo in project eclipselink by eclipse-ee4j.

the class JaxbTypeToSchemaTypeTestCases method testDatahandlerTypes.

public void testDatahandlerTypes() throws Exception {
    TypeMappingInfo tmi = new TypeMappingInfo();
    tmi.setType(DataHandler.class);
    tmi.setElementScope(TypeMappingInfo.ElementScope.Local);
    tmi.setXmlTagName(new QName("uri1", "tmi1"));
    Annotation[] annotations = getClass().getField("attachmentRefField").getAnnotations();
    tmi.setAnnotations(annotations);
    TypeMappingInfo tmi2 = new TypeMappingInfo();
    tmi2.setElementScope(TypeMappingInfo.ElementScope.Local);
    tmi2.setXmlTagName(new QName("uri1", "tmi2"));
    tmi2.setType(DataHandler.class);
    TypeMappingInfo[] tmis = new TypeMappingInfo[] { tmi, tmi2 };
    JAXBContext ctx = (JAXBContext) JAXBContextFactory.createContext(tmis, null, Thread.currentThread().getContextClassLoader());
    Map<Type, QName> typeMap = ctx.getTypeToSchemaType();
    assertEquals(0, typeMap.size());
    Map<TypeMappingInfo, QName> tmiMap = ctx.getTypeMappingInfoToSchemaType();
    assertEquals(2, tmiMap.size());
    assertNotNull(tmiMap.get(tmi2));
    assertEquals(XMLConstants.BASE_64_BINARY_QNAME, tmiMap.get(tmi2));
    assertNotNull(tmiMap.get(tmi));
    assertEquals(XMLConstants.SWA_REF_QNAME, tmiMap.get(tmi));
}
Also used : Type(java.lang.reflect.Type) QName(javax.xml.namespace.QName) JAXBContext(org.eclipse.persistence.jaxb.JAXBContext) TypeMappingInfo(org.eclipse.persistence.jaxb.TypeMappingInfo) Annotation(java.lang.annotation.Annotation)

Example 27 with TypeMappingInfo

use of org.eclipse.persistence.jaxb.TypeMappingInfo in project eclipselink by eclipse-ee4j.

the class JaxbTypeToSchemaTypeTestCases method testInnerClass.

public void testInnerClass() throws Exception {
    TypeMappingInfo tmi1 = new TypeMappingInfo();
    tmi1.setXmlTagName(new QName("test", "theRoot"));
    tmi1.setElementScope(ElementScope.Global);
    tmi1.setType(MyInnerClass.class);
    TypeMappingInfo[] typesToBeBound = new TypeMappingInfo[1];
    typesToBeBound[0] = tmi1;
    JAXBContext ctx = (JAXBContext) JAXBContextFactory.createContext(typesToBeBound, null, Thread.currentThread().getContextClassLoader());
    Map<TypeMappingInfo, QName> types = ctx.getTypeMappingInfoToSchemaType();
    assertEquals(1, types.size());
    assertNotNull(types.get(tmi1));
}
Also used : QName(javax.xml.namespace.QName) JAXBContext(org.eclipse.persistence.jaxb.JAXBContext) TypeMappingInfo(org.eclipse.persistence.jaxb.TypeMappingInfo)

Example 28 with TypeMappingInfo

use of org.eclipse.persistence.jaxb.TypeMappingInfo in project eclipselink by eclipse-ee4j.

the class JaxbTypeToSchemaTypeTestCases method testStringType.

public void testStringType() throws Exception {
    TypeMappingInfo tmi = mappingInfo("stringField");
    TypeMappingInfo[] tmis = new TypeMappingInfo[] { tmi };
    JAXBContext ctx = (JAXBContext) JAXBContextFactory.createContext(tmis, null, Thread.currentThread().getContextClassLoader());
    Map<Type, QName> typeMap = ctx.getTypeToSchemaType();
    assertEquals(0, typeMap.size());
    Map<TypeMappingInfo, QName> tmiMap = ctx.getTypeMappingInfoToSchemaType();
    assertEquals(1, tmiMap.size());
    assertNotNull(tmiMap.get(tmi));
}
Also used : Type(java.lang.reflect.Type) QName(javax.xml.namespace.QName) JAXBContext(org.eclipse.persistence.jaxb.JAXBContext) TypeMappingInfo(org.eclipse.persistence.jaxb.TypeMappingInfo)

Example 29 with TypeMappingInfo

use of org.eclipse.persistence.jaxb.TypeMappingInfo in project eclipselink by eclipse-ee4j.

the class JaxbTypeToSchemaTypeTestCases method testByteArray.

public void testByteArray() throws Exception {
    TypeMappingInfo tmi = new TypeMappingInfo();
    tmi.setType(byte[].class);
    TypeMappingInfo[] tmis = new TypeMappingInfo[] { tmi };
    JAXBContext ctx = (JAXBContext) JAXBContextFactory.createContext(tmis, null, Thread.currentThread().getContextClassLoader());
    Map<Type, QName> typeMap = ctx.getTypeToSchemaType();
    assertEquals(0, typeMap.size());
    Map<TypeMappingInfo, QName> tmiMap = ctx.getTypeMappingInfoToSchemaType();
    assertEquals(1, tmiMap.size());
    assertNotNull(tmiMap.get(tmi));
}
Also used : Type(java.lang.reflect.Type) QName(javax.xml.namespace.QName) JAXBContext(org.eclipse.persistence.jaxb.JAXBContext) TypeMappingInfo(org.eclipse.persistence.jaxb.TypeMappingInfo)

Example 30 with TypeMappingInfo

use of org.eclipse.persistence.jaxb.TypeMappingInfo in project eclipselink by eclipse-ee4j.

the class JaxbTypeToSchemaTypeTestCases method testInteger2DArray.

public void testInteger2DArray() throws Exception {
    TypeMappingInfo tmi = new TypeMappingInfo();
    tmi.setType(Integer[][].class);
    TypeMappingInfo[] tmis = new TypeMappingInfo[] { tmi };
    JAXBContext ctx = (JAXBContext) JAXBContextFactory.createContext(tmis, null, Thread.currentThread().getContextClassLoader());
    Map<Type, QName> typeMap = ctx.getTypeToSchemaType();
    assertEquals(0, typeMap.size());
    Map<TypeMappingInfo, QName> tmiMap = ctx.getTypeMappingInfoToSchemaType();
    assertEquals(1, tmiMap.size());
    assertNotNull(tmiMap.get(tmi));
}
Also used : Type(java.lang.reflect.Type) QName(javax.xml.namespace.QName) JAXBContext(org.eclipse.persistence.jaxb.JAXBContext) TypeMappingInfo(org.eclipse.persistence.jaxb.TypeMappingInfo)

Aggregations

TypeMappingInfo (org.eclipse.persistence.jaxb.TypeMappingInfo)94 QName (javax.xml.namespace.QName)83 Annotation (java.lang.annotation.Annotation)19 Type (java.lang.reflect.Type)18 JAXBContext (org.eclipse.persistence.jaxb.JAXBContext)17 HashMap (java.util.HashMap)6 JAXBContext (jakarta.xml.bind.JAXBContext)5 JAXBElement (jakarta.xml.bind.JAXBElement)4 Map (java.util.Map)4 JavaClass (org.eclipse.persistence.jaxb.javamodel.JavaClass)4 Element (org.w3c.dom.Element)4 JAXBException (org.eclipse.persistence.exceptions.JAXBException)3 JAXBMarshaller (org.eclipse.persistence.jaxb.JAXBMarshaller)3 TypeInfo (com.sun.xml.ws.spi.db.TypeInfo)2 XmlElement (jakarta.xml.bind.annotation.XmlElement)2 XmlList (jakarta.xml.bind.annotation.XmlList)2 XmlRootElement (jakarta.xml.bind.annotation.XmlRootElement)2 StringWriter (java.io.StringWriter)2 GenericArrayType (java.lang.reflect.GenericArrayType)2 ArrayList (java.util.ArrayList)2