use of org.apache.cxf.binding.corba.wsdl.Fixed in project cxf by apache.
the class WSDLTypes method processDecimalType.
public static CorbaType processDecimalType(XmlSchemaSimpleTypeRestriction restrictionType, QName name, CorbaType corbaTypeImpl, boolean anonymous) throws Exception {
String tdigits = null;
String fdigits = null;
boolean boundedDecimal = false;
boolean boundedScale = false;
for (XmlSchemaFacet val : restrictionType.getFacets()) {
if (val instanceof XmlSchemaTotalDigitsFacet) {
tdigits = val.getValue().toString();
boundedDecimal = true;
}
if (val instanceof XmlSchemaFractionDigitsFacet) {
fdigits = val.getValue().toString();
boundedScale = true;
}
}
int digits = 0;
int scale = 0;
if (boundedDecimal) {
try {
digits = Integer.parseInt(tdigits);
if ((digits > 31) || (digits < 1)) {
String msg = "totalDigits facet for the type " + name + " cannot be more than 31 for corba fixed types";
LOG.log(Level.WARNING, msg);
boundedDecimal = false;
} else if (digits == 31) {
boundedDecimal = false;
}
} catch (NumberFormatException ex) {
String msg = "totalDigits facet on the simple type restriction for type" + name.getLocalPart() + "is incorrect.";
throw new Exception(msg);
}
}
if (boundedScale) {
try {
scale = Integer.parseInt(fdigits);
if ((scale > 6) || (scale < 0)) {
String msg = "fixedDigits facet for the type " + name + " cannot be more than 6 for corba fixed types";
LOG.log(Level.WARNING, msg);
boundedScale = false;
} else if (scale == 6) {
boundedScale = false;
}
} catch (NumberFormatException ex) {
String msg = "fractionDigits facet on the simple type restriction for type" + name.getLocalPart() + " is incorrect.";
throw new Exception(msg);
}
}
if (!boundedDecimal) {
if (anonymous && corbaTypeImpl instanceof Anonfixed) {
Anonfixed fixed = (Anonfixed) corbaTypeImpl;
digits = Integer.parseInt(String.valueOf(fixed.getDigits()));
} else if (corbaTypeImpl instanceof Fixed) {
Fixed fixed = (Fixed) corbaTypeImpl;
digits = Integer.parseInt(String.valueOf(fixed.getDigits()));
}
}
if (!boundedScale) {
if (anonymous) {
Anonfixed fixed = (Anonfixed) corbaTypeImpl;
scale = Integer.parseInt(String.valueOf(fixed.getScale()));
} else {
Fixed fixed = (Fixed) corbaTypeImpl;
scale = Integer.parseInt(String.valueOf(fixed.getScale()));
}
}
if (boundedDecimal || boundedScale) {
if (anonymous) {
corbaTypeImpl = getAnonFixedCorbaType(name, W3CConstants.NT_SCHEMA_DECIMAL, digits, scale);
} else {
corbaTypeImpl = getFixedCorbaType(name, W3CConstants.NT_SCHEMA_DECIMAL, digits, scale);
}
}
return corbaTypeImpl;
}
use of org.apache.cxf.binding.corba.wsdl.Fixed in project cxf by apache.
the class WSDLTypes method getFixedCorbaType.
public static CorbaType getFixedCorbaType(QName name, QName stype, int digits, int scale) {
Fixed fixed = new Fixed();
fixed.setName(name.getLocalPart());
fixed.setQName(name);
fixed.setType(stype);
fixed.setDigits(digits);
fixed.setScale(scale);
fixed.setRepositoryID(WSDLToCorbaHelper.REPO_STRING + name.getLocalPart().replace('.', '/') + WSDLToCorbaHelper.IDL_VERSION);
return fixed;
}
use of org.apache.cxf.binding.corba.wsdl.Fixed in project cxf by apache.
the class WSDLToCorbaBindingTest method checkFixedTypeOne.
private void checkFixedTypeOne(BindingOperation bindingOperation, Map<String, CorbaType> mapType) {
assertEquals(bindingOperation.getBindingInput().getName(), "op_k");
assertEquals(bindingOperation.getBindingOutput().getName(), "op_kResponse");
for (ExtensibilityElement extElement : getExtensibilityElements(bindingOperation)) {
if (extElement.getElementType().getLocalPart().equals("operation")) {
OperationType corbaOpType = (OperationType) extElement;
assertEquals(corbaOpType.getName(), "op_k");
assertEquals(3, corbaOpType.getParam().size());
assertEquals("fixed_1", corbaOpType.getParam().get(0).getIdltype().getLocalPart());
assertEquals("fixed_1", corbaOpType.getReturn().getIdltype().getLocalPart());
Fixed fixed = (Fixed) mapType.get(corbaOpType.getReturn().getIdltype().getLocalPart());
assertNotNull("Could not find the decimal type", fixed.getType());
assertEquals("Fixed digits is incorrect for the return corba parameter", 31, fixed.getDigits());
assertEquals("Fixed scale is incorrect for the return corba parameter", 6, fixed.getScale());
}
}
}
use of org.apache.cxf.binding.corba.wsdl.Fixed in project cxf by apache.
the class WSDLToCorbaBindingTest method checkFixedTypeTwo.
private void checkFixedTypeTwo(BindingOperation bindingOperation, Map<String, CorbaType> mapType) {
for (ExtensibilityElement extElement : getExtensibilityElements(bindingOperation)) {
if (extElement.getElementType().getLocalPart().equals("operation")) {
OperationType corbaOpType = (OperationType) extElement;
assertEquals(corbaOpType.getName(), "op_m");
assertEquals(3, corbaOpType.getParam().size());
assertEquals("X.PARAM.H", corbaOpType.getParam().get(0).getIdltype().getLocalPart());
assertEquals("X.H", corbaOpType.getReturn().getIdltype().getLocalPart());
Fixed fixed = (Fixed) mapType.get(corbaOpType.getReturn().getIdltype().getLocalPart());
assertNotNull("Could not find the decimal type", fixed.getType());
assertEquals("Fixed digits is incorrect for the return corba parameter", 10, fixed.getDigits());
assertEquals("Fixed scale is incorrect for the return corba parameter", 2, fixed.getScale());
}
}
}
use of org.apache.cxf.binding.corba.wsdl.Fixed in project cxf by apache.
the class WSDLToCorbaBindingTest method checkFixedTypeThree.
private void checkFixedTypeThree(BindingOperation bindingOperation, Map<String, CorbaType> mapType) {
for (ExtensibilityElement extElement : getExtensibilityElements(bindingOperation)) {
if (extElement.getElementType().getLocalPart().equals("operation")) {
OperationType corbaOpType = (OperationType) extElement;
assertEquals(corbaOpType.getName(), "op_n");
assertEquals(3, corbaOpType.getParam().size());
assertEquals("fixed_1", corbaOpType.getParam().get(0).getIdltype().getLocalPart());
assertEquals("Z.H", corbaOpType.getReturn().getIdltype().getLocalPart());
Fixed fixed = (Fixed) mapType.get(corbaOpType.getReturn().getIdltype().getLocalPart());
assertNotNull("Could not find the decimal type", fixed.getType());
assertEquals("Fixed digits is incorrect for the return corba parameter", 8, fixed.getDigits());
assertEquals("Fixed scale is incorrect for the return corba parameter", 6, fixed.getScale());
}
}
}
Aggregations