Package com.google.gwt.core.ext.typeinfo

Examples of com.google.gwt.core.ext.typeinfo.JPrimitiveType


   *
   * @param type TypeOracle type to get the name for
   * @return binary name for a type
   */
  public static String getRpcTypeName(JType type) {
    JPrimitiveType primitiveType = type.isPrimitive();
    if (primitiveType != null) {
      return primitiveType.getJNISignature();
    }
 
    JArrayType arrayType = type.isArray();
    if (arrayType != null) {
      JType component = arrayType.getComponentType();
View Full Code Here


      sourceWriter.print("::");
      sourceWriter.print(fieldName);
      sourceWriter.println(";");
    } else {
      sourceWriter.print("return ");
      JPrimitiveType primType = fieldType.isPrimitive();
      if (primType != null) {
        sourceWriter.print("(" + primType.getQualifiedBoxedSourceName() + ") ");
      } else {
        sourceWriter.print("(" + fieldTypeQualifiedSourceName + ") ");
      }
      sourceWriter.println(
          "ReflectionHelper.getField(" + serializableClassQualifedName
View Full Code Here

        serializationSto.getSerializableTypes());
    Collections.addAll(serializableTypes,
        deserializationSto.getSerializableTypes());
    for (JMethod m : serviceIntf.getOverridableMethods()) {
      // Pick up any primitive return types, which get sent boxed
      JPrimitiveType mustBox = m.getReturnType().isPrimitive();
      if (mustBox != null) {
        serializableTypes.add(m.getReturnType());
      }
    }

    StringBuilder sb = new StringBuilder("@ArtificialRescue({");
    for (JType serializableType : serializableTypes) {

      JArrayType serializableArray = serializableType.isArray();
      JClassType serializableClass = serializableType.isClass();
      JPrimitiveType serializablePrimitive = serializableType.isPrimitive();
      if (serializableArray != null) {
        sb.append("\n@Rescue(className = \"");
        sb.append(serializableArray.getQualifiedSourceName());
        sb.append("\",\n instantiable = true),");
      } else if (serializableClass != null) {
        writeSingleRescue(typeOracle, deserializationSto, sb, serializableClass);
      } else if (serializablePrimitive != null) {
        JClassType boxedClass = typeOracle.findType(serializablePrimitive.getQualifiedBoxedSourceName());
        assert boxedClass != null : "No boxed version of "
            + serializablePrimitive.getQualifiedSourceName();
        writeSingleRescue(typeOracle, deserializationSto, sb, boxedClass);
      }
    }
    sb.append("})");
    return sb;
View Full Code Here

  }

  private String getBinaryOrPrimitiveName(JType type) {
    JArrayType asArray = type.isArray();
    JClassType asClass = type.isClassOrInterface();
    JPrimitiveType asPrimitive = type.isPrimitive();
    if (asClass != null) {
      return getBinaryName(asClass);
    } else if (asPrimitive != null) {
      return asPrimitive.getQualifiedSourceName();
    } else if (asArray != null) {
      JType componentType = asArray.getComponentType();
      return getBinaryOrPrimitiveName(componentType) + "[]";
    } else {
      throw new InternalCompilerException("Cannot create binary name for "
View Full Code Here

      }
      currentType = currentMethod.getReturnType();
    }

    if (expectedReturnType != null) {
      JPrimitiveType expectedIsPrimitive = expectedReturnType.isPrimitive();
      JClassType expectedIsClassType = expectedReturnType.isClassOrInterface();
      boolean error = false;

      if (expectedIsPrimitive != null) {
        if (!expectedIsPrimitive.equals(currentMethod.getReturnType())) {
          error = true;
        }
      } else {
        JClassType returnIsClassType = currentMethod.getReturnType().isClassOrInterface();
        if (returnIsClassType == null) {
View Full Code Here

      for (Value val : def.getValues()) {
        returnValues.add(Generator.escape(val.toString()));
      }
      returnExpr = "\"" + Joiner.on(" ").join(returnValues) + "\"";
    } else {
      JPrimitiveType returnType = toImplement.getReturnType().isPrimitive();
      if (returnType == null) {
        logger.log(TreeLogger.ERROR, toImplement.getName()
            + ": Return type must be primitive type or String for "
            + "@def accessors");
        throw new UnableToCompleteException();
      }
      NumberValue numberValue = def.getValues().get(0).isNumberValue();
      if (returnType == JPrimitiveType.INT || returnType == JPrimitiveType.LONG) {
        returnExpr = "" + Math.round(numberValue.getValue());
      } else if (returnType == JPrimitiveType.FLOAT) {
        returnExpr = numberValue.getValue() + "F";
      } else if (returnType == JPrimitiveType.DOUBLE) {
        returnExpr = "" + numberValue.getValue();
      } else {
        logger.log(TreeLogger.ERROR, returnType.getQualifiedSourceName()
            + " is not a valid primitive return type for @def accessors");
        throw new UnableToCompleteException();
      }
    }
View Full Code Here

    }
    return NO_ANNOTATIONS;
  }

  private String getQualifiedSourceNonPrimitiveType(JType elementType) {
    JPrimitiveType primitive = elementType.isPrimitive();
    return primitive == null ? elementType.getQualifiedSourceName()
        : primitive.getQualifiedBoxedSourceName();
  }
View Full Code Here

      //since our bean cannot inherit the method json() from JsoModelBase, we have to block this getter
      if(method.getName().equals("json")) continue;
     
      if (isGetter(method)) {
        JPrimitiveType pType = method.getReturnType().isPrimitive();
        if (pType != null) {
          if (pType != JPrimitiveType.BOOLEAN) {
            sw.println("final public "
                + pType.getSimpleSourceName() + " "
                + method.getName() + "" + "() {");
            sw.indent();
            sw.println("return (" + pType.getSimpleSourceName()
                + ") json().getNumber("
                + quotedFieldName(method) + ");");
            sw.outdent();
            sw.println("}");
          } else if (pType == JPrimitiveType.BOOLEAN) {
            sw.println("final public boolean " + method.getName()
                + "() {");
            sw.indent();
            sw.println("return json().getBoolean("
                + quotedFieldName(method) + ");");
            sw.outdent();
            sw.println("}");
          } else {
            // shouldn't reach here (only void left)
            throw new UnableToCompleteException();
          }
        } else {
          JClassType cType = method.getReturnType()
              .isClassOrInterface();
          if (cType.isAssignableTo(types.stringType)) {
            sw.println("final public String " + method.getName()
                + "() {");
            sw.indent();
            sw.println("return json().getString("
                + quotedFieldName(method) + ");");
            sw.outdent();
            sw.println("}");
          } else {
            sw.println("final public "
                + method.getReturnType()
                    .getParameterizedQualifiedSourceName()
                + " " + method.getName() + "" + "() {");
            sw.indent();
            generateDependentType(logger, context, types, method
                .getReturnType().isClassOrInterface());
            sw.println("return Util.reinterpret_cast(json().get("
                + quotedFieldName(method) + "))" + ";");
            sw.outdent();
            sw.println("}");
            // handle arrays
            // handle nested models
          }
        }
      } else if (isSetter(method)) {
        JPrimitiveType pType = method.getParameters()[0].getType()
            .isPrimitive();
        if (pType != null) {
          if (pType != JPrimitiveType.BOOLEAN) {
            sw.println("final public " + fluentOrVoid(method,simpleName) + " "
                + method.getName() + "("
                + pType.getSimpleSourceName() + " arg) {");
            sw.indent();
            sw.println("json().put(" + quotedFieldName(method)
                + ", arg);");
            maybeFluentReturn(sw, method);
            sw.outdent();
View Full Code Here

    String jsniSignature;
    JArrayType arrayType = type.isArray();

    if (arrayType != null) {
      JType componentType = arrayType.getComponentType();
      JPrimitiveType primitiveType = componentType.isPrimitive();
      if (primitiveType != null) {
        jsniSignature = "[" + primitiveType.getJNISignature();
      } else {
        jsniSignature = "[" + "Ljava/lang/Object;";
      }
    } else {
      jsniSignature = type.getJNISignature();
View Full Code Here

    return Long.toString(crc.getValue());
  }

  public String getSerializedTypeName(JType type) {
    JPrimitiveType primitiveType = type.isPrimitive();
    if (primitiveType != null) {
      return primitiveType.getJNISignature();
    }

    JArrayType arrayType = type.isArray();
    if (arrayType != null) {
      JType component = arrayType.getComponentType();
View Full Code Here

TOP

Related Classes of com.google.gwt.core.ext.typeinfo.JPrimitiveType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.