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

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


          continue;
        }

        TreeLogger fieldLogger = localLogger.branch(TreeLogger.DEBUG,
            field.toString(), null);
        JType fieldType = field.getType();

        TypePath path = TypePaths.createFieldPath(parent, field);
        if (typeInfo.isManuallySerializable()
            && fieldType.getLeafType() == typeOracle.getJavaLangObject()) {
          checkAllSubtypesOfObject(fieldLogger.branch(TreeLogger.WARN,
              "Object was reached from a manually serializable type", null),
              path, problems);
        } else {
          allSucceeded &= computeTypeInstantiability(fieldLogger, fieldType, path,
View Full Code Here


    // will contains dots.
    //
    String className;
    String packageName;

    JType leafType = type.getLeafType();
    if (leafType.isPrimitive() != null) {
      className = leafType.getSimpleSourceName();
      packageName = "";
    } else {
      JClassType classOrInterface = leafType.isClassOrInterface();
      assert (classOrInterface != null);
      className = classOrInterface.getName();
      packageName = classOrInterface.getPackage().getName();
    }
View Full Code Here

    for (Entry<String, String> property : localizedValues.entrySet()) {
      String key = property.getKey();
      String value = property.getValue();

      JType paramType = unfilledRequiredParams.get(key);
      if (paramType != null) {
        if (!isString(writer, paramType)) {
          writer.die("In %s, cannot apply message attribute to non-string "
              + "constructor argument %s %s.", elem,
              paramType.getSimpleSourceName(), key);
        }

        requiredValues.put(key, value);
        unfilledRequiredParams.remove(key);
      } else {
        JMethod setter = ownerFieldClass.getSetter(key);
        JParameter[] params = setter == null ? null : setter.getParameters();

        if (setter == null || !(params.length == 1)
            || !isString(writer, params[0].getType())) {
          writer.die("In %s, no method found to apply message attribute %s",
              elem, key);
        } else {
          setterValues.put(key, value);
        }
      }
    }

    // Now go through the element and dispatch its attributes, remembering
    // that constructor arguments get first dibs
    for (int i = elem.getAttributeCount() - 1; i >= 0; i--) {
      // Backward traversal b/c we're deleting attributes from the xml element

      XMLAttribute attribute = elem.getAttribute(i);

      // Ignore xmlns attributes
      if (attribute.getName().startsWith("xmlns:")) {
        continue;
      }

      String propertyName = attribute.getLocalName();
      if (setterValues.keySet().contains(propertyName)
          || requiredValues.containsKey(propertyName)) {
        writer.die("Duplicate attribute name: %s", propertyName);
      }

      if (unfilledRequiredParams.keySet().contains(propertyName)) {
        JType paramType = unfilledRequiredParams.get(propertyName);
        String value = elem.consumeAttributeWithDefault(attribute.getName(),
            null, paramType);
        if (value == null) {
          writer.die("In %s, unable to parse %s as constructor argument "
              + "of type %s", elem, attribute, paramType.getSimpleSourceName());
        }
        requiredValues.put(propertyName, value);
        unfilledRequiredParams.remove(propertyName);
      } else {
        JMethod setter = ownerFieldClass.getSetter(propertyName);
View Full Code Here

    return propertyName.substring(0, 1).toUpperCase() +
    propertyName.substring(1);
  }

  private boolean isString(UiBinderWriter writer, JType paramType) {
    JType stringType = writer.getOracle().findType(String.class.getName());
    return stringType.equals(paramType);
  }
View Full Code Here

        {
          if (!k.matches("\\w*"))
          {
        throw new CruxGeneratorException("Invalid KeyPath. ObjectStoreName["+objectStoreName+"]");
          }
          JType jType = JClassUtils.getTypeForProperty(k, targetObjectType);
         
          if (jType == null || jType.isPrimitive() != null)
          {
            throw new CruxGeneratorException("Invalid keyPath for objectStore ["+targetObjectType.getParameterizedQualifiedSourceName()+"]. Crux does not accept primitive types as object store keys");
          }
        }
    }
View Full Code Here

          String getterMethod = JClassUtils.getGetterMethod(key, targetObjectType);
      if (StringUtils.isEmpty(getterMethod))
      {
        throw new CruxGeneratorException("Invalid keyPath for objectStore ["+targetObjectType.getParameterizedQualifiedSourceName()+"]");
      }
      JType jType = JClassUtils.getReturnTypeFromMethodClass(targetObjectType, getterMethod, new JType[]{});
          if (jType.equals(stringType))
          {
              srcWriter.println("result["+i+"] = key.getString("+i+");");
          }
          else if (jType.equals(integerType) || (jType.equals(JPrimitiveType.INT)))
          {
              srcWriter.println("result["+i+"] = (int)key.getNumber("+i+");");
          }
          else if (jType.equals(doubleType) || (jType.equals(JPrimitiveType.DOUBLE)))
          {
              srcWriter.println("result["+i+"] = key.getNumber("+i+");");
          }
          else if (jType.equals(dateType))
          {
              srcWriter.println("result["+i+"] = new "+Date.class.getCanonicalName()+"((long)key.getNumber("+i+"));");
          }
          else
          {
View Full Code Here

        srcWriter.println("if ("+keyVar+" == null){");
        srcWriter.println("result.push((String)null);");
        srcWriter.println("}");
        srcWriter.println("else{");
     
      JType jType = JClassUtils.getTypeForProperty(key, targetObjectType);
      if (jType == null)
      {
        throw new CruxGeneratorException("Invalid keyPath for objectStore ["+targetObjectType.getParameterizedQualifiedSourceName()+"]");
      }
      if (jType.equals(stringType))
      {
        srcWriter.println("result.push((String)"+keyVar+");");
      }
      else if (jType.equals(integerType) || (jType.equals(JPrimitiveType.INT)))
      {
        if (keyPath.length > 1)
        {
          srcWriter.println("result.push((Integer)"+keyVar+");");
        }
        else
        {
          srcWriter.println("result.push((int)"+keyVar+");");
        }
      }
      else if (jType.equals(doubleType) || (jType.equals(JPrimitiveType.DOUBLE)))
      {
        if (keyPath.length > 1)
        {
          srcWriter.println("result.push((Double)"+keyVar+");");
        }
        else
        {
          srcWriter.println("result.push((double)"+keyVar+");");
        }
      }
      else if (jType.equals(dateType))
      {
        srcWriter.println("result.push((double)(("+Date.class.getCanonicalName()+")"+keyVar+").getTime());");
      }
      else
      {
View Full Code Here

    {
      return "Object[]";
    }
    else if (keyPath.length == 1)
    {
      JType jType = JClassUtils.getTypeForProperty(keyPath[0], targetObjectType);
      if (jType == null)
      {
        throw new CruxGeneratorException("Invalid keyPath for objectStore ["+targetObjectType.getParameterizedQualifiedSourceName()+"]");
      }
          if (jType.equals(stringType))
          {
            return "String";
          }
          else if (jType.equals(integerType) || (jType.equals(JPrimitiveType.INT)))
          {
            return "Integer";
          }
          else if (jType.equals(doubleType) || (jType.equals(JPrimitiveType.DOUBLE)))
          {
            return "Double";
          }
          else if (jType.equals(dateType))
          {
            return Date.class.getCanonicalName();
           
          }
          else
View Full Code Here

  @Override
    protected void generateWrapperMethod(JMethod method, SourcePrinter srcWriter)
    {
    if (mustDelegateToController(method))
    {
      JType returnType = method.getReturnType().getErasedType();

      srcWriter.println(method.getReadableDeclaration(false, false, false, false, true)+"{");
      if (returnType != JPrimitiveType.VOID)
      {
        srcWriter.print("return ");
View Full Code Here

        {
          String fieldName = field.getName();
      if (!added.contains(fieldName))
          {
        added.add(fieldName);
        JType fieldType = field.getType();
        if ((fieldType.isPrimitive()== null))
        {
          String injectionExpression = getFieldInjectionExpression(field, iocContainerVariable, configurations);
          if (injectionExpression != null)
          {
            if (JClassUtils.isPropertyVisibleToWrite(type, field, false))
            {
              if (JClassUtils.hasSetMethod(field, type))
              {
                String setterMethodName = "set"+Character.toUpperCase(fieldName.charAt(0))+fieldName.substring(1);
                                JMethod method = type.findMethod(setterMethodName, new JType[]{field.getType()});
                                if (method.getAnnotation(Inject.class) == null) // Annotated methods are handled apart
                                {
                                  srcWriter.println(fieldType.getQualifiedSourceName()+" field_"+fieldName+" = "+ injectionExpression+";");
                                  srcWriter.println(parentVariable+"."+setterMethodName+"(field_"+ fieldName+");");
                                }
              }
              else
              {
View Full Code Here

TOP

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

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.