Search in sources :

Example 1 with Anonstring

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

the class WSDLTypes method processStringType.

public static CorbaType processStringType(CorbaType corbaTypeImpl, QName name, String maxLength, String length) throws Exception {
    boolean boundedString = true;
    int bound = 0;
    try {
        if (maxLength != null) {
            bound = Integer.parseInt(maxLength);
        } else if (length != null) {
            bound = Integer.parseInt(length);
        } else {
            boundedString = false;
        }
    } catch (NumberFormatException ex) {
        throw new Exception("illegal number", ex);
    } catch (Exception e) {
        throw new Exception("illegal number", e);
    }
    if (boundedString) {
        // bounded string
        Anonstring anonString = new Anonstring();
        anonString.setBound(bound);
        anonString.setName(name.getLocalPart());
        anonString.setQName(name);
        anonString.setType(corbaTypeImpl.getQName());
        corbaTypeImpl = anonString;
    }
    return corbaTypeImpl;
}
Also used : Anonstring(org.apache.cxf.binding.corba.wsdl.Anonstring)

Example 2 with Anonstring

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

the class WSDLToIDLAction method checkAnon.

private IdlType checkAnon(CorbaType corbaTypeImpl, IdlScopeBase scope, String local) throws Exception {
    IdlType result = null;
    if (corbaTypeImpl instanceof Anonstring) {
        Anonstring as = (Anonstring) corbaTypeImpl;
        long lbound = as.getBound();
        result = IdlString.create((int) lbound);
    }
    return result;
}
Also used : IdlType(org.apache.cxf.tools.corba.common.idltypes.IdlType) Anonstring(org.apache.cxf.binding.corba.wsdl.Anonstring)

Example 3 with Anonstring

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

the class StringVisitor method visitBoundedString.

private void visitBoundedString() {
    // xmlschema:bounded string
    XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema, true);
    simpleType.setName(stringScopedName.toString());
    XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
    restriction.setBaseTypeName(Constants.XSD_STRING);
    XmlSchemaMaxLengthFacet maxLengthFacet = new XmlSchemaMaxLengthFacet();
    maxLengthFacet.setValue(boundNode.toString());
    restriction.getFacets().add(maxLengthFacet);
    simpleType.setContent(restriction);
    setSchemaType(simpleType);
    Scope anonstringScopedName = new Scope(getScope(), "_Anon1_" + stringScopedName.tail());
    String anonstringName = anonstringScopedName.toString();
    final CorbaType anon;
    if (stringNode.getType() == IDLTokenTypes.LITERAL_string) {
        // corba:anonstring
        Anonstring anonstring = new Anonstring();
        anonstring.setQName(new QName(typeMap.getTargetNamespace(), anonstringName));
        anonstring.setBound(Long.parseLong(boundNode.toString()));
        anonstring.setType(simpleType.getQName());
        anon = anonstring;
    } else if (stringNode.getType() == IDLTokenTypes.LITERAL_wstring) {
        // corba:anonwstring
        Anonwstring anonwstring = new Anonwstring();
        anonwstring.setQName(new QName(typeMap.getTargetNamespace(), anonstringName));
        anonwstring.setBound(Long.valueOf(boundNode.toString()));
        anonwstring.setType(simpleType.getQName());
        anon = anonwstring;
    } else {
        // should never get here
        throw new RuntimeException("StringVisitor attempted to visit an invalid node");
    }
    // add corba:anonstring
    typeMap.getStructOrExceptionOrUnion().add(anon);
    // corba:alias
    Alias alias = new Alias();
    alias.setQName(new QName(typeMap.getTargetNamespace(), stringScopedName.toString()));
    alias.setBasetype(anon.getQName());
    alias.setType(simpleType.getQName());
    alias.setRepositoryID(stringScopedName.toIDLRepositoryID());
    // add corba:alias
    setCorbaType(alias);
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) Anonwstring(org.apache.cxf.binding.corba.wsdl.Anonwstring) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) QName(javax.xml.namespace.QName) Alias(org.apache.cxf.binding.corba.wsdl.Alias) XmlSchemaSimpleTypeRestriction(org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction) XmlSchemaMaxLengthFacet(org.apache.ws.commons.schema.XmlSchemaMaxLengthFacet) Anonstring(org.apache.cxf.binding.corba.wsdl.Anonstring)

