use of org.apache.cxf.binding.corba.wsdl.Enumerator in project cxf by apache.
the class CorbaObjectReader method readEnum.
// -- complex types --
public void readEnum(CorbaObjectHandler obj) throws CorbaBindingException {
int enumIndex = stream.read_long();
Enum enumType = (Enum) obj.getType();
List<Enumerator> enumerators = enumType.getEnumerator();
CorbaEnumHandler enumObj = (CorbaEnumHandler) obj;
enumObj.setValue(enumerators.get(enumIndex).getValue());
}
use of org.apache.cxf.binding.corba.wsdl.Enumerator in project cxf by apache.
the class CorbaObjectReader method readEnumDiscriminator.
public void readEnumDiscriminator(CorbaUnionHandler unionHandler, CorbaEnumHandler disc) throws CorbaBindingException {
int enumIndex = stream.read_long();
Enum enumType = (Enum) disc.getType();
List<Enumerator> enumerators = enumType.getEnumerator();
if (enumIndex == Integer.MAX_VALUE) {
enumIndex = unionHandler.getDefaultIndex();
}
disc.setValue(enumerators.get(enumIndex).getValue());
}
use of org.apache.cxf.binding.corba.wsdl.Enumerator in project cxf by apache.
the class CorbaEnumHandler method setValue.
public void setValue(String val) {
value = val;
Enum enumType = (Enum) this.type;
List<Enumerator> enumerators = enumType.getEnumerator();
index = -1;
for (int i = 0; i < enumerators.size(); ++i) {
Enumerator e = enumerators.get(i);
if (e.getValue().equals(val)) {
index = i;
break;
}
}
}
use of org.apache.cxf.binding.corba.wsdl.Enumerator in project cxf by apache.
the class CorbaEnumHandlerTest method testCorbaEnumHandler.
@Test
public void testCorbaEnumHandler() {
Enum enumType = new Enum();
enumType.setName("EnumType");
enumType.setRepositoryID("IDL:EnumType:1.0");
Enumerator enumerator0 = new Enumerator();
enumerator0.setValue("ENUM0");
Enumerator enumerator1 = new Enumerator();
enumerator1.setValue("ENUM1");
Enumerator enumerator2 = new Enumerator();
enumerator2.setValue("ENUM2");
enumType.getEnumerator().add(enumerator0);
enumType.getEnumerator().add(enumerator1);
enumType.getEnumerator().add(enumerator2);
QName enumName = new QName("EnumType");
QName enumIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "EnumType", CorbaConstants.NP_WSDL_CORBA);
String[] members = new String[3];
members[0] = enumerator0.getValue();
members[1] = enumerator1.getValue();
members[2] = enumerator2.getValue();
TypeCode enumTC = orb.create_enum_tc(enumType.getRepositoryID(), enumType.getName(), members);
CorbaEnumHandler obj = new CorbaEnumHandler(enumName, enumIdlType, enumTC, enumType);
assertNotNull(obj);
obj.setValue(members[1]);
assertEquals(obj.getValue(), enumerator1.getValue());
assertTrue(obj.getIndex() == 1);
}
use of org.apache.cxf.binding.corba.wsdl.Enumerator in project cxf by apache.
the class WSDLToCorbaHelper method processOMGUnion.
private CorbaType processOMGUnion(XmlSchemaComplexType complex, QName defaultName) throws Exception {
QName name;
QName schematypeName = checkPrefix(complex.getQName());
if (schematypeName == null) {
schematypeName = defaultName;
name = createQNameCorbaNamespace(defaultName.getLocalPart() + "Type");
} else {
name = createQNameCorbaNamespace(schematypeName.getLocalPart());
}
Union corbaUnion = new Union();
corbaUnion.setName(name.getLocalPart());
corbaUnion.setQName(name);
String id = REPO_STRING + name.getLocalPart().replace('.', '/') + IDL_VERSION;
corbaUnion.setRepositoryID(id);
corbaUnion.setType(schematypeName);
XmlSchemaSequence stype = (XmlSchemaSequence) complex.getParticle();
Iterator<XmlSchemaSequenceMember> it = stype.getItems().iterator();
XmlSchemaParticle st1 = (XmlSchemaParticle) it.next();
XmlSchemaParticle st2 = (XmlSchemaParticle) it.next();
final XmlSchemaElement discEl;
final XmlSchemaChoice choice;
if (st1 instanceof XmlSchemaElement) {
discEl = (XmlSchemaElement) st1;
choice = (XmlSchemaChoice) st2;
} else {
discEl = (XmlSchemaElement) st2;
choice = (XmlSchemaChoice) st1;
}
CorbaType disctype = convertSchemaToCorbaType(discEl.getSchemaType(), discEl.getQName(), discEl.getSchemaType(), null, false);
corbaUnion.setDiscriminator(disctype.getQName());
List<MemberType> fields = processContainerAsMembers(choice, defaultName, schematypeName);
List<String> caselist = new ArrayList<>();
if (disctype instanceof Enum) {
Enum corbaenum = (Enum) disctype;
Iterator<Enumerator> iterator = corbaenum.getEnumerator().iterator();
while (iterator.hasNext()) {
Enumerator enumerator = iterator.next();
caselist.add(enumerator.getValue());
}
} else if (SUPPORTEDDISTYPES.contains(disctype.getQName().getLocalPart())) {
if ("long".equals(disctype.getQName().getLocalPart()) || "short".equals(disctype.getQName().getLocalPart())) {
for (int i = 0; i < fields.size(); i++) {
caselist.add(Integer.toString(i));
}
} else if ("char".equals(disctype.getQName().getLocalPart())) {
for (int i = 0; i < fields.size(); i++) {
caselist.add(Integer.toString(i));
}
} else if ("boolean".equals(disctype.getQName().getLocalPart())) {
if (fields.size() == 2) {
caselist.add("TRUE");
caselist.add("FALSE");
} else if (fields.size() == 1) {
caselist.add("TRUE");
} else {
String msg = "Discriminator Type does not match number of Choices in Union:" + name;
LOG.log(Level.WARNING, msg);
}
}
}
WSDLTypes.processUnionBranches(corbaUnion, fields, caselist);
return corbaUnion;
}
Aggregations