當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。