use of org.apache.cxf.binding.corba.wsdl.CaseType in project cxf by apache.
the class CorbaUnionListener method determineDescriminatorValue.
private String determineDescriminatorValue(Unionbranch branch) {
String descriminatorValue;
// Determine the value of the discriminator.
List<CaseType> branchCases = branch.getCase();
if (!branchCases.isEmpty()) {
CaseType caseLabel = branchCases.get(0);
descriminatorValue = caseLabel.getLabel();
} else {
// This represents the default case.
descriminatorValue = ((CorbaUnionHandler) handler).createDefaultDiscriminatorLabel();
}
return descriminatorValue;
}
use of org.apache.cxf.binding.corba.wsdl.CaseType in project cxf by apache.
the class WSDLTypes method processUnionBranches.
public static Union processUnionBranches(Union corbaUnion, List<MemberType> fields, List<String> caselist) {
int caseIndex = 0;
for (int i = 0; i < fields.size(); i++) {
MemberType field = fields.get(i);
Unionbranch branch = new Unionbranch();
branch.setName(field.getName());
branch.setIdltype(field.getIdltype());
if (field.isSetQualified() && field.isQualified()) {
branch.setQualified(true);
}
branch.setDefault(false);
CaseType c = new CaseType();
c.setLabel(caselist.get(caseIndex));
caseIndex++;
branch.getCase().add(c);
corbaUnion.getUnionbranch().add(branch);
}
return corbaUnion;
}
use of org.apache.cxf.binding.corba.wsdl.CaseType in project cxf by apache.
the class UnionVisitor method createCase.
private void createCase(AST caseNode, Unionbranch unionBranch) {
AST node = caseNode.getFirstChild();
if (node != null) {
if (node.getType() == IDLTokenTypes.LITERAL_case) {
// corba:case
CaseType caseType = new CaseType();
caseType.setLabel(node.getNextSibling().toString());
unionBranch.getCase().add(caseType);
// recursive call
createCase(node, unionBranch);
} else {
// corba:case
CaseType caseType = new CaseType();
caseType.setLabel(node.toString());
unionBranch.getCase().add(caseType);
}
}
}
use of org.apache.cxf.binding.corba.wsdl.CaseType in project cxf by apache.
the class WSDLToIDLAction method createUnion.
private IdlType createUnion(Union u, IdlScopeBase scope, String local) throws Exception {
boolean undefinedCircular = false;
IdlType disc = findType(u.getDiscriminator());
IdlUnion union = IdlUnion.create(scope, local, disc);
scope.holdForScope(union);
for (Unionbranch ub : u.getUnionbranch()) {
QName qname = ub.getIdltype();
IdlType bt = findType(qname);
boolean isDefault = false;
if (ub.isSetDefault()) {
isDefault = ub.isDefault();
}
IdlUnionBranch b = IdlUnionBranch.create(union, ub.getName(), bt, isDefault);
for (CaseType cs : ub.getCase()) {
b.addCase(cs.getLabel());
}
if (!undefinedCircular && !(bt instanceof IdlSequence)) {
String mlocal = qname.getLocalPart();
String[] mname = unscopeName(mlocal);
undefinedCircular = null != root.lookup(mname, true);
}
union.addBranch(b);
}
if (undefinedCircular) {
scope.parkHeld();
} else {
scope.promoteHeldToScope();
if (union.isCircular()) {
// resolving this union closed a recursion
scope.flush();
}
}
return union;
}
use of org.apache.cxf.binding.corba.wsdl.CaseType in project cxf by apache.
the class CorbaObjectReader method readUnion.
public void readUnion(CorbaUnionHandler unionHandler) throws CorbaBindingException {
Union unionType = (Union) unionHandler.getType();
List<Unionbranch> branches = unionType.getUnionbranch();
CorbaObjectHandler discriminator = unionHandler.getDiscriminator();
if (!branches.isEmpty()) {
final String discLabel;
if (discriminator.getTypeCodeKind().value() == TCKind._tk_enum) {
CorbaEnumHandler disc = (CorbaEnumHandler) discriminator;
readEnumDiscriminator(unionHandler, disc);
discLabel = disc.getValue();
} else {
read(discriminator);
discLabel = ((CorbaPrimitiveHandler) discriminator).getDataFromValue();
}
// Now find the label in the union to get the right case
Unionbranch defaultBranch = null;
boolean caseFound = false;
for (Iterator<Unionbranch> branchIter = branches.iterator(); branchIter.hasNext(); ) {
Unionbranch branch = branchIter.next();
if (branch.isSetDefault() && branch.isDefault()) {
defaultBranch = branch;
}
List<CaseType> cases = branch.getCase();
for (Iterator<CaseType> caseIter = cases.iterator(); caseIter.hasNext(); ) {
CaseType c = caseIter.next();
if (c.getLabel().equalsIgnoreCase(discLabel)) {
CorbaObjectHandler branchObj = unionHandler.getBranchByName(branch.getName());
this.read(branchObj);
unionHandler.setValue(branch.getName(), branchObj);
caseFound = true;
break;
}
}
if (caseFound) {
break;
}
}
// found the default case.
if (!caseFound && defaultBranch != null) {
CorbaObjectHandler branchObj = unionHandler.getBranchByName(defaultBranch.getName());
this.read(branchObj);
unionHandler.setValue(defaultBranch.getName(), branchObj);
}
}
}
Aggregations