use of org.apache.cxf.binding.corba.wsdl.Alias 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.Alias in project cxf by apache.
the class WSDLToIDLAction method createType.
protected IdlType createType(QName idlType, String[] name, CorbaType corbaType) throws Exception {
if (idlType.getLocalPart().equals("CORBA.Object")) {
return IdlInterface.create(null, "Object");
}
CorbaType corbaTypeImpl = corbaType;
if (corbaTypeImpl == null) {
corbaTypeImpl = getCorbaType(idlType);
}
if (corbaTypeImpl == null) {
String msgStr = "Type " + idlType.getLocalPart() + " not found.";
org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
throw new Exception(msg.toString());
}
IdlScopeBase scope = root;
StringBuilder dotScopedName = new StringBuilder("");
for (int i = 0; i < name.length - 1; ++i) {
dotScopedName.append(name[i]);
// name array.
if ("CORBA".equals(dotScopedName.toString()) && name.length == 2 && i == 0 && name[1].equals("Object")) {
break;
}
IdlDefn idlDef = scope.lookup(name[i]);
if (idlDef == null) {
// Before creating module, check to see if a Corba type
// represent this name aleady exists.
// For example if type is a.b.c and we are about to create
// module b, look to see if a.b
// is an interface that needs to be processed
QName qname = new QName(corbaTypeImpl.getType().getNamespaceURI(), dotScopedName.toString());
// Check to see if CORBAType exists. If so, create type for it
// otherwise
// create module for this scope
CorbaType possibleCorbaType = getCorbaType(qname);
if (possibleCorbaType != null) {
idlDef = findType(qname);
}
if (idlDef == null) {
idlDef = IdlModule.create(scope, name[i]);
scope.addToScope(idlDef);
}
}
dotScopedName.append(".");
scope = (IdlScopeBase) idlDef;
}
IdlType result = null;
String local = name[name.length - 1];
if (corbaTypeImpl instanceof Enum) {
result = createEnum((Enum) corbaTypeImpl, scope, local);
} else if (corbaTypeImpl instanceof Sequence) {
result = createSequence((Sequence) corbaTypeImpl, scope, local);
} else if (corbaTypeImpl instanceof Anonsequence) {
result = createAnonSequence((Anonsequence) corbaTypeImpl, scope, local);
} else if (corbaTypeImpl instanceof org.apache.cxf.binding.corba.wsdl.Exception) {
result = createIdlException((org.apache.cxf.binding.corba.wsdl.Exception) corbaTypeImpl, scope, local);
} else if (corbaTypeImpl instanceof Struct) {
result = createStruct((Struct) corbaTypeImpl, scope, local);
} else if (corbaTypeImpl instanceof Union) {
result = createUnion((Union) corbaTypeImpl, scope, local);
} else if (corbaTypeImpl instanceof Alias) {
result = createTypedef((Alias) corbaTypeImpl, scope, local);
} else if (corbaTypeImpl instanceof Array) {
result = createArray((Array) corbaTypeImpl, scope, local);
} else if (corbaTypeImpl instanceof Anonarray) {
result = createAnonArray((Anonarray) corbaTypeImpl, scope, local);
} else if (corbaTypeImpl instanceof Fixed) {
result = createFixed((Fixed) corbaTypeImpl, scope, local);
} else if (corbaTypeImpl instanceof Anonfixed) {
result = createAnonFixed((Anonfixed) corbaTypeImpl, scope, local);
} else if (corbaTypeImpl instanceof Const) {
result = createConst((Const) corbaTypeImpl, scope, local);
} else {
result = checkAnon(corbaTypeImpl, scope, local);
}
if (result == null && corbaTypeImpl instanceof org.apache.cxf.binding.corba.wsdl.Object) {
result = createInterface((org.apache.cxf.binding.corba.wsdl.Object) corbaTypeImpl, scope, local);
}
return result;
}
use of org.apache.cxf.binding.corba.wsdl.Alias in project cxf by apache.
the class TypedefVisitor method generateAlias.
private void generateAlias(AST identifierNode, XmlSchemaType schemaType, CorbaType corbaType, Scope fqName) {
Scope scopedName = new Scope(getScope(), identifierNode);
// corba:alias
Alias alias = new Alias();
alias.setQName(new QName(typeMap.getTargetNamespace(), scopedName.toString()));
if (corbaType != null) {
alias.setBasetype(corbaType.getQName());
// if (schemaType == null) might not be correct here
} else if (schemaType == null) {
wsdlVisitor.getDeferredActions().add(fqName, new TypedefDeferredAction(alias));
scopedNames.add(scopedName);
}
alias.setRepositoryID(scopedName.toIDLRepositoryID());
// add corba:alias
setCorbaType(alias);
}
use of org.apache.cxf.binding.corba.wsdl.Alias in project cxf by apache.
the class TypedefVisitor method generateStringAlias.
private void generateStringAlias(AST typeDeclaratorNode, AST identifierNode, XmlSchemaType schemaType, CorbaType corbaType, Scope fqName) {
Scope typedefScope = new Scope(getScope(), identifierNode);
Alias corbaString = new Alias();
if (typeDeclaratorNode.getType() == IDLTokenTypes.LITERAL_string) {
corbaString.setBasetype(CorbaConstants.NT_CORBA_STRING);
} else if (typeDeclaratorNode.getType() == IDLTokenTypes.LITERAL_wstring) {
corbaString.setBasetype(CorbaConstants.NT_CORBA_WSTRING);
} else {
// should never get here
throw new RuntimeException("[TypedefVisitor] Attempted to visit an invalid node: " + typeDeclaratorNode.toString());
}
Scope newScope = new Scope(typedefScope.getParent(), identifierNode);
corbaString.setQName(new QName(typeMap.getTargetNamespace(), newScope.toString()));
corbaString.setType(Constants.XSD_STRING);
corbaString.setRepositoryID(newScope.toIDLRepositoryID());
typeMap.getStructOrExceptionOrUnion().add(corbaString);
}
use of org.apache.cxf.binding.corba.wsdl.Alias in project cxf by apache.
the class CorbaUtils method getComplexTypeCode.
public static TypeCode getComplexTypeCode(ORB orb, QName type, Object obj, CorbaTypeMap typeMap, Stack<QName> seenTypes) {
TypeCode tc = getAnonTypeCode(orb, type, obj, typeMap, seenTypes);
if (tc == null) {
if (obj instanceof Alias) {
Alias aliasType = (Alias) obj;
tc = orb.create_alias_tc(aliasType.getRepositoryID(), getTypeCodeName(aliasType.getName()), getTypeCode(orb, aliasType.getBasetype(), typeMap, seenTypes));
} else if (obj instanceof Array) {
Array arrayType = (Array) obj;
tc = orb.create_array_tc((int) arrayType.getBound(), getTypeCode(orb, arrayType.getElemtype(), typeMap, seenTypes));
} else if (obj instanceof Enum) {
Enum enumType = (Enum) obj;
String name = enumType.getName();
List<Enumerator> enums = enumType.getEnumerator();
String[] members = new String[enums.size()];
for (int i = 0; i < members.length; ++i) {
members[i] = enums.get(i).getValue();
}
name = getTypeCodeName(name);
tc = orb.create_enum_tc(enumType.getRepositoryID(), name, members);
} else if (obj instanceof Exception) {
Exception exceptType = (Exception) obj;
List<MemberType> list = exceptType.getMember();
StructMember[] members = new StructMember[list.size()];
for (int i = 0; i < members.length; ++i) {
MemberType member = list.get(i);
members[i] = new StructMember(member.getName(), getTypeCode(orb, member.getIdltype(), typeMap, seenTypes), null);
}
String name = getTypeCodeName(exceptType.getName());
tc = orb.create_exception_tc(exceptType.getRepositoryID(), name, members);
} else if (obj instanceof Fixed) {
Fixed fixedType = (Fixed) obj;
tc = orb.create_fixed_tc((short) fixedType.getDigits(), (short) fixedType.getScale());
} else if (obj instanceof org.apache.cxf.binding.corba.wsdl.Object) {
org.apache.cxf.binding.corba.wsdl.Object objType = (org.apache.cxf.binding.corba.wsdl.Object) obj;
if (objType.getName().equals("CORBA.Object")) {
tc = orb.create_interface_tc(objType.getRepositoryID(), "Object");
} else {
tc = orb.create_interface_tc(objType.getRepositoryID(), getTypeCodeName(objType.getName()));
}
} else if (obj instanceof Sequence) {
Sequence seqType = (Sequence) obj;
tc = orb.create_sequence_tc((int) seqType.getBound(), getTypeCode(orb, seqType.getElemtype(), typeMap, seenTypes));
} else if (obj instanceof Struct) {
Struct structType = (Struct) obj;
if (seenTypes.contains(new QName(structType.getName()))) {
tc = orb.create_recursive_tc(structType.getRepositoryID());
} else {
seenTypes.push(new QName(structType.getName()));
List<MemberType> list = structType.getMember();
StructMember[] members = new StructMember[list.size()];
for (int i = 0; i < members.length; ++i) {
MemberType member = list.get(i);
members[i] = new StructMember(member.getName(), getTypeCode(orb, member.getIdltype(), typeMap, seenTypes), null);
}
String name = getTypeCodeName(structType.getName());
tc = orb.create_struct_tc(structType.getRepositoryID(), name, members);
seenTypes.pop();
}
} else if (obj instanceof Union) {
tc = getUnionTypeCode(orb, obj, typeMap, seenTypes);
}
}
return tc;
}
Aggregations