List of usage examples for com.google.gwt.core.ext.typeinfo JPrimitiveType getJNISignature
public String getJNISignature()
From source file:com.totsp.gwt.freezedry.rebind.SerializableTypeOracleImpl.java
License:Apache License
public String getSerializedTypeName(JType type) { JPrimitiveType primitiveType = type.isPrimitive(); if (primitiveType != null) { return primitiveType.getJNISignature(); }/*from w ww . j av a 2s .c om*/ JArrayType arrayType = type.isArray(); if (arrayType != null) { JType component = arrayType.getComponentType(); if (component.isClassOrInterface() != null) { return "[L" + getSerializedTypeName(arrayType.getComponentType()) + ";"; } else { return "[" + getSerializedTypeName(arrayType.getComponentType()); } } JParameterizedType parameterizedType = type.isParameterized(); if (parameterizedType != null) { return getSerializedTypeName(parameterizedType.getRawType()); } JClassType classType = type.isClassOrInterface(); assert (classType != null); JClassType enclosingType = classType.getEnclosingType(); if (enclosingType != null) { return getSerializedTypeName(enclosingType) + "$" + classType.getSimpleSourceName(); } return classType.getQualifiedSourceName(); }
From source file:com.tyf.gwtphp.rebind.TypeUtil.java
License:Open Source License
/** * Returns the special binary name of a type. This type name corresponds the one * used in the GWT-PHP RPC library. This method also puts all other types referenced * into the given set.//from w w w. j a va 2 s. c om * * E.g. HashMap<String, Integer> actually contains three types, all of which will be * discovered and their names combined to get the final PHP RPC type name. * * @param type * TypeOracle type to get the name for * @param typeSet * A Set to receive classes discovered during type name parsing * @return binary name for a type */ public static String getPHPRpcTypeName(JType type, Set<JType> typeSet) { JPrimitiveType primitiveType = type.isPrimitive(); if (primitiveType != null) { return primitiveType.getJNISignature(); } JArrayType arrayType = type.isArray(); if (arrayType != null) { JType component = arrayType.getComponentType(); if (component.isClassOrInterface() != null) { return "[L" + getPHPRpcTypeName(arrayType.getComponentType(), typeSet) + ";"; } else { return "[" + getPHPRpcTypeName(arrayType.getComponentType(), typeSet); } } JParameterizedType parameterizedType = type.isParameterized(); if (parameterizedType != null) { String base = getPHPRpcTypeName(parameterizedType.getBaseType(), typeSet); StringBuilder sb = new StringBuilder(base); sb.append('<'); JClassType[] args = parameterizedType.getTypeArgs(); for (int i = 0; i < args.length; i++) { sb.append(getPHPRpcTypeName(args[i], typeSet)); if (i != args.length - 1) sb.append(','); } sb.append('>'); return sb.toString(); } JClassType classType = type.isClassOrInterface(); assert (classType != null); JClassType enclosingType = classType.getEnclosingType(); if (enclosingType != null) { return getPHPRpcTypeName(enclosingType, typeSet) + "$" + classType.getSimpleSourceName(); } typeSet.add(classType); return classType.getQualifiedSourceName(); }