Here you can find the source of toJavaImplClassName(String podName, String typeName)
public static String toJavaImplClassName(String podName, String typeName)
//package com.java2s; // Licensed under the Academic Free License version 3.0 public class Main { /**//from www . j a v a 2 s .co m * Given a Fantom qname, get the Java implementation class name: * sys::Obj => fan.sys.FanObj * sys::Float => fan.sys.FanFloat * sys::Obj => fan.sys.FanObj */ public static String toJavaImplClassName(String podName, String typeName) { if (podName.equals("sys")) { switch (typeName.charAt(0)) { case 'B': if (typeName.equals("Bool")) return "fan.sys.FanBool"; break; case 'D': if (typeName.equals("Decimal")) return "fan.sys.FanDecimal"; break; case 'F': if (typeName.equals("Float")) return "fan.sys.FanFloat"; break; case 'I': if (typeName.equals("Int")) return "fan.sys.FanInt"; break; case 'N': if (typeName.equals("Num")) return "fan.sys.FanNum"; break; case 'O': if (typeName.equals("Obj")) return "fan.sys.FanObj"; break; case 'S': if (typeName.equals("Str")) return "fan.sys.FanStr"; break; } } // if pod starts with [java] parse as FFI name if (podName.charAt(0) == '[') return ffiToJavaClass(podName, typeName, false); return "fan." + podName + "." + typeName; } /** * Given a FFI fan signatures such as [java]foo.bar::Baz get the * Java classname. If sig is true then get as a signature otherwise * as a classname: * qname sig=true sig=false * -------------- -------- --------- * [java]::int I int * [java]foo::Bar foo/Bar foo.Bar * [java]foo::[Bar [Lfoo/Bar; [Lfoo/Bar; * [java]fanx.interop::IntArray [I [int */ private static String ffiToJavaClass(String podName, String typeName, boolean sig) { // sanity check if (!podName.startsWith("[java]")) throw new UnsupportedOperationException("Invalid FFI: " + podName); // primitives: [java]::int if (podName.length() == 6) // "[java]" { if (typeName.equals("int")) return sig ? "I" : "int"; if (typeName.equals("char")) return sig ? "C" : "char"; if (typeName.equals("byte")) return sig ? "B" : "byte"; if (typeName.equals("short")) return sig ? "S" : "short"; if (typeName.equals("float")) return sig ? "F" : "float"; } // primitives: [java]fanx.interop if (podName.equals("[java]fanx.interop")) { if (typeName.equals("BooleanArray")) return "[Z"; if (typeName.equals("ByteArray")) return "[B"; if (typeName.equals("ShortArray")) return "[S"; if (typeName.equals("CharArray")) return "[C"; if (typeName.equals("IntArray")) return "[I"; if (typeName.equals("LongArray")) return "[J"; if (typeName.equals("FloatArray")) return "[F"; if (typeName.equals("DoubleArray")) return "[D"; } // buffer for signature StringBuilder s = new StringBuilder(podName.length() + typeName.length()); // arrays: [java]foo.bar::[Baz -> [Lfoo/bar/Baz; boolean isArray = typeName.charAt(0) == '['; if (isArray) { while (typeName.charAt(0) == '[') { s.append('['); typeName = typeName.substring(1); } s.append('L'); } // build Java class name signature for (int i = 6; i < podName.length(); ++i) { char ch = podName.charAt(i); if (ch == '.') s.append(sig ? '/' : '.'); else s.append(ch); } s.append(sig ? '/' : '.').append(typeName); if (isArray) s.append(';'); return s.toString(); } }