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

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


  }

  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


    LinkedList<JClassType> classesToBeProcessed = new LinkedList<JClassType>();
    classesToBeProcessed.add(classType);
    JClassType tempClassType = null;
    while (classesToBeProcessed.peek() != null) {
      tempClassType = classesToBeProcessed.remove();
      JField declaredFields[] = tempClassType.getFields();
      for (JField field : declaredFields) {
        JClassType fieldType = field.getType().isClass();
        JParameterizedType parameterizedType = null;
        if (fieldType != null) {
          parameterizedType = fieldType.isParameterized();
        }
        if (field.isPrivate()
            || parameterizedType == null
            || !(parameterizedType.getBaseType().getQualifiedSourceName().equals(Property.class.getName()))) {
          continue;
        }
        JField existing = fieldsByName.put(field.getName(), field);
        if (existing != null) {
          if (existing.getEnclosingType().isAssignableTo(
              field.getEnclosingType())) {
            fieldsByName.put(field.getName(), existing);
          }
        }
      }
View Full Code Here

    final JClassType localHasTextType = typeOracle.findType(HasText.class.getName());

    Map<String, JField> recordFieldNames = getAccessiblePropertyFields(recordType);
    Map<JField, JClassType> localUiPropertyFields = new HashMap<JField, JClassType>();
    for (final JField uiField : viewType.getFields()) {
      JField recordField = recordFieldNames.get(uiField.getName());
      if (uiField.getAnnotation(UiField.class) == null || recordField == null) {
        continue;
      }
      JParameterizedType parameterizedField = recordField.getType().isClass().isParameterized();
      if (parameterizedField == null
          || parameterizedField.getBaseType() != propertyType
          || parameterizedField.getTypeArgs().length != 1) {
        logger.log(TreeLogger.ERROR,
            "A property type must have exactly one type argument");
View Full Code Here

      JClassType viewType) {
    sw.indent();
    sw.println("public boolean isChanged(" + viewType.getName() + " view) {");
    sw.indent();
    for (Entry<JField, JClassType> uiFieldEntry : uiPropertyFields.entrySet()) {
      JField property = recordType.getField(uiFieldEntry.getKey().getName());
      if (property != null) {
        String getter = "getValue";
        if (uiFieldEntry.getValue() == hasTextType) {
          getter = "getText";
        }
        sw.println(String.format(
            "view.getValue().set%s(view.%s.%s());",
            capitalize(property.getName()),
            uiFieldEntry.getKey().getName(), getter));
      }
    }
    sw.println("return view.getValue().isChanged();");
    sw.outdent();
View Full Code Here

      }
      return null;
    }


    JField field = type.getField(name);

    if (field == null) {
      throw new RuntimeException("no such field: " + field);
    }
View Full Code Here

  }

  protected Visibility createVisibility() {
    Visibility visibility = null;
    while (true) {
      final JField field = this.getJField();
      if (field.isPrivate()) {
        visibility = Visibility.PRIVATE;
        break;
      }
      if (field.isDefaultAccess()) {
        visibility = Visibility.PACKAGE_PRIVATE;
        break;
      }
      if (field.isProtected()) {
        visibility = Visibility.PROTECTED;
        break;
      }
      if (field.isPublic()) {
        visibility = Visibility.PUBLIC;
        break;
      }
      Checker.fail("Unknown visibility for field " + field);
    }
View Full Code Here

      source.println("FieldImpl field = null;");

      JField[] fields = classType.getFields();

      for (int i = 0; i < fields.length; i++) {
        JField field = fields[i];

        if (needReflect
            || field.getAnnotation(HasReflect.class) != null) {
          if (field.isEnumConstant() == null)
            source.println("field = new FieldImpl(this, \""
                + field.getName() + "\");");
          else
            source.println("field = new EnumConstantImpl(this, \""
                + field.getName() + "\", "
                + field.isEnumConstant().getOrdinal() + ");");

          source.println("field.addModifierBits("
              + GeneratorHelper.AccessDefToInt(field) + "); ");
          source
              .println("field.setTypeName(\""
                  + field.getType().getQualifiedSourceName()
                  + "\");");

          // GeneratorHelper.addMetaDatas("field", source, field);

          if (this.reflectable.fieldAnnotations()
              || (field.getAnnotation(HasReflect.class) != null && field
                  .getAnnotation(HasReflect.class)
                  .annotation())) {
            Annotation[] annotations = AnnotationsHelper
                .getAnnotations(field);
            GeneratorHelper.addAnnotations_AnnotationImpl(
View Full Code Here

          + ")instance;");

      JField[] fields = classType.getFields();

      for (int i = 0; i < fields.length; i++) {
        JField jField = fields[i];
       
        if (jField.isPrivate() || jField.isFinal() || (jField.isProtected() && GeneratorHelper.isSystemClass(classType))) {
          continue;
        }

        if (!this.reflectable.fields()) {
          HasReflect hasReflect = jField
              .getAnnotation(HasReflect.class);
          if (hasReflect == null)
            continue;
        }

        String fieldName = jField.getName();

        sourceWriter.println("if (fieldName.equals(\"" + fieldName
            + "\")) {");
        sourceWriter.indent();

        String value = unboxWithoutConvert(jField.getType()
            .getQualifiedSourceName(), "value");
        sourceWriter
            .println("content." + fieldName + "=" + value + ";");

        sourceWriter.outdent();
View Full Code Here

          + ")instance;");

      JField[] fields = classType.getFields();

      for (int i = 0; i < fields.length; i++) {
        JField jField = fields[i];
        //Private or protected field under package java.x, javax.x is not accessible
        if (jField.isPrivate() || (jField.isProtected() && GeneratorHelper.isSystemClass(classType))) {
          continue;
        }

        if (!this.reflectable.fields()) {
          HasReflect hasReflect = jField
              .getAnnotation(HasReflect.class);
          if (hasReflect == null)
            continue;
        }

        String fieldName = jField.getName();

        sourceWriter.println("if (fieldName.equals(\"" + fieldName
            + "\")) {");
        sourceWriter.indent();
View Full Code Here

   * @param classType
   * @param fieldName
   * @return
   */
  public static JField findField(JClassType classType, String fieldName){
    JField result = null;
    JClassType parent = classType;
    while (parent != null){
      result = parent.findField(fieldName);
      if (result != null)
        return result;
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.