Package org.springframework.ide.eclipse.beans.ui.editor.util

Examples of org.springframework.ide.eclipse.beans.ui.editor.util.BeansJavaDocUtils


    if ("class".equals(attName) && attributes.getNamedItem("class") != null) {
      String className = attributes.getNamedItem("class").getNodeValue();
      if (className != null && file != null) {
        IType type = JdtUtils.getJavaType(file.getProject(), className);
        if (type != null) {
          BeansJavaDocUtils utils = new BeansJavaDocUtils(type);
          result = utils.getJavaDoc();
        }
      }
    }
    else if ("name".equals(attName)
        && "property".equals(xmlnode.getNodeName())) {

      String propertyName = attributes.getNamedItem(attName)
          .getNodeValue();
      String[] paths = StringUtils.split(propertyName, ".");
      if (paths == null) {
        paths = new String[] { propertyName };
      }
      List<String> propertyPaths = Arrays.asList(paths);
      List classNames = BeansEditorUtils.getClassNamesOfBean(file,
          xmlnode.getParentNode());
      List<IMethod> methods = new ArrayList<IMethod>();
      BeansEditorUtils.extractAllMethodsFromPropertyPathElements(
          propertyPaths, classNames, file, 0,
          methods);

      StringBuffer buf = new StringBuffer();
      for (int i = 0; i < methods.size(); i++) {
        IMethod method = methods.get(i);

        if (method != null) {
          BeansJavaDocUtils utils = new BeansJavaDocUtils(method);
          buf.append(utils.getJavaDoc() + "<br>");
        }
      }
      result = buf.toString();
    }
    else if ("local".equals(attName)
        && attributes.getNamedItem(attName) != null) {
      Element ref = xmlnode.getOwnerDocument().getElementById(
          attributes.getNamedItem(attName).getNodeValue());
      result = BeansEditorUtils.createAdditionalProposalInfo(ref, file);
    }
    else if ("bean".equals(attName)
        && attributes.getNamedItem(attName) != null) {
      String target = attributes.getNamedItem(attName).getNodeValue();
      // assume this is an external reference
      Iterator beans = BeansEditorUtils.getBeansFromConfigSets(file)
          .iterator();
      while (beans.hasNext()) {
        IBean modelBean = (IBean) beans.next();
        if (modelBean.getElementName().equals(target)) {
          result = BeansEditorUtils
              .createAdditionalProposalInfo(modelBean);
        }
      }
    }
    else if (("ref".equals(attName)
        || "local".equals(attName)
        || "parent".equals(attName)
        || "depends-on".equals(attName)
        || "factory-bean".equals(attName)
        || "key-ref".equals(attName)
        || "value-ref".equals(attName)
        || attName.endsWith("-ref")
        || ("name".equals(attName) && "alias".equals(xmlnode
            .getNodeName())) || ("bean".equals(attName) && "ref"
        .equals(xmlnode.getNodeName())))
        && attributes.getNamedItem(attName) != null) {
      Element ref = xmlnode.getOwnerDocument().getElementById(
          attributes.getNamedItem(attName).getNodeValue());
      if (ref != null) {
        result = BeansEditorUtils.createAdditionalProposalInfo(ref,
            file);
      }
      else {
        String target = attributes.getNamedItem(attName).getNodeValue();
        // assume this is an external reference
        Iterator beans = BeansEditorUtils.getBeansFromConfigSets(file)
            .iterator();
        while (beans.hasNext()) {
          IBean modelBean = (IBean) beans.next();
          if (modelBean.getElementName().equals(target)) {
            result = BeansEditorUtils
                .createAdditionalProposalInfo(modelBean);
          }
        }
      }
    }
    else if (("factory-method").equals(attName)) {
      String factoryMethod = attributes.getNamedItem(attName)
          .getNodeValue();
      String className = BeansEditorUtils.getClassNameForBean(
          file, xmlnode.getOwnerDocument(), xmlnode);
      if (file != null && file.exists()) {
        IType type = JdtUtils.getJavaType(file.getProject(), className);
        if (type != null) {
          try {
            IMethod[] methods = type.getMethods();
            for (IMethod method : methods) {
              if (method.getElementName().equals(factoryMethod)) {
                BeansJavaDocUtils utils = new BeansJavaDocUtils(
                    method);
                result = utils.getJavaDoc();
              }
            }
          }
          catch (JavaModelException e) {
          }
        }
      }
    }
    if ("init-method".equals(attName) || "destroy-method".equals(attName)) {
      String factoryMethod = attributes.getNamedItem(attName)
          .getNodeValue();
      String className = BeansEditorUtils.getClassNameForBean(
          file, xmlnode.getOwnerDocument(), xmlnode);
      if (file != null && file.exists()) {
        IType type = JdtUtils.getJavaType(file.getProject(), className);
        try {
          IMethod method = Introspector.findMethod(type, factoryMethod,
              0, Public.DONT_CARE, Static.DONT_CARE);
          if (method != null) {
            BeansJavaDocUtils utils = new BeansJavaDocUtils(method);
            result = utils.getJavaDoc();
          }
        }
        catch (JavaModelException e) {
        }
      }
    }
    else if (("lookup-method".equals(xmlnode.getNodeName()) && "name"
        .equals(attName))
        || ("replaced-method".equals(xmlnode.getNodeName()) && "name"
            .equals(attName))) {
      String factoryMethod = attributes.getNamedItem(attName)
          .getNodeValue();
      String className = BeansEditorUtils.getClassNameForBean(
          file, xmlnode.getOwnerDocument(),
          xmlnode.getParentNode());
      if (file != null && file.exists()) {
        IType type = JdtUtils.getJavaType(file.getProject(), className);
        try {
          IMethod method = Introspector.findMethod(type, factoryMethod,
              0, Public.DONT_CARE, Static.DONT_CARE);
          if (method != null) {
            BeansJavaDocUtils utils = new BeansJavaDocUtils(method);
            result = utils.getJavaDoc();
          }
        }
        catch (JavaModelException e) {
        }
      }
View Full Code Here

TOP

Related Classes of org.springframework.ide.eclipse.beans.ui.editor.util.BeansJavaDocUtils

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.