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

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


    JMethod jMethod = JClassUtils.getMethod(clazz, JClassUtils.getGetterMethod(propertyName, clazz), new JType[]{});
    if (jMethod != null && (jMethod.isPublic() || (allowProtected && jMethod.isProtected())))
    {
      return (parentVariable+"."+jMethod.getName()+"()");
    }
    JField field = getField(clazz, propertyName);

    if (field.isPublic() || (allowProtected && field.isProtected()))
    {
      return parentVariable+"."+field.getName();
    }

    throw new CruxGeneratorException("Property ["+propertyName+"] could not be created. It is not visible neither has a getter/setter method.");
  }
View Full Code Here


      if (method == null) {
        method = getMethod(type, "has" + cap(p));
      }

      // Fall back to field
      JField field = getField(type, p);

      if (method != null) {
        sb.append(".").append(method.getName()).append("()");
        type = method.getReturnType().isClassOrInterface();
      } else if (field != null) {
        sb.append(".").append(p);
        type = field.getType().isClassOrInterface();
      } else {
        getLogger().log(Type.WARN, "Method get" + cap(p) + " could not be found");
        throw new NoSuchMethodException();
      }
View Full Code Here

    return type;
  }

  private JField getField(JClassType type, String p) {
    for (JClassType superType : type.getFlattenedSupertypeHierarchy()) {
      JField field = superType.findField(p);
      if (field != null && field.isPublic()){
        return field;
      }
    }
    return null;
  }
View Full Code Here

    }

    String methodName = "set" + cap(lastPathElement);

    JMethod method = getMethod(type, methodName);
    JField field = getField(type, lastPathElement);
    if (method != null && typesMatch(getValueType(), method.getParameterTypes()[0])) {
      sb.append(".").append(methodName).append("(").append(valueName).append(")");
    } else if (field != null && typesMatch(getValueType(), field.getType())) {
      sb.append(".").append(lastPathElement).append(" = ").append(valueName);
    } else {
      getLogger().log(Type.DEBUG, "Method " + methodName + " of type " + getValueType() + " could not be found.");
      return null;
    }
View Full Code Here

    String elseStm = "";
    JField[] fields = JClassUtils.getDeclaredFields(dtoType);
    for (int i = 0; i < fields.length; i++)
    {
      JField field = fields[i];
      String name = field.getName();
      JType type = field.getType();
      String typeName = type.getQualifiedSourceName();
     
      if (type.isPrimitive() != null)
      {
        JPrimitiveType jPrimitiveType = type.isPrimitive();
View Full Code Here

    JField[] fields = JClassUtils.getDeclaredFields(dtoType);
   
    String elseStm = "";
    for (int i = 0; i < fields.length; i++)
    {
      JField field = fields[i];
      String name = field.getName();
      JType type = field.getType();
      String typeName = type.getQualifiedSourceName();
     
      if (type.isPrimitive() != null)
      {
        JPrimitiveType jPrimitiveType = type.isPrimitive();
View Full Code Here

    JField[] fields = JClassUtils.getDeclaredFields(dtoType);
    String dtoTypeName = dtoType.getParameterizedQualifiedSourceName();
   
    for (int i = 0; i < fields.length; i++)
    {
      JField field = fields[i];
      String name = field.getName();
      JType fieldType = field.getType();
      String fieldTypeName = fieldType.getParameterizedQualifiedSourceName();
      String setterName = null;
      String getterName = null;

      if (fieldType.isPrimitive() != null)
      {
        JPrimitiveType jPrimitiveType = fieldType.isPrimitive();
        fieldTypeName = jPrimitiveType.getQualifiedBoxedSourceName();
      }
     
      try
      {
        setterName = dtoType.getMethod(ClassUtils.getSetterMethod(name), new JType[]{fieldType}).getName();
        getterName = dtoType.getMethod(ClassUtils.getGetterMethod(name), new JType[]{}).getName();
      }
      catch (NotFoundException e)
      {
        // do nothing
      }
     
      boolean isPublic = field.isPublic() && !field.isStatic();
      boolean hasGetterAndSetter = setterName != null && getterName != null;
      boolean isAccessible = isPublic || hasGetterAndSetter;
     
      if(isAccessible)
      {
View Full Code Here

    // Try to resolve annotations, ignore any that fail.
    Map<Class<? extends java.lang.annotation.Annotation>, java.lang.annotation.Annotation> declaredAnnotations = newAnnotationMap();
    resolveAnnotations(logger, jfield.annotations, declaredAnnotations);

    String name = String.valueOf(jfield.name);
    JField field;
    if (jfield.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) {
      assert (enclosingType.isEnum() != null);
      field = new JEnumConstant(enclosingType, name, declaredAnnotations,
          jfield.binding.original().id);
    } else {
      field = new JField(enclosingType, name, declaredAnnotations);
    }

    // Get modifiers.
    //
    field.addModifierBits(Shared.bindingToModifierBits(jfield.binding));

    // Set the field type.
    //
    TypeBinding jfieldType = jfield.binding.type;

    JType fieldType = resolveType(logger, jfieldType);
    if (fieldType == null) {
      // Unresolved type.
      //
      return false;
    }
    field.setType(fieldType);

    return true;
  }
View Full Code Here

  }

  private void createSingleImport(XMLElement elem, JClassType enclosingType,
      String rawFieldName, String constantName)
      throws UnableToCompleteException {
    JField field = enclosingType.findField(constantName);
    if (field == null) {
      writer.die(elem, "Unable to locate a field named %s in %s", constantName,
          enclosingType.getQualifiedSourceName());
    } else if (!field.isStatic()) {
      writer.die(elem, "Field %s in type %s is not static", constantName,
          enclosingType.getQualifiedSourceName());
    }

    JType importType = field.getType();
    JClassType fieldType;
    if (importType instanceof JPrimitiveType) {
      fieldType = oracle.findType(((JPrimitiveType) importType).getQualifiedBoxedSourceName());
    } else {
      fieldType = (JClassType) importType;
View Full Code Here

   */
  public JField[] getSerializableFields(JClassType classType) {
    List fields = new ArrayList();
    JField[] declFields = classType.getFields();
    for (int iField = 0; iField < declFields.length; ++iField) {
      JField field = declFields[iField];
      // TODO(mmendez): this is shared with the serializable type oracle
      // builder, join with that
      if (field.isStatic() || field.isTransient() || field.isFinal()) {
        continue;
      }

      fields.add(field);
    }
View Full Code Here

TOP

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

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.