You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by er...@apache.org on 2008/06/17 05:40:17 UTC

svn commit: r668385 - in /webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba: exceptions/InvalidIDLException.java idl/parser/IDLVisitor.java idl/types/PrimitiveDataType.java

Author: eranga
Date: Mon Jun 16 20:40:17 2008
New Revision: 668385

URL: http://svn.apache.org/viewvc?rev=668385&view=rev
Log:
Fixed issues in string<n> IDL construct

Added:
    webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/exceptions/InvalidIDLException.java
Modified:
    webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/IDLVisitor.java
    webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/PrimitiveDataType.java

Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/exceptions/InvalidIDLException.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/exceptions/InvalidIDLException.java?rev=668385&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/exceptions/InvalidIDLException.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/exceptions/InvalidIDLException.java Mon Jun 16 20:40:17 2008
@@ -0,0 +1,38 @@
+/*
+ * 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.axis2.corba.exceptions;
+
+public class InvalidIDLException extends CorbaException {
+    public InvalidIDLException() {
+	    super();
+    }
+
+    public InvalidIDLException(String message) {
+        super(message);
+    }
+
+    public InvalidIDLException(Throwable cause) {
+        super(cause);
+    }
+
+    public InvalidIDLException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

Modified: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/IDLVisitor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/IDLVisitor.java?rev=668385&r1=668384&r2=668385&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/IDLVisitor.java (original)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/IDLVisitor.java Mon Jun 16 20:40:17 2008
@@ -19,7 +19,6 @@
 
 package org.apache.axis2.corba.idl.parser;
 
-import antlr.ASTVisitor;
 import antlr.collections.AST;
 import org.apache.axis2.corba.idl.types.ArrayType;
 import org.apache.axis2.corba.idl.types.CompositeDataType;
@@ -37,6 +36,7 @@
 import org.apache.axis2.corba.idl.types.UnionMember;
 import org.apache.axis2.corba.idl.types.UnionType;
 import org.apache.axis2.corba.idl.types.ValueType;
+import org.apache.axis2.corba.exceptions.InvalidIDLException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -48,7 +48,7 @@
  * Date: Feb 11, 2007
  * Time: 10:06:23 PM
  */
