Search in sources :

Example 31 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.

the class StringVisitor method visitAnonBoundedString.

private void visitAnonBoundedString() {
    // xmlschema:bounded anon string
    XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema, true);
    simpleType.setName(stringScopedName.toString());
    XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
    restriction.setBaseTypeName(Constants.XSD_STRING);
    XmlSchemaMaxLengthFacet maxLengthFacet = new XmlSchemaMaxLengthFacet();
    maxLengthFacet.setValue(boundNode.toString());
    restriction.getFacets().add(maxLengthFacet);
    simpleType.setContent(restriction);
    setSchemaType(simpleType);
    CorbaType anon = null;
    if (stringNode.getType() == IDLTokenTypes.LITERAL_string) {
        // corba:anonstring
        Anonstring anonstring = new Anonstring();
        anonstring.setQName(new QName(typeMap.getTargetNamespace(), stringScopedName.toString()));
        anonstring.setBound(Long.parseLong(boundNode.toString()));
        anonstring.setType(simpleType.getQName());
        anon = anonstring;
    } else if (stringNode.getType() == IDLTokenTypes.LITERAL_wstring) {
        // corba:anonwstring
        Anonwstring anonwstring = new Anonwstring();
        anonwstring.setQName(new QName(typeMap.getTargetNamespace(), stringScopedName.toString()));
        anonwstring.setBound(Long.parseLong(boundNode.toString()));
        anonwstring.setType(simpleType.getQName());
        anon = anonwstring;
    } else {
        // should never get here
        throw new RuntimeException("StringVisitor attempted to visit an invalid node");
    }
    // add corba:anonstring
    typeMap.getStructOrExceptionOrUnion().add(anon);
    setCorbaType(anon);
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) Anonwstring(org.apache.cxf.binding.corba.wsdl.Anonwstring) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) QName(javax.xml.namespace.QName) XmlSchemaSimpleTypeRestriction(org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction) XmlSchemaMaxLengthFacet(org.apache.ws.commons.schema.XmlSchemaMaxLengthFacet) Anonstring(org.apache.cxf.binding.corba.wsdl.Anonstring)

Example 32 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.

the class StringVisitor method visitBoundedString.

private void visitBoundedString() {
    // xmlschema:bounded string
    XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema, true);
    simpleType.setName(stringScopedName.toString());
    XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
    restriction.setBaseTypeName(Constants.XSD_STRING);
    XmlSchemaMaxLengthFacet maxLengthFacet = new XmlSchemaMaxLengthFacet();
    maxLengthFacet.setValue(boundNode.toString());
    restriction.getFacets().add(maxLengthFacet);
    simpleType.setContent(restriction);
    setSchemaType(simpleType);
    Scope anonstringScopedName = new Scope(getScope(), "_Anon1_" + stringScopedName.tail());
    String anonstringName = anonstringScopedName.toString();
    CorbaType anon = null;
    if (stringNode.getType() == IDLTokenTypes.LITERAL_string) {
        // corba:anonstring
        Anonstring anonstring = new Anonstring();
        anonstring.setQName(new QName(typeMap.getTargetNamespace(), anonstringName));
        anonstring.setBound(Long.parseLong(boundNode.toString()));
        anonstring.setType(simpleType.getQName());
        anon = anonstring;
    } else if (stringNode.getType() == IDLTokenTypes.LITERAL_wstring) {
        // corba:anonwstring
        Anonwstring anonwstring = new Anonwstring();
        anonwstring.setQName(new QName(typeMap.getTargetNamespace(), anonstringName));
        anonwstring.setBound(Long.valueOf(boundNode.toString()));
        anonwstring.setType(simpleType.getQName());
        anon = anonwstring;
    } else {
        // should never get here
        throw new RuntimeException("StringVisitor attempted to visit an invalid node");
    }
    // add corba:anonstring
    typeMap.getStructOrExceptionOrUnion().add(anon);
    // corba:alias
    Alias alias = new Alias();
    alias.setQName(new QName(typeMap.getTargetNamespace(), stringScopedName.toString()));
    alias.setBasetype(anon.getQName());
    alias.setType(simpleType.getQName());
    alias.setRepositoryID(stringScopedName.toIDLRepositoryID());
    // add corba:alias
    setCorbaType(alias);
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) Anonwstring(org.apache.cxf.binding.corba.wsdl.Anonwstring) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) QName(javax.xml.namespace.QName) Alias(org.apache.cxf.binding.corba.wsdl.Alias) XmlSchemaSimpleTypeRestriction(org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction) XmlSchemaMaxLengthFacet(org.apache.ws.commons.schema.XmlSchemaMaxLengthFacet) Anonstring(org.apache.cxf.binding.corba.wsdl.Anonstring)

