List of utility methods to do Type Convert
Class | typeToClass(Class type) type To Class if (type == boolean.class) return Boolean.class; if (type == byte.class) return Byte.class; if (type == char.class) return Character.class; if (type == short.class) return Short.class; ... |
String | typeToFilename(String var) Converts type names to file names, substitutes ":" for "_" return var.replaceAll(":", "_").toLowerCase(); |
String | typeToHex(byte buffer[]) type To Hex StringBuffer sb = new StringBuffer(buffer.length * 2); for (int i = 0; i < buffer.length; i++) { sb.append(Character.forDigit((buffer[i] & 240) >> 4, 16)); sb.append(Character.forDigit(buffer[i] & 15, 16)); return sb.toString(); |
int | typeToInt(String type) type To Int switch (type) { case "A": return 1; case "NS": return 2; case "MD": return 3; case "MF": ... |
String | typeToJavaCode(Class> type) type To Java Code if (type.isArray()) { return type.getComponentType().getName() + "[]"; } else { return type.getName(); |
String | typeToSignature(String className) Converts class name ("foo.Bar") to signature ("foo/bar"). return className.replace('.', '/'); |
String | typeToSignature(String type) type To Signature if (type.endsWith("[]")) { return "[" + typeToSignature(type.substring(0, type.length() - 2)); } else { return scalarTypeToSignature(type); |
String | typeToSimpleName(String typeName) type To Simple Name int dotIdx = typeName.indexOf('.'); if (dotIdx == -1) { return typeName; return typeName.substring(dotIdx + 1); |
String | TypeToString(int typeNum) Type To String switch (typeNum) { case TYPE_FIRE: return "Fire"; case TYPE_WATER: return "Water"; case TYPE_EARTH: return "Earth"; case TYPE_WIND: ... |
String | typeToString(Object o) type To String if (o instanceof String) { return "'" + (String) o + "'"; } else if (o instanceof Enum) { return "'" + ((Enum<?>) o).name() + "'"; } else if (o instanceof Class) { return "'" + ((Class<?>) o).getName() + "'"; } else return String.valueOf(o); ... |