-public class IDLVisitor implements ASTVisitor {
+public class IDLVisitor /*implements ASTVisitor*/ {
     private static final Log log = LogFactory.getLog(IDLVisitor.class);
     private IDL idl = new IDL();
     private String module = "";
@@ -63,7 +63,7 @@
         this.idl = idl;
     }
 
-    public void visit(AST node) {
+    public void visit(AST node) throws InvalidIDLException {
         while (node != null) {
             switch (node.getType()) {
 
@@ -113,14 +113,14 @@
                 }
 
                 default: {
-                    log.error("Unsupported IDL token " + node);
+                    throw new InvalidIDLException("Unsupported IDL token " + node);
                 }
             }
             node = node.getNextSibling();
         }
     }
 
-    private Struct visitStruct(AST node) {
+    private Struct visitStruct(AST node) throws InvalidIDLException {
         AST structNode = node.getFirstChild();
         String structName = structNode.toString();
         Struct struct = new Struct();
@@ -167,7 +167,7 @@
         return struct;
     }
 
-    private ValueType visitValueType(AST node) {
+    private ValueType visitValueType(AST node) throws InvalidIDLException {
         AST valueNode = node.getFirstChild();
         ValueType value = new ValueType();
         value.setModule(module);
@@ -204,7 +204,7 @@
         return value;
     }
 
-    private Interface visitInterface(AST node) {
+    private Interface visitInterface(AST node) throws InvalidIDLException {
         Interface intf = new Interface();
         intf.setModule(module);
         AST interfaceNode = node.getFirstChild();
@@ -267,7 +267,7 @@
         return intf;
     }
 
-    private Operation visitGetAttribute(AST node) {
+    private Operation visitGetAttribute(AST node) throws InvalidIDLException {
         Operation operation = new Operation();
         AST type = node.getFirstChild();
         operation.setReturnType(findDataType(type));
@@ -276,7 +276,7 @@
         return operation;
     }
 
-    private Operation visitSetAttribute(AST node) {
+    private Operation visitSetAttribute(AST node) throws InvalidIDLException {
         Operation operation = new Operation();
         AST type = node.getFirstChild();
         operation.setReturnType(PrimitiveDataType.getPrimitiveDataType("void"));
@@ -290,7 +290,7 @@
         return operation;
     }
 
-    private Operation visitOperation(AST node) {
+    private Operation visitOperation(AST node) throws InvalidIDLException {
         Operation operation = new Operation();
         operation.setName(node.toString());
         AST type = node.getFirstChild();
@@ -317,7 +317,7 @@
         return operation;
     }
 
-    private ExceptionType visitException(AST node) {
+    private ExceptionType visitException(AST node) throws InvalidIDLException {
         ExceptionType raisesType = new ExceptionType();
         AST exNode = node.getFirstChild();
         String exName = exNode.toString();
@@ -335,10 +335,10 @@
         return raisesType;
     }
 
-    private DataType findDataType(AST typeNode) {
+    private DataType findDataType(AST typeNode) throws InvalidIDLException {
         return findDataType(typeNode, true);
     }
-    private DataType findDataType(AST typeNode, boolean root) {
+    private DataType findDataType(AST typeNode, boolean root) throws InvalidIDLException {
         // Check for sequences
         if (typeNode.getType()==IDLTokenTypes.LITERAL_sequence) {
             return visitAnonymousSequence(typeNode, root);
@@ -367,6 +367,8 @@
         if (dataType==null)
             dataType = PrimitiveDataType.getPrimitiveDataType(typeName);
 
+        if (dataType == null)
+            throw new InvalidIDLException("Invalid data type: " + typeName);
         return dataType;
     }
 
@@ -402,7 +404,7 @@
         return enumType;
     }
 
-    private UnionType visitUnion(AST node) {
+    private UnionType visitUnion(AST node) throws InvalidIDLException {
         UnionType unionType = new UnionType();
         AST exNode = node.getFirstChild();
         String exName = exNode.toString();
@@ -435,7 +437,7 @@
         return unionType;
     }
 
-    private void visitAndAddTypedefs(AST node, String moduleName) {
+    private void visitAndAddTypedefs(AST node, String moduleName) throws InvalidIDLException {
         AST typedefNode = node.getFirstChild();
 
         DataType dataType;
@@ -486,7 +488,7 @@
         }
     }
 
-    private SequenceType visitAnonymousSequence(AST node, boolean root) {
+    private SequenceType visitAnonymousSequence(AST node, boolean root) throws InvalidIDLException {
         AST typeNode = node.getFirstChild();
         SequenceType sequenceType = new SequenceType();
         DataType dataType = findDataType(typeNode, false);

Modified: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/PrimitiveDataType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/PrimitiveDataType.java?rev=668385&r1=668384&r2=668385&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/PrimitiveDataType.java (original)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/PrimitiveDataType.java Mon Jun 16 20:40:17 2008
@@ -61,7 +61,13 @@
     }
 
     public static TypeCode getTypeCode(String typeName) {
-        return (TypeCode) PRIMITIVE_TYPES.get(typeName);
+        TypeCode typeCode = (TypeCode) PRIMITIVE_TYPES.get(typeName);
+        if (typeCode == null && typeName != null && typeName.contains("::")) {
+            String typeName2 = typeName.substring(0, typeName.indexOf("::"));
+            typeCode = (TypeCode) PRIMITIVE_TYPES.get(typeName2);
+            return typeCode;
+        }
+        return typeCode;
     }
 
     public static boolean isPrimitive(TypeCode typeCode) {
@@ -82,25 +88,30 @@
 
     public String getTypeName() {
         String ret = null;
-        switch(typeCode.kind().value()) {
-            case TCKind._tk_long : ret = "int"; break;
-            case TCKind._tk_ulong : ret = "int"; break;
-            case TCKind._tk_longlong : ret = "long"; break;
-            case TCKind._tk_ulonglong : ret = "long"; break;
-            case TCKind._tk_short : ret = "short"; break;
-            case TCKind._tk_ushort : ret = "short"; break;
-            case TCKind._tk_float : ret = "float"; break;
-            case TCKind._tk_double : ret = "double"; break;
-            case TCKind._tk_char : ret = "char"; break;
-            case TCKind._tk_wchar : ret = "char"; break;
-            case TCKind._tk_boolean : ret = "boolean"; break;
-            case TCKind._tk_octet : ret = "byte"; break;
-            case TCKind._tk_string : ret = "java.lang.String"; break;
-            case TCKind._tk_wstring : ret = "java.lang.String"; break;
-            case TCKind._tk_void : ret = "void"; break;
-             default:
-                log.error("Invalid primitive data type");
-                break;
+        if (typeCode != null) {
+            TCKind kind = typeCode.kind();
+            if (kind != null) {
+                switch(kind.value()) {
+                    case TCKind._tk_long : ret = "int"; break;
+                    case TCKind._tk_ulong : ret = "int"; break;
+                    case TCKind._tk_longlong : ret = "long"; break;
+                    case TCKind._tk_ulonglong : ret = "long"; break;
+                    case TCKind._tk_short : ret = "short"; break;
+                    case TCKind._tk_ushort : ret = "short"; break;
+                    case TCKind._tk_float : ret = "float"; break;
+                    case TCKind._tk_double : ret = "double"; break;
+                    case TCKind._tk_char : ret = "char"; break;
+                    case TCKind._tk_wchar : ret = "char"; break;
+                    case TCKind._tk_boolean : ret = "boolean"; break;
+                    case TCKind._tk_octet : ret = "byte"; break;
+                    case TCKind._tk_string : ret = "java.lang.String"; break;
+                    case TCKind._tk_wstring : ret = "java.lang.String"; break;
+                    case TCKind._tk_void : ret = "void"; break;
+                    default:
+                        log.error("Invalid primitive data type");
+                        break;
+                }
+            }
         }
         return ret;
     }