langtools/src/share/classes/sun/tools/javap/TypeSignature.java
author jjg
Thu, 22 May 2008 16:06:00 -0700
changeset 656 4718b910737c
parent 10 06bc494ca11e
child 735 372aa565a221
permissions -rw-r--r--
6657909: javap has unchecked compilation warnings Reviewed-by: mcimadamore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
06bc494ca11e Initial load
duke
parents:
diff changeset
     2
 * Copyright 2002-2003 Sun Microsystems, Inc.  All Rights Reserved.
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
 * have any questions.
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
package sun.tools.javap;
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import java.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import java.io.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 * Returns java type signature.
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * @author  Sucheta Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
public class TypeSignature {
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
    String parameters = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
    String returntype = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
    String fieldtype = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
    int argumentlength = 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
    public TypeSignature(String JVMSignature){
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
        if(JVMSignature != null){
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
            if(JVMSignature.indexOf("(") == -1){
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
                //This is a field type.
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
                this.fieldtype = getFieldTypeSignature(JVMSignature);
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
            }else {
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
                String parameterdes = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
                if((JVMSignature.indexOf(")")-1) > (JVMSignature.indexOf("("))){
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
                    //Get parameter signature.
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
                    parameterdes =
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
                        JVMSignature.substring(JVMSignature.indexOf("(")+1,
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
                                               JVMSignature.indexOf(")"));
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
                    this.parameters = getParametersHelper(parameterdes);
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
                }else this.parameters = "()";
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
                //Get return type signature.
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
                String returndes = JVMSignature.substring(JVMSignature.lastIndexOf(")")+1);
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
                this.returntype = getReturnTypeHelper(returndes);
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     * Returns java type signature of a field.
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
    public String getFieldTypeSignature(String fielddes){
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
        if(fielddes.startsWith("L")){
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
            return(getObjectType(fielddes));
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
        }else if(fielddes.startsWith("[")){
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
            return(getArrayType(fielddes));
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
        }else
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
            return(getBaseType(fielddes));
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     * Returns java type signature of a parameter.
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    public String getParametersHelper(String parameterdes){
656
4718b910737c 6657909: javap has unchecked compilation warnings
jjg
parents: 10
diff changeset
    82
        Vector<String> parameters = new Vector<String>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
        int startindex = -1;
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
        int endindex = -1;
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
        String param = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
        while(parameterdes != null){
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
            if(parameterdes.startsWith("L")){
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
                //parameter is a object.
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
                startindex = parameterdes.indexOf("L");
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
                endindex = parameterdes.indexOf(";");
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
                if(startindex < parameterdes.length()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
                    if(endindex == parameterdes.length()-1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
                        //last parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
                        param = parameterdes.substring(startindex);
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
                        parameterdes = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
                    }else if(endindex+1 < parameterdes.length()){
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
                        //rest parameters
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
                        param = parameterdes.substring(startindex, endindex+1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
                        parameterdes = parameterdes.substring(endindex+1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
                    parameters.add(getObjectType(param));
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
            }else if(parameterdes.startsWith("[")){
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
                //parameter is an array.
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
                String componentType = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
                int enddim = -1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
                int st = 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
                while(true){
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
                    if(st < parameterdes.length()){
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
                        if(parameterdes.charAt(st) == '['){
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
                            enddim = st;
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
                            st++;
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
                        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
                        else break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
                    else break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
                if(enddim+1 < parameterdes.length()){
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
                    /* Array dimension.*/
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
                    param = parameterdes.substring(0,enddim+1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
                int stotherparam = param.lastIndexOf("[")+1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
                if(stotherparam < parameterdes.length()){
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
                    componentType =  parameterdes.substring(stotherparam);
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
                if(componentType.startsWith("L")){
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
                    //parameter is array of objects.
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
                    startindex = parameterdes.indexOf("L");
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
                    endindex = parameterdes.indexOf(";");
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
                    if(endindex ==  parameterdes.length()-1){
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
                        //last parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
                        param += parameterdes.substring(startindex);
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
                        parameterdes = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
                    }else if(endindex+1 <  parameterdes.length()){
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
                        //rest parameters
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
                        param += parameterdes.substring(startindex, endindex+1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
                        parameterdes = parameterdes.substring(endindex+1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
                }else{
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
                    //parameter is array of base type.
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
                    if(componentType.length() == 1){
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
                        //last parameter.
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
                        param += componentType;
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
                        parameterdes = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
                    else if (componentType.length() > 1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
                        //rest parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
                        param += componentType.substring(0,1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
                        parameterdes = componentType.substring(1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
                parameters.add(getArrayType(param));
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
            }else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
                //parameter is of base type.
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
                if(parameterdes.length() == 1){
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
                    //last parameter
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
                    param = parameterdes;
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
                    parameterdes = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
                else if (parameterdes.length() > 1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
                    //rest parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
                    param = parameterdes.substring(0,1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
                    parameterdes = parameterdes.substring(1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
                parameters.add(getBaseType(param));
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
        /* number of arguments of a method.*/
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
        argumentlength =  parameters.size();
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
        /* java type signature.*/
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
        String parametersignature = "(";
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
        int i;
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
        for(i = 0; i < parameters.size(); i++){
656
4718b910737c 6657909: javap has unchecked compilation warnings
jjg
parents: 10
diff changeset
   190
            parametersignature += parameters.elementAt(i);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
            if(i != parameters.size()-1){
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
                parametersignature += ", ";
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
        parametersignature += ")";
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
        return parametersignature;
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
     * Returns java type signature for a return type.
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
    public String getReturnTypeHelper(String returndes){
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
        return getFieldTypeSignature(returndes);
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
     * Returns java type signature for a base type.
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
    public String getBaseType(String baseType){
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
        if(baseType != null){
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
            if(baseType.equals("B")) return "byte";
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
            else if(baseType.equals("C")) return "char";
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
            else if(baseType.equals("D")) return "double";
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
            else if(baseType.equals("F")) return "float";
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
            else if(baseType.equals("I")) return "int";
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
            else if(baseType.equals("J")) return "long";
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
            else if(baseType.equals("S")) return "short";
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
            else if(baseType.equals("Z")) return "boolean";
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
            else if(baseType.equals("V")) return "void";
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
     * Returns java type signature for a object type.
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
    public String getObjectType(String JVMobjectType) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
        String objectType = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
        int startindex = JVMobjectType.indexOf("L")+1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
        int endindex =  JVMobjectType.indexOf(";");
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
        if((startindex != -1) && (endindex != -1)){
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
            if((startindex < JVMobjectType.length()) && (endindex < JVMobjectType.length())){
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
                objectType = JVMobjectType.substring(startindex, endindex);
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
            objectType = objectType.replace('/','.');
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
            return objectType;
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
     * Returns java type signature for array type.
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
    public String getArrayType(String arrayType) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
        if(arrayType != null){
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
            String dimention = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
            while(arrayType.indexOf("[") != -1){
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
                dimention += "[]";
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
                int startindex = arrayType.indexOf("[")+1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
                if(startindex <= arrayType.length()){
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
                arrayType = arrayType.substring(startindex);
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
            String componentType = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
            if(arrayType.startsWith("L")){
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
                componentType = getObjectType(arrayType);
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
            }else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
                componentType = getBaseType(arrayType);
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
            return componentType+dimention;
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
     * Returns java type signature for parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
     public String getParameters(){
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
        return parameters;
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
     * Returns java type signature for return type.
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
    public String getReturnType(){
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
        return returntype;
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
     * Returns java type signature for field type.
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
    public String getFieldType(){
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
        return fieldtype;
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
     * Return number of arguments of a method.
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
    public int getArgumentlength(){
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
        return argumentlength;
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
}