Package com.sun.javadoc

Examples of com.sun.javadoc.ClassDoc


    boolean isJavaxType = qName.startsWith("javax.");
    boolean isBaseObject = qName.equals("java.lang.Object");
    boolean isClass = qName.equals("java.lang.Class");
    boolean isWildcard = qName.equals("?");

    ClassDoc classDoc = type.asClassDoc();

    if (isPrimitive || isJavaxType || isClass || isWildcard || isBaseObject || classDoc == null || classDoc.isEnum() || alreadyStoredType(type)) {
      return;
    }

    // check if its got an exclude tag
    // see if deprecated
    if (this.options.isExcludeDeprecatedModelClasses() && ParserHelper.isDeprecated(classDoc)) {
      return;
    }

    // see if excluded via a tag
    if (ParserHelper.hasTag(classDoc, this.options.getExcludeClassTags())) {
      return;
    }

    // see if excluded via its FQN
    if (this.options.getExcludeModelPrefixes() != null && !this.options.getExcludeModelPrefixes().isEmpty()) {
      for (String prefix : this.options.getExcludeModelPrefixes()) {
        String className = classDoc.qualifiedName();
        if (className.startsWith(prefix)) {
          return;
        }
      }
    }

    // if parameterized then build map of the param vars
    ParameterizedType pt = type.asParameterizedType();
    if (pt != null) {
      Type[] typeArgs = pt.typeArguments();
      if (typeArgs != null && typeArgs.length > 0) {
        TypeVariable[] vars = classDoc.typeParameters();
        int i = 0;
        for (TypeVariable var : vars) {
          this.varsToTypes.put(var.qualifiedTypeName(), typeArgs[i]);
          i++;
        }
View Full Code Here


    Map<String, Property> elements = new HashMap<String, Property>();
    for (Map.Entry<String, TypeRef> entry : types.entrySet()) {
      String typeName = entry.getKey();
      TypeRef typeRef = entry.getValue();
      Type type = typeRef.type;
      ClassDoc typeClassDoc = type.asClassDoc();

      OptionalName propertyTypeFormat = this.translator.typeName(type);
      String propertyType = propertyTypeFormat.value();

      // set enum values
View Full Code Here

   * This parses the api declarations from the resource classes of the api
   * @param declarations The map of resource name to declaration which will be added to
   */
  public void parse(Map<String, ApiDeclaration> declarations) {

    ClassDoc currentClassDoc = this.classDoc;
    while (currentClassDoc != null) {

      // read default error type for class
      String defaultErrorTypeClass = ParserHelper.getTagValue(currentClassDoc, this.options.getDefaultErrorTypeTags());
      Type defaultErrorType = ParserHelper.findModel(this.classes, defaultErrorTypeClass);

      Set<Model> classModels = new HashSet<Model>();
      if (this.options.isParseModels() && defaultErrorType != null) {
        classModels.addAll(new ApiModelParser(this.options, this.options.getTranslator(), defaultErrorType).parse());
      }

      // read class level resource path, priority and description
      String classResourcePath = ParserHelper.getTagValue(currentClassDoc, this.options.getResourceTags());
      String classResourcePriority = ParserHelper.getTagValue(currentClassDoc, this.options.getResourcePriorityTags());
      String classResourceDescription = ParserHelper.getTagValue(currentClassDoc, this.options.getResourceDescriptionTags());

      // check if its a sub resource
      // TODO: be more deterministic e.g. build map of sub resource types that are explicitly referenced
      boolean isSubResourceClass = (getRootPath() == null || getRootPath().isEmpty()) && !currentClassDoc.isAbstract();

      // dont process a subresource outside the context of its parent method
      if (isSubResourceClass && this.parentMethod == null) {
        // skip
      } else {
        for (MethodDoc method : currentClassDoc.methods()) {
          ApiMethodParser methodParser = this.parentMethod == null ? new ApiMethodParser(this.options, this.rootPath, method, this.classes,
              defaultErrorTypeClass) : new ApiMethodParser(this.options, this.parentMethod, method, this.classes, defaultErrorTypeClass);

          Method parsedMethod = methodParser.parse();
          if (parsedMethod == null) {
            continue;
          }

          // see which resource path to use for the method, if its got a resourceTag then use that
          // otherwise use the root path
          String resourcePath = buildResourcePath(classResourcePath, method);

          if (parsedMethod.isSubResource()) {
            ClassDoc subResourceClassDoc = lookUpClassDoc(method.returnType());
            if (subResourceClassDoc != null) {
              // delete class from the dictionary to handle recursive sub-resources
              Collection<ClassDoc> shrunkClasses = new ArrayList<ClassDoc>(this.classes);
              shrunkClasses.remove(currentClassDoc);
              // recursively parse the sub-resource class
View Full Code Here

        if (this.options.isParseModels()) {
          this.models.addAll(new ApiModelParser(this.options, this.translator, paramType).parse());
        }

        // set enum values
        ClassDoc typeClassDoc = parameter.type().asClassDoc();
        allowableValues = ParserHelper.getAllowableValues(typeClassDoc);
        if (allowableValues != null) {
          typeName = "string";
        }
View Full Code Here

        }
    }

    private void addRelatedClasses(ClassDoc type) {
        // Generalization
        ClassDoc superType = type.superclass();
        if (superType != null &&
            !superType.qualifiedName().equals("java.lang.Object") &&
            !superType.qualifiedName().equals("java.lang.Annotation") &&
            !superType.qualifiedName().equals("java.lang.Enum")) {
            addNode(superType, false);
            addEdge(new Edge(GENERALIZATION, type, superType));
        }

        // Realization
View Full Code Here

            for (Edge edge: directEdges) {
                if (!useSee && edge.getType() == SEE_ALSO) {
                    continue;
                }

                ClassDoc source = (ClassDoc) edge.getSource();
                ClassDoc target = (ClassDoc) edge.getTarget();

                boolean excluded = false;
                if (forceInherit || cls.tags(TAG_INHERIT).length > 0) {
                    for (Tag t: pkg.tags(TAG_EXCLUDE)) {
                        Pattern p = Pattern.compile(t.text().trim());

                        if (p.matcher(source.qualifiedName()).find()) {
                            excluded = true;
                            break;
                        }
                        if (p.matcher(target.qualifiedName()).find()) {
                            excluded = true;
                            break;
                        }
                    }
                    if (excluded) {
                        continue;
                    }
                }

                for (Tag t: cls.tags(TAG_EXCLUDE)) {
                    Pattern p = Pattern.compile(t.text().trim());

                    if (p.matcher(source.qualifiedName()).find()) {
                        excluded = true;
                        break;
                    }
                    if (p.matcher(target.qualifiedName()).find()) {
                        excluded = true;
                        break;
                    }
                }
                if (excluded) {
                    continue;
                }

                edgesToRender.add(edge);
                nodesToRender.put(source.qualifiedName(), source);
                nodesToRender.put(target.qualifiedName(), target);
            }

            Set<Edge> reversedDirectEdges = reversedEdges.get(cls);
            if (reversedDirectEdges != null) {
                for (Edge edge: reversedDirectEdges) {
                    if (!useSee && edge.getType() == SEE_ALSO) {
                        continue;
                    }

                    ClassDoc source = (ClassDoc) edge.getSource();
                    ClassDoc target = (ClassDoc) edge.getTarget();

                    boolean excluded = false;
                    if (forceInherit || cls.tags(TAG_INHERIT).length > 0) {
                        for (Tag t: pkg.tags(TAG_EXCLUDE)) {
                            Pattern p = Pattern.compile(t.text().trim());

                            if (p.matcher(source.qualifiedName()).find()) {
                                excluded = true;
                                break;
                            }
                            if (p.matcher(target.qualifiedName()).find()) {
                                excluded = true;
                                break;
                            }
                        }
                        if (excluded) {
                            continue;
                        }
                    }

                    for (Tag t: cls.tags(TAG_EXCLUDE)) {
                        Pattern p = Pattern.compile(t.text().trim());

                        if (p.matcher(source.qualifiedName()).find()) {
                            excluded = true;
                            break;
                        }
                        if (p.matcher(target.qualifiedName()).find()) {
                            excluded = true;
                            break;
                        }
                    }
                    if (excluded) {
                        continue;
                    }

                    edgesToRender.add(edge);
                    nodesToRender.put(source.qualifiedName(), source);
                    nodesToRender.put(target.qualifiedName(), target);
                }
            }
        }
    }
View Full Code Here

        AnnotationValue[] vals = (AnnotationValue[]) val;
        if (vals != null && vals.length > 0) {
          ClassDoc[] res = new ClassDoc[vals.length];
          int i = 0;
          for (AnnotationValue annotationVal : vals) {
            ClassDoc classDoc = (ClassDoc) annotationVal.value();
            res[i++] = classDoc;
          }
          return res;
        }
      }
View Full Code Here

          }
        });

        Iterator<ClassDoc> iter = Arrays.asList(classes).iterator();
        while (iter.hasNext()) {
          ClassDoc cls = iter.next();

          // Each class links to Sun's main JavaDoc
          pw.format("  <dt><a href=\"%s%s.html\">%s</a></dt>\n", packURL,
              cls.name(), cls.name());

          // Print out all fields
          Collection<FieldDoc> fields = new ArrayList<FieldDoc>();
          fields.addAll(Arrays.asList(cls.fields(true)));

          if (!fields.isEmpty()) {
            pw.format("  <dd style='margin-bottom: 0.5em;'>%s</dd>\n", createFieldList(fields));
          }

          // Print out all constructors and methods
          Collection<ExecutableMemberDoc> members = new ArrayList<ExecutableMemberDoc>();
          members.addAll(Arrays.asList(cls.constructors(true)));
          members.addAll(Arrays.asList(cls.methods(true)));

          if (!members.isEmpty()) {
            pw.format("  <dd>%s</dd>\n", createMemberList(members));
          }
View Full Code Here

   private void associateBeansWithTreeNodes(List<Class<?>> configBeans, TreeNode root) {
      for (TreeNode n : root) {
         if (n.getBeanClass() == null) {
            for (Class<?> clazz : configBeans) {
               ClassDoc classDoc = rootDoc.classNamed(clazz.getName());
               if (classDoc != null) {
                  List<Tag> list = Arrays.asList(classDoc.tags(CONFIG_REF));
                  for (Tag tag : list) {
                     String text = tag.text().trim();
                     Map<String, String> p = parseTag(text);
                     String thisNode = p.get("name");
                     String parentNode = p.get("parentName");
View Full Code Here

      sb.append("\n<a name=\"").append("ce_" + n.getParent().getName() + "_" + n.getName() + "\">" + "</a>");
      sb.append("<div class=\"section\"><h3><a name=\"" + n.getName() + "\"></a>" + n.getName() + "</h3>");
      sb.append("\n<p>");
      Class<?> beanClass = n.getBeanClass();
      //System.out.println("Generating " + n + " bean is " + beanClass);
      ClassDoc classDoc = rootDoc.classNamed(beanClass.getName());
      Tag[] tags = classDoc.tags(CONFIG_REF);
      for (Tag tag : tags) {
         String text = tag.text().trim();
         Map<String, String> m = parseTag(text);
         sb.append(m.get("desc"));
      }
View Full Code Here

TOP

Related Classes of com.sun.javadoc.ClassDoc

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.