Java Type Convert typeToSignature(String type)

Here you can find the source of typeToSignature(String type)

Description

type To Signature

License

Open Source License

Declaration

private static String typeToSignature(String type) 

Method Source Code

//package com.java2s;
/*/*from   w  w w.  ja  va 2s  .  c  o m*/
 * FindBugs - Find Bugs in Java programs
 * Copyright (C) 2006, University of Maryland
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

public class Main {
    private static String typeToSignature(String type) {
        if (type.endsWith("[]")) {
            return "[" + typeToSignature(type.substring(0, type.length() - 2));
        } else {
            return scalarTypeToSignature(type);
        }
    }

    private static String scalarTypeToSignature(String type) {
        if ("boolean".equals(type)) {
            return "Z";
        } else if ("byte".equals(type)) {
            return "B";
        } else if ("char".equals(type)) {
            return "C";
        } else if ("short".equals(type)) {
            return "S";
        } else if ("int".equals(type)) {
            return "I";
        } else if ("long".equals(type)) {
            return "J";
        } else if ("float".equals(type)) {
            return "F";
        } else if ("double".equals(type)) {
            return "D";
        } else if ("void".equals(type)) {
            return "V";
        } else {
            return "L" + type.replace('.', '/') + ";";
        }
    }
}

Related

  1. typeToFilename(String var)
  2. typeToHex(byte buffer[])
  3. typeToInt(String type)
  4. typeToJavaCode(Class type)
  5. typeToSignature(String className)
  6. typeToSimpleName(String typeName)
  7. TypeToString(int typeNum)
  8. typeToString(Object o)
  9. typeToTag(String TheType)