incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r425735 - in /incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl: ArrayVisitor.java TypesUtils.java TypesVisitorBase.java
Date Wed, 26 Jul 2006 13:43:01 GMT
Author: bravi
Date: Wed Jul 26 06:43:00 2006
New Revision: 425735

URL: http://svn.apache.org/viewvc?rev=425735&view=rev
Log:
[YOKO-95] : Forgot to add the files in my earlier commit. (Adding support for element list
& typedef sequence in the idltowsdl tool)

Added:
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ArrayVisitor.java
  (with props)
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesUtils.java
  (with props)
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitorBase.java
  (with props)

Added: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ArrayVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ArrayVisitor.java?rev=425735&view=auto
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ArrayVisitor.java
(added)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ArrayVisitor.java
Wed Jul 26 06:43:00 2006
@@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.yoko.tools.processors.idl;
+
+import antlr.collections.AST;
+
+import org.apache.schemas.yoko.bindings.corba.Sequence;
+import org.apache.schemas.yoko.bindings.corba.TypeMappingType;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaType;
+
+import org.apache.yoko.tools.common.CORBAConstants;
+
+public class ArrayVisitor extends TypesVisitorBase {
+
+    XmlSchema schema;
+    TypeMappingType typeMap;
+
+    public ArrayVisitor(XmlSchemaCollection xmlSchemas,
+                        XmlSchema xmlSchema,
+                        TypeMappingType typeMapRef) {
+        super(xmlSchemas, xmlSchema, typeMapRef);
+    }
+    
+    public void visit(AST node) {
+        AST seq = node.getFirstChild();
+        AST node2 = seq.getFirstChild();
+        XmlSchemaType stype = TypesUtils.findType(schemas, schema, node2);
+        if (stype == null) {
+            //System.err.println("Couldn't find type: " + node2);
+        } else {
+            long bound = -1;
+            if (node2.getNextSibling() != null) {
+                bound = Long.parseLong(node2.getNextSibling().toString());
+            }
+            node2 = seq.getNextSibling();
+            XmlSchemaComplexType ct = new XmlSchemaComplexType(getSchema());
+            String name = node2.toString();
+            ct.setName(name);
+            XmlSchemaSequence sequence = new XmlSchemaSequence();
+            XmlSchemaElement el = new XmlSchemaElement();
+            el.setName("item");
+            el.setMinOccurs(0);
+            if (bound != -1) {
+                el.setMaxOccurs(bound);
+            } else {
+                el.setMaxOccurs(Long.MAX_VALUE);
+            }
+            el.setSchemaTypeName(stype.getQName());
+            sequence.getItems().add(el);
+            ct.setParticle(sequence);
+            getSchema().getItems().add(ct);
+            getSchema().addType(ct);
+
+            //create the corba sequence
+            Sequence corbaSeq = new Sequence();
+            if (bound == -1) {
+                bound = 0;
+            }                
+            corbaSeq.setBound(bound);
+            corbaSeq.setName(name);
+            corbaSeq.setType(ct.getQName());
+            corbaSeq.setElemtype(TypesUtils.findCorbaType(getCorbaTypeMap(), stype.getQName()).getQName());
+            corbaSeq.setRepositoryID(CORBAConstants.REPO_STRING
+                                     + name
+                                     + CORBAConstants.IDL_VERSION);
+            getCorbaTypeMap().getStructOrExceptionOrUnion().add(corbaSeq);
+            setSchemaType(ct);
+            setCorbaType(corbaSeq);
+        }
+    }
+
+}

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ArrayVisitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ArrayVisitor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesUtils.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesUtils.java?rev=425735&view=auto
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesUtils.java
(added)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesUtils.java
Wed Jul 26 06:43:00 2006
@@ -0,0 +1,134 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.yoko.tools.processors.idl;
+
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import antlr.collections.AST;
+
+import org.apache.schemas.yoko.bindings.corba.TypeMappingType;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaType;
+import org.apache.ws.commons.schema.constants.Constants;
+import org.apache.yoko.tools.common.CorbaPrimitiveMap;
+import org.apache.yoko.wsdl.CorbaTypeImpl;
+
+public final class TypesUtils {
+
+    static CorbaPrimitiveMap corbaPrimitiveMap = new CorbaPrimitiveMap();
+
+
+    private TypesUtils() {
+        //complete
+    }
+
+    public static XmlSchemaType findType(XmlSchemaCollection schemas, XmlSchema schema, AST
node) {
+        XmlSchemaType result = getPrimitiveType(schemas, node);
+        if (result == null) {
+            //REVISIT, properly reference the node name, need to look at the siblings.
+            result = schema.getTypeByName(new QName(schema.getTargetNamespace(),
+                                                    node.toString()));
+        }
+        return result;
+    }
+
+    public static CorbaTypeImpl findCorbaType(TypeMappingType typeMap, QName schemaTypeName)
{
+        CorbaTypeImpl result = (CorbaTypeImpl) corbaPrimitiveMap.get(schemaTypeName);
+        if (result == null) {
+            Iterator corbaTypes = typeMap.getStructOrExceptionOrUnion().iterator();
+            while (corbaTypes.hasNext()) {
+                CorbaTypeImpl type = (CorbaTypeImpl) corbaTypes.next();
+                if (type.getName().equals(schemaTypeName.getLocalPart())) {
+                    result = type;
+                    break;
+                }
+            }
+        }
+        return result;
+    }
+
+    private static XmlSchemaType getPrimitiveType(XmlSchemaCollection schemas, AST node)
{
+        XmlSchemaType result = null;
+        switch (node.getType()) {
+        case IDLTokenTypes.LITERAL_long:
+            if (node.getNextSibling().getType() == IDLTokenTypes.LITERAL_long) {
+                // long long
+                result = schemas.getTypeByQName(Constants.XSD_LONG);
+            } else {
+                // long
+                result = schemas.getTypeByQName(Constants.XSD_INT);
+            }
+            break;
+        case IDLTokenTypes.LITERAL_unsigned:
+            AST node2 = node.getNextSibling();
+            if (node2.getType() == IDLTokenTypes.LITERAL_short) {
+                // unsigned short
+                result = schemas.getTypeByQName(Constants.XSD_UNSIGNEDSHORT);
+            } else if (node2.getType() == IDLTokenTypes.LITERAL_long) {
+                AST node3 = node2.getNextSibling();
+                if (node3.getType() == IDLTokenTypes.LITERAL_long) {
+                    // unsigned long long
+                    result = schemas.getTypeByQName(Constants.XSD_UNSIGNEDLONG);
+                } else {
+                    // unsigned long
+                    result = schemas.getTypeByQName(Constants.XSD_UNSIGNEDINT);
+                }
+            } else {
+                // TBD: we should never get here
+            }
+            break;
+        case IDLTokenTypes.LITERAL_short:
+            result = schemas.getTypeByQName(Constants.XSD_SHORT);
+            break;
+        case IDLTokenTypes.LITERAL_float:
+            result = schemas.getTypeByQName(Constants.XSD_FLOAT);
+            break;            
+        case IDLTokenTypes.LITERAL_double:
+            result = schemas.getTypeByQName(Constants.XSD_DOUBLE);
+            break;            
+        case IDLTokenTypes.LITERAL_char:
+            result = schemas.getTypeByQName(Constants.XSD_BYTE);
+            break;
+        case IDLTokenTypes.LITERAL_wchar:
+        case IDLTokenTypes.LITERAL_string:
+        case IDLTokenTypes.LITERAL_wstring:
+            result = schemas.getTypeByQName(Constants.XSD_STRING);
+            break;
+        case IDLTokenTypes.LITERAL_boolean:
+            result = schemas.getTypeByQName(Constants.XSD_BOOLEAN);
+            break;            
+        case IDLTokenTypes.LITERAL_octet:
+            result = schemas.getTypeByQName(Constants.XSD_UNSIGNEDBYTE);
+            break;            
+        case IDLTokenTypes.LITERAL_any:
+            result = schemas.getTypeByQName(Constants.XSD_ANYTYPE);
+            break;            
+        default:
+            // TBD 
+            break;
+        }
+        return result;
+    }
+
+}

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesUtils.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitorBase.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitorBase.java?rev=425735&view=auto
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitorBase.java
(added)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitorBase.java
Wed Jul 26 06:43:00 2006
@@ -0,0 +1,85 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.yoko.tools.processors.idl;
+
+import javax.xml.namespace.QName;
+
+import antlr.ASTVisitor;
+import antlr.collections.AST;
+
+import org.apache.schemas.yoko.bindings.corba.TypeMappingType;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaType;
+import org.apache.yoko.wsdl.CorbaTypeImpl;
+
+public abstract class TypesVisitorBase implements ASTVisitor {
+
+    protected XmlSchema schema;
+    protected XmlSchemaCollection schemas;
+    protected TypeMappingType typeMap;
+
+    XmlSchemaType schemaType;
+    CorbaTypeImpl corbaType;
+    
+    public TypesVisitorBase(XmlSchemaCollection xmlSchemas,
+                            XmlSchema xmlSchema,
+                            TypeMappingType typeMapRef) {
+        schemas = xmlSchemas;
+        schema = xmlSchema;
+        typeMap = typeMapRef;
+    }
+
+    public XmlSchema getSchema() {
+        return schema;
+    }
+
+    public TypeMappingType getCorbaTypeMap() {
+        return typeMap;
+    }
+
+
+    public abstract void visit(AST node);
+
+    public XmlSchemaType getSchemaType() {
+        return schemaType;
+    }
+
+    public CorbaTypeImpl getCorbaType() {
+        return corbaType;
+    }
+
+    public QName getSchemaTypeName() {
+        return schemaType.getQName();
+    }
+    
+    public QName getCorbaTypeName() {
+        return corbaType.getQName();
+    }
+
+    public void setSchemaType(XmlSchemaType type) {
+        schemaType = type;
+    }
+
+    public void setCorbaType(CorbaTypeImpl type) {
+        corbaType = type;
+    }
+}

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitorBase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitorBase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message