Package org.apache.xmlbeans

Examples of org.apache.xmlbeans.SchemaType


     * Called by code generated code to get the default attribute value
     * for a given attribute name, or null if none.
     */
    protected XmlAnySimpleType get_default_attribute_value(QName name)
    {
        SchemaType sType = schemaType();
        SchemaAttributeModel aModel = sType.getAttributeModel();
        if (aModel == null)
            return null;
        SchemaLocalAttribute sAttr = aModel.getAttribute(name);
        if (sAttr == null)
            return null;
View Full Code Here


        // first check against any patterns...
        if (_validateOnSet() && !_schemaType.matchPatternFacet(s))
            throw new XmlValueOutOfRangeException(XmlErrorCodes.DATATYPE_VALID$PATTERN_VALID,
                    new Object[] { "list", s, QNameHelper.readable(_schemaType) });

        SchemaType itemType = _schemaType.getListItemType();

        XmlSimpleList newval = lex(s, itemType, _voorVc, has_store() ? get_store() : null);

        // check enumeration
        if (_validateOnSet())
View Full Code Here

                s.indexOf('\r') >= 0;
    }

    public void set_list(List list)
    {
        SchemaType itemType = _schemaType.getListItemType();
        XmlSimpleList xList;

        boolean pushed = false;
        if (has_store())
        {
            NamespaceContext.push(new NamespaceContext(get_store()));
            pushed = true;
        }

        try
        {
            XmlAnySimpleType[] newval = new XmlAnySimpleType[list.size()];
            for (int i = 0; i < list.size(); i++)
            {
                Object entry = list.get(i);
                if ((entry instanceof XmlObject) && permits_inner_space((XmlObject)list.get(i)))
                {
                    String stringrep = list.get(i).toString();
                    if (contains_white_space(stringrep))
                        throw new XmlValueOutOfRangeException();
                }
                newval[i] = itemType.newValue(entry);
            }
            xList = new XmlSimpleList(Arrays.asList(newval));
        }
        finally
        {
View Full Code Here

                }
            } else {
                throw new DeploymentException("either root type qname or anonymous type qname must be set");
            }

            SchemaType schemaType = (SchemaType) schemaTypeKeyToSchemaTypeMap.get(key);
            if (schemaType == null) {
                // if it is a built-in type, then one assumes a redundant mapping.
                if (null != TypeMappingLookup.getFactoryPair(key.getqName())) {
                    continue;
                }
//              throw new DeploymentException("Schema type key " + key + " not found in analyzed schema: " + schemaTypeKeyToSchemaTypeMap);
                log.warn("Schema type key " + key + " not found in analyzed schema: " + schemaTypeKeyToSchemaTypeMap);
                continue;
            }
            mappedTypeQNames.add(key.getqName());

            String className = javaXmlTypeMapping.getJavaType().getStringValue().trim();
            Class clazz = null;
            try {
                clazz = ClassLoading.loadClass(className, cl);
            } catch (ClassNotFoundException e2) {
                throw new DeploymentException("Could not load java type", e2);
            }

            TypeInfo.UpdatableTypeInfo internalTypeInfo = defineSerializerPair(schemaType, clazz);

            populateInternalTypeInfo(clazz, key, schemaType, javaXmlTypeMapping, internalTypeInfo);

            typeInfoList.add(internalTypeInfo.buildTypeInfo());
        }

        Map qNameToKey = new HashMap();
        for (Iterator iter = schemaTypeKeyToSchemaTypeMap.keySet().iterator(); iter.hasNext();) {
            SchemaTypeKey key = (SchemaTypeKey) iter.next();
            qNameToKey.put(key.getqName(), key);
        }

        for (Iterator iter = operations.iterator(); iter.hasNext();) {
            OperationDesc operationDesc = (OperationDesc) iter.next();
            ArrayList parameters = new ArrayList(operationDesc.getParameters());
            ParameterDesc returnParameterDesc = operationDesc.getReturnParamDesc();
            if (null != returnParameterDesc.getTypeQName() &&
                    false == returnParameterDesc.getTypeQName().equals(XMLType.AXIS_VOID)) {
                parameters.add(returnParameterDesc);
            }
            for (Iterator iterator = parameters.iterator(); iterator.hasNext();) {
                ParameterDesc parameterDesc = (ParameterDesc) iterator.next();
                QName typeQName = parameterDesc.getTypeQName();
                if (null == typeQName) {
                    continue;
                } else if (mappedTypeQNames.contains(typeQName)) {
                    continue;
                } else if (typeQName.getNamespaceURI().equals(XML_SCHEMA_NS) ||
                        typeQName.getNamespaceURI().equals(SOAP_ENCODING_NS)) {
                    continue;
                }

                SchemaTypeKey key = (SchemaTypeKey) qNameToKey.get(typeQName);
                if (null == key) {
                    log.warn("Type QName [" + typeQName + "] defined by operation [" +
                            operationDesc + "] has not been found in schema: " + schemaTypeKeyToSchemaTypeMap);
                    continue;
                }
                SchemaType schemaType = (SchemaType) schemaTypeKeyToSchemaTypeMap.get(key);
                mappedTypeQNames.add(key.getqName());

                if (false == schemaType.isSimpleType()) {
                    if (false == parameterDesc.getJavaType().isArray()) {
                        if (false == mappedTypeQNames.contains(schemaType.getName())) {
                            // TODO: this lookup is not enough: the jaxrpc mapping file may define an anonymous
                            // mapping.
                            log.warn("Operation [" + operationDesc + "] uses XML type [" + schemaType +
                                    "], whose mapping is not declared by the jaxrpc mapping file.\n Continuing deployment; " +
                                    "yet, the deployment is not-portable.");
View Full Code Here

    {
        if ( xBean == null )
        {
            throw new IllegalArgumentException( MSG.getMessage( Keys.NULL_PARAM_NOT_ALLOWED ) );
        }
        SchemaType docSchemaType;
        if ( isDocument( xBean ) )
        {
            docSchemaType = xBean.schemaType();
        }
        else
        {
            docSchemaType = xBean.schemaType().getOuterType();
        }

        QName name;
        if ( docSchemaType != null )
        {
            name = docSchemaType.getDocumentElementName();
        }
        else
        {
            XmlCursor xCursor = xBean.newCursor();
            name = getName( xCursor );
View Full Code Here

        }

        if (wrappedStyle) {
            Part inputPart = getWrappedPart(input);
            QName name = inputPart.getElementName();
            SchemaType operationType = (SchemaType) schemaInfoBuilder.getComplexTypesInWsdl().get(name);

            Set expectedInParams = new HashSet();

            // schemaType should be complex using xsd:sequence compositor
            SchemaParticle parametersType = operationType.getContentModel();
            //parametersType can be null if the element has empty content such as
//            <element name="getMarketSummary">
//             <complexType>
//              <sequence/>
//             </complexType>
//            </element>

            if (parametersType != null) {
                if (SchemaParticle.ELEMENT == parametersType.getParticleType()) {
                    expectedInParams.add(parametersType.getName().getLocalPart());
                } else if (SchemaParticle.SEQUENCE == parametersType.getParticleType()) {
                    SchemaParticle[] parameters = parametersType.getParticleChildren();
                    for (int i = 0; i < parameters.length; i++) {
                        expectedInParams.add(parameters[i].getName().getLocalPart());
                    }
                }
            }
            if (!inParamNames.equals(expectedInParams)) {
                throw new DeploymentException("Not all wrapper children were mapped for operation name" + operationName);
            }
        } else {
            //check that all input message parts are mapped
            if (!inParamNames.equals(input.getParts().keySet())) {
                throw new DeploymentException("Not all input message parts were mapped for operation name" + operationName);
            }
        }

        Class[] paramTypes = new Class[parameterDescriptions.length];
        for (int i = 0; i < parameterDescriptions.length; i++) {
            ParameterDesc parameterDescription = parameterDescriptions[i];
            if (parameterDescription == null) {
                throw new DeploymentException("There is no mapping for parameter number " + i + " for operation " + operationName);
            }
            operationDesc.addParameter(parameterDescription);
            paramTypes[i] = parameterDescription.getJavaType();
        }

        String methodName = methodMapping.getJavaMethodName().getStringValue().trim();
        Method method = null;
        try {
            method = serviceEndpointInterface.getMethod(methodName, paramTypes);
        } catch (NoSuchMethodException e) {
            String args = "(";
            for (int i = 0; i < paramTypes.length; i++) {
                args += paramTypes[i].getName();
                if (i < paramTypes.length - 1) {
                    args += ",";
                }
            }
            args += ")";

            throw new DeploymentException("Mapping references non-existent method in service-endpoint: " + methodName + args);
        }

        operationDesc.setMethod(method);

        // MAP RETURN TYPE
        operationDesc.setMep(operation.getStyle());
        if (methodMapping.isSetWsdlReturnValueMapping()) {
            mapReturnType();
        } else if (operation.getStyle() == OperationType.REQUEST_RESPONSE) {
            //TODO WARNING THIS APPEARS TO SUBVERT THE COMMENT IN j2ee_jaxrpc_mapping_1_1.xsd IN service-endpoint-method-mappingType:
            //The wsdl-return-value-mapping is not specified for one-way operations.
            operationDesc.setReturnQName(null);             //??
            operationDesc.setReturnType(XMLType.AXIS_VOID);
            operationDesc.setReturnClass(void.class);
        }

        if (null != output && wrappedStyle) {
            Part inputPart = getWrappedPart(output);
            QName name = inputPart.getElementName();
            SchemaType operationType = (SchemaType) schemaInfoBuilder.getComplexTypesInWsdl().get(name);

            Set expectedOutParams = new HashSet();

            // schemaType should be complex using xsd:sequence compositor
            SchemaParticle parametersType = operationType.getContentModel();
            //again, no output can give null parametersType
            if (parametersType != null) {
                if (SchemaParticle.ELEMENT == parametersType.getParticleType()) {
                    expectedOutParams.add(parametersType.getName().getLocalPart());
                } else if (SchemaParticle.SEQUENCE == parametersType.getParticleType()) {
View Full Code Here

            faultTypeQName = (QName) schemaInfoBuilder.getElementToTypeMap().get(part.getElementName());
            if (faultTypeQName == null) {
                throw new DeploymentException("Can not find type for: element: " + part.getElementName() + ", known elements: " + schemaInfoBuilder.getElementToTypeMap());
            }
        }
        SchemaType complexType = (SchemaType) schemaInfoBuilder.getComplexTypesInWsdl().get(faultTypeQName);
        boolean isComplex = complexType != null;
        FaultDesc faultDesc = new FaultDesc(faultQName, className, faultTypeQName, isComplex);

        //constructor parameters
        if (exceptionMapping.isSetConstructorParameterOrder()) {
            if (!isComplex) {
                throw new DeploymentException("ConstructorParameterOrder can only be set for complex types, not " + faultTypeQName);
            }
            Map elementMap = new HashMap();
            SchemaProperty[] properties = complexType.getProperties();
            for (int i = 0; i < properties.length; i++) {
                SchemaProperty property = properties[i];
                QName elementName = property.getName();
                SchemaType elementType = property.getType();
                elementMap.put(elementName.getLocalPart(), elementType);
            }
            ArrayList parameterTypes = new ArrayList();
            ConstructorParameterOrderType constructorParameterOrder = exceptionMapping.getConstructorParameterOrder();
            for (int i = 0; i < constructorParameterOrder.getElementNameArray().length; i++) {
                String elementName = constructorParameterOrder.getElementNameArray(i).getStringValue().trim();
                SchemaType elementType = (SchemaType) elementMap.get(elementName);
                Class javaElementType;

                QName elementTypeQName = elementType.getName();
                if (elementTypeQName != null) {
                    if (schemaInfoBuilder.getComplexTypesInWsdl().containsKey(elementType)) {
                        String javaClassName = (String) publicTypes.get(elementTypeQName);
                        if (javaClassName == null) {
                            throw new DeploymentException("No class mapped for element type: " + elementType);
                        }
                        javaElementType = getJavaClass(javaClassName);
                    } else {
                        javaElementType = (Class) qnameToClassMap.get(elementTypeQName);
                        if (javaElementType == null) {
                            throw new DeploymentException("Unknown type: " + elementType + " of name: " + elementName + " and QName: " + elementTypeQName);
                        }
                    }
                } else {
                    //anonymous type
                    //anonymous type qname is constructed using rules 1.b and 2.b
                    String anonymousQName = complexType.getName().getNamespaceURI() + ":>" + complexType.getName().getLocalPart() + ">" + elementName;
                    String javaClassName = (String) anonymousTypes.get(anonymousQName);
                    if (javaClassName == null) {
                        if (elementType.isSimpleType()) {
                            //maybe it's a restriction of a built in simple type
                            SchemaType baseType = elementType.getBaseType();
                            QName simpleTypeQName = baseType.getName();
                            javaElementType = (Class) qnameToClassMap.get(simpleTypeQName);
                            if (javaElementType == null) {
                                throw new DeploymentException("Unknown simple type: " + elementType + " of name: " + elementName + " and QName: " + simpleTypeQName);
                            }
                        } else {
View Full Code Here

    private SchemaParticle getWrapperChild(Part part, String wsdlMessagePartName) throws DeploymentException {
        QName name = part.getElementName();

        wrapperElementQNames.add(name);

        SchemaType operationType = (SchemaType) schemaInfoBuilder.getComplexTypesInWsdl().get(name);
        if (null == operationType) {
            throw new DeploymentException("No global element named " + name + " for operation " + operationName);
        }

        // schemaType should be complex using xsd:sequence compositor
        SchemaParticle parametersType = operationType.getContentModel();
        if (SchemaParticle.ELEMENT == parametersType.getParticleType()) {
            if (parametersType.getName().getLocalPart().equals(wsdlMessagePartName)) {
                return parametersType;
            }
            throw new DeploymentException("Global element named " + name +
View Full Code Here

        return typeInfoList;
    }

    private void populateInternalTypeInfo(Class javaClass, QName typeQName, SchemaTypeKey key, TypeInfo.UpdatableTypeInfo typeInfo) throws DeploymentException {
        SchemaType schemaType = (SchemaType) schemaTypeKeyToSchemaTypeMap.get(key);
        if (schemaType == null) {
            throw new DeploymentException("Schema type key " + key + " not found in analyzed schema: " + schemaTypeKeyToSchemaTypeMap);
        }
        typeInfo.setCanSearchParents(schemaType.getDerivationType() == SchemaType.DT_RESTRICTION);

        Map nameToType = new HashMap();
        if (null  == schemaType.getContentModel()) {
            ;
        } else if (SchemaParticle.SEQUENCE == schemaType.getContentModel().getParticleType()
                || SchemaParticle.ALL == schemaType.getContentModel().getParticleType()) {
            SchemaParticle[] properties = schemaType.getContentModel().getParticleChildren();
            for (int i = 0; i < properties.length; i++) {
                SchemaParticle parameter = properties[i];
//                if (SchemaParticle.ELEMENT != parameter.getType().getContentModel().getParticleType()) {
//                    throw new DeploymentException(parameter.getName() + " is not an element in schema " + schemaType.getName());
//                }
                nameToType.put(parameter.getName(), parameter);
            }
        } else if (SchemaParticle.ELEMENT == schemaType.getContentModel().getParticleType()) {
            SchemaParticle parameter = schemaType.getContentModel();
            nameToType.put(parameter.getName(), parameter);
        } else {
            throw new DeploymentException("Only all, choice and sequence particle types are supported." +
                    " SchemaType name =" + schemaType.getName());
        }

        PropertyDescriptor[] descriptors;
        try {
            descriptors = Introspector.getBeanInfo(javaClass).getPropertyDescriptors();
View Full Code Here

        ret = typeSystem.findType(qn).getFullJavaName();
        return ret.replace('$', '.');
    }

    public String getWrappedElementType(QName wrapperElement, QName item) {       
        SchemaType st = typeSystem.findElement(wrapperElement).getType();
        SchemaType partType = st.getElementProperty(item).getType();       
        return XMLBeansSchemaTypeUtils.getNaturalJavaClassName(partType);       
    }
View Full Code Here

TOP

Related Classes of org.apache.xmlbeans.SchemaType

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.