Example 33 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.

the class StructVisitor method visitStructMembers.

private void visitStructMembers(AST identifierNode, Struct struct, XmlSchemaSequence sequence, Scope structScope) {
    AST memberTypeNode = identifierNode.getNextSibling();
    while (memberTypeNode != null) {
        AST memberNode = TypesUtils.getCorbaTypeNameNode(memberTypeNode);
        XmlSchemaType schemaType = null;
        CorbaType corbaType = null;
        Scope fqName = null;
        try {
            TypesVisitor visitor = new TypesVisitor(structScope, definition, schema, wsdlVisitor, null);
            visitor.visit(memberTypeNode);
            schemaType = visitor.getSchemaType();
            corbaType = visitor.getCorbaType();
            fqName = visitor.getFullyQualifiedName();
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
        // (hence the ScopedNameVisitor.accept() call).
        while (memberNode != null && memberNode.getType() == IDLTokenTypes.IDENT && !ScopedNameVisitor.accept(structScope, definition, schema, memberNode, wsdlVisitor, true)) {
            XmlSchemaType memberSchemaType = schemaType;
            CorbaType memberCorbaType = corbaType;
            // needed for anonymous arrays in structs
            if (ArrayVisitor.accept(memberNode)) {
                Scope anonScope = new Scope(structScope, TypesUtils.getCorbaTypeNameNode(memberTypeNode));
                ArrayVisitor arrayVisitor = new ArrayVisitor(anonScope, definition, schema, wsdlVisitor, null, fqName);
                arrayVisitor.setSchemaType(schemaType);
                arrayVisitor.setCorbaType(corbaType);
                arrayVisitor.visit(memberNode);
                memberSchemaType = arrayVisitor.getSchemaType();
                memberCorbaType = arrayVisitor.getCorbaType();
                fqName = arrayVisitor.getFullyQualifiedName();
            }
            XmlSchemaElement member = createXmlSchemaElement(memberNode, memberSchemaType, fqName);
            sequence.getItems().add(member);
            MemberType memberType = createMemberType(memberNode, memberCorbaType, fqName);
            struct.getMember().add(memberType);
            memberNode = memberNode.getNextSibling();
        }
        memberTypeNode = memberNode;
    }
}
Also used : AST(antlr.collections.AST) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 34 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.

the class TypedefVisitor method visit.

public void visit(AST typedefNode) {
    // "typedef" <type_declarator>
    // <type_declarator> ::= <type_spec> <declarators>
    AST typeDeclaratorNode = typedefNode.getFirstChild();
    AST identifierNode = TypesUtils.getCorbaTypeNameNode(typeDeclaratorNode);
    TypesVisitor typesVisitor = new TypesVisitor(getScope(), definition, schema, wsdlVisitor, identifierNode);
    typesVisitor.visit(typeDeclaratorNode);
    XmlSchemaType schemaType = typesVisitor.getSchemaType();
    CorbaType corbaType = typesVisitor.getCorbaType();
    Scope fullyQualifiedName = typesVisitor.getFullyQualifiedName();
    Scope typedefScope = new Scope(getScope(), identifierNode);
    if (SequenceVisitor.accept(typeDeclaratorNode) || FixedVisitor.accept(typeDeclaratorNode)) {
        // Handle cases "typedef sequence"
        // "typedef fixed"
        DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(typedefScope, definition, schema, wsdlVisitor, schemaType, corbaType, fullyQualifiedName);
        declaratorVisitor.visit(identifierNode);
    } else if (StringVisitor.accept(typeDeclaratorNode)) {
        if (StringVisitor.isBounded(typeDeclaratorNode) && !wsdlVisitor.getBoundedStringOverride()) {
            DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(typedefScope, definition, schema, wsdlVisitor, schemaType, corbaType, fullyQualifiedName);
            declaratorVisitor.visit(identifierNode);
        } else {
            while (identifierNode != null) {
                if (ArrayVisitor.accept(identifierNode)) {
                    ArrayVisitor arrayVisitor = new ArrayVisitor(new Scope(getScope(), identifierNode.getText()), definition, schema, wsdlVisitor, identifierNode, fullyQualifiedName);
                    arrayVisitor.setSchemaType(schemaType);
                    arrayVisitor.setCorbaType(corbaType);
                    arrayVisitor.visit(identifierNode);
                } else {
                    generateStringAlias(typeDeclaratorNode, identifierNode, schemaType, corbaType, fullyQualifiedName);
                }
                identifierNode = identifierNode.getNextSibling();
            }
        }
    } else {
        // if declaring an array, do not generate aliases
        if (!ArrayVisitor.accept(identifierNode)) {
            generateAlias(identifierNode, schemaType, corbaType, fullyQualifiedName);
            corbaType = getCorbaType();
        }
        DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(typedefScope, definition, schema, wsdlVisitor, schemaType, corbaType, fullyQualifiedName);
        declaratorVisitor.visit(identifierNode);
    }
    setSchemaType(schemaType);
    setCorbaType(corbaType);
    setFullyQualifiedName(fullyQualifiedName);
}
Also used : AST(antlr.collections.AST) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 35 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.

the class UnionVisitor method processCaseNodes.

private void processCaseNodes(AST caseNode, Scope scope, XmlSchemaChoice choice, Union corbaUnion) {
    while (caseNode != null) {
        AST typeNode = null;
        AST nameNode = null;
        AST labelNode = null;
        // xmlschema:element
        XmlSchemaElement element = new XmlSchemaElement(schema, false);
        // corba:unionbranch
        Unionbranch unionBranch = new Unionbranch();
        if (caseNode.getType() == IDLTokenTypes.LITERAL_default) {
            // default:
            unionBranch.setDefault(true);
            typeNode = caseNode.getFirstChild();
            nameNode = typeNode.getNextSibling();
        } else {
            // case:
            createCase(caseNode, unionBranch);
            labelNode = caseNode.getFirstChild();
            if (labelNode.getType() == IDLTokenTypes.LITERAL_case) {
                labelNode = labelNode.getNextSibling();
            }
            typeNode = labelNode.getNextSibling();
            nameNode = typeNode.getNextSibling();
        }
        TypesVisitor visitor = new TypesVisitor(scope, definition, schema, wsdlVisitor, null);
        visitor.visit(typeNode);
        XmlSchemaType stype = visitor.getSchemaType();
        CorbaType ctype = visitor.getCorbaType();
        Scope fullyQualifiedName = visitor.getFullyQualifiedName();
        // needed for anonymous arrays in unions
        if (ArrayVisitor.accept(nameNode)) {
            Scope anonScope = new Scope(scope, TypesUtils.getCorbaTypeNameNode(nameNode));
            ArrayVisitor arrayVisitor = new ArrayVisitor(anonScope, definition, schema, wsdlVisitor, null, fullyQualifiedName);
            arrayVisitor.setSchemaType(stype);
            arrayVisitor.setCorbaType(ctype);
            arrayVisitor.visit(nameNode);
            stype = arrayVisitor.getSchemaType();
            ctype = arrayVisitor.getCorbaType();
            fullyQualifiedName = visitor.getFullyQualifiedName();
        }
        // xmlschema:element
        element.setName(nameNode.toString());
        if (stype != null) {
            element.setSchemaTypeName(stype.getQName());
            if (stype.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) {
                element.setNillable(true);
            }
        } else {
            UnionDeferredAction elementAction = new UnionDeferredAction(element);
            wsdlVisitor.getDeferredActions().add(fullyQualifiedName, elementAction);
        }
        choice.getItems().add(element);
        // corba:unionbranch
        unionBranch.setName(nameNode.toString());
        if (ctype != null) {
            unionBranch.setIdltype(ctype.getQName());
        } else {
            // its type is forward declared.
            UnionDeferredAction unionBranchAction = new UnionDeferredAction(unionBranch);
            wsdlVisitor.getDeferredActions().add(fullyQualifiedName, unionBranchAction);
        }
        corbaUnion.getUnionbranch().add(unionBranch);
        caseNode = caseNode.getNextSibling();
    }
}
Also used : AST(antlr.collections.AST) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) Unionbranch(org.apache.cxf.binding.corba.wsdl.Unionbranch)

Aggregations

CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)71 QName (javax.xml.namespace.QName)44 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)22 MemberType (org.apache.cxf.binding.corba.wsdl.MemberType)13 AST (antlr.collections.AST)9 TypeMappingType (org.apache.cxf.binding.corba.wsdl.TypeMappingType)8 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)8 Test (org.junit.Test)8 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)7 Alias (org.apache.cxf.binding.corba.wsdl.Alias)6 Anonsequence (org.apache.cxf.binding.corba.wsdl.Anonsequence)6 Sequence (org.apache.cxf.binding.corba.wsdl.Sequence)6 Struct (org.apache.cxf.binding.corba.wsdl.Struct)6 Union (org.apache.cxf.binding.corba.wsdl.Union)6 File (java.io.File)5 Definition (javax.wsdl.Definition)5 ArrayList (java.util.ArrayList)4 Anonarray (org.apache.cxf.binding.corba.wsdl.Anonarray)4 Anonstring (org.apache.cxf.binding.corba.wsdl.Anonstring)4 Array (org.apache.cxf.binding.corba.wsdl.Array)4