Search in sources :

Example 1 with Anonfixed

use of org.apache.cxf.binding.corba.wsdl.Anonfixed 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 Anonfixed

use of org.apache.cxf.binding.corba.wsdl.Anonfixed in project cxf by apache.

the class WSDLToIDLAction method createType.

protected IdlType createType(QName idlType, String[] name, CorbaType corbaType) throws Exception {
    if (idlType.getLocalPart().equals("CORBA.Object")) {
        return IdlInterface.create(null, "Object");
    }
    CorbaType corbaTypeImpl = corbaType;
    if (corbaTypeImpl == null) {
        corbaTypeImpl = getCorbaType(idlType);
    }
    if (corbaTypeImpl == null) {
        String msgStr = "Type " + idlType.getLocalPart() + " not found.";
        org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
        throw new Exception(msg.toString());
    }
    IdlScopeBase scope = root;
    StringBuilder dotScopedName = new StringBuilder("");
    for (int i = 0; i < name.length - 1; ++i) {
        dotScopedName.append(name[i]);
        // name array.
        if ("CORBA".equals(dotScopedName.toString()) && name.length == 2 && i == 0 && name[1].equals("Object")) {
            break;
        }
        IdlDefn idlDef = scope.lookup(name[i]);
        if (idlDef == null) {
            // Before creating module, check to see if a Corba type
            // represent this name aleady exists.
            // For example if type is a.b.c and we are about to create
            // module b, look to see if a.b
            // is an interface that needs to be processed
            QName qname = new QName(corbaTypeImpl.getType().getNamespaceURI(), dotScopedName.toString());
            // Check to see if CORBAType exists. If so, create type for it
            // otherwise
            // create module for this scope
            CorbaType possibleCorbaType = getCorbaType(qname);
            if (possibleCorbaType != null) {
                idlDef = findType(qname);
            }
            if (idlDef == null) {
                idlDef = IdlModule.create(scope, name[i]);
                scope.addToScope(idlDef);
            }
        }
        dotScopedName.append(".");
        scope = (IdlScopeBase) idlDef;
    }
    IdlType result = null;
    String local = name[name.length - 1];
    if (corbaTypeImpl instanceof Enum) {
        result = createEnum((Enum) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Sequence) {
        result = createSequence((Sequence) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Anonsequence) {
        result = createAnonSequence((Anonsequence) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof org.apache.cxf.binding.corba.wsdl.Exception) {
        result = createIdlException((org.apache.cxf.binding.corba.wsdl.Exception) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Struct) {
        result = createStruct((Struct) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Union) {
        result = createUnion((Union) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Alias) {
        result = createTypedef((Alias) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Array) {
        result = createArray((Array) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Anonarray) {
        result = createAnonArray((Anonarray) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Fixed) {
        result = createFixed((Fixed) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Anonfixed) {
        result = createAnonFixed((Anonfixed) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Const) {
        result = createConst((Const) corbaTypeImpl, scope, local);
    } else {
        result = checkAnon(corbaTypeImpl, scope, local);
    }
    if (result == null && corbaTypeImpl instanceof org.apache.cxf.binding.corba.wsdl.Object) {
        result = createInterface((org.apache.cxf.binding.corba.wsdl.Object) corbaTypeImpl, scope, local);
    }
    return result;
}
Also used : IdlEnum(org.apache.cxf.tools.corba.common.idltypes.IdlEnum) Enum(org.apache.cxf.binding.corba.wsdl.Enum) IdlString(org.apache.cxf.tools.corba.common.idltypes.IdlString) IdlType(org.apache.cxf.tools.corba.common.idltypes.IdlType) Union(org.apache.cxf.binding.corba.wsdl.Union) IdlUnion(org.apache.cxf.tools.corba.common.idltypes.IdlUnion) IdlStruct(org.apache.cxf.tools.corba.common.idltypes.IdlStruct) Struct(org.apache.cxf.binding.corba.wsdl.Struct) Anonarray(org.apache.cxf.binding.corba.wsdl.Anonarray) IdlFixed(org.apache.cxf.tools.corba.common.idltypes.IdlFixed) IdlAnonFixed(org.apache.cxf.tools.corba.common.idltypes.IdlAnonFixed) Fixed(org.apache.cxf.binding.corba.wsdl.Fixed) QName(javax.xml.namespace.QName) IdlDefn(org.apache.cxf.tools.corba.common.idltypes.IdlDefn) Const(org.apache.cxf.binding.corba.wsdl.Const) IdlConst(org.apache.cxf.tools.corba.common.idltypes.IdlConst) IdlScopeBase(org.apache.cxf.tools.corba.common.idltypes.IdlScopeBase) IdlAnonSequence(org.apache.cxf.tools.corba.common.idltypes.IdlAnonSequence) Sequence(org.apache.cxf.binding.corba.wsdl.Sequence) IdlSequence(org.apache.cxf.tools.corba.common.idltypes.IdlSequence) IdlException(org.apache.cxf.tools.corba.common.idltypes.IdlException) IdlAnonArray(org.apache.cxf.tools.corba.common.idltypes.IdlAnonArray) Array(org.apache.cxf.binding.corba.wsdl.Array) IdlArray(org.apache.cxf.tools.corba.common.idltypes.IdlArray) Anonfixed(org.apache.cxf.binding.corba.wsdl.Anonfixed) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) Alias(org.apache.cxf.binding.corba.wsdl.Alias) Anonsequence(org.apache.cxf.binding.corba.wsdl.Anonsequence)

Example 3 with Anonfixed

use of org.apache.cxf.binding.corba.wsdl.Anonfixed in project cxf by apache.

the class WSDLTypes method getAnonFixedCorbaType.

public static CorbaType getAnonFixedCorbaType(QName name, QName stype, int digits, int scale) {
    Anonfixed fixed = new Anonfixed();
    fixed.setName(name.getLocalPart());
    fixed.setQName(name);
    fixed.setType(stype);
    fixed.setDigits(digits);
    fixed.setScale(scale);
    return fixed;
}
Also used : Anonfixed(org.apache.cxf.binding.corba.wsdl.Anonfixed)

Example 4 with Anonfixed

use of org.apache.cxf.binding.corba.wsdl.Anonfixed in project cxf by apache.

the class FixedVisitor method visit.

public void visit(AST fixedNode) {
    // "typedef" <type_declarator>
    // <type_declarator> ::= <type_spec> <declarators>
    // <type_spec> ::= <simple_type_spec>
    // | <constr_type_spec>
    // <simple_type_spec> ::= <base_type_spec>
    // | <template_type_spec>
    // | <scoped_name>
    // <base_type_spec> ::= ... omitted (integer, char, octect, etc)
    // <template_type_spec> ::= <sequence_type>
    // | <string_type>
    // | <wstring_type>
    // | <fixed_pt_type>
    // <constr_type_spec> ::= <struct_type>
    // | <union_type>
    // | <enum_type>
    // <declarators> ::= <declarator> {"," <declarator>}*
    // <declarator> ::= <simple_declarator>
    // | <complex_declarator>
    // <simple_declarator> ::= <identifier>
    // <complex_declarator> ::= <array_declarator>
    // <array_declarator> ::= <identifier> <fixed_array_size>+
    // <fixed_array_size> ::= "[" <positive_int_const> "]"
    AST digitsNode = fixedNode.getFirstChild();
    AST scaleNode = digitsNode.getNextSibling();
    Scope scopedName = null;
    if (identifierNode == null) {
        scopedName = TypesUtils.generateAnonymousScopedName(getScope(), schema);
    } else {
        scopedName = new Scope(getScope(), identifierNode);
    }
    // validate digits and scale
    Long digits = Long.valueOf(digitsNode.toString());
    Long scale = Long.valueOf(scaleNode.toString());
    if (digits < 1 || digits > 31) {
        // throw IllegalIDLException();
        System.out.println("Digits cannot be greater than 31");
        return;
    }
    if (scale.compareTo(digits) > 0) {
        // throw IllegalIDLException();
        System.out.println("Scale cannot be greater than digits");
        return;
    }
    // xmlschema:fixed
    XmlSchemaSimpleType fixedSimpleType = new XmlSchemaSimpleType(schema, true);
    XmlSchemaSimpleTypeRestriction fixedRestriction = new XmlSchemaSimpleTypeRestriction();
    fixedRestriction.setBaseTypeName(Constants.XSD_DECIMAL);
    XmlSchemaTotalDigitsFacet fixedTotalDigits = new XmlSchemaTotalDigitsFacet();
    fixedTotalDigits.setValue(digitsNode.toString());
    XmlSchemaFractionDigitsFacet fixedFractionDigits = new XmlSchemaFractionDigitsFacet();
    fixedFractionDigits.setValue(scaleNode.toString());
    fixedFractionDigits.setFixed(true);
    fixedRestriction.getFacets().add(fixedTotalDigits);
    fixedRestriction.getFacets().add(fixedFractionDigits);
    fixedSimpleType.setName(mapper.mapToQName(scopedName));
    fixedSimpleType.setContent(fixedRestriction);
    // add xmlschema:fixed
    setSchemaType(fixedSimpleType);
    CorbaType type = null;
    if (identifierNode != null) {
        // corba:fixed
        Fixed corbaFixed = new Fixed();
        corbaFixed.setQName(new QName(typeMap.getTargetNamespace(), scopedName.toString()));
        corbaFixed.setDigits(digits);
        corbaFixed.setScale(scale);
        corbaFixed.setRepositoryID(scopedName.toIDLRepositoryID());
        // corbaFixed.setType(Constants.XSD_DECIMAL);
        corbaFixed.setType(fixedSimpleType.getQName());
        type = corbaFixed;
    } else {
        // corba:anonfixed
        Anonfixed corbaFixed = new Anonfixed();
        corbaFixed.setQName(new QName(typeMap.getTargetNamespace(), scopedName.toString()));
        corbaFixed.setDigits(digits);
        corbaFixed.setScale(scale);
        // corbaFixed.setType(Constants.XSD_DECIMAL);
        corbaFixed.setType(fixedSimpleType.getQName());
        typeMap.getStructOrExceptionOrUnion().add(corbaFixed);
        type = corbaFixed;
    }
    // add corba:fixed
    setCorbaType(type);
}
Also used : Anonfixed(org.apache.cxf.binding.corba.wsdl.Anonfixed) AST(antlr.collections.AST) XmlSchemaTotalDigitsFacet(org.apache.ws.commons.schema.XmlSchemaTotalDigitsFacet) XmlSchemaFractionDigitsFacet(org.apache.ws.commons.schema.XmlSchemaFractionDigitsFacet) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) QName(javax.xml.namespace.QName) XmlSchemaSimpleTypeRestriction(org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction) Fixed(org.apache.cxf.binding.corba.wsdl.Fixed)

Example 5 with Anonfixed

use of org.apache.cxf.binding.corba.wsdl.Anonfixed in project cxf by apache.

the class CorbaUtils method getAnonTypeCode.

private static TypeCode getAnonTypeCode(ORB orb, QName type, Object obj, CorbaTypeMap typeMap, Stack<QName> seenTypes) {
    TypeCode tc = null;
    if (obj instanceof Anonarray) {
        Anonarray anonArrayType = (Anonarray) obj;
        tc = orb.create_array_tc((int) anonArrayType.getBound(), getTypeCode(orb, anonArrayType.getElemtype(), typeMap, seenTypes));
    } else if (obj instanceof Anonfixed) {
        Anonfixed anonFixedType = (Anonfixed) obj;
        tc = orb.create_fixed_tc((short) anonFixedType.getDigits(), (short) anonFixedType.getScale());
    } else if (obj instanceof Anonsequence) {
        Anonsequence anonSeqType = (Anonsequence) obj;
        tc = orb.create_sequence_tc((int) anonSeqType.getBound(), getTypeCode(orb, anonSeqType.getElemtype(), typeMap, seenTypes));
    } else if (obj instanceof Anonstring) {
        Anonstring anonStringType = (Anonstring) obj;
        tc = orb.create_string_tc((int) anonStringType.getBound());
    } else if (obj instanceof Anonwstring) {
        Anonwstring anonWStringType = (Anonwstring) obj;
        tc = orb.create_wstring_tc((int) anonWStringType.getBound());
    }
    return tc;
}
Also used : Anonfixed(org.apache.cxf.binding.corba.wsdl.Anonfixed) Anonwstring(org.apache.cxf.binding.corba.wsdl.Anonwstring) TypeCode(org.omg.CORBA.TypeCode) Anonarray(org.apache.cxf.binding.corba.wsdl.Anonarray) Anonsequence(org.apache.cxf.binding.corba.wsdl.Anonsequence) Anonstring(org.apache.cxf.binding.corba.wsdl.Anonstring)

Aggregations

Anonfixed (org.apache.cxf.binding.corba.wsdl.Anonfixed)6 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)3 Fixed (org.apache.cxf.binding.corba.wsdl.Fixed)3 QName (javax.xml.namespace.QName)2 Anonarray (org.apache.cxf.binding.corba.wsdl.Anonarray)2 Anonsequence (org.apache.cxf.binding.corba.wsdl.Anonsequence)2 Anonstring (org.apache.cxf.binding.corba.wsdl.Anonstring)2 Struct (org.apache.cxf.binding.corba.wsdl.Struct)2 XmlSchemaFractionDigitsFacet (org.apache.ws.commons.schema.XmlSchemaFractionDigitsFacet)2 XmlSchemaTotalDigitsFacet (org.apache.ws.commons.schema.XmlSchemaTotalDigitsFacet)2 AST (antlr.collections.AST)1 File (java.io.File)1 Definition (javax.wsdl.Definition)1 Alias (org.apache.cxf.binding.corba.wsdl.Alias)1 Anonwstring (org.apache.cxf.binding.corba.wsdl.Anonwstring)1 Array (org.apache.cxf.binding.corba.wsdl.Array)1 Const (org.apache.cxf.binding.corba.wsdl.Const)1 Enum (org.apache.cxf.binding.corba.wsdl.Enum)1 Sequence (org.apache.cxf.binding.corba.wsdl.Sequence)1 TypeMappingType (org.apache.cxf.binding.corba.wsdl.TypeMappingType)1