Example 4 with Anonstring

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

the class StringVisitor method visitAnonBoundedString.

private void visitAnonBoundedString() {
    // xmlschema:bounded anon string
    XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema, true);
    simpleType.setName(stringScopedName.toString());
    XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
    restriction.setBaseTypeName(Constants.XSD_STRING);
    XmlSchemaMaxLengthFacet maxLengthFacet = new XmlSchemaMaxLengthFacet();
    maxLengthFacet.setValue(boundNode.toString());
    restriction.getFacets().add(maxLengthFacet);
    simpleType.setContent(restriction);
    setSchemaType(simpleType);
    final CorbaType anon;
    if (stringNode.getType() == IDLTokenTypes.LITERAL_string) {
        // corba:anonstring
        Anonstring anonstring = new Anonstring();
        anonstring.setQName(new QName(typeMap.getTargetNamespace(), stringScopedName.toString()));
        anonstring.setBound(Long.parseLong(boundNode.toString()));
        anonstring.setType(simpleType.getQName());
        anon = anonstring;
    } else if (stringNode.getType() == IDLTokenTypes.LITERAL_wstring) {
        // corba:anonwstring
        Anonwstring anonwstring = new Anonwstring();
        anonwstring.setQName(new QName(typeMap.getTargetNamespace(), stringScopedName.toString()));
        anonwstring.setBound(Long.parseLong(boundNode.toString()));
        anonwstring.setType(simpleType.getQName());
        anon = anonwstring;
    } else {
        // should never get here
        throw new RuntimeException("StringVisitor attempted to visit an invalid node");
    }
    // add corba:anonstring
    typeMap.getStructOrExceptionOrUnion().add(anon);
    setCorbaType(anon);
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) Anonwstring(org.apache.cxf.binding.corba.wsdl.Anonwstring) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) QName(javax.xml.namespace.QName) XmlSchemaSimpleTypeRestriction(org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction) XmlSchemaMaxLengthFacet(org.apache.ws.commons.schema.XmlSchemaMaxLengthFacet) Anonstring(org.apache.cxf.binding.corba.wsdl.Anonstring)

Example 5 with Anonstring

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

Anonstring (org.apache.cxf.binding.corba.wsdl.Anonstring)7 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)4 Anonwstring (org.apache.cxf.binding.corba.wsdl.Anonwstring)3 File (java.io.File)2 Definition (javax.wsdl.Definition)2 QName (javax.xml.namespace.QName)2 Anonfixed (org.apache.cxf.binding.corba.wsdl.Anonfixed)2 Struct (org.apache.cxf.binding.corba.wsdl.Struct)2 TypeMappingType (org.apache.cxf.binding.corba.wsdl.TypeMappingType)2 WSDLToIDLAction (org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction)2 XmlSchemaMaxLengthFacet (org.apache.ws.commons.schema.XmlSchemaMaxLengthFacet)2 XmlSchemaSimpleType (org.apache.ws.commons.schema.XmlSchemaSimpleType)2 XmlSchemaSimpleTypeRestriction (org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction)2 Test (org.junit.Test)2 Document (org.w3c.dom.Document)2 Element (org.w3c.dom.Element)2 Alias (org.apache.cxf.binding.corba.wsdl.Alias)1 Anonarray (org.apache.cxf.binding.corba.wsdl.Anonarray)1 Anonsequence (org.apache.cxf.binding.corba.wsdl.Anonsequence)1 Union (org.apache.cxf.binding.corba.wsdl.Union)1