use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.
the class CorbaTypeMap method getIdlType.
// This is used by the Any type when trying to re-construct the type stored inside a
// CORBA Any.
public QName getIdlType(TypeCode tc) {
final String repId;
try {
repId = tc.id();
} catch (org.omg.CORBA.TypeCodePackage.BadKind ex) {
// No id has been set.
return null;
}
if (repId == null) {
return null;
}
Set<Map.Entry<String, CorbaType>> mapSet = typeMap.entrySet();
for (Iterator<Map.Entry<String, CorbaType>> i = mapSet.iterator(); i.hasNext(); ) {
Map.Entry<String, CorbaType> entry = i.next();
if (entry.getValue() instanceof NamedType) {
NamedType n = (NamedType) entry.getValue();
if (n.getRepositoryID().equals(repId)) {
return new QName(getTargetNamespace(), entry.getKey());
}
}
}
return null;
}
use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.
the class CorbaHandlerUtils method createTypeHandler.
public static CorbaObjectHandler createTypeHandler(ORB orb, QName name, QName idlType, CorbaTypeMap typeMap) {
CorbaObjectHandler handler = null;
TypeCode tc = CorbaUtils.getTypeCode(orb, idlType, typeMap);
try {
while (tc.kind().value() == TCKind._tk_alias) {
Alias alias = (Alias) CorbaUtils.getCorbaType(idlType, typeMap);
if (alias == null) {
throw new CorbaBindingException("Couldn't find corba alias type: " + idlType);
}
tc = tc.content_type();
idlType = alias.getBasetype();
}
} catch (Throwable ex) {
throw new CorbaBindingException(ex);
}
if (CorbaUtils.isPrimitiveIdlType(idlType)) {
handler = new CorbaPrimitiveHandler(name, idlType, tc, null);
} else if (tc.kind().value() == TCKind._tk_any) {
// Any is a special kind of primitive so it gets its own handler
handler = new CorbaAnyHandler(name, idlType, tc, null);
((CorbaAnyHandler) handler).setTypeMap(typeMap);
} else {
CorbaType type = CorbaUtils.getCorbaType(idlType, typeMap);
switch(tc.kind().value()) {
case TCKind._tk_array:
handler = new CorbaArrayHandler(name, idlType, tc, type);
break;
case TCKind._tk_enum:
handler = new CorbaEnumHandler(name, idlType, tc, type);
break;
case TCKind._tk_except:
handler = new CorbaExceptionHandler(name, idlType, tc, type);
break;
case TCKind._tk_fixed:
handler = new CorbaFixedHandler(name, idlType, tc, type);
break;
case TCKind._tk_sequence:
if (isOctets(type)) {
handler = new CorbaOctetSequenceHandler(name, idlType, tc, type);
} else {
handler = new CorbaSequenceHandler(name, idlType, tc, type);
}
break;
case TCKind._tk_struct:
handler = new CorbaStructHandler(name, idlType, tc, type);
break;
case TCKind._tk_union:
handler = new CorbaUnionHandler(name, idlType, tc, type);
break;
case TCKind._tk_string:
case TCKind._tk_wstring:
// These need to be here to catch the anonymous string types.
handler = new CorbaPrimitiveHandler(name, idlType, tc, type);
break;
case TCKind._tk_objref:
handler = new CorbaObjectReferenceHandler(name, idlType, tc, type);
break;
default:
handler = new CorbaObjectHandler(name, idlType, tc, type);
}
}
return handler;
}
use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.
the class CorbaHandlerUtils method getTypeListener.
public static CorbaTypeListener getTypeListener(QName name, QName idlType, CorbaTypeMap typeMap, ORB orb, ServiceInfo serviceInfo) throws CorbaBindingException {
final CorbaObjectHandler handler;
TypeCode tc = CorbaUtils.getTypeCode(orb, idlType, typeMap);
try {
while (tc.kind().value() == TCKind._tk_alias) {
Alias alias = (Alias) CorbaUtils.getCorbaType(idlType, typeMap);
if (alias == null) {
throw new CorbaBindingException("Couldn't find corba alias type: " + idlType);
}
tc = tc.content_type();
idlType = alias.getBasetype();
}
} catch (Throwable ex) {
throw new CorbaBindingException(ex);
}
CorbaTypeListener result = null;
if (CorbaUtils.isPrimitiveIdlType(idlType)) {
handler = new CorbaPrimitiveHandler(name, idlType, tc, null);
result = new CorbaPrimitiveListener(handler);
} else {
CorbaType type = CorbaUtils.getCorbaType(idlType, typeMap);
switch(tc.kind().value()) {
case TCKind._tk_any:
handler = new CorbaAnyHandler(name, idlType, tc, type);
((CorbaAnyHandler) handler).setTypeMap(typeMap);
result = new CorbaAnyListener(handler, typeMap, orb, serviceInfo);
break;
case TCKind._tk_array:
handler = new CorbaArrayHandler(name, idlType, tc, type);
result = new CorbaArrayListener(handler, typeMap, orb, serviceInfo);
break;
case TCKind._tk_enum:
handler = new CorbaEnumHandler(name, idlType, tc, type);
result = new CorbaEnumListener(handler);
break;
case TCKind._tk_except:
handler = new CorbaExceptionHandler(name, idlType, tc, type);
result = new CorbaExceptionListener(handler, typeMap, orb, serviceInfo);
break;
case TCKind._tk_fixed:
handler = new CorbaFixedHandler(name, idlType, tc, type);
result = new CorbaFixedListener(handler);
break;
case TCKind._tk_sequence:
if (isOctets(type)) {
handler = new CorbaOctetSequenceHandler(name, idlType, tc, type);
result = new CorbaOctetSequenceListener(handler);
} else {
handler = new CorbaSequenceHandler(name, idlType, tc, type);
result = new CorbaSequenceListener(handler, typeMap, orb, serviceInfo);
}
break;
case TCKind._tk_string:
case TCKind._tk_wstring:
// These can be handled just like regular strings
handler = new CorbaPrimitiveHandler(name, idlType, tc, type);
result = new CorbaPrimitiveListener(handler);
break;
case TCKind._tk_struct:
handler = new CorbaStructHandler(name, idlType, tc, type);
result = new CorbaStructListener(handler, typeMap, orb, serviceInfo);
break;
case TCKind._tk_union:
handler = new CorbaUnionHandler(name, idlType, tc, type);
result = new CorbaUnionListener(handler, typeMap, orb, serviceInfo);
break;
case TCKind._tk_objref:
handler = new CorbaObjectReferenceHandler(name, idlType, tc, type);
result = new CorbaObjectReferenceListener(handler, orb);
break;
default:
throw new CorbaBindingException("Unsupported complex type " + idlType);
}
}
return result;
}
use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.
the class CorbaTypeMapTest method testCorbaTypeMap.
@Test
public void testCorbaTypeMap() throws Exception {
CorbaTypeMap typeMap = new CorbaTypeMap("http://yoko.apache.org/ComplexTypes");
String targetNamespace = typeMap.getTargetNamespace();
assertEquals(targetNamespace, "http://yoko.apache.org/ComplexTypes");
QName type = new QName("http://yoko.apache.org/ComplexTypes", "xsd1:Test.MultiPart.Colour", "");
CorbaType corbaTypeImpl = new CorbaType();
corbaTypeImpl.setType(type);
corbaTypeImpl.setName("Test.MultiPart.Colour");
typeMap.addType("Test.MultiPart.Colour", corbaTypeImpl);
CorbaType corbatype = typeMap.getType("Test.MultiPart.Colour");
assertEquals(corbatype.getName(), "Test.MultiPart.Colour");
assertEquals(corbatype.getType().getLocalPart(), "xsd1:Test.MultiPart.Colour");
}
use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.
the class CorbaStructListener method processStartElement.
public void processStartElement(QName name) {
if (depth == 0 && (currentElement != null) && (!currentElement.equals(name))) {
currentTypeListener = null;
}
depth++;
if (currentTypeListener == null) {
QName elName = name;
MemberType member = null;
while (true) {
member = structMembers.get(memberCount++);
// members - we have a chance to "catch up" and add required (empty sequences) members
if (member.getName().equals(name.getLocalPart()) || (member.isSetAnonschematype() && member.isAnonschematype())) {
break;
}
currentTypeListener = CorbaHandlerUtils.getTypeListener(elName, member.getIdltype(), typeMap, orb, serviceInfo);
currentTypeListener.setNamespaceContext(ctx);
((CorbaStructHandler) handler).addMember(currentTypeListener.getCorbaObject());
}
boolean anonType = false;
if (member.isSetAnonschematype() && member.isAnonschematype()) {
anonType = true;
elName = CorbaUtils.getEmptyQName();
currentElement = null;
} else {
currentElement = name;
}
currentTypeListener = CorbaHandlerUtils.getTypeListener(elName, member.getIdltype(), typeMap, orb, serviceInfo);
currentTypeListener.setNamespaceContext(ctx);
((CorbaStructHandler) handler).addMember(currentTypeListener.getCorbaObject());
if (anonType) {
currentTypeListener.getCorbaObject().setAnonymousType(true);
currentTypeListener.processStartElement(name);
} else {
CorbaType type = CorbaUtils.getCorbaType(member.getIdltype(), typeMap);
boolean wrapped = true;
if (type instanceof Abstractsequence) {
wrapped = ((Abstractsequence) type).isWrapped();
} else if (type instanceof Abstractanonsequence) {
wrapped = ((Abstractanonsequence) type).isWrapped();
}
// to process StartElement of first element of collection
if (!wrapped) {
currentTypeListener.processStartElement(name);
}
}
} else {
currentTypeListener.processStartElement(name);
}
}
Aggregations