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

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


      throws UnableToCompleteException {
    context.parentLogger.branch(TreeLogger.DEBUG,
        "Building primitive value getter statement", null);
    SourceWriter sw = context.sw;
    String argName = context.parameterName;
    JPrimitiveType primitiveType = context.returnType.isPrimitive();
    // Map boolean values that are undefined or null to false
    if (primitiveType != null && primitiveType.equals(JPrimitiveType.BOOLEAN)) {
      sw.print("!!" + argName);
    } else {
      sw.print(argName);
    }
  }
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

     * @param type type to find the default value
     *
     * @return the default value of the type.
     */
    public static String getDefaultValueForType( JType type ) {
        JPrimitiveType primitiveType = type.isPrimitive();
        if ( null != primitiveType ) {
            return primitiveType.getUninitializedFieldExpression();
        }
        return "null";
    }
View Full Code Here

        offset = offsetAnnot.value();
      }
      this.pluralOffset = offset;
      boolean isArray = false;
      boolean isList = false;
      JPrimitiveType primType = argType.isPrimitive();
      JClassType classType = argType.isInterface();
      if (classType != null) {
        classType = classType.getErasedType();
        if ("java.util.List".equals(classType.getQualifiedSourceName())) {
          isList = true;
View Full Code Here

                + "returning Map or Map<String,String>");
      }
    }
    if (intValue != null) {
      constantsCount++;
      JPrimitiveType primType = returnType.isPrimitive();
      if (primType != JPrimitiveType.INT) {
        throw new AnnotationsError(
            "@DefaultIntValue can only be used with a method returning int");
      }
    }
    if (floatValue != null) {
      constantsCount++;
      JPrimitiveType primType = returnType.isPrimitive();
      if (primType != JPrimitiveType.FLOAT) {
        throw new AnnotationsError(
            "@DefaultFloatValue can only be used with a method returning float");
      }
    }
    if (doubleValue != null) {
      constantsCount++;
      JPrimitiveType primType = returnType.isPrimitive();
      if (primType != JPrimitiveType.DOUBLE) {
        throw new AnnotationsError(
            "@DefaultDoubleValue can only be used with a method returning double");
      }
    }
    if (booleanValue != null) {
      constantsCount++;
      JPrimitiveType primType = returnType.isPrimitive();
      if (primType != JPrimitiveType.BOOLEAN) {
        throw new AnnotationsError(
            "@DefaultBooleanValue can only be used with a method returning boolean");
      }
    }
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

      sw.println("public %s {", getBaseMethodDeclaration(jmethod));
      sw.indent();
      switch (method.getAction()) {
        case GET: {
          // Must handle de-boxing primitive types
          JPrimitiveType primitive = jmethod.getReturnType().isPrimitive();
          if (primitive != null) {
            // Object toReturn = values.get("foo");
            sw.println("Object toReturn = values.get(\"%s\");",
                method.getPropertyName());
            sw.println("if (toReturn == null) {");
            // return 0;
            sw.indentln("return %s;",
                primitive.getUninitializedFieldExpression());
            sw.println("} else {");
            // return (BoxedType) toReturn;
            sw.indentln("return (%s) toReturn;",
                primitive.getQualifiedBoxedSourceName());
            sw.println("}");
          } else {
            // return (ReturnType) values.get(\"foo\");
            sw.println("return (%s) values.get(\"%s\");",
                ModelUtils.getQualifiedBaseSourceName(jmethod.getReturnType()),
View Full Code Here

     * @throws UnableToCompleteException
     */
    public GenericSelector(TreeLogger logger, JMethod m, int i,
        JParameter[] params) throws UnableToCompleteException {
      super(logger, i, params);
      JPrimitiveType primType = argType.isPrimitive();
      JClassType classType = argType.isClass();
      JEnumType tempEnumType = null;
      boolean tempIsString = false;
      if (primType != null) {
        if (primType == JPrimitiveType.DOUBLE
View Full Code Here

        Map<String, String> formatArgs,
        String subformat,
        String argName,
        JType argType,
        Parameters params) {
      JPrimitiveType argPrimType = argType.isPrimitive();
      if (argPrimType != null) {
        if (argPrimType == JPrimitiveType.BOOLEAN || argPrimType == JPrimitiveType.VOID) {
          logger.log(TreeLogger.ERROR, "Illegal argument type for number format");
          return true;
        }
View Full Code Here

    if (classReturnType != null
        && "java.lang.String".equals(classReturnType.getQualifiedSourceName())) {
      returnExpr = "\"" + Generator.escape(def.getValues().get(0).toString())
          + "\"";
    } 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();
      }
      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();
      }
    }
    sw.print(toImplement.getReadableDeclaration(false, false, false, false,
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.