Search in sources :

Example 1 with Fixed

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;
}
Also used : XmlSchemaFacet(org.apache.ws.commons.schema.XmlSchemaFacet) Anonfixed(org.apache.cxf.binding.corba.wsdl.Anonfixed) XmlSchemaTotalDigitsFacet(org.apache.ws.commons.schema.XmlSchemaTotalDigitsFacet) XmlSchemaFractionDigitsFacet(org.apache.ws.commons.schema.XmlSchemaFractionDigitsFacet) Fixed(org.apache.cxf.binding.corba.wsdl.Fixed)

Example 2 with Fixed

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;
}
Also used : Fixed(org.apache.cxf.binding.corba.wsdl.Fixed)

Example 3 with 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());
        }
    }
}
Also used : OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Fixed(org.apache.cxf.binding.corba.wsdl.Fixed)

Example 4 with Fixed

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());
        }
    }
}
Also used : OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Fixed(org.apache.cxf.binding.corba.wsdl.Fixed)

Example 5 with Fixed

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());
        }
    }
}
Also used : OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Fixed(org.apache.cxf.binding.corba.wsdl.Fixed)

Aggregations

Fixed (org.apache.cxf.binding.corba.wsdl.Fixed)12 QName (javax.xml.namespace.QName)6 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)4 OperationType (org.apache.cxf.binding.corba.wsdl.OperationType)4 Alias (org.apache.cxf.binding.corba.wsdl.Alias)3 Anonfixed (org.apache.cxf.binding.corba.wsdl.Anonfixed)3 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)3 Sequence (org.apache.cxf.binding.corba.wsdl.Sequence)3 TypeCode (org.omg.CORBA.TypeCode)3 Array (org.apache.cxf.binding.corba.wsdl.Array)2 Enum (org.apache.cxf.binding.corba.wsdl.Enum)2 Struct (org.apache.cxf.binding.corba.wsdl.Struct)2 Union (org.apache.cxf.binding.corba.wsdl.Union)2 XmlSchemaFractionDigitsFacet (org.apache.ws.commons.schema.XmlSchemaFractionDigitsFacet)2 Test (org.junit.Test)2 AST (antlr.collections.AST)1 List (java.util.List)1 CorbaBindingException (org.apache.cxf.binding.corba.CorbaBindingException)1 CorbaFixedHandler (org.apache.cxf.binding.corba.types.CorbaFixedHandler)1 Anonarray (org.apache.cxf.binding.corba.wsdl.Anonarray)1