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

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


        throw new UnableToCompleteException();
      }

      // Pick a method to use
      // Try getter first
      JMethod method = getMethod(type, p);
      if (method == null) {
        method = getMethod(type, "get" + cap(p));
      }
      if (method == null) {
        method = getMethod(type, "is" + cap(p));
      }
      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");
View Full Code Here


      return null;
    }

    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.");
View Full Code Here

            + field.getName(), false);
      }
    }

    // Try to find any bundle instance created with @UiFactory.
    JMethod method = getOwnerClass().getUiFactoryMethod(bundleClass);
    if (method != null) {
      return new BundleAttributeParser(bundleClass, "owner." + method.getName()
          + "()", false);
    }

    return new BundleAttributeParser(bundleClass, "my"
        + bundleClass.getName().replace('.', '_') + "Instance", true);
View Full Code Here

      }
    }

    /* Nope. Maybe a @UiFactory will make it */

    JMethod factoryMethod = writer.getOwnerClass().getUiFactoryMethod(
        resourceType);
    if (factoryMethod != null) {
      fieldWriter.setInitializer(String.format("owner.%s()",
          factoryMethod.getName()));
    }

    /*
     * If neither of the above, the FieldWriter's default GWT.create call will
     * do just fine.
View Full Code Here

        }

        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);
        if (setter == null) {
          writer.die("In %s, class %s has no appropriate set%s() method", elem,
              elem.getLocalName(), initialCap(propertyName));
        }
View Full Code Here

            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+");");
                                }
              }
View Full Code Here

               + "\n\t 3. Check the versions of all your modules."
               ;
        throw new CruxGeneratorException(message);
      }

      JMethod exposedMethod = getControllerMethodWithEvent(event.getMethod(), eventClassType, controllerClass);
      if (exposedMethod == null)
      {
        if (allowNoParameterCall)
        {
          exposedMethod = JClassUtils.getMethod(controllerClass, event.getMethod(), new JType[]{});
View Full Code Here

               + "\n\t 3. Check the versions of all your modules."
               ;
      throw new CruxGeneratorException(message);
      }

      JMethod exposedMethod = getControllerMethodWithEvent(event.getMethod(), eventClassType, controllerClass);
    if (exposedMethod == null)
      {
      exposedMethod = JClassUtils.getMethod(controllerClass, event.getMethod(), new JType[]{});
        if (exposedMethod == null)
        {
View Full Code Here

   */
  private boolean hasMethod(JClassType clazz, String methodName, JType[] params)
  {
    if (clazz != null && methodName != null)
    {
      JMethod method = clazz.findMethod(methodName, params);
      if (method != null)
      {
        return true;
      }

View Full Code Here

   
    JParameter[] params = method.getParameters();
    if (params.length == 1)
    {
      JParameter param = params[0];
      JMethod validate = controllerClass.findMethod(validationMethod, new JType[]{param.getType()});
      if (validate != null)
      {
        sourceWriter.print(param.getName());
      }
    }
View Full Code Here

TOP

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

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.