当前位置: 首页>>代码示例>>Java>>正文


Java Doc类代码示例

本文整理汇总了Java中com.sun.javadoc.Doc的典型用法代码示例。如果您正苦于以下问题:Java Doc类的具体用法?Java Doc怎么用?Java Doc使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Doc类属于com.sun.javadoc包,在下文中一共展示了Doc类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: javaDocFor

import com.sun.javadoc.Doc; //导入依赖的package包/类
/**Get javadoc for given element.
 * @deprecated The new DocTree API should be used to traverse Javadoc comments.
 * Use {@link DocTrees#getDocCommentTree(javax.lang.model.element.Element)} instead.
 */
@Deprecated
public Doc javaDocFor(Element element) {
    if (element != null) {
        DocEnv env = DocEnv.instance(ctx);
        switch (element.getKind()) {
            case ANNOTATION_TYPE:
            case CLASS:
            case ENUM:
            case INTERFACE:
                return env.getClassDoc((ClassSymbol)element);
            case ENUM_CONSTANT:
            case FIELD:
                return env.getFieldDoc((VarSymbol)element);
            case METHOD:
                if (((MethodSymbol)element).enclClass().getKind() == ElementKind.ANNOTATION_TYPE)
                    return env.getAnnotationTypeElementDoc((MethodSymbol)element);
                return env.getMethodDoc((MethodSymbol)element);
            case CONSTRUCTOR:
                return env.getConstructorDoc((MethodSymbol)element);
            case PACKAGE:
                return env.getPackageDoc((PackageSymbol)element);
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:ElementUtilities.java

示例2: updateJavadoc

import com.sun.javadoc.Doc; //导入依赖的package包/类
private Comment updateJavadoc(Element method, Element targetElement, boolean addDeprecated) {
    Doc javadoc = workingCopy.getElementUtilities().javaDocFor(method);
    
    List<Tag> otherTags = new LinkedList<Tag>(Arrays.asList(javadoc.tags()));
    List<Tag> returnTags = new LinkedList<Tag>(Arrays.asList(javadoc.tags("@return"))); // NOI18N
    List<Tag> throwsTags = new LinkedList<Tag>(Arrays.asList(javadoc.tags("@throws"))); // NOI18N
    List<Tag> paramTags = new LinkedList<Tag>(Arrays.asList(javadoc.tags("@param"))); // NOI18N

    otherTags.removeAll(returnTags);
    otherTags.removeAll(throwsTags);
    otherTags.removeAll(paramTags);
    
    StringBuilder text = new StringBuilder(javadoc.commentText()).append("\n\n"); // NOI18N
    text.append(tagsToString(paramTags));
    text.append(tagsToString(returnTags));
    text.append(tagsToString(throwsTags));
    text.append(tagsToString(otherTags));
    if(addDeprecated) {
        String target = targetElement.asType().toString() + "#" + method.getSimpleName(); // NOI18N
        text.append(org.openide.util.NbBundle.getMessage(MoveMembersTransformer.class, "TAG_Deprecated", target));
    }
    Comment comment = Comment.create(Comment.Style.JAVADOC, NOPOS, NOPOS, NOPOS, text.toString());
    return comment;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:MoveMembersTransformer.java

示例3: getTagletOutput

import com.sun.javadoc.Doc; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * @see com.sun.tools.doclets.internal.toolkit.taglets.Taglet#getTagletOutput(com.sun.javadoc.Doc, com.sun.tools.doclets.internal.toolkit.taglets.TagletWriter)
 */
@Override
public TagletOutput getTagletOutput(Doc doc, TagletWriter writer) throws IllegalArgumentException {
	Tag[] tags = doc.tags(getName());
	if (tags.length==0 && doc instanceof MethodDoc) { // inherit if necessary and possible
		final DocFinder.Output inheritedDoc = DocFinder.search(new DocFinder.Input((MethodDoc) doc, this));
		tags = inheritedDoc.holderTag == null ? tags : new Tag[] {inheritedDoc.holderTag};
	}
	if (tags.length==0)
		return null;
	final StringBuilder out = writeHeader(new StringBuilder());
	for(Tag tag : tags) { 
		writeTag(out, tag, writer);
	}
	return new TagletOutputImpl(out.toString());
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:20,代码来源:SpecificationTaglet.java

示例4: addUsedBy

import com.sun.javadoc.Doc; //导入依赖的package包/类
/**
 *  @param usedClassToPackagesMap  ClassDoc to (PackageDoc to (UsageType to (Set of Doc)))
 */
private void addUsedBy(Map usedClassToPackagesMap,
                       ClassDoc usedClass, UsageType usageType, Doc user, PackageDoc userPackage)
{
   Map packageToUsageTypeMap = (Map)usedClassToPackagesMap.get(usedClass);
   if (null == packageToUsageTypeMap) {
      packageToUsageTypeMap = new HashMap();
      usedClassToPackagesMap.put(usedClass, packageToUsageTypeMap);
   }

   Map usageTypeToUsersMap = (Map)packageToUsageTypeMap.get(userPackage);
   if (null == usageTypeToUsersMap) {
      usageTypeToUsersMap = new TreeMap();
      packageToUsageTypeMap.put(userPackage, usageTypeToUsersMap);
   }

   Set userSet = (Set)usageTypeToUsersMap.get(usageType);
   if (null == userSet) {
      userSet = new TreeSet(); // FIXME: we need the collator from Main here
      usageTypeToUsersMap.put(usageType, userSet);
   }
   userSet.add(user);
}
 
开发者ID:vilie,项目名称:javify,代码行数:26,代码来源:AbstractDoclet.java

示例5: getTagletOutput

import com.sun.javadoc.Doc; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Content getTagletOutput(Doc doc, TagletWriter writer) throws IllegalArgumentException {
	Tag[] tags = doc.tags(getName());
	if (tags.length==0 && doc instanceof MethodDoc) { // inherit if necessary and possible
		final DocFinder.Output inheritedDoc = DocFinder.search(new DocFinder.Input((MethodDoc) doc, this));
		tags = inheritedDoc.holderTag == null ? tags : new Tag[] {inheritedDoc.holderTag};
	}
	if (tags.length==0)
		return null;
	final StringBuilder out = writeHeader(new StringBuilder());
	for(Tag tag : tags) { 
		writeTag(out, tag, writer);
	}
	return new RawHtml(out.toString());
}
 
开发者ID:emina,项目名称:kodkod,代码行数:19,代码来源:SpecificationTaglet.java

示例6: toStandardTags

import com.sun.javadoc.Doc; //导入依赖的package包/类
/**
 * Transforms common tags on the Doc object into XML.
 *
 * @param doc The Doc object.
 * @return The corresponding list of nodes.
 */
private static List<XMLNode> toStandardTags(Doc doc) {
  // Create the comment node
  List<XMLNode> nodes = new ArrayList<XMLNode>();

  // Handle the tags
  for (Tag tag : doc.tags()) {
    Taglet taglet = options.getTagletForName(tag.name().length() > 1? tag.name().substring(1) : "");
    if (taglet instanceof BlockTag) {
      nodes.add(((BlockTag) taglet).toXMLNode(tag));
    }
  }

  // Add the node to the host
  return nodes;
}
 
开发者ID:pageseeder,项目名称:xmldoclet,代码行数:22,代码来源:XMLDoclet.java

示例7: toTags

import com.sun.javadoc.Doc; //导入依赖的package包/类
/**
 * Transforms comments on the Doc object into XML.
 *
 * @param doc The Doc object.
 * @param node The node to add the comment nodes to.
 */
private static XMLNode toTags(Doc doc) {
  // Create the comment node
  XMLNode node = new XMLNode("tags");

  boolean hasTags = false;

  // Handle the tags
  for (Tag tag : doc.tags()) {
    Taglet taglet = options.getTagletForName(tag.name().length() > 1? tag.name().substring(1) : "");
    if (taglet != null && !(taglet instanceof BlockTag)) {
      XMLNode tNode = new XMLNode("tag");
      tNode.attribute("name", tag.name());
      tNode.text(taglet.toString(tag));
      node.child(tNode);
      hasTags = true;
    }
  }

  // Add the node to the host
  return hasTags? node : null;
}
 
开发者ID:pageseeder,项目名称:xmldoclet,代码行数:28,代码来源:XMLDoclet.java

示例8: toComment

import com.sun.javadoc.Doc; //导入依赖的package包/类
/**
 * Transforms comments on the Doc object into XML.
 *
 * @param doc The Doc object.
 * @param node The node to add the comment nodes to.
 */
private static XMLNode toComment(Doc doc) {
  if (doc.commentText() == null || doc.commentText().length() == 0) return null;
  XMLNode node = new XMLNode("comment", doc, doc.position().line());
  StringBuilder comment = new StringBuilder();

  // Analyse each token and produce comment node
  for (Tag t : doc.inlineTags()) {
    Taglet taglet = options.getTagletForName(t.name());
    if (taglet != null) {
      comment.append(taglet.toString(t));
    } else {
      comment.append(t.text());
    }
  }

  return node.text(comment.toString());
}
 
开发者ID:pageseeder,项目名称:xmldoclet,代码行数:24,代码来源:XMLDoclet.java

示例9: exclude

import com.sun.javadoc.Doc; //导入依赖的package包/类
private static boolean exclude(Doc doc) {
    // if (doc.name().contains("UnitTest")) {
    // return true;
    // }
    if (doc != null) {
        if (doc.tags(EXCLUDE_TAG).length > 0) {
            return true;
        } else if (doc instanceof ProgramElementDoc) {
            if (exclude(((ProgramElementDoc) doc).containingPackage())) {
                return true;
            } else if (exclude(((ProgramElementDoc) doc).containingClass())) {
                return true;
            }
        }
    }
    // nothing above found a reason to exclude
    return false;
}
 
开发者ID:SUPENTA,项目名称:flitchio-sdk,代码行数:19,代码来源:JavadocFilter.java

示例10: process

import com.sun.javadoc.Doc; //导入依赖的package包/类
private static Object process(Object obj, Class expect) {
    if (obj == null) {
        return null;
    }
    Class cls = obj.getClass();
    if (cls.getName().startsWith("com.sun.")) {
        return Proxy.newProxyInstance(cls.getClassLoader(), cls.getInterfaces(), new ExcludeHandler(obj));
    } else if (obj instanceof Object[]) {
        Class componentType = expect.getComponentType();
        Object[] array = (Object[]) obj;
        List<Object> list = new ArrayList<>(array.length);
        for (Object entry : array) {
            if ((entry instanceof Doc) && exclude((Doc) entry)) {
                continue;
            }
            list.add(process(entry, componentType));
        }
        return list.toArray((Object[]) Array.newInstance(componentType, list.size()));
    } else {
        return obj;
    }
}
 
开发者ID:SUPENTA,项目名称:flitchio-sdk,代码行数:23,代码来源:JavadocFilter.java

示例11: parseIdentifier

import com.sun.javadoc.Doc; //导入依赖的package包/类
private String parseIdentifier(Doc doc) {
  if (doc instanceof ClassDoc) {
    ClassDoc classDoc = (ClassDoc) doc;

    return parseIdentifier((Doc) classDoc.containingPackage()) + classDoc.name() + "/";
  } else if (doc instanceof AnnotationTypeElementDoc) {
    AnnotationTypeElementDoc annotationTypeElementDoc = (AnnotationTypeElementDoc) doc;
    return parseIdentifier((Doc) annotationTypeElementDoc.containingClass()) + "#" + annotationTypeElementDoc.name();
  } else if (doc instanceof FieldDoc) {
    FieldDoc fieldDoc = (FieldDoc) doc;
    return parseIdentifier((Doc) fieldDoc.containingClass()) + "#" + fieldDoc.name();
  } else if (doc instanceof ConstructorDoc) {
    ConstructorDoc constructorDoc = (ConstructorDoc) doc;
    return parseIdentifier((Doc) constructorDoc.containingClass()) + "#" + constructorDoc.name() + URLEncoder.encode(constructorDoc.flatSignature());
  } else if (doc instanceof MethodDoc) {
    MethodDoc methodDoc = (MethodDoc) doc;
    return parseIdentifier((Doc) methodDoc.containingClass()) + "#" + methodDoc.name() + URLEncoder.encode(methodDoc.flatSignature());
  } else {
    return "/" + doc.name() + "/";
  }
}
 
开发者ID:riptano,项目名称:xml-doclet,代码行数:22,代码来源:Parser.java

示例12: getTagletOutput

import com.sun.javadoc.Doc; //导入依赖的package包/类
/**
 * Checks the type of the program element and determines comment
 * accordingly.
 */
@Override
public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) {

	Doc doc = tag.holder();

	String text;
	if (doc instanceof MethodDoc) {
		text = methodDoc((MethodDoc) doc);
	} else if (doc instanceof ClassDoc) {
		text = classDoc((ClassDoc) doc);
	} else if (doc instanceof FieldDoc) {
		text = fieldDoc((FieldDoc) doc);
	} else {
		throw new IllegalStateException("Should not happen.");
	}

	if (isFirstSentence(writer)) {
		text = getFirstSentence(text);
	}

	TagletOutput result = writer.getOutputInstance();
	result.setOutput(text);
	return result;
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:29,代码来源:ConQATTaglet.java

示例13: getFirstSentence

import com.sun.javadoc.Doc; //导入依赖的package包/类
private static String getFirstSentence(Doc doc) {
    Tag[] tags = doc.firstSentenceTags();
    if (tags.length == 0) {
        return null;
    }
    StringBuilder buffer = new StringBuilder();
    for (Tag tag : tags) {
        if (tag instanceof SeeTag) {
            buffer.append("{");
            buffer.append(tag.name());
            buffer.append(" ");
            buffer.append(((SeeTag)tag).referencedClassName());
            buffer.append("}");
        } else {
            buffer.append(tag.text());
        }
    }
    return buffer.toString();
}
 
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:20,代码来源:ResourceInfoDoclet.java

示例14: formatDeprecatedTags

import com.sun.javadoc.Doc; //导入依赖的package包/类
private String formatDeprecatedTags(Doc doc)
{
  Tag[] deprecatedTags = doc.tags("deprecated");
  if(deprecatedTags.length > 0)
  {
    StringBuilder deprecatedText = new StringBuilder();
    for(int i = 0; i < deprecatedTags.length; i++)
    {
      deprecatedText.append(deprecatedTags[i].text());
      if(i < deprecatedTags.length - 1)
      {
        deprecatedText.append(" ");
      }
    }
    return deprecatedText.toString();
  }
  else
  {
    return null;
  }
}
 
开发者ID:ppdai,项目名称:rest4j,代码行数:22,代码来源:DocletDocsProvider.java

示例15: filterHidden

import com.sun.javadoc.Doc; //导入依赖的package包/类
/**
 * Filters out hidden elements.
 */
private static Object filterHidden(Object o, Class<?> expected) {
  if (o == null) {
    return null;
  }

  Class<?> type = o.getClass();
  if (type.getName().startsWith("com.sun.")) {
    // TODO: Implement interfaces from superclasses, too.
    return Proxy
        .newProxyInstance(type.getClassLoader(), type.getInterfaces(), new HideHandler(o));
  } else if (o instanceof Object[]) {
    Class<?> componentType = expected.getComponentType();
    Object[] array = (Object[]) o;
    List<Object> list = new ArrayList<Object>(array.length);
    for (Object entry : array) {
      if ((entry instanceof Doc) && isHidden((Doc) entry)) {
        continue;
      }
      list.add(filterHidden(entry, componentType));
    }
    return list.toArray((Object[]) Array.newInstance(componentType, list.size()));
  } else {
    return o;
  }
}
 
开发者ID:kwf2030,项目名称:doclava,代码行数:29,代码来源:Doclava.java


注:本文中的com.sun.javadoc.Doc类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。