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);
}
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);
}
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;
}
}
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);
}
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();
}
}
Aggregations