Package org.apache.cxf.aegis.type

Examples of org.apache.cxf.aegis.type.Type


        assertTrue(type instanceof EnumType);
    }

    @Test
    public void testTypeAttributeOnEnum() throws Exception {
        Type type = tm.getTypeCreator().createType(TestEnum.class);

        assertEquals("urn:xfire:foo", type.getSchemaType().getNamespaceURI());

        assertTrue(type instanceof EnumType);
    }
View Full Code Here


        assertTrue(type instanceof EnumType);
    }

    @Test
    public void testXFireTypeAttributeOnEnum() throws Exception {
        Type type = tm.getTypeCreator().createType(XFireTestEnum.class);

        assertEquals("urn:xfire:foo", type.getSchemaType().getNamespaceURI());

        assertTrue(type instanceof EnumType);
    }
View Full Code Here

        assertTrue(type instanceof EnumType);
    }

    @Test
    public void testJaxbTypeAttributeOnEnum() throws Exception {
        Type type = tm.getTypeCreator().createType(JaxbTestEnum.class);

        assertEquals("urn:xfire:foo", type.getSchemaType().getNamespaceURI());

        assertTrue(type instanceof EnumType);
    }
View Full Code Here

        assertValid("//xsd:restriction[@base='xsd:string']/xsd:enumeration[@value='POUNDS']", wsdl);
    }

    @Test
    public void testNillable() throws Exception {
        Type type = tm.getTypeCreator().createType(EnumBean.class);

        tm.register(type);

        Element root = new Element("root");
        JDOMWriter writer = new JDOMWriter(root);

        type.writeObject(new EnumBean(), writer, getContext());

        JDOMReader reader = new JDOMReader(root);
        Object value = type.readObject(reader, getContext());

        assertTrue(value instanceof EnumBean);
        EnumBean bean = (EnumBean)value;
        assertNull(bean.getCurrency());
    }
View Full Code Here

                rootClasses.add(c);
            }
        }
        
        for (Class<?> c : rootClasses) {
            Type t = typeMapping.getType(c);
            if (t == null) {
                t = typeMapping.getTypeCreator().createType(c);
                typeMapping.register(t);
            }
            rootTypeQNames.add(t.getSchemaType());
            if (t instanceof BeanType) {
                BeanType bt = (BeanType)t;
                bt.getTypeInfo().setExtension(true);
                rootTypes.add(bt);
            }
View Full Code Here

    protected Collection readCollection(MessageReader reader, Context context) throws DatabindingException {
        Collection<Object> values = createCollection();

        while (reader.hasMoreElementReaders()) {
            MessageReader creader = reader.getNextElementReader();
            Type compType = TypeUtil.getReadType(creader.getXMLStreamReader(), context.getGlobalContext(),
                                                 getComponentType());

            if (creader.isXsiNil()) {
                values.add(null);
                creader.readToEnd();
            } else {
                values.add(compType.readObject(creader, context));
            }

            // check max occurs
            int size = values.size();
            if (size > maxOccurs) {
View Full Code Here

        boolean forceXsiWrite = false;
        if (values == null) {
            return;
        }

        Type type = getComponentType();
        if (type == null) {
            throw new DatabindingException("Couldn't find type for array.");
        }
        if (XmlSchemaConstants.ANY_TYPE_QNAME.equals(type.getSchemaType())) {
            forceXsiWrite = true;
        }

        String ns = null;
        if (type.isAbstract()) {
            ns = getSchemaType().getNamespaceURI();
        } else {
            ns = type.getSchemaType().getNamespaceURI();
        }

        String name = type.getSchemaType().getLocalPart();


        Class arrayType = type.getTypeClass();

        boolean oldXsiWrite = context.getGlobalContext().isWriteXsiTypes();
        try {
            if (forceXsiWrite) {
                context.getGlobalContext().setWriteXsiTypes(true);
View Full Code Here

            complex.addContent(seq);

            Element element = new Element("element", SOAPConstants.XSD_PREFIX, SOAPConstants.XSD);
            seq.addContent(element);

            Type componentType = getComponentType();
            String prefix = NamespaceHelper.getUniquePrefix(root, componentType.getSchemaType()
                .getNamespaceURI());

            element.setAttribute(new Attribute("name", componentType.getSchemaType().getLocalPart()));
            element.setAttribute(TypeUtil.createTypeAttribute(prefix, componentType, root));

            if (componentType.isNillable()) {
                element.setAttribute(new Attribute("nillable", "true"));
            }

            element.setAttribute(new Attribute("minOccurs", Long.valueOf(getMinOccurs()).toString()));
View Full Code Here

     * @return
     */
    public Type getComponentType() {
        Class compType = getTypeClass().getComponentType();

        Type type;

        if (componentName == null) {
            type = getTypeMapping().getType(compType);
        } else {
            type = getTypeMapping().getType(componentName);
View Full Code Here

        if (null == typeName && !readToDocument) {
            throw new DatabindingException("Missing 'xsi:type' attribute value");
        }

        Type type = null;
        QName typeQName = null;
        if (typeName != null) {
            typeQName = extractQName(reader, typeName);
        } else {
            typeQName = reader.getName();
        }

        TypeMapping tm = context.getTypeMapping();
        if (tm == null) {
            tm = getTypeMapping();
        }

        type = tm.getType(typeQName);

        if (type == null) {
            type = tm.getType(getSchemaType());
        }

        if (type == this) {
            throw new DatabindingException("Could not determine how to read type: " + typeQName);
        }
       
        if (type == null && readToDocument) {
            type = getTypeMapping().getType(Document.class);
        }

        if (null == type) {
            // TODO should check namespace as well..
            if (serializedWhenUnknown && "serializedJavaObject".equals(typeName)) {
                return reconstituteJavaObject(reader);
            }

            throw new DatabindingException("No mapped type for '" + typeName + "' (" + typeQName + ")");
        }

        return type.readObject(reader, context);
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.aegis.type.Type